Skip to content

Commit

Permalink
Use CircleCI Orbs
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Feb 15, 2019
1 parent 8f8f06f commit 91a5c99
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 407 deletions.
276 changes: 29 additions & 247 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,257 +1,39 @@
defaults: &defaults
working_directory: ~/project
docker:
- image: quay.io/haskell_works/stack-build-cabal:18.04_2018-06-09
version: 2.1

steps:
- checkout
orbs:
haskell: haskell-works/haskell-build@1.5.3
github: haskell-works/github-release@1.2.1
hackage: haskell-works/hackage@1.0.0

- run:
name: Remove Cabal file
command: rm -f *.cabal

- run:
name: Copying scripts
command: |
mkdir -p ~/.local/bin
cp ./scripts/* ~/.local/bin
- run:
name: Query resolver & ghc version
command: |
resolver "$(resolver $LTS)" > resolver.version
ghc-version $(cat resolver.version) > ghc.version
- run:
name: Find all sub-projects
command: projects-summary > projects.summary

##### Building library
- restore_cache:
keys:
- stack--nAz6PsL--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--{{ checksum "package.yaml" }}--{{ checksum "stack.yaml" }}
- stack--nAz6PsL--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--{{ checksum "package.yaml" }}
- stack--nAz6PsL--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--
- stack--nAz6PsL--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--X

- run:
name: Stack setup
command: stack setup --resolver ${LTS}

- save_cache:
key: stack--nAz6PsL--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--X
paths: [~/.stack, ~/project/.stack-work]

- run:
name: Building dependencies
command: |
stack build --resolver ${LTS} --dependencies-only
stack build --resolver ${LTS} --dependencies-only --test --no-run-tests
- save_cache:
key: stack--nAz6PsL--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--{{ checksum "package.yaml" }}
paths: [~/.stack, ~/project/.stack-work]

- run: stack build --resolver ${LTS} --test --no-run-tests

- save_cache:
key: stack--nAz6PsL--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--{{ checksum "package.yaml" }}--{{ checksum "stack.yaml" }}
paths: [~/.stack, ~/project/.stack-work]

##### Running tests
- run:
name: Running tests against latest on hackage
command: stack test --resolver ${LTS}

cabalbuild: &cabalbuild
working_directory: ~/project

steps:
- checkout

- run:
name: Add GHC tools to PATH
command: |
echo "HOME=$HOME"
echo "BASH_ENV=$BASH_ENV"
echo "PATH=$PATH"
echo 'export PATH="$PATH:/opt/ghc/bin/"' >> $BASH_ENV
- run:
name: Copying scripts
command: |
mkdir -p ~/.local/bin
cp ./scripts/* ~/.local/bin
- run:
name: GHC version
command: |
echo "$GHC" > ghc.version
date +%Y-%m > month.version
- run:
name: Find all sub-projects
command: ./scripts/projects-summary > projects.summary

- run:
name: Generate cabal file
command: |
rm -f *.cabal
hpack
##### Building library
- restore_cache:
keys:
- cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--extra
- cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--
- cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "month.version"}}

- run:
name: Building build dependencies
command: |
./scripts/mk-cabal-project > cabal.project
cabal update
cabal new-build --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j${CABAL_THREADS:-4} all
cabal new-build --enable-tests --enable-benchmarks --project-file="cabal.project" --dep -j${CABAL_THREADS:-4} all
- save_cache:
key: cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--
paths: [~/.cabal/packages, ~/.cabal/store]

- run:
name: Building project
command: |
cabal new-build --enable-tests --enable-benchmarks --project-file="cabal.project" -j${CABAL_THREADS:-4} all
- save_cache:
key: cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--extra
paths: [~/.cabal/packages, ~/.cabal/store]

- save_cache:
key: cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "month.version"}}
paths: [~/.cabal/packages, ~/.cabal/store]

- run:
name: Running tests
command: |
if grep '^test-suite' *.cabal > /dev/null; then
cabal new-test --enable-tests --project-file="cabal.project" -j${CABAL_THREADS:-4} all
else
echo Not tests to run
fi
version: 2.0
jobs:
ghc-8.6.3:
environment:
- GHC: "ghc8.6.3"
docker:
- image: quay.io/haskell_works/ghc-8.6.3
<<: *cabalbuild

ghc-8.4.4:
environment:
- GHC: "ghc8.4.4"
docker:
- image: quay.io/haskell_works/ghc-8.4.4
<<: *cabalbuild

ghc-8.2.2:
environment:
- GHC: "ghc8.2.2"
docker:
- image: quay.io/haskell_works/ghc-8.2.2
<<: *cabalbuild

lts-12:
environment:
- LTS: "lts-12"
<<: *defaults

checked-builds:
docker:
- image: quay.io/haskell_works/ghc-8.4.4

steps:
- checkout

- run:
name: Add GHC tools to PATH
command: |
echo "HOME=$HOME"
echo "BASH_ENV=$BASH_ENV"
echo "PATH=$PATH"
echo 'export PATH="$PATH:/opt/ghc/bin/"' >> $BASH_ENV
- run:
name: Copying scripts
command: |
mkdir -p ~/.local/bin
cp ./scripts/* ~/.local/bin
- deploy:
command: |
hpack
if [ "$CIRCLE_PROJECT_USERNAME" == "haskell-works" ]; then
if [[ "$CIRCLE_BRANCH" == master ]]; then
when tag autotag
elif [[ "$CIRCLE_TAG" =~ v.* ]]; then
publish
fi
fi
release:
docker:
- image: quay.io/haskell_works/ghc-8.4.4

steps:
- checkout
workflows:
multiple-ghc-build:
jobs:
- haskell/build:
name: GHC 8.2.2
executor: haskell/ghc-8_2_2

- run:
name: Add GHC tools to PATH
command: |
echo "HOME=$HOME"
echo "BASH_ENV=$BASH_ENV"
echo "PATH=$PATH"
echo 'export PATH="$PATH:/opt/ghc/bin/"' >> $BASH_ENV
- haskell/build:
name: GHC 8.4.4
executor: haskell/ghc-8_4_4

- run:
name: Copying scripts
command: |
mkdir -p ~/.local/bin
cp ./scripts/* ~/.local/bin
- haskell/build:
name: GHC 8.6.3
executor: haskell/ghc-8_6_3

- deploy:
command: |
hpack
if [ "$CIRCLE_PROJECT_USERNAME" == "haskell-works" ]; then
if [[ "$CIRCLE_BRANCH" == master ]]; then
when tag autotag
elif [[ "$CIRCLE_TAG" =~ v.* ]]; then
publish
fi
fi
workflows:
version: 2
multiple-ghcs:
jobs:
- ghc-8.6.3
- ghc-8.4.4
- ghc-8.2.2
- lts-12
- checked-builds:
- github/release-cabal:
name: GitHub Release
requires:
- lts-12
- GHC 8.2.2
- GHC 8.4.4
- GHC 8.6.3
checkout: true
filters:
branches:
only: master

tagged-release:
jobs:
- release:
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
- hackage/upload:
publish: true
requires:
- GitHub Release
username: ${HACKAGE_USER}
password: ${HACKAGE_PASS}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ cabal.sandbox.config
*.aux
*.hp

/*.cabal
/cabal.project
/*.submodules
/.stack-work/
Expand Down
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ before_install:
- "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"
- HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
- echo $HCNUMVER
- curl -L https://github.com/sol/hpack/releases/download/0.28.2/hpack_linux.gz --output $HOME/.local/bin/hpack.gz
- gunzip $HOME/.local/bin/hpack.gz
- chmod a+x $HOME/.local/bin/hpack

install:
- hpack
- cabal --version
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
- BENCH=${BENCH---enable-benchmarks}
Expand All @@ -76,7 +72,6 @@ install:
# any command which exits with a non-zero exit code causes the build to fail.
script:
# test that source-distributions can be generated
- hpack
- (cd "." && cabal sdist)
- mv "."/dist/hw-rankselect-*.tar.gz ${DISTDIR}/
- cd ${DISTDIR} || false
Expand Down
Loading

0 comments on commit 91a5c99

Please sign in to comment.