-
Notifications
You must be signed in to change notification settings - Fork 16
/
travis.sh
143 lines (125 loc) · 3.74 KB
/
travis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/sh
# This script is invoked from my Travis-CI commands
# It bootstraps to grab the 'neil' tool and run 'neil test'
set -e # exit on errors
set -x # echo each line
GITHUB_USER=$1
COMMIT=$2
if [ -z "$GITHUB_USER" ]; then
GITHUB_USER=ndmitchell
fi
if [ -z "$COMMIT" ]; then
COMMIT=master
fi
retry(){
($@) && return
sleep 15
($@) && return
sleep 15
$@
}
timer(){
set +x
local before=$(date +%s)
set -x
$@
set +x
local after=$(date +%s)
echo Timing: $(expr $after - $before) spent doing $@
set -x
}
# make sure we hlint check before running the tests, in case they generate non-compliant hlint
if [ "$HLINT_ARGUMENTS" = "" ]; then
HLINT_ARGUMENTS=.
fi
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s $HLINT_ARGUMENTS --with-group=extra --with-group=future
# Temporary until GHC 8.10 is released
# if [ "$GHCVER" = "head" ]; then
# GHCVER=8.10.1
# export GHC_HEAD=1
# fi
if [ "$GHCVER" = "8.0" ]; then GHCVER=8.0.2; fi
if [ "$GHCVER" = "8.2" ]; then GHCVER=8.2.2; fi
if [ "$GHCVER" = "8.4" ]; then GHCVER=8.4.4; fi
if [ "$GHCVER" = "8.6" ]; then GHCVER=8.6.5; fi
if [ "$GHCVER" = "8.8" ]; then GHCVER=8.8.4; fi
if [ "$GHCVER" = "8.10" ]; then GHCVER=8.10.2; fi
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
# Try and use the Cabal that ships with the same GHC version
if [ "$GHCVER" = "8.8.4" ] || [ "$GHCVER" = "8.10.2" ]; then
CABALVER=3.0
else
CABALVER=2.4
fi
retry sudo add-apt-repository -y ppa:hvr/ghc
# Sometimes apt-get update fails silently, but then apt-get install fails loudly, so retry both
update_install(){
sudo apt-get --allow-unauthenticated update && sudo apt-get --allow-unauthenticated install ghc-$GHCVER cabal-install-$CABALVER happy-1.19.4 alex-3.1.3
}
retry update_install
export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:/opt/happy/1.19.4/bin:/opt/alex/3.1.3/bin:$PATH
retry cabal update
else
brew update
brew install ghc cabal-install
retry cabal update
cabal install alex happy
fi
export PATH=$HOME/.cabal/bin:$PATH
ghc --version
cabal --version
happy --version
alex --version
haddock --version
if [ "$GHCVER" = "" ]; then
# Only happens on Mac where ghc is installed via brew
export GHCVER=$(ghc --numeric-version)
fi
if [ "$GHCVER" = "head" ]; then
export GHC_HEAD=1
fi
if [ "$GHCVER" = "8.6.5" ]; then
export GHC_STABLE=1
fi
ghc-pkg list
if [ "$HASKELL_DEPENDENCIES" != "" ]; then
retry cabal v1-install $HASKELL_DEPENDENCIES
fi
retry cabal v1-install --only-dependencies --enable-tests $CABALFLAGS || FAIL=1
if [ "$GHC_HEAD" = "1" ] && [ "$FAIL" = "1" ]; then
FAIL=
retry cabal v1-install --only-dependencies --enable-tests --force-reinstalls --allow-newer || FAIL=1
if [ "$FAIL" = "1" ]; then
echo Failed because some dependencies failed to install, not my fault
exit
fi
fi
ghc-pkg list
retry git clone -n "https://github.com/$GITHUB_USER/neil" .neil
(cd .neil && git checkout $COMMIT && retry cabal v1-install --allow-newer --flags=small)
if [ -e travis.hs ]; then
# ensure that reinstalling this package won't break the test script
mkdir travis
ghc --make travis.hs -outputdir travis -o travis/travis
fi
FLAGS=
if [ "$GHCVER" = "head" ]; then
FLAGS=--no-warnings
fi
timer neil test --install $FLAGS
if [ -e travis.hs ]; then
timer travis/travis
fi
git diff --exit-code # check regenerating doesn't change anything
# Generate artifacts for release
mkdir travis-release
if [ "$GHC_STABLE" = "1" ] || [ "$TRAVIS_OS_NAME" = "osx" ]; then
neil binary
if [ -d dist/bin ]; then
cp dist/bin/* travis-release
fi
fi
if [ "$GHC_STABLE" = "1" ]; then
cabal v1-sdist
cp dist/*.tar.gz travis-release
fi