gitlab-ci: Ensure that build environment is clean
[ghc.git] / .gitlab-ci.yml
1 variables:
2   GIT_SSL_NO_VERIFY: "1"
3
4 before_script:
5   - python3 .gitlab/fix-submodules.py
6   - git submodule sync --recursive
7   - git submodule update --init --recursive
8   - git checkout .gitmodules
9
10 stages:
11   - lint
12   - build
13   - full-build
14
15 ############################################################
16 # Tags
17 ############################################################
18 #
19 # * x86_64-linux: Any Docker-capable x86_64 Linux machine
20 # * aarch64-linux: Any Docker-capable AArch64 Linux machine
21 # * x86_64-windows: A x86_64 Windows machine
22 # * lint: Any Docker-capable x86_64 Linux machine; distinct from
23 #         x86_64-linux to ensure low-latency availability.
24 #
25
26
27 ############################################################
28 # Linting
29 ############################################################
30
31 ghc-linters:
32   stage: lint
33   image: ghcci/linters:0.1
34   script:
35     - |
36       if [ -n "$CI_MERGE_REQUEST_ID" ]; then
37         base="$(git merge-base $CI_MERGE_REQUEST_BRANCH_NAME HEAD)"
38         validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA)
39         submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA)
40         validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA)
41         .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA
42         .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA
43       fi
44   tags:
45     - lint
46
47 ############################################################
48 # Validation via Pipelines (hadrian)
49 ############################################################
50
51 .validate-hadrian:
52   allow_failure: true
53   script:
54     - git clean -xdf
55     - bash .circleci/prepare-system.sh
56     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
57     - ./boot
58     - ./configure $CONFIGURE_ARGS
59     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh`
60   cache:
61     key: hadrian
62     paths:
63       - cabal-cache
64
65 validate-x86_64-linux-deb8-hadrian:
66   extends: .validate-hadrian
67   stage: build
68   image: ghcci/x86_64-linux-deb8:0.1
69   before_script:
70     # workaround for docker permissions
71     - sudo chown ghc:ghc -R .
72     - python3 .gitlab/fix-submodules.py
73     - git submodule sync --recursive
74     - git submodule update --init --recursive
75     - git checkout .gitmodules
76   tags:
77     - x86_64-linux
78
79 ############################################################
80 # Validation via Pipelines (make)
81 ############################################################
82
83 .validate:
84   variables:
85     TEST_TYPE: test
86   script:
87     - git clean -xdf
88     - ./boot
89     - ./configure $CONFIGURE_ARGS
90     - |
91       THREADS=`mk/detect-cpu-count.sh`
92       make V=0 -j$THREADS
93     - |
94       make binary-dist TAR_COMP_OPTS="-1"
95       mv ghc-*.tar.xz ghc.tar.xz
96     - |
97       THREADS=`mk/detect-cpu-count.sh`
98       make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml
99   artifacts:
100     reports:
101       junit: junit.xml
102     expire_in: 2 week
103     paths:
104       - ghc.tar.xz
105       - junit.xml
106
107 validate-x86_64-darwin:
108   extends: .validate
109   stage: full-build
110   allow_failure: true
111   tags:
112     - x86_64-darwin
113   variables:
114     GHC_VERSION: 8.6.3
115     MACOSX_DEPLOYMENT_TARGET: "10.7"
116     # Only Sierra and onwards supports clock_gettime. See #12858
117     ac_cv_func_clock_gettime: "no"
118     LANG: "en_US.UTF-8"
119   before_script:
120     - python .gitlab/fix-submodules.py
121     - git submodule sync --recursive
122     - git submodule update --init --recursive
123     - git checkout .gitmodules
124
125     - bash .gitlab/darwin-init.sh
126     - PATH="`pwd`/toolchain/bin:$PATH"
127       # Disable sphinx PDF output as MacTeX apparently doesn't provide xelatex
128     - echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
129     - echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk
130   after_script:
131     - cp -Rf $HOME/.cabal cabal-cache
132   artifacts:
133     when: always
134     expire_in: 2 week
135   cache:
136     key: darwin
137     paths:
138       - cabal-cache
139       - toolchain
140
141 .validate-linux:
142   extends: .validate
143   tags:
144     - x86_64-linux
145   before_script:
146     - python3 .gitlab/fix-submodules.py
147     - git submodule sync --recursive
148     - git submodule update --init --recursive
149     - git checkout .gitmodules
150
151     - bash .circleci/prepare-system.sh
152     # workaround for docker permissions
153     - sudo chown ghc:ghc -R .
154   after_script:
155     - cp -Rf $HOME/.cabal cabal-cache
156   cache:
157     key: linux
158     paths:
159       - cabal-cache
160       - toolchain
161
162 validate-aarch64-linux-deb9:
163   extends: .validate-linux
164   stage: full-build
165   image: ghcci/aarch64-linux-deb9:0.1
166   allow_failure: true
167   artifacts:
168     when: always
169     expire_in: 2 week
170   cache:
171     key: linux-aarch64-deb9
172   tags:
173     - aarch64-linux
174
175 nightly-aarch64-linux-deb9:
176   extends: validate-aarch64-linux-deb9
177   stage: full-build
178   artifacts:
179     expire_in: 2 year
180   variables:
181     TEST_TYPE: slowtest
182   only:
183     variables:
184       - $NIGHTLY
185
186 validate-x86_64-linux-deb9:
187   extends: .validate-linux
188   stage: build
189   image: ghcci/x86_64-linux-deb9:0.2
190   artifacts:
191     when: always
192     expire_in: 2 week
193   cache:
194     key: linux-x86_64-deb9
195
196 nightly-x86_64-linux-deb9:
197   extends: validate-x86_64-linux-deb9
198   stage: build
199   artifacts:
200     expire_in: 2 year
201   variables:
202     TEST_TYPE: slowtest
203   only:
204     variables:
205       - $NIGHTLY
206
207 validate-x86_64-linux-deb9-llvm:
208   extends: .validate-linux
209   stage: full-build
210   allow_failure: true
211   image: ghcci/x86_64-linux-deb9:0.2
212   variables:
213     BUILD_FLAVOUR: perf-llvm
214   cache:
215     key: linux-x86_64-deb9
216
217 validate-x86_64-linux-deb8:
218   extends: .validate-linux
219   stage: full-build
220   image: ghcci/x86_64-linux-deb8:0.1
221   cache:
222     key: linux-x86_64-deb8
223   artifacts:
224     when: always
225     expire_in: 2 week
226
227 validate-x86_64-linux-fedora27:
228   extends: .validate-linux
229   stage: full-build
230   image: ghcci/x86_64-linux-fedora27:0.1
231   cache:
232     key: linux-x86_64-fedora27
233   artifacts:
234     when: always
235     expire_in: 2 week
236
237 validate-x86_64-linux-deb9-integer-simple:
238   extends: .validate-linux
239   stage: full-build
240   allow_failure: true
241   variables:
242     INTEGER_LIBRARY: integer-simple
243   image: ghcci/x86_64-linux-deb9:0.2
244   cache:
245     key: linux-x86_64-deb9
246
247 nightly-x86_64-linux-deb9-integer-simple:
248   extends: validate-x86_64-linux-deb9-integer-simple
249   stage: full-build
250   artifacts:
251     expire_in: 2 year
252   variables:
253     TEST_TYPE: slowtest
254   only:
255     variables:
256       - $NIGHTLY
257
258 validate-x86_64-linux-deb9-unreg:
259   extends: .validate-linux
260   stage: full-build
261   variables:
262     CONFIGURE_ARGS: --enable-unregisterised
263   image: ghcci/x86_64-linux-deb9:0.2
264   cache:
265     key: linux-x86_64-deb9
266
267 ############################################################
268 # Validation via Pipelines (Windows)
269 ############################################################
270
271 .validate-windows:
272   before_script:
273     - git clean -xdf
274     - PATH=C:\msys64\usr\bin;%PATH%
275     - python .gitlab/fix-submodules.py
276     - git submodule sync --recursive
277     - git submodule update --init --recursive
278     - git checkout .gitmodules
279     - bash .gitlab/win32-init.sh
280   cache:
281     paths:
282       - cabal-cache
283       - ghc-8.6.2
284       - ghc-tarballs
285
286 validate-x86_64-windows-hadrian:
287   extends: .validate-windows
288   stage: full-build
289   variables:
290     GHC_VERSION: "8.6.2"
291     LANG: "en_US.UTF-8"
292   # due to #16073
293   allow_failure: true
294   script:
295     - |
296       set MSYSTEM=MINGW64
297       python boot
298       bash -c './configure --with-ghc=`pwd`/toolchain/bin/ghc --enable-tarballs-autodownload HappyCmd=`pwd`/toolchain/bin/happy AlexCmd=`pwd`/toolchain/bin/alex'
299       mkdir -p _build
300       cp -R inplace/mingw _build/mingw
301     # FIXME: --no-lint due to #15950
302     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --no-lint"
303     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh binary-dist"
304     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
305     - cp -Rf $APPDATA/cabal cabal-cache
306   cache:
307     key: x86_64-windows
308   tags:
309     - x86_64-windows
310
311 validate-x86_64-windows:
312   extends: .validate-windows
313   stage: full-build
314   variables:
315     GHC_VERSION: "8.6.2"
316     LANG: "en_US.UTF-8"
317   script:
318     - |
319       set MSYSTEM=MINGW64
320       python boot
321       bash -c './configure --with-ghc=`pwd`/toolchain/bin/ghc --enable-tarballs-autodownload HappyCmd=`pwd`/toolchain/bin/happy AlexCmd=`pwd`/toolchain/bin/alex'
322     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
323     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
324     - cp -Rf $APPDATA/cabal cabal-cache
325   cache:
326     key: x86_64-windows
327   tags:
328     - x86_64-windows
329
330 ############################################################
331 # Validation via CircleCI
332 ############################################################
333
334 .circleci:
335   stage: build
336   image: ghcci/x86_64-linux-deb8:0.1
337   artifacts:
338     when: always
339     expire_in: 2 week
340     reports:
341       junit: junit.xml
342     paths:
343       - ghc.tar.xz
344       - junit.xml
345   tags:
346     - circleci
347
348 # All validation jobs keep the bindists and test results are artifacts,
349 # when we get far enough to generate them.
350 #
351 # This requires updating the maximum artifacts size limit in Gitlab to
352 # something like 200MB.
353
354 circleci-validate-x86_64-darwin:
355   extends: .circleci
356   script: ".gitlab/circle-ci-job.sh validate-x86_64-darwin"