on master help sign in
Add travis build matrix config.
commit1784479f81c5ea19c87d600a267e5b87b4fca862 authorDiogo Biazus <diogo@biazus.me> dateSat 16 Dec 2017, 17:09 (9 years ago) parent7290d32
5 files changed+113−42
.travis.yml+36−40 .travis/attach-binary.sh+25 .travis/install-ghr.sh+21 .travis/install-stack.sh+27 src/lib/ProjectM36/ScriptSession.hs+4−2
.travis.yml+36−40
@@ -1,4 +1,4 @@
1−# For more information, see https://github.com/hvr/multi-ghc-travis
1+# For more information, see https://github.com/ChrisPenner/haskell-stack-travis-ci
22language: c
33sudo: false
44
@@ -7,52 +7,48 @@ 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:
2316 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
17+ - env: CACHE_NAME=7.10.3 STACK_YAML=stack.ghc7.10.yaml
18+ compiler: ": #stack 7.10.3"
4119
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
20+ - env: CACHE_NAME=8.0.2 STACK_YAML=stack.yaml
21+ compiler: ": #stack 8.0.2"
4722
48− - cabal new-build -w ${HC} --enable-tests --dep -j2 all
23+ - env: CACHE_NAME=osx-7.10.3 STACK_YAML=stack.ghc7.10.yaml
24+ os: osx
25+ compiler: ": #stack 7.10.3"
26+
27+ - env: CACHE_NAME=osx-8.0.2 STACK_YAML=stack.yaml
28+ os: osx
29+ compiler: ": #stack 8.0.2"
30+
31+install:
32+ - unset CC
33+ - export PATH=$HOME/.local/bin:$PATH
34+ - ./.travis/install-ghr.sh
35+ - ./.travis/install-stack.sh
36+ - travis_wait travis_retry stack setup
37+ - travis_retry stack build --only-dependencies
4938
5039# Here starts the actual work to be performed for the package under test;
5140# any command which exits with a non-zero exit code causes the build to fail.
5241script:
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
42+ - GHC_OPTIONS=""
43+ - |
44+ set -ex
45+ # Run tests
46+ stack --no-terminal test --ghc-options="$GHC_OPTIONS"
47+ set +ex
48+
49+after_success:
50+ - |
51+ # Build and ship binary
52+ ./.travis/attach-binary.sh
53+
5854# 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+27
@@ -0,0 +1,27 @@
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
src/lib/ProjectM36/ScriptSession.hs+4−2
@@ -46,7 +46,9 @@ initScriptSession ghcPkgPaths = do
4646
4747 sandboxPkgPaths <- liftIO $ concat <$> mapM glob [
4848 "./dist-newstyle/packagedb/ghc-" ++ ghcVersion,
49− ".cabal-sandbox/*ghc-" ++ ghcVersion ++ "-packages.conf.d",
49+ ".cabal-sandbox/*ghc-" ++ ghcVersion ++ "-packages.conf.d",
50+ ".stack-work/install/*/*/" ++ ghcVersion ++ "/pkgdb",
51+ homeDir </> ".stack/snapshots/*/*/" ++ ghcVersion ++ "/pkgdb",
5052 homeDir </> ".cabal/store/ghc-" ++ ghcVersion ++ "/package.db"
5153 ]
5254
@@ -171,4 +173,4 @@ typeCheckScript expectedType inp = do
171173 pure Nothing
172174 else
173175 pure (Just (TypeCheckCompilationError (showType dflags expectedType) (showType dflags funcType)))
174−
176+