forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-linux-template.yml
136 lines (130 loc) · 5.25 KB
/
azure-linux-template.yml
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
jobs:
- job: ${{ parameters.name }}
timeoutInMinutes: 120
variables:
- group: AWS_Keys
pool:
vmImage: ${{ parameters.vmImage }}
strategy:
matrix:
stack-def:
BUILD: stack
STACK_YAML: stack.yaml
stack-lts-12:
BUILD: stack
STACK_YAML: stack-lts-12.yaml
nightly:
BUILD: stack
STACK_YAML: stack-nightly.yaml
style:
BUILD: style
pedantic:
BUILD: pedantic
STACK_YAML: stack.yaml
maxParallel: 5
steps:
- script: |
echo $OS_NAME
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
echo $STACK_ROOT
mkdir -p ~/.local/bin
curl -f -L "https://github.com/fpco/cache-s3/releases/download/${CACHE_S3_VERSION}/cache-s3-${CACHE_S3_VERSION}-${OS_NAME}-x86_64.tar.gz" -o ~/.local/bin/cache-s3.tar.gz
tar xzf ~/.local/bin/cache-s3.tar.gz -C ~/.local/bin
export PATH=$HOME/.local/bin:$PATH;
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack --base-branch="${BASE_BRANCH}"
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack work --base-branch="${BASE_BRANCH}"
./.travis-setup.sh
case "$BUILD" in
style)
export PATH="$(pwd)"/hlint:$PATH
;;
cabal)
export PATH=$HOME/.local/bin:$HOME/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/happy/1.19.5/bin:/opt/alex/3.1.7/bin:/opt/cabal/$CABALVER/bin:$PATH
;;
*)
export PATH=$HOME/.local/bin:/opt/ghc/$GHCVER/bin:/opt/happy/1.19.5/bin:/opt/alex/3.1.7/bin:$PATH
;;
esac
if ! [ "$BUILD" = style ]; then echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"; fi
set -ex
case "$BUILD" in
style)
./etc/scripts/get-hlint.sh
;;
cabal)
cabal --version
cabal update
rm -f $HOME/.cabal/bin/stack
echo "stack is located at $(which stack)"
stack --version
echo Removing any old dist files
rm -f $(stack --stack-yaml=$STACK_YAML path --dist-dir)/stack-*.tar.gz
echo To avoid custom Cabal setup business, switching temporarily to Simple
cp stack.cabal stack.orig-cabal
sed 's@build-type\:.*@build-type\: Simple@' < stack.orig-cabal > stack.cabal
echo Generating new dist with pvp bounds in the cabal file
stack --system-ghc --stack-yaml=$STACK_YAML sdist --pvp-bounds=both
echo Grabbing the newly generated stack.cabal file from the tarball
tar xf $(stack --system-ghc --compiler=ghc-$GHCVER path --dist-dir)/stack-*.tar.gz --wildcards --strip-components=1 '*/stack.cabal'
echo Switching back to Custom build type
cp stack.cabal stack.orig-cabal
sed 's@build-type\:.*@build-type\: Custom@' < stack.orig-cabal > stack.cabal
rm -f stack.orig-cabal
echo Performing the actual build now that we have the right stack.cabal
cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1
;;
*)
stack --no-terminal build Cabal
stack --no-terminal test --only-dependencies
;;
esac
set +ex
GHC_OPTIONS="-Werror"
if [ $GHCVER = 8.2.1 ]; then GHC_OPTIONS="$GHC_OPTIONS -Wno-missing-home-modules"; fi
set -ex
case "$BUILD" in
style)
hlint src/
hlint src/ --cpp-define=WINDOWS=1
hlint test/ --cpp-simple
;;
stack)
stack --no-terminal test --haddock --no-haddock-deps --ghc-options="$GHC_OPTIONS"
;;
pedantic)
stack --system-ghc --no-terminal build --pedantic
;;
cabal)
cabal configure --enable-tests --enable-benchmarks -v2 --ghc-options="-O0 $GHC_OPTIONS"
cabal build
cabal test
cabal check
cabal sdist
cabal copy
cd test/integration
true stack setup --compiler=ghc-$GHCVER
true stack test --compiler=ghc-$GHCVER
cd ../..
SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
;;
esac
set +ex
env:
OS_NAME: ${{ parameters.os }}
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
displayName: 'Installation ${{parameters.os}}'
continueOnError: ${{ eq(variables['STACK_YAML'], 'stack-nightly.yaml') }}
- script: |
export PATH=$HOME/.local/bin:$PATH;
export AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID)";
export AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)";
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
if [ "$(Build.SourceBranchName)" = "${BASE_BRANCH}" ]; then
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack;
fi;
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack work
env:
OS_NAME: ${{ parameters.os }}
displayName: 'Cache data'