|
| 1 | +# This is the complex Travis configuration, which is intended for use |
| 2 | +# on open source libraries which need compatibility across multiple GHC |
| 3 | +# versions, must work with cabal-install, and should be |
| 4 | +# cross-platform. For more information and other options, see: |
| 5 | +# |
| 6 | +# https://docs.haskellstack.org/en/stable/travis_ci/ |
| 7 | +# |
| 8 | +# Copy these contents into the root directory of your Github project in a file |
| 9 | +# named .travis.yml |
| 10 | + |
| 11 | +# Do not choose a language; we provide our own build tools. |
1 | 12 | language: generic |
2 | 13 |
|
3 | 14 | services: |
4 | 15 | - docker |
5 | 16 |
|
| 17 | +# Caching so the next build will be fast too. |
6 | 18 | cache: |
7 | 19 | directories: |
| 20 | + - $HOME/.ghc |
| 21 | + - $HOME/.cabal |
8 | 22 | - $HOME/.stack |
| 23 | + - $TRAVIS_BUILD_DIR/.stack-work |
9 | 24 | - $TRAVIS_BUILD_DIR/examples/.stack-work |
10 | | - - $TRAVIS_BUILD_DIR/kubernetes/.stack-work |
11 | | - - $TRAVIS_BUILD_DIR/kubernetes-client/.stack-work |
12 | 25 |
|
13 | | -jobs: |
| 26 | +# The different configurations we want to test. We have BUILD=cabal which uses |
| 27 | +# cabal-install, and BUILD=stack which uses Stack. More documentation on each |
| 28 | +# of those below. |
| 29 | +# |
| 30 | +# We set the compiler values here to tell Travis to use a different |
| 31 | +# cache file per set of arguments. |
| 32 | +# |
| 33 | +# If you need to have different apt packages for each combination in the |
| 34 | +# matrix, you can use a line such as: |
| 35 | +# addons: {apt: {packages: [libfcgi-dev,libgmp-dev]}} |
| 36 | +matrix: |
14 | 37 | include: |
15 | | - - stage: Integration Tests |
16 | | - install: |
17 | | - # Download and install stack |
18 | | - - travis_retry curl -sSL https://get.haskellstack.org/ | sh |
19 | | - |
20 | | - # Download and install kubectl |
21 | | - - curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ |
22 | | - |
23 | | - # Download and install kind |
24 | | - - curl -LO https://github.com/kubernetes-sigs/kind/releases/download/v0.5.1/kind-linux-amd64 && chmod +x kind-linux-amd64 && sudo mv kind-linux-amd64 /usr/local/bin/kind |
25 | | - before_script: |
26 | | - # Create a new Kubernetes cluster using KinD |
27 | | - - kind create cluster |
28 | | - |
29 | | - # Set KUBECONFIG environment variable |
30 | | - - export KUBECONFIG="$(kind get kubeconfig-path)" |
31 | | - script: |
32 | | - # Verify if kubernetes installation is alright |
33 | | - - kubectl get pods -A |
34 | | - |
35 | | - # Compile the examples |
36 | | - - | |
37 | | - pushd examples \ |
38 | | - && stack build --no-terminal --fast \ |
39 | | - && popd |
40 | | -
|
41 | | - # Run simple test |
42 | | - - | |
43 | | - pushd examples \ |
44 | | - && stack exec simple \ |
45 | | - && popd |
46 | | -
|
47 | | - # Build and load the in-cluster-example image |
48 | | - - | |
49 | | - pushd examples \ |
50 | | - && cp "$(stack exec which in-cluster)" in-cluster-example \ |
51 | | - && docker build . -f in-cluster/Dockerfile -t in-cluster-example:latest \ |
52 | | - && kind load docker-image in-cluster-example:latest \ |
53 | | - && popd |
54 | | -
|
55 | | - # Wait for kind node to be ready |
56 | | - - kubectl wait --for=condition=Ready node --all |
57 | | - |
58 | | - # Run the test pod |
59 | | - - ./examples/in-cluster/run-test.sh |
| 38 | + - env: BUILD=integration-tests |
| 39 | + compiler: ": #integration-tests" |
| 40 | + addons: {apt: {packages: [libgmp-dev]}} |
| 41 | + |
| 42 | + - env: BUILD=stack ARGS="" |
| 43 | + compiler: ": #stack default" |
| 44 | + addons: {apt: {packages: [libgmp-dev]}} |
| 45 | + |
| 46 | + # - env: BUILD=cabal GHCVER=8.0.2 CABALVER=1.24 HAPPYVER=1.19.5 ALEXVER=3.1.7 |
| 47 | + # compiler: ": #GHC 8.0.2" |
| 48 | + # addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}} |
| 49 | + - env: BUILD=cabal GHCVER=8.2.2 CABALVER=2.0 HAPPYVER=1.19.5 ALEXVER=3.1.7 |
| 50 | + compiler: ": #GHC 8.2.2" |
| 51 | + addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}} |
| 52 | + - env: BUILD=cabal GHCVER=8.4.4 CABALVER=2.2 HAPPYVER=1.19.5 ALEXVER=3.1.7 |
| 53 | + compiler: ": #GHC 8.4.4" |
| 54 | + addons: {apt: {packages: [cabal-install-2.2,ghc-8.4.4,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}} |
| 55 | + - env: BUILD=cabal GHCVER=8.6.5 CABALVER=2.4 HAPPYVER=1.19.5 ALEXVER=3.1.7 |
| 56 | + compiler: ": #GHC 8.6.5" |
| 57 | + addons: {apt: {packages: [cabal-install-2.4,ghc-8.6.5,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}} |
| 58 | + |
| 59 | + # Build with the newest GHC and cabal-install. This is an accepted failure, |
| 60 | + # see below. |
| 61 | + - env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7 |
| 62 | + compiler: ": #GHC HEAD" |
| 63 | + addons: {apt: {packages: [cabal-install-head,ghc-head,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}} |
| 64 | + |
| 65 | + # The Stack builds. We can pass in arbitrary Stack arguments via the ARGS |
| 66 | + # variable, such as using --stack-yaml to point to a different file. |
| 67 | + - env: BUILD=stack ARGS="--resolver lts-11 --stack-yaml stack-8.2.2.yaml" |
| 68 | + compiler: ": #stack 8.2.2" |
| 69 | + addons: {apt: {packages: [libgmp-dev]}} |
| 70 | + |
| 71 | + - env: BUILD=stack ARGS="--resolver lts-12 --stack-yaml stack-8.4.4.yaml" |
| 72 | + compiler: ": #stack 8.4.4" |
| 73 | + addons: {apt: {packages: [libgmp-dev]}} |
| 74 | + |
| 75 | + - env: BUILD=stack ARGS="--resolver lts-14" |
| 76 | + compiler: ": #stack 8.6.5" |
| 77 | + addons: {apt: {packages: [libgmp-dev]}} |
| 78 | + |
| 79 | + # Nightly builds are allowed to fail |
| 80 | + - env: BUILD=stack ARGS="--resolver nightly" |
| 81 | + compiler: ": #stack nightly" |
| 82 | + addons: {apt: {packages: [libgmp-dev]}} |
| 83 | + |
| 84 | + # Build on macOS in addition to Linux |
| 85 | + - env: BUILD=stack ARGS="" |
| 86 | + compiler: ": #stack default osx" |
| 87 | + os: osx |
| 88 | + |
| 89 | + - env: BUILD=stack ARGS="--resolver lts-11 --stack-yaml stack-8.2.2.yaml" |
| 90 | + compiler: ": #stack 8.2.2 osx" |
| 91 | + os: osx |
| 92 | + |
| 93 | + - env: BUILD=stack ARGS="--resolver lts-12 --stack-yaml stack-8.4.4.yaml" |
| 94 | + compiler: ": #stack 8.4.4 osx" |
| 95 | + os: osx |
| 96 | + |
| 97 | + - env: BUILD=stack ARGS="--resolver lts-14" |
| 98 | + compiler: ": #stack 8.6.5 osx" |
| 99 | + os: osx |
| 100 | + |
| 101 | + - env: BUILD=stack ARGS="--resolver nightly" |
| 102 | + compiler: ": #stack nightly osx" |
| 103 | + os: osx |
| 104 | + |
| 105 | + allow_failures: |
| 106 | + - env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7 |
| 107 | + - env: BUILD=stack ARGS="--resolver nightly" |
| 108 | + |
| 109 | +before_install: |
| 110 | +# Using compiler above sets CC to an invalid value, so unset it |
| 111 | +- unset CC |
| 112 | + |
| 113 | +# We want to always allow newer versions of packages when building on GHC HEAD |
| 114 | +- CABALARGS="" |
| 115 | +- if [ "x$GHCVER" = "xhead" ]; then CABALARGS=--allow-newer; fi |
| 116 | + |
| 117 | +# Download and unpack the stack executable |
| 118 | +- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:/opt/alex/$ALEXVER/bin:/opt/happy/$HAPPYVER/bin:$HOME/.cabal/bin:$PATH |
| 119 | +- mkdir -p ~/.local/bin |
| 120 | +- | |
| 121 | + if [ `uname` = "Darwin" ] |
| 122 | + then |
| 123 | + travis_retry curl --insecure -L https://get.haskellstack.org/stable/osx-x86_64.tar.gz | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin |
| 124 | + else |
| 125 | + travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' |
| 126 | + fi |
| 127 | +
|
| 128 | + # Use the more reliable S3 mirror of Hackage |
| 129 | + mkdir -p $HOME/.cabal |
| 130 | + echo 'remote-repo: hackage.haskell.org:http://hackage.fpcomplete.com/' > $HOME/.cabal/config |
| 131 | + echo 'remote-repo-cache: $HOME/.cabal/packages' >> $HOME/.cabal/config |
| 132 | +
|
| 133 | +
|
| 134 | +install: |
| 135 | +- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" |
| 136 | +- if [ -f configure.ac ]; then autoreconf -i; fi |
| 137 | +- | |
| 138 | + set -ex |
| 139 | + case "$BUILD" in |
| 140 | + stack) |
| 141 | + # Add in extra-deps for older snapshots, as necessary |
| 142 | + # |
| 143 | + # This is disabled by default, as relying on the solver like this can |
| 144 | + # make builds unreliable. Instead, if you have this situation, it's |
| 145 | + # recommended that you maintain multiple stack-lts-X.yaml files. |
| 146 | +
|
| 147 | + #stack --no-terminal --install-ghc $ARGS test --bench --dry-run || ( \ |
| 148 | + # stack --no-terminal $ARGS build cabal-install && \ |
| 149 | + # stack --no-terminal $ARGS solver --update-config) |
| 150 | +
|
| 151 | + # Build the dependencies |
| 152 | + stack --no-terminal --install-ghc $ARGS test --bench --only-dependencies --fast |
| 153 | + ;; |
| 154 | + cabal) |
| 155 | + cabal --version |
| 156 | + travis_retry cabal update |
| 157 | +
|
| 158 | + # Get the list of packages from the stack.yaml file. Note that |
| 159 | + # this will also implicitly run hpack as necessary to generate |
| 160 | + # the .cabal files needed by cabal-install. |
| 161 | + PACKAGES=$(stack --system-ghc query locals | grep '^ *path' | sed 's@^ *path:@@') |
| 162 | +
|
| 163 | + cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS $PACKAGES |
| 164 | + ;; |
| 165 | + integration-tests) |
| 166 | + curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ |
| 167 | + # Download and install kind |
| 168 | + curl -LO https://github.com/kubernetes-sigs/kind/releases/download/v0.5.1/kind-linux-amd64 && chmod +x kind-linux-amd64 && sudo mv kind-linux-amd64 /usr/local/bin/kind |
| 169 | + # Create a new Kubernetes cluster using KinD |
| 170 | + kind create cluster |
| 171 | +
|
| 172 | + # Set KUBECONFIG environment variable |
| 173 | + export KUBECONFIG="$(kind get kubeconfig-path)" |
| 174 | +
|
| 175 | + stack --no-terminal --install-ghc --stack-yaml ./examples/stack.yaml --work-dir .stack-work build --only-dependencies --fast |
| 176 | + ;; |
| 177 | + esac |
| 178 | + set +ex |
| 179 | +
|
| 180 | +script: |
| 181 | +- | |
| 182 | + set -ex |
| 183 | + case "$BUILD" in |
| 184 | + stack) |
| 185 | + stack --no-terminal $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps --fast |
| 186 | + ;; |
| 187 | + cabal) |
| 188 | + cabal install --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS $PACKAGES |
| 189 | +
|
| 190 | + ORIGDIR=$(pwd) |
| 191 | + for dir in $PACKAGES |
| 192 | + do |
| 193 | + cd $dir |
| 194 | + cabal check || [ "$CABALVER" == "1.16" ] |
| 195 | + cabal sdist |
| 196 | + PKGVER=$(cabal info . | awk '{print $2;exit}') |
| 197 | + SRC_TGZ=$PKGVER.tar.gz |
| 198 | + cd dist |
| 199 | + tar zxfv "$SRC_TGZ" |
| 200 | + cd "$PKGVER" |
| 201 | + cabal configure --enable-tests --ghc-options -O0 |
| 202 | + cabal build |
| 203 | + if [ "$CABALVER" = "1.16" ] || [ "$CABALVER" = "1.18" ]; then |
| 204 | + cabal test |
| 205 | + else |
| 206 | + cabal test --show-details=streaming --log=/dev/stdout |
| 207 | + fi |
| 208 | + cd $ORIGDIR |
| 209 | + done |
| 210 | + ;; |
| 211 | + integration-tests) |
| 212 | + EXAMPLE_ARGS="--no-terminal --install-ghc --stack-yaml ./examples/stack.yaml --work-dir .stack-work" |
| 213 | + stack $EXAMPLE_ARGS build --fast |
| 214 | +
|
| 215 | + # Run simple test |
| 216 | + stack $EXAMPLE_ARGS exec simple |
| 217 | +
|
| 218 | + # Build and load the in-cluster-example image |
| 219 | + cp "$(stack $EXAMPLE_ARGS exec which in-cluster)" in-cluster-example |
| 220 | + docker build . -f ./examples/in-cluster/Dockerfile -t in-cluster-example:latest |
| 221 | + kind load docker-image in-cluster-example:latest |
| 222 | +
|
| 223 | + # Wait for kind node to be ready |
| 224 | + kubectl wait --for=condition=Ready node --all |
| 225 | +
|
| 226 | + # Run the test pod |
| 227 | + ./examples/in-cluster/run-test.sh |
| 228 | + ;; |
| 229 | + esac |
| 230 | + set +ex |
0 commit comments