Skip to content

Commit 4a46304

Browse files
committed
Rework cabal and travis files
1 parent 5124f03 commit 4a46304

10 files changed

Lines changed: 134 additions & 103 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ cabal.sandbox.config
77
*~
88
*.hi
99
*.o
10+
.stack-work

.travis.yml

Lines changed: 21 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cache:
66
directories:
77
- $HOME/.cabsnap
88
- $HOME/.cabal/packages
9+
- $HOME/.stack
910

1011
before_cache:
1112
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
@@ -17,77 +18,41 @@ env:
1718

1819
matrix:
1920
include:
20-
- env: CABALVER=1.18 GHCVER=7.8.4
21+
- env: BUILD=cabal CABALVER=1.18 GHCVER=7.8.4
2122
compiler: ": #GHC 7.8.4"
2223
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
23-
- env: CABALVER=1.18 GHCVER=7.8.4 STACKAGESNAPSHOT=lts-2.22
24+
- env: BUILD=cabal CABALVER=1.18 GHCVER=7.8.4 STACKAGESNAPSHOT=lts-2.22
2425
compiler: ": #GHC 7.8.4 lts-2.22"
2526
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
26-
- env: CABALVER=1.22 GHCVER=7.10.2
27+
- env: BUILD=cabal CABALVER=1.22 GHCVER=7.10.2
2728
compiler: ": #GHC 7.10.2"
2829
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2], sources: [hvr-ghc]}}
29-
- env: CABALVER=1.22 GHCVER=7.10.2 STACKAGESNAPSHOT=lts-3
30+
- env: BUILD=cabal CABALVER=1.22 GHCVER=7.10.2 STACKAGESNAPSHOT=lts-3
3031
compiler: ": #GHC 7.10.2 lts-3"
3132
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2], sources: [hvr-ghc]}}
33+
- env: BUILD=stack STACK_YAML=stack-lts-2.yaml
34+
compiler: ": #STACK LTS2"
35+
addons: {apt: {packages: [ghc-7.8.4], sources: [hvr-ghc]}}
36+
- env: BUILD=stack STACK_YAML=stack-lts-3.yaml
37+
compiler: ": #STACK LTS3"
38+
addons: {apt: {packages: [ghc-7.10.2], sources: [hvr-ghc]}}
39+
- env: BUILD=stack STACK_YAML=stack-nightly.yaml
40+
compiler: ": #STACK nightly"
41+
addons: {apt: {packages: [ghc-7.10.3], sources: [hvr-ghc]}}
42+
- env: BUILD=stack STACK_YAML=stack-lts-3.yaml
43+
compiler: ": #stack LTS3 OSX"
44+
os: osx
3245

3346
before_install:
34-
- unset CC
35-
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
47+
- unset CC
48+
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:$PATH
3649

3750
install:
38-
- if [ -n "$STACKAGESNAPSHOT" ]; then wget https://www.stackage.org/$STACKAGESNAPSHOT/cabal.config; fi
39-
- cabal --version
40-
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
41-
- if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
42-
then
43-
zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
44-
$HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
45-
fi
46-
- travis_retry cabal update -v
47-
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
48-
- cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
49-
- sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
50-
51-
# check whether current requested install-plan matches cached package-db snapshot
52-
- if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
53-
then
54-
echo "cabal build-cache HIT";
55-
rm -rfv .ghc;
56-
cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
57-
cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
58-
else
59-
echo "cabal build-cache MISS";
60-
rm -rf $HOME/.cabsnap;
61-
mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
62-
cabal install --only-dependencies --enable-tests --enable-benchmarks;
63-
fi
64-
65-
# snapshot package-db on cache miss
66-
- if [ ! -d $HOME/.cabsnap ];
67-
then
68-
echo "snapshotting package-db to build-cache";
69-
mkdir $HOME/.cabsnap;
70-
cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
71-
cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
72-
fi
51+
- sh travis-install.sh
7352

7453
# Here starts the actual work to be performed for the package under test;
7554
# any command which exits with a non-zero exit code causes the build to fail.
7655
script:
77-
- if [ -f configure.ac ]; then autoreconf -i; fi
78-
- cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
79-
- cabal build # this builds all libraries and executables (including tests/benchmarks)
80-
- cabal test --show-details=always
81-
82-
- if [ "$CABALVER" = "1.22" ]; then cabal check; fi
83-
- if [ "$CABALVER" = "1.22" ]; then cabal haddock; fi
84-
85-
- cabal sdist # tests that a source-distribution can be generated
86-
87-
# Check that the resulting source distribution can be built & installed.
88-
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
89-
# `cabal install --force-reinstalls dist/*-*.tar.gz`
90-
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
91-
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
56+
- sh travis-script.sh
9257

9358
# EOF

github.cabal

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,22 @@
1-
-- github.cabal auto-generated by cabal init. For additional options,
2-
-- see
3-
-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.
4-
-- The name of the package.
51
Name: github
6-
7-
-- The package version. See the Haskell package versioning policy
8-
-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
9-
-- standards guiding when and how versions should be incremented.
102
Version: 0.14.0
11-
12-
-- A short (one-line) description of the package.
133
Synopsis: Access to the Github API, v3.
14-
15-
-- A longer description of the package.
164
Description: The Github API provides programmatic access to the full
175
Github Web site, from Issues to Gists to repos down to the underlying git data
186
like references and trees. This library wraps all of that, exposing a basic but
197
Haskell-friendly set of functions and data structures.
208
.
219
For more of an overview please see the README: <https://github.com/jwiegley/github/blob/master/README.md>
22-
23-
-- The license under which the package is released.
2410
License: BSD3
25-
26-
-- The file containing the license text.
2711
License-file: LICENSE
28-
29-
-- The package author(s).
30-
Author: Mike Burns, John Wiegley
31-
32-
-- An email address to which users can send suggestions, bug reports,
33-
-- and patches.
34-
Maintainer: [email protected]
35-
36-
Homepage: https://github.com/jwiegley/github
37-
38-
-- A copyright notice.
39-
Copyright: Copyright 2012-2013 Mike Burns, Copyright 2013-2015 John Wiegley
40-
41-
Category: Network APIs
42-
12+
Author: Mike Burns, John Wiegley, Oleg Grenrus
13+
Maintainer: Oleg Grenrus <[email protected]>
14+
Homepage: https://github.com/phadej/github
15+
Copyright: Copyright 2012-2013 Mike Burns, Copyright 2013-2015 John Wiegley, Copyright 2016 Oleg Grenrus
16+
Category: Network
4317
Build-type: Simple
44-
4518
Tested-with: GHC==7.8.4, GHC==7.10.2
46-
47-
-- Extra files to be distributed with the package, such as examples or
48-
-- a README.
19+
Cabal-version: >=1.10
4920
Extra-source-files: README.md
5021
,samples/Gists/Comments/ShowComment.hs
5122
,samples/Gists/Comments/ShowComments.hs
@@ -124,9 +95,10 @@ Extra-source-files: README.md
12495
,samples/Users/ShowUser.hs
12596
,LICENSE
12697

127-
128-
-- Constraint on the version of Cabal needed to build this package.
129-
Cabal-version: >=1.10
98+
flag aeson-compat
99+
description: Whether to use aeson-compat or aeson-extra
100+
default: True
101+
manual: False
130102

131103
source-repository head
132104
type: git
@@ -135,6 +107,7 @@ source-repository head
135107
Library
136108
-- Modules exported by the library.
137109
Default-Language: Haskell2010
110+
GHC-Options: -Wall
138111
Exposed-modules: Github.All,
139112
Github.Auth,
140113
Github.Data,
@@ -186,7 +159,6 @@ Library
186159
Build-depends: base >= 4.0 && < 5.0,
187160
time >=1.4 && <1.6,
188161
aeson >= 0.6.1.0,
189-
aeson-extra >= 0.2.0.0 && <0.3,
190162
attoparsec >= 0.10.3.0,
191163
bytestring,
192164
case-insensitive >= 0.4.0.4,
@@ -205,11 +177,10 @@ Library
205177
byteable >= 0.1.0,
206178
base16-bytestring >= 0.1.1.6
207179

208-
-- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
209-
-- Build-tools:
210-
211-
GHC-Options: -Wall -fno-warn-orphans
212-
180+
if flag(aeson-compat)
181+
Build-depends: aeson-compat >= 0.3.0.0 && <0.4
182+
else
183+
Build-depends: aeson-extra >= 0.2.0.0 && <0.3
213184

214185
test-suite github-test
215186
default-language: Haskell2010
@@ -220,11 +191,14 @@ test-suite github-test
220191
Github.UsersSpec
221192
Github.OrganizationsSpec
222193
main-is: Spec.hs
194+
ghc-options: -Wall
223195
build-depends: base >= 4.0 && < 5.0,
224196
base-compat,
225-
aeson-extra >= 0.2.0.0 && <0.3,
226197
github,
227198
file-embed,
228199
hspec
200+
if flag(aeson-compat)
201+
build-depends: aeson-compat >= 0.3.0.0 && <0.4
202+
else
203+
build-depends: aeson-extra >= 0.2.0.0 && <0.3
229204

230-
ghc-options: -Wall -fno-warn-orphans

spec/Github/SearchSpec.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
{-# LANGUAGE OverloadedStrings #-}
33
module Github.SearchSpec where
44

5-
import Control.Applicative ((<$>))
5+
import Prelude ()
6+
import Prelude.Compat
7+
68
import Data.Aeson.Compat (eitherDecodeStrict)
79
import Data.FileEmbed (embedFile)
810
import Test.Hspec (Spec, describe, it, shouldBe)

stack-lts-2.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
packages:
2+
- '.'
3+
extra-deps:
4+
- aeson-extra-0.2.3.0
5+
resolver: lts-2.22
6+
flags:
7+
github:
8+
aeson-compat: false

stack-lts-3.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
packages:
2+
- '.'
3+
extra-deps: []
4+
resolver: lts-3.20
5+
flags:
6+
github:
7+
aeson-compat: false

stack-nightly.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resolver: nightly-2016-01-03
2+
packages:
3+
- '.'
4+
extra-deps: []
5+
flags:
6+
github:
7+
aeson-compat: true

stack.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stack-lts-3.yaml

travis-install.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
case $BUILD in
2+
stack)
3+
mkdir -p ~/.local/bin;
4+
if [ `uname` = "Darwin" ]; then
5+
curl -kL https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin;
6+
else
7+
curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack';
8+
fi
9+
stack --no-terminal setup
10+
;;
11+
cabal)
12+
if [ -n "$STACKAGESNAPSHOT" ]; then wget https://www.stackage.org/$STACKAGESNAPSHOT/cabal.config; fi
13+
cabal --version
14+
echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
15+
if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ]; then
16+
zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz > $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
17+
fi
18+
travis_retry cabal update -v
19+
sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
20+
cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
21+
sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
22+
23+
# check whether current requested install-plan matches cached package-db snapshot
24+
if diff -u installplan.txt $HOME/.cabsnap/installplan.txt; then
25+
echo "cabal build-cache HIT";
26+
rm -rfv .ghc;
27+
cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
28+
cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
29+
else
30+
echo "cabal build-cache MISS";
31+
rm -rf $HOME/.cabsnap;
32+
mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
33+
cabal install --only-dependencies --enable-tests --enable-benchmarks;
34+
fi
35+
36+
# snapshot package-db on cache miss
37+
if [ ! -d $HOME/.cabsnap ]; then
38+
echo "snapshotting package-db to build-cache";
39+
mkdir $HOME/.cabsnap;
40+
cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
41+
cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
42+
fi
43+
;;
44+
esac

travis-script.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
case $BUILD in
2+
stack)
3+
stack --no-terminal test --only-dependencies
4+
;;
5+
cabal)
6+
if [ -f configure.ac ]; then autoreconf -i; fi
7+
cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
8+
cabal build # this builds all libraries and executables (including tests/benchmarks)
9+
cabal test --show-details=always
10+
11+
if [ "$CABALVER" = "1.22" ]; then cabal check; fi
12+
if [ "$CABALVER" = "1.22" ]; then cabal haddock; fi
13+
14+
cabal sdist # tests that a source-distribution can be generated
15+
16+
# Check that the resulting source distribution can be built & installed.
17+
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
18+
# `cabal install --force-reinstalls dist/*-*.tar.gz`
19+
SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
20+
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
21+
;;
22+
esac

0 commit comments

Comments
 (0)