Skip to content

Commit

Permalink
Merge pull request #22 from arbor/upgrade-build
Browse files Browse the repository at this point in the history
Upgrade build
  • Loading branch information
AlexeyRaga authored Feb 28, 2019
2 parents 9a51866 + e4bd9b4 commit 10134e4
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 443 deletions.
276 changes: 36 additions & 240 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,249 +1,45 @@
defaults: &defaults
working_directory: ~/project
docker:
- image: quay.io/haskell_works/stack-build-cabal:18.04
version: 2.1

steps:
- checkout
orbs:
haskell: haskell-works/haskell-build@1.6.2
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.4.3:
environment:
- GHC: "ghc8.4.3"
docker:
- image: quay.io/haskell_works/ghc-8.4.3:18.04_2018-09-19
<<: *cabalbuild

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

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

checked-builds:
docker:
- image: quay.io/haskell_works/ghc-8.4.3:18.04_2018-09-19

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" == "arbor" ]; 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.3:18.04_2018-09-19

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" == "arbor" ]; then
if [[ "$CIRCLE_BRANCH" == master ]]; then
when tag autotag
elif [[ "$CIRCLE_TAG" =~ v.* ]]; then
publish
fi
fi
workflows:
version: 2
multiple-ghcs:
multiple-ghc-build:
jobs:
- ghc-8.4.3
- ghc-8.2.2
- lts-12
- checked-builds:
- haskell/build:
name: GHC 8.2.2
executor: haskell/ghc-8_2_2

- haskell/build:
name: GHC 8.4.4
executor: haskell/ghc-8_4_4

# - haskell/build:
# name: GHC 8.6.3
# executor: haskell/ghc-8_6_3

# - github/release-cabal:
# name: GitHub Release
# requires:
# - GHC 8.2.2
# - GHC 8.4.4
# - GHC 8.6.3
# checkout: true
# filters:
# branches:
# only: master

- hackage/upload:
publish: true
requires:
- lts-12
- GHC 8.2.2
- GHC 8.4.4
# - GHC 8.6.3
username: ${HACKAGE_USER}
password: ${HACKAGE_PASS}
filters:
branches:
only: master

tagged-release:
jobs:
- release:
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
26 changes: 4 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Created by http://www.gitignore.io

### OSX ###
.DS_Store
*.DS_Store
Expand All @@ -12,31 +10,30 @@ Icon
# Thumbnails
._*

docker/rdkafka/

# Files that might appear on external disk
.Spotlight-V100
.Trashes

### Haskell ###
dist
dist/
dist-newstyle/
cabal-dev
.ghc.environment*
*.o
*.hi
*.chi
*.chs.h
.virthualenv
.hsenv
.cabal-sandbox/
*.cabal
cabal.sandbox.config
cabal.config
cabal.project.local
.stack-work/
*.aux
*.ps
*.hp
*.prof
/out

### Emacs ###
# -*- mode: gitignore; -*-
Expand All @@ -63,18 +60,3 @@ tramp
# elpa packages
/elpa/
TAGS

## Python
.idea

/state

*.ipynb
__pycache*

# transient librdkafka
.librdkafka

# Asif files
/*.asif
/*.asif.gz
Loading

0 comments on commit 10134e4

Please sign in to comment.