Remove trailing whitespace
[ghc.git] / .gitlab-ci.yml
1 variables:
2   GIT_SSL_NO_VERIFY: "1"
3
4   # Commit of ghc/ci-images repository from which to pull Docker images
5   DOCKER_REV: 6d19c3adc1f5c28c82aed8c5b1ac40931ac60f3f
6
7 before_script:
8   - python3 .gitlab/fix-submodules.py
9   - git submodule sync --recursive
10   - git submodule update --init --recursive
11   - git checkout .gitmodules
12   - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
13
14 stages:
15   - lint
16   - build
17   - full-build
18   - cleanup # See Note [Cleanup on Windows]
19
20 ############################################################
21 # Runner Tags
22 ############################################################
23 #
24 # * x86_64-linux: Any Docker-capable x86_64 Linux machine
25 # * aarch64-linux: Any Docker-capable AArch64 Linux machine
26 # * x86_64-windows: A x86_64 Windows machine
27 # * lint: Any Docker-capable x86_64 Linux machine; distinct from
28 #         x86_64-linux to ensure low-latency availability.
29 #
30
31
32 ############################################################
33 # Linting
34 ############################################################
35
36 ghc-linters:
37   stage: lint
38   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
39   script:
40     - |
41       if [ -n "$CI_MERGE_REQUEST_ID" ]; then
42         base="$(git merge-base $CI_MERGE_REQUEST_BRANCH_NAME HEAD)"
43         validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA)
44         submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA)
45         validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA)
46         .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA
47         .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA
48       fi
49   dependencies: []
50   tags:
51     - lint
52
53 ############################################################
54 # Validation via Pipelines (hadrian)
55 ############################################################
56
57 .validate-hadrian:
58   allow_failure: true
59   script:
60     - cabal update
61     - git clean -xdf && git submodule foreach git clean -xdf
62     - bash .circleci/prepare-system.sh
63     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
64     - ./boot
65     - ./configure $CONFIGURE_ARGS
66     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh`
67     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx docs
68   cache:
69     key: hadrian
70     paths:
71       - cabal-cache
72
73 validate-x86_64-linux-deb8-hadrian:
74   extends: .validate-hadrian
75   stage: build
76   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV"
77   before_script:
78     # workaround for docker permissions
79     - sudo chown ghc:ghc -R .
80     - python3 .gitlab/fix-submodules.py
81     - git submodule sync --recursive
82     - git submodule update --init --recursive
83     - git checkout .gitmodules
84     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
85   tags:
86     - x86_64-linux
87
88 hadrian-ghc-in-ghci:
89   stage: build
90   image: ghcci/x86_64-linux-deb8:0.1
91   before_script:
92     # workaround for docker permissions
93     - sudo chown ghc:ghc -R .
94     - python3 .gitlab/fix-submodules.py
95     - git submodule sync --recursive
96     - git submodule update --init --recursive
97     - git checkout .gitmodules
98   tags:
99     - x86_64-linux
100   script:
101     - cabal update
102     - git clean -xdf && git submodule foreach git clean -xdf
103     - bash .circleci/prepare-system.sh
104     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
105     - ./boot
106     - ./configure $CONFIGURE_ARGS
107     # Load ghc-in-ghci then immediately exit
108     - echo ":q" | hadrian/ghci.sh
109   cache:
110     key: hadrian-ghci
111     paths:
112       - cabal-cache
113
114 ############################################################
115 # Validation via Pipelines (make)
116 ############################################################
117
118 .validate:
119   variables:
120     TEST_TYPE: test
121   before_script:
122     - git clean -xdf && git submodule foreach git clean -xdf
123   script:
124     - ./boot
125     - ./configure $CONFIGURE_ARGS
126     - |
127       THREADS=`mk/detect-cpu-count.sh`
128       make V=0 -j$THREADS WERROR=-Werror
129     - |
130       make binary-dist TAR_COMP_OPTS="-1"
131       mv ghc-*.tar.xz ghc.tar.xz
132     - |
133       # Prepare to push git notes.
134       METRICS_FILE=$(mktemp)
135       git config user.email "ben+ghc-ci@smart-cactus.org"
136       git config user.name "GHC GitLab CI"
137     - |
138       THREADS=`mk/detect-cpu-count.sh`
139       make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE
140     - |
141       # Push git notes.
142       METRICS_FILE=$METRICS_FILE .gitlab/push-test-metrics.sh
143   dependencies: []
144   artifacts:
145     reports:
146       junit: junit.xml
147     expire_in: 2 week
148     paths:
149       - ghc.tar.xz
150       - junit.xml
151
152 #################################
153 # x86_64-darwin
154 #################################
155
156 validate-x86_64-darwin:
157   extends: .validate
158   stage: full-build
159   tags:
160     - x86_64-darwin
161   variables:
162     GHC_VERSION: 8.6.3
163     MACOSX_DEPLOYMENT_TARGET: "10.7"
164     # Only Sierra and onwards supports clock_gettime. See #12858
165     ac_cv_func_clock_gettime: "no"
166     LANG: "en_US.UTF-8"
167     CONFIGURE_ARGS: --with-intree-gmp
168     TEST_ENV: "x86_64-darwin"
169   before_script:
170     - git clean -xdf && git submodule foreach git clean -xdf
171     - python3 .gitlab/fix-submodules.py
172     - git submodule sync --recursive
173     - git submodule update --init --recursive
174     - git checkout .gitmodules
175     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
176
177     - bash .gitlab/darwin-init.sh
178     - PATH="`pwd`/toolchain/bin:$PATH"
179   after_script:
180     - cp -Rf $HOME/.cabal cabal-cache
181   artifacts:
182     when: always
183     expire_in: 2 week
184   cache:
185     key: darwin
186     paths:
187       - cabal-cache
188       - toolchain
189
190 .validate-linux:
191   extends: .validate
192   tags:
193     - x86_64-linux
194   before_script:
195     - git clean -xdf && git submodule foreach git clean -xdf
196     - python3 .gitlab/fix-submodules.py
197     - git submodule sync --recursive
198     - git submodule update --init --recursive
199     - git checkout .gitmodules
200     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
201
202     - bash .circleci/prepare-system.sh
203     # workaround for docker permissions
204     - sudo chown ghc:ghc -R .
205   after_script:
206     - cp -Rf $HOME/.cabal cabal-cache
207   cache:
208     key: linux
209     paths:
210       - cabal-cache
211       - toolchain
212
213 #################################
214 # aarch64-linux-deb9
215 #################################
216
217 .build-aarch64-linux-deb9:
218   extends: .validate-linux
219   stage: full-build
220   image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb9:$DOCKER_REV"
221   allow_failure: true
222   variables:
223     TEST_ENV: "aarch64-linux-deb9"
224   cache:
225     key: linux-aarch64-deb9
226   tags:
227     - aarch64-linux
228
229 validate-aarch64-linux-deb9:
230   extends: .build-aarch64-linux-deb9
231   artifacts:
232     when: always
233     expire_in: 2 week
234
235 nightly-aarch64-linux-deb9:
236   extends: .build-aarch64-linux-deb9
237   artifacts:
238     expire_in: 2 year
239   variables:
240     TEST_TYPE: slowtest
241   only:
242     variables:
243       - $NIGHTLY
244
245 #################################
246 # i386-linux-deb9
247 #################################
248
249 .build-i386-linux-deb9:
250   extends: .validate-linux
251   stage: full-build
252   image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV"
253   variables:
254     TEST_ENV: "i386-linux-deb9"
255   cache:
256     key: linux-i386-deb9
257
258 validate-i386-linux-deb9:
259   extends: .build-i386-linux-deb9
260   artifacts:
261     when: always
262     expire_in: 2 week
263
264 nightly-i386-linux-deb9:
265   extends: .build-i386-linux-deb9
266   variables:
267     TEST_TYPE: slowtest
268   artifacts:
269     when: always
270     expire_in: 2 week
271   only:
272     variables:
273       - $NIGHTLY
274
275 #################################
276 # x86_64-linux-deb9
277 #################################
278
279 .build-x86_64-linux-deb9:
280   extends: .validate-linux
281   stage: build
282   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
283   variables:
284     TEST_ENV: "x86_64-linux-deb9"
285   cache:
286     key: linux-x86_64-deb9
287
288 validate-x86_64-linux-deb9:
289   extends: .build-x86_64-linux-deb9
290   artifacts:
291     when: always
292     expire_in: 2 week
293
294 nightly-x86_64-linux-deb9:
295   extends: .build-x86_64-linux-deb9
296   artifacts:
297     expire_in: 2 year
298   variables:
299     TEST_TYPE: slowtest
300   only:
301     variables:
302       - $NIGHTLY
303
304 # N.B. Has DEBUG assertions enabled in stage2
305 validate-x86_64-linux-deb9-debug:
306   extends: .build-x86_64-linux-deb9
307   variables:
308     BUILD_FLAVOUR: validate
309     TEST_ENV: "x86_64-linux-deb9-debug"
310
311 validate-x86_64-linux-deb9-llvm:
312   extends: .build-x86_64-linux-deb9
313   stage: full-build
314   variables:
315     BUILD_FLAVOUR: perf-llvm
316     TEST_ENV: "x86_64-linux-deb9-llvm"
317
318 validate-x86_64-linux-deb9-integer-simple:
319   extends: .build-x86_64-linux-deb9
320   stage: full-build
321   variables:
322     INTEGER_LIBRARY: integer-simple
323     TEST_ENV: "x86_64-linux-deb9-integer-simple"
324
325 nightly-x86_64-linux-deb9-integer-simple:
326   extends: .build-x86_64-linux-deb9
327   stage: full-build
328   variables:
329     INTEGER_LIBRARY: integer-simple
330     TEST_ENV: "x86_64-linux-deb9-integer-simple"
331     TEST_TYPE: slowtest
332   artifacts:
333     expire_in: 2 year
334   only:
335     variables:
336       - $NIGHTLY
337
338 validate-x86_64-linux-deb9-unreg:
339   extends: .build-x86_64-linux-deb9
340   stage: full-build
341   variables:
342     CONFIGURE_ARGS: --enable-unregisterised
343     TEST_ENV: "x86_64-linux-deb9-unreg"
344
345
346 #################################
347 # x86_64-linux-deb8
348 #################################
349
350 release-x86_64-linux-deb8:
351   extends: .validate-linux
352   stage: full-build
353   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV"
354   variables:
355     TEST_ENV: "x86_64-linux-deb8"
356   only:
357     - tags
358   cache:
359     key: linux-x86_64-deb8
360   artifacts:
361     when: always
362     expire_in: 2 week
363
364
365 #################################
366 # x86_64-linux-fedora27
367 #################################
368
369 release-x86_64-linux-fedora27:
370   extends: .validate-linux
371   stage: full-build
372   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV"
373   variables:
374     TEST_ENV: "x86_64-linux-fedora27"
375   only:
376     - tags
377   cache:
378     key: linux-x86_64-fedora27
379   artifacts:
380     when: always
381     expire_in: 2 week
382
383 ############################################################
384 # Validation via Pipelines (Windows)
385 ############################################################
386
387 .validate-windows:
388   before_script:
389     - git clean -xdf
390     - git submodule foreach git clean -xdf
391
392     # Use a local temporary directory to ensure that concurrent builds don't
393     # interfere with one another
394     - |
395       mkdir tmp
396       set TMP=%cd%\tmp
397       set TEMP=%cd%\tmp
398
399     - set PATH=C:\msys64\usr\bin;%PATH%
400     - python .gitlab/fix-submodules.py
401     - git submodule sync --recursive
402     - git submodule update --init --recursive
403     - git checkout .gitmodules
404     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
405     - bash .gitlab/win32-init.sh
406   after_script:
407     - rd /s /q tmp
408     - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache
409     - bash -c 'make clean || true'
410   dependencies: []
411   variables:
412     FORCE_SYMLINKS: 1
413   cache:
414     paths:
415       - cabal-cache
416       - ghc-8.6.2
417       - ghc-tarballs
418
419 validate-x86_64-windows-hadrian:
420   extends: .validate-windows
421   stage: full-build
422   variables:
423     GHC_VERSION: "8.6.2"
424     LANG: "en_US.UTF-8"
425   script:
426     - |
427       set MSYSTEM=MINGW64
428       python boot
429       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
430     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick"
431     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx docs
432     # FIXME: Bindist disabled due to #16073
433     #- bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh binary-dist"
434     # FIXME: Testsuite disabled due to #16156.
435     #- bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
436   cache:
437     key: x86_64-windows
438   tags:
439     - x86_64-windows
440
441 validate-x86_64-windows:
442   extends: .validate-windows
443   stage: full-build
444   # due to #16084
445   allow_failure: true
446   variables:
447     GHC_VERSION: "8.6.2"
448     LANG: "en_US.UTF-8"
449   script:
450     - |
451       set MSYSTEM=MINGW64
452       python boot
453       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
454     - bash -c "echo include mk/flavours/quick.mk > mk/build.mk"
455     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
456     - |
457       bash -c "make binary-dist TAR_COMP_OPTS=-1"
458       mv ghc-*.tar.xz ghc.tar.xz
459     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
460   cache:
461     key: x86_64-windows
462   tags:
463     - x86_64-windows
464   artifacts:
465     when: always
466     reports:
467       junit: junit.xml
468     paths:
469       - ghc.tar.xz
470       - junit.xml
471
472 ############################################################
473 # Cleanup
474 ############################################################
475
476 # Note [Cleaning up after shell executor]
477 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
478 #
479 # As noted in [1], gitlab-runner's shell executor doesn't clean up its working
480 # directory after builds. Unfortunately, we are forced to use the shell executor
481 # on Windows. To avoid running out of disk space we add a stage at the end of
482 # the build to remove the \GitLabRunner\builds directory. Since we only run a
483 # single build at a time on Windows this should be safe.
484 #
485 # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856
486
487 # See Note [Cleanup after shell executor]
488 cleanup-windows:
489   stage: cleanup
490   tags:
491     - x86_64-windows
492   when: always
493   dependencies: []
494   before_script:
495     - echo "Time to clean up"
496   script:
497     - echo "Let's go"
498   after_script:
499     - set "BUILD_DIR=%CI_PROJECT_DIR%"
500     - set "BUILD_DIR=%BUILD_DIR:/=\%"
501     - echo "Cleaning %BUILD_DIR%"
502     - cd \GitLabRunner
503     # This is way more complicated than it should be:
504     # See https://stackoverflow.com/questions/1965787
505     - del %BUILD_DIR%\* /F /Q
506     - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p"
507     - exit /b 0
508
509 # See Note [Cleanup after shell executor]
510 cleanup-darwin:
511   stage: cleanup
512   tags:
513     - x86_64-darwin
514   when: always
515   dependencies: []
516   before_script:
517     - echo "Time to clean up"
518   script:
519     - echo "Let's go"
520   after_script:
521     - BUILD_DIR=$CI_PROJECT_DIR
522     - echo "Cleaning $BUILD_DIR"
523     - cd $HOME
524     - rm -Rf $BUILD_DIR/*
525     - exit 0
526