From 77c00b56960e20e54a969930f4e5eeceb4c18d1d Mon Sep 17 00:00:00 2001 From: Andreas Ekeroot Date: Fri, 22 Mar 2019 16:52:13 +0100 Subject: [PATCH] Reworked the circleci file to upload releases to Github. Moved circleci configuration file from circle.yml to .circleci/config.yml to automatically work with circleci.com. Removed lens-aeson since it isn't used. Gave stm-containers an exact hard version bound to make the project build with cabal new-build. --- .circleci/config.yml | 71 +++++++++++++++++++++++++++++++++++++++ circle.yml | 22 ------------ postgres-websockets.cabal | 3 +- 3 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 circle.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..1f16446 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,71 @@ +# This file is heavily inspired by these pages: +# - https://circleci.com/docs/2.0/language-haskell/ +# - https://circleci.com/blog/publishing-to-github-releases-via-circleci/ +# +version: 2 +jobs: + build-test-and-publish: + docker: + - image: fpco/stack-build-small:lts + - image: postgres:11-alpine + environment: + POSTGRES_DB: postgres_ws_test + POSTGRES_USER: root + steps: + - checkout + - restore_cache: + name: Restore Cached Dependencies + keys: + - postgres-websockets-v1-{{ checksum "postgres-websockets.cabal" }} + - run: + name: Install curl + command: apt-get update && apt-get -qq -y install curl libpq-dev + - run: + name: Download and run hlint + command: curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s . + - run: + name: Download ghr + command: | + curl -sSLO https://github.com/tcnksm/ghr/releases/download/v0.12.0/ghr_v0.12.0_linux_386.tar.gz + curl -sSLO https://github.com/tcnksm/ghr/releases/download/v0.12.0/v0.12.0_SHASUMS + sha256sum --check --ignore-missing v0.12.0_SHASUMS + tar --strip-components=1 -zxvf ghr_v0.12.0_linux_386.tar.gz ghr_v0.12.0_linux_386/ghr + - run: + name: Resolve and update dependencies + command: stack setup + - run: + name: Build the dependencies and the library + command: stack --silent build + - run: + name: Run tests + command: stack test + - run: + name: Install executable + command: stack --silent install + - run: + name: Calculate and save checksum + command: sha256sum ~/.local/bin/postgres-websockets > /root/postgres-websockets.sha256 + - save_cache: + name: Cache Dependencies + key: postgres-websockets-v1-{{ checksum "postgres-websockets.cabal" }} + paths: + - ".stack" + - ".stack-work" + - run: + name: Publish Release on GitHub + command: | + mkdir /root/result/ + cp /root/postgres-websockets.sha256 /root/.local/bin/postgres-websockets /root/result/ + VERSION=$(awk '/^version: / { print $2 };' < postgres-websockets.cabal) + ./ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} /root/result/ + +workflows: + version: 2 + main: + jobs: + - build-test-and-publish: + filters: + branches: + only: master + tags: + only: /^[\d.]+$/ diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 34eed71..0000000 --- a/circle.yml +++ /dev/null @@ -1,22 +0,0 @@ -dependencies: - cache_directories: - - "~/.stack" - - ".stack-work" - pre: - - curl -L https://github.com/commercialhaskell/stack/releases/download/v1.9.1/stack-1.9.1-linux-x86_64.tar.gz | tar zx -C /tmp - - sudo mv /tmp/stack-1.9.1-linux-x86_64/stack /usr/bin - override: - - stack setup - - rm -fr $(stack path --dist-dir) $(stack path --local-install-root) - - stack install hlint - - stack build - - stack build --test --no-run-tests - -test: - override: - - createdb postgres_ws_test - - stack test - - git ls-files | grep '\.l\?hs$' | xargs stack exec -- hlint -X QuasiQuotes "$@" - - cp -f `find .stack-work/install -type f -name postgres-websockets | tail -n1` . - - gzip ./postgres-websockets - - cp -f ./postgres-websockets.gz $CIRCLE_ARTIFACTS diff --git a/postgres-websockets.cabal b/postgres-websockets.cabal index 1216091..9c3e2fa 100644 --- a/postgres-websockets.cabal +++ b/postgres-websockets.cabal @@ -31,7 +31,6 @@ library , bytestring >= 0.10 , postgresql-libpq , lens - , lens-aeson , jose >= 0.6 , unordered-containers >= 0.2 , postgresql-libpq >= 0.9 && < 1.0 @@ -40,7 +39,7 @@ library , jwt >= 0.7.2 && < 0.8 , hasql >= 0.19 , either - , stm-containers + , stm-containers == 0.2.16 , stm , retry , stringsearch