Skip to content

Commit 2fb6073

Browse files
committed
Switch to new-style Travis CI job configuration
This configuration is generated via a script based on the `tested-with`-field from the .cabal file. Moreover, this makes use of Travis' new caching feature allowing to halve build-times to under 2 minutes for cache-hits.
1 parent ee0a441 commit 2fb6073

File tree

2 files changed

+77
-30
lines changed

2 files changed

+77
-30
lines changed

.travis.yml

Lines changed: 76 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,84 @@
1-
# NB: don't set `language: haskell` here
1+
# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
2+
language: c
3+
sudo: false
24

3-
# The following enables several GHC versions to be tested; often it's enough to test only against the last release in a major GHC version. Feel free to omit lines listings versions you don't need/want testing for.
4-
env:
5-
- GHCVER=7.4.2
6-
- GHCVER=7.6.3
7-
- GHCVER=7.8.1
8-
# - GHCVER=head # see section about GHC HEAD snapshots
5+
cache:
6+
directories:
7+
- $HOME/.cabsnap
8+
- $HOME/.cabal/packages
9+
10+
before_cache:
11+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
12+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
13+
14+
matrix:
15+
include:
16+
- env: CABALVER=1.16 GHCVER=7.4.2
17+
compiler: ": #GHC 7.4.2"
18+
addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2], sources: [hvr-ghc]}}
19+
- env: CABALVER=1.16 GHCVER=7.6.3
20+
compiler: ": #GHC 7.6.3"
21+
addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}}
22+
- env: CABALVER=1.18 GHCVER=7.8.4
23+
compiler: ": #GHC 7.8.4"
24+
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
25+
- env: CABALVER=1.22 GHCVER=7.10.3
26+
compiler: ": #GHC 7.10.3"
27+
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}}
928

10-
# Note: the distinction between `before_install` and `install` is not important.
1129
before_install:
12-
- sudo add-apt-repository -y ppa:hvr/ghc
13-
- sudo apt-get update
14-
- sudo apt-get install cabal-install-1.18 ghc-$GHCVER happy
15-
- export PATH=/opt/ghc/$GHCVER/bin:$PATH
30+
- unset CC
31+
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
1632

17-
# Benchmarks aren't built as installing their dependencies causes a
18-
# dependency cycle.
1933
install:
20-
- cabal-1.18 update
21-
- cabal-1.18 install --only-dependencies --enable-tests
34+
- cabal --version
35+
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
36+
- if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
37+
then
38+
zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
39+
$HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
40+
fi
41+
- travis_retry cabal update -v
42+
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
43+
- cabal install --only-dependencies --enable-tests --dry -v > installplan.txt
44+
- sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
2245

23-
# Here starts the actual work to be performed for the package under test; any command which exits with a non-zero exit code causes the build to fail.
24-
script:
25-
- cabal-1.18 configure --enable-tests -v2 # -v2 provides useful information for debugging
26-
- cabal-1.18 build # this builds all libraries and executables (including tests/benchmarks)
27-
- cabal-1.18 test
28-
- cabal-1.18 sdist # tests that a source-distribution can be generated
29-
30-
# The following scriptlet checks that the resulting source distribution can be built & installed
31-
- export SRC_TGZ=$(cabal-1.18 info . | awk '{print $2 ".tar.gz";exit}') ;
32-
cd dist/;
33-
if [ -f "$SRC_TGZ" ]; then
34-
cabal-1.18 install "$SRC_TGZ";
46+
# check whether current requested install-plan matches cached package-db snapshot
47+
- if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
48+
then
49+
echo "cabal build-cache HIT";
50+
rm -rfv .ghc;
51+
cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
52+
cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
3553
else
36-
echo "expected '$SRC_TGZ' not found";
37-
exit 1;
54+
echo "cabal build-cache MISS";
55+
rm -rf $HOME/.cabsnap;
56+
mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
57+
cabal install --only-dependencies --enable-tests;
58+
fi
59+
60+
# snapshot package-db on cache miss
61+
- if [ ! -d $HOME/.cabsnap ];
62+
then
63+
echo "snapshotting package-db to build-cache";
64+
mkdir $HOME/.cabsnap;
65+
cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
66+
cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
3867
fi
68+
69+
# Here starts the actual work to be performed for the package under test;
70+
# any command which exits with a non-zero exit code causes the build to fail.
71+
script:
72+
- if [ -f configure.ac ]; then autoreconf -i; fi
73+
- cabal configure --enable-tests -v2 # -v2 provides useful information for debugging
74+
- cabal build # this builds all libraries and executables (including tests)
75+
- cabal test
76+
- cabal sdist # tests that a source-distribution can be generated
77+
78+
# Check that the resulting source distribution can be built & installed.
79+
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
80+
# `cabal install --force-reinstalls dist/*-*.tar.gz`
81+
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
82+
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
83+
84+
# EOF

unordered-containers.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ category: Data
2020
build-type: Simple
2121
cabal-version: >=1.8
2222
extra-source-files: CHANGES.md
23+
tested-with: GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2
2324

2425
flag debug
2526
description: Enable debug support

0 commit comments

Comments
 (0)