on master help sign in
Add travis build matrix config.
commit047b40cbe64076e6acad59d763cba7d89471f02c authorDiogo Biazus <diogo@biazus.me> dateSat 16 Dec 2017, 17:09 (9 years ago) parent14f4a77
4 files changed+115−41
.travis.yml+40−41 .travis/attach-binary.sh+25 .travis/install-ghr.sh+21 .travis/install-stack.sh+29
.travis.yml+40−41
@@ -1,5 +1,5 @@
1−# For more information, see https://github.com/hvr/multi-ghc-travis
2−language: c
1+# For more information, see https://github.com/ChrisPenner/haskell-stack-travis-ci
2+language: nix
33sudo: false
44
55git:
@@ -7,52 +7,51 @@ git:
77
88cache:
99 directories:
10− - $HOME/.cabal/packages
11− - $HOME/.cabal/store
12−
13−before_cache:
14− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
15− # remove files that are regenerated by 'cabal update'
16− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
17− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
18− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
19− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
20− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
10+ - $HOME/.ghc
11+ - $HOME/.cabal
12+ - $HOME/.stack
13+ - .stack-work
2114
2215matrix:
16+ fast_finish: true
2317 include:
24− #- compiler: "ghc-7.8.4"
25− # env: TEST=--disable-tests BENCH=--disable-benchmarks
26− # addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}}
27− - compiler: "ghc-7.10.3"
28− # env: TEST=--disable-tests BENCH=--disable-benchmarks
29− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}}
30− - compiler: "ghc-8.0.2"
31− # env: TEST=--disable-tests BENCH=--disable-benchmarks
32− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
33− #- compiler: "ghc-8.2.1"
34− # env: TEST=--disable-tests BENCH=--disable-benchmarks
35− # addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
36−
37−before_install:
38− - HC=${CC}
39− - unset CC
40− - PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
18+ - env: GHCVER=7.10.3 CACHE_NAME=7.10.3
19+ compiler: ": #stack 7.10.3"
20+ addons: {apt: {packages: [ghc-7.10.3], sources: [hvr-ghc]}}
4121
42−install:
43− - cabal --version
44− - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
45− - travis_retry cabal update -v
46− - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
22+ - env: GHCVER=8.0.2 CACHE_NAME=8.0.2
23+ compiler: ": #stack 8.0.2"
24+ addons: {apt: {packages: [ghc-8.0.2], sources: [hvr-ghc]}}
4725
48− - cabal new-build -w ${HC} --enable-tests --dep -j2 all
26+ - env: GHCVER=8.2.1 CACHE_NAME=8.2.1 BUILD_BINARY=1
27+ compiler: ": #stack 8.2.1"
28+ addons: {apt: {packages: [ghc-8.2.1], sources: [hvr-ghc]}}
29+
30+ - env: GHCVER=8.2.1 CACHE_NAME=8.2.1-osx BUILD_BINARY=1
31+ os: osx
32+ compiler: ": #stack 8.2.1"
33+ addons: {apt: {packages: [ghc-8.2.1], sources: [hvr-ghc]}}
34+
35+install:
36+ - unset CC
37+ - export PATH=$HOME/.local/bin:/opt/ghc/$GHCVER/bin:$PATH
38+ - ./.travis/install-ghr.sh
39+ - ./.travis/install-stack.sh
4940
5041# Here starts the actual work to be performed for the package under test;
5142# any command which exits with a non-zero exit code causes the build to fail.
5243script:
53− - cabal sdist
54− - cabal new-build -w ${HC} -j1
55− - cabal new-test -w ${HC}
56− - curl -sL https://raw.github.com/ndmitchell/hlint/master/misc/travis.sh | sh -s lint src test examples --cpp-define VERSION_project_m36=HLINT
57− - cabal new-haddock
44+ - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
45+ - GHC_OPTIONS=""
46+ - |
47+ set -ex
48+ # Run tests
49+ stack --no-terminal test --ghc-options="$GHC_OPTIONS"
50+ set +ex
51+
52+after_success:
53+ - |
54+ # Build and ship binary
55+ ./.travis/attach-binary.sh
56+
5857# EOF
.travis/attach-binary.shnew file+25
@@ -0,0 +1,25 @@
1+#!/bin/sh
2+set -o errexit -o verbose
3+
4+if test ! "$BUILD_BINARY" || test ! "$TRAVIS_TAG"
5+then
6+ echo 'This is not a release build.'
7+elif test ! "$GITHUB_TOKEN"
8+then
9+ echo 'The GITHUB_TOKEN environment variable is not set!'
10+ exit 1
11+else
12+ echo "Building binary for $TRAVIS_OS_NAME to $TRAVIS_TAG..."
13+ stack build --ghc-options -O2 --pedantic
14+ echo "Attaching binary for $TRAVIS_OS_NAME to $TRAVIS_TAG..."
15+ OWNER="$(echo "$TRAVIS_REPO_SLUG" | cut -f1 -d/)"
16+ REPO="$(echo "$TRAVIS_REPO_SLUG" | cut -f2 -d/)"
17+ BIN="$(stack path --local-install-root)/bin/$REPO"
18+ BUNDLE_NAME="$REPO-$TRAVIS_TAG-$TRAVIS_OS_NAME.tar.gz"
19+ cp "$BIN" "./$REPO"
20+ chmod +x "./$REPO"
21+ tar -czf "$BUNDLE_NAME" "$REPO"
22+ echo "SHA256:"
23+ shasum -a 256 "$BUNDLE_NAME"
24+ ghr -t "$GITHUB_TOKEN" -u "$OWNER" -r "$REPO" --replace "$(git describe --tags)" "$BUNDLE_NAME"
25+fi
.travis/install-ghr.shnew file+21
@@ -0,0 +1,21 @@
1+#!/bin/sh
2+set -o errexit -o verbose
3+
4+if test ! "$BUILD_BINARY" || test ! "$TRAVIS_TAG"
5+then
6+ echo 'This is not a release build.'
7+else
8+ if [ "$TRAVIS_OS_NAME" = "linux" ]
9+ then
10+ ARCH="linux"
11+ else
12+ ARCH="darwin"
13+ fi
14+ echo "Installing ghr"
15+ URL="https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_${ARCH}_386.zip"
16+ curl -L ${URL} > ghr.zip
17+ mkdir -p "$HOME/bin"
18+ export PATH="$HOME/bin:$PATH"
19+ unzip ghr.zip -d "$HOME/bin"
20+ rm ghr.zip
21+fi
.travis/install-stack.shnew file+29
@@ -0,0 +1,29 @@
1+#!/bin/sh
2+
3+# Adapted from https://github.com/commercialhaskell/stack
4+
5+set -eux
6+
7+travis_retry() {
8+ cmd=$*
9+ $cmd || (sleep 2 && $cmd) || (sleep 10 && $cmd)
10+}
11+
12+fetch_stack_osx() {
13+ curl -skL https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin;
14+}
15+
16+fetch_stack_linux() {
17+ curl -sL https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack';
18+}
19+
20+# We need stack to generate cabal files with precise bounds, even for cabal
21+# builds.
22+mkdir -p ~/.local/bin;
23+if [ "$(uname)" = "Darwin" ]; then
24+ travis_retry fetch_stack_osx
25+else
26+ travis_retry fetch_stack_linux
27+fi
28+
29+travis_retry stack --no-terminal setup;