gitlab-ci: Fetch submodules before running submodule linter
[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: ac65f31dcffb09cd7ca7aaa70f447fcbb19f427f
6
7   # Sequential version number capturing the versions of all tools fetched by
8   # .gitlab/win32-init.sh.
9   WINDOWS_TOOLCHAIN_VERSION: 1
10
11   # Disable shallow clones; they break our linting rules
12   GIT_DEPTH: 0
13
14 before_script:
15   - python3 .gitlab/fix-submodules.py
16   - git submodule sync --recursive
17   - git submodule update --init --recursive
18   - git checkout .gitmodules
19   - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
20
21 stages:
22   - lint       # Source linting
23   - build      # A quick smoke-test to weed out broken commits
24   - full-build # Build all the things
25   - cleanup    # See Note [Cleanup after the shell executor]
26   - packaging  # Source distribution, etc.
27   - hackage    # head.hackage testing
28   - deploy     # push documentation
29
30 .only-default: &only-default
31   only:
32     - master
33     - /ghc-[0-9]+\.[0-9]+/
34     - merge_requests
35     - tags
36     - web
37
38 ############################################################
39 # Runner Tags
40 ############################################################
41 #
42 # * x86_64-linux: Any Docker-capable x86_64 Linux machine
43 # * aarch64-linux: Any Docker-capable AArch64 Linux machine
44 # * x86_64-windows: A x86_64 Windows machine
45 # * lint: Any Docker-capable x86_64 Linux machine; distinct from
46 #         x86_64-linux to ensure low-latency availability.
47 #
48
49
50 ############################################################
51 # Linting
52 ############################################################
53
54 ghc-linters:
55   stage: lint
56   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
57   script:
58     - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
59     - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)"
60     - "echo Linting changes between $base..$CI_COMMIT_SHA"
61     #    - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA)
62     - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA)
63     - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA
64     - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA
65     - .gitlab/linters/check-version-number.sh
66   dependencies: []
67   tags:
68     - lint
69   only:
70     refs:
71       - merge_requests
72
73 # We allow the submodule checker to fail when run on merge requests (to
74 # accomodate, e.g., haddock changes not yet upstream) but not on `master` or
75 # Marge jobs.
76 .lint-submods:
77   stage: lint
78   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
79   script:
80     - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
81     - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)"
82     - "echo Linting submodule changes between $base..$CI_COMMIT_SHA"
83     - git submodule foreach git remote update
84     - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA)
85   dependencies: []
86   tags:
87     - lint
88
89 lint-submods-marge:
90   extends: .lint-submods
91   only:
92     refs:
93       - merge_requests
94     variables:
95       - $CI_MERGE_REQUEST_LABELS =~ /.*wip/marge_bot_batch_merge_job.*/
96
97 lint-submods-mr:
98   extends: .lint-submods
99   # Allow failure since any necessary submodule patches may not be upstreamed
100   # yet.
101   allow_failure: true
102   only:
103     refs:
104       - merge_requests
105   except:
106     variables:
107       - $CI_MERGE_REQUEST_LABELS =~ /.*wip/marge_bot_batch_merge_job.*/
108
109 lint-submods-branch:
110   extends: .lint-submods
111   script:
112     - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"
113     - git submodule foreach git remote update
114     - submodchecker .git $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA)
115   only:
116     refs:
117       - master
118       - /ghc-[0-9]+\.[0-9]+/
119
120 .lint-changelogs:
121   stage: lint
122   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
123   dependencies: []
124   tags:
125     - lint
126   script:
127     - |
128       grep TBA libraries/*/changelog.md && (
129           echo "Error: Found \"TBA\"s in changelogs."
130           exit 1
131       )
132
133 lint-changelogs:
134   extends: .lint-changelogs
135   # Allow failure since this isn't a final release.
136   allow_failure: true
137   only:
138     refs:
139       - /ghc-[0-9]+\.[0-9]+/
140
141 lint-release-changelogs:
142   extends: .lint-changelogs
143   only:
144     refs:
145       - /ghc-[0-9]+\.[0-9]+\.[0-9]+-.*/
146
147
148 ############################################################
149 # Validation via Pipelines (hadrian)
150 ############################################################
151
152 .validate-hadrian:
153   <<: *only-default
154   allow_failure: true
155   script:
156     - cabal update
157     - git clean -xdf && git submodule foreach git clean -xdf
158     - bash .circleci/prepare-system.sh
159     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
160     - ./boot
161     - ./configure $CONFIGURE_ARGS
162     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist
163     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx test --summary-junit=./junit.xml
164     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
165   cache:
166     key: hadrian
167     paths:
168       - cabal-cache
169   artifacts:
170     reports:
171       junit: junit.xml
172     expire_in: 2 week
173     paths:
174       - ghc.tar.xz
175       - junit.xml
176
177 validate-x86_64-linux-deb9-hadrian:
178   extends: .validate-hadrian
179   stage: build
180   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
181   before_script:
182     # workaround for docker permissions
183     - sudo chown ghc:ghc -R .
184     - python3 .gitlab/fix-submodules.py
185     - git submodule sync --recursive
186     - git submodule update --init --recursive
187     - git checkout .gitmodules
188     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
189   tags:
190     - x86_64-linux
191
192 hadrian-ghc-in-ghci:
193   <<: *only-default
194   stage: build
195   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
196   before_script:
197     # workaround for docker permissions
198     - sudo chown ghc:ghc -R .
199     - python3 .gitlab/fix-submodules.py
200     - git submodule sync --recursive
201     - git submodule update --init --recursive
202     - git checkout .gitmodules
203   tags:
204     - x86_64-linux
205   script:
206     - cabal update
207     - cd hadrian; cabal new-build --project-file=ci.project; cd ..
208     - git clean -xdf && git submodule foreach git clean -xdf
209     - bash .circleci/prepare-system.sh
210     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
211     - ./boot
212     - ./configure $CONFIGURE_ARGS
213     # Load ghc-in-ghci then immediately exit and check the modules loaded
214     - echo ":q" | hadrian/ghci.sh | tail -n2 | grep "Ok,"
215   cache:
216     key: hadrian-ghci
217     paths:
218       - cabal-cache
219
220 ############################################################
221 # Validation via Pipelines (make)
222 ############################################################
223
224 .validate:
225   <<: *only-default
226   variables:
227     TEST_TYPE: test
228   before_script:
229     - git clean -xdf && git submodule foreach git clean -xdf
230   script:
231     - ./boot
232     - ./configure $CONFIGURE_ARGS
233     - |
234       THREADS=`mk/detect-cpu-count.sh`
235       make V=0 -j$THREADS WERROR=-Werror
236     - |
237       make bindisttest
238     - |
239       make binary-dist TAR_COMP_OPTS="-1"
240     - |
241       # Prepare to push git notes.
242       METRICS_FILE=$(mktemp)
243       git config user.email "ben+ghc-ci@smart-cactus.org"
244       git config user.name "GHC GitLab CI"
245     - |
246       THREADS=`mk/detect-cpu-count.sh`
247       make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE
248     - |
249       # Push git notes.
250       METRICS_FILE=$METRICS_FILE .gitlab/push-test-metrics.sh
251   dependencies: []
252   artifacts:
253     reports:
254       junit: junit.xml
255     expire_in: 2 week
256     paths:
257       - ghc-*.tar.xz
258       - junit.xml
259
260 #################################
261 # x86_64-darwin
262 #################################
263
264 validate-x86_64-darwin:
265   extends: .validate
266   stage: full-build
267   tags:
268     - x86_64-darwin
269   variables:
270     GHC_VERSION: 8.6.3
271     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz"
272     MACOSX_DEPLOYMENT_TARGET: "10.7"
273     # Only Sierra and onwards supports clock_gettime. See #12858
274     ac_cv_func_clock_gettime: "no"
275     LANG: "en_US.UTF-8"
276     CONFIGURE_ARGS: --with-intree-gmp
277     TEST_ENV: "x86_64-darwin"
278   before_script:
279     - git clean -xdf && git submodule foreach git clean -xdf
280     - python3 .gitlab/fix-submodules.py
281     - git submodule sync --recursive
282     - git submodule update --init --recursive
283     - git checkout .gitmodules
284     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
285
286     - bash .gitlab/darwin-init.sh
287     - PATH="`pwd`/toolchain/bin:$PATH"
288   after_script:
289     - cp -Rf $HOME/.cabal cabal-cache
290   artifacts:
291     when: always
292     expire_in: 2 week
293   cache:
294     key: darwin
295     paths:
296       - cabal-cache
297       - toolchain
298
299 # Disabled because of OS X CI capacity
300 .validate-x86_64-darwin-hadrian:
301   <<: *only-default
302   stage: full-build
303   tags:
304     - x86_64-darwin
305   variables:
306     GHC_VERSION: 8.6.3
307     MACOSX_DEPLOYMENT_TARGET: "10.7"
308     ac_cv_func_clock_gettime: "no"
309     LANG: "en_US.UTF-8"
310     CONFIGURE_ARGS: --with-intree-gmp
311     TEST_ENV: "x86_64-darwin"
312   before_script:
313     - git clean -xdf && git submodule foreach git clean -xdf
314     - python3 .gitlab/fix-submodules.py
315     - git submodule sync --recursive
316     - git submodule update --init --recursive
317     - git checkout .gitmodules
318     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
319
320     - bash .gitlab/darwin-init.sh
321     - PATH="`pwd`/toolchain/bin:$PATH"
322   script:
323     - cabal update
324     - ./boot
325     - ./configure $CONFIGURE_ARGS
326     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist
327     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx test --summary-junit=./junit.xml
328     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
329   after_script:
330     - cp -Rf $HOME/.cabal cabal-cache
331   artifacts:
332     when: always
333     expire_in: 2 week
334     reports:
335       junit: junit.xml
336     paths:
337       - ghc.tar.xz
338       - junit.xml
339
340 .validate-linux:
341   extends: .validate
342   tags:
343     - x86_64-linux
344   before_script:
345     - git clean -xdf && git submodule foreach git clean -xdf
346     - python3 .gitlab/fix-submodules.py
347     - git submodule sync --recursive
348     - git submodule update --init --recursive
349     - git checkout .gitmodules
350     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
351       # Build hyperlinked sources for documentation when building releases
352     - |
353       if [[ -n "$CI_COMMIT_TAG" ]]; then
354         echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk
355       fi
356
357     - bash .circleci/prepare-system.sh
358     # workaround for docker permissions
359     - sudo chown ghc:ghc -R .
360   after_script:
361     - cp -Rf $HOME/.cabal cabal-cache
362   cache:
363     key: linux
364     paths:
365       - cabal-cache
366       - toolchain
367
368 #################################
369 # aarch64-linux-deb9
370 #################################
371
372 .build-aarch64-linux-deb9:
373   extends: .validate-linux
374   stage: full-build
375   image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb9:$DOCKER_REV"
376   allow_failure: true
377   variables:
378     TEST_ENV: "aarch64-linux-deb9"
379     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz"
380   cache:
381     key: linux-aarch64-deb9
382   tags:
383     - aarch64-linux
384
385 validate-aarch64-linux-deb9:
386   extends: .build-aarch64-linux-deb9
387   artifacts:
388     when: always
389     expire_in: 2 week
390
391 nightly-aarch64-linux-deb9:
392   extends: .build-aarch64-linux-deb9
393   artifacts:
394     expire_in: 2 year
395   variables:
396     TEST_TYPE: slowtest
397   only:
398     variables:
399       - $NIGHTLY
400
401 #################################
402 # i386-linux-deb9
403 #################################
404
405 .build-i386-linux-deb9:
406   extends: .validate-linux
407   stage: full-build
408   image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV"
409   variables:
410     TEST_ENV: "i386-linux-deb9"
411     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz"
412   cache:
413     key: linux-i386-deb9
414
415 validate-i386-linux-deb9:
416   extends: .build-i386-linux-deb9
417   artifacts:
418     when: always
419     expire_in: 2 week
420
421 nightly-i386-linux-deb9:
422   extends: .build-i386-linux-deb9
423   variables:
424     TEST_TYPE: slowtest
425   artifacts:
426     when: always
427     expire_in: 2 week
428   only:
429     variables:
430       - $NIGHTLY
431
432 #################################
433 # x86_64-linux-deb9
434 #################################
435
436 .build-x86_64-linux-deb9:
437   extends: .validate-linux
438   stage: full-build
439   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
440   variables:
441     TEST_ENV: "x86_64-linux-deb9"
442     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz"
443   cache:
444     key: linux-x86_64-deb9
445
446 validate-x86_64-linux-deb9:
447   extends: .build-x86_64-linux-deb9
448   artifacts:
449     when: always
450     expire_in: 2 week
451
452 nightly-x86_64-linux-deb9:
453   extends: .build-x86_64-linux-deb9
454   artifacts:
455     expire_in: 2 year
456   variables:
457     TEST_TYPE: slowtest
458   only:
459     variables:
460       - $NIGHTLY
461
462 # N.B. Has DEBUG assertions enabled in stage2
463 validate-x86_64-linux-deb9-debug:
464   extends: .build-x86_64-linux-deb9
465   stage: build
466   variables:
467     BUILD_FLAVOUR: validate
468     TEST_TYPE: slowtest
469     TEST_ENV: "x86_64-linux-deb9-debug"
470
471 validate-x86_64-linux-deb9-llvm:
472   extends: .build-x86_64-linux-deb9
473   stage: full-build
474   variables:
475     BUILD_FLAVOUR: perf-llvm
476     TEST_ENV: "x86_64-linux-deb9-llvm"
477
478 validate-x86_64-linux-deb9-integer-simple:
479   extends: .build-x86_64-linux-deb9
480   stage: full-build
481   variables:
482     INTEGER_LIBRARY: integer-simple
483     TEST_ENV: "x86_64-linux-deb9-integer-simple"
484     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz"
485
486 nightly-x86_64-linux-deb9-integer-simple:
487   extends: .build-x86_64-linux-deb9
488   stage: full-build
489   variables:
490     INTEGER_LIBRARY: integer-simple
491     TEST_ENV: "x86_64-linux-deb9-integer-simple"
492     TEST_TYPE: slowtest
493   artifacts:
494     expire_in: 2 year
495   only:
496     variables:
497       - $NIGHTLY
498
499 validate-x86_64-linux-deb9-unreg:
500   extends: .build-x86_64-linux-deb9
501   stage: full-build
502   variables:
503     CONFIGURE_ARGS: --enable-unregisterised
504     TEST_ENV: "x86_64-linux-deb9-unreg"
505
506 release-x86_64-linux-deb9-dwarf:
507   extends: .validate-linux
508   stage: build
509   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
510   allow_failure: true
511   variables:
512     CONFIGURE_ARGS: "--enable-dwarf-unwind"
513     BUILD_FLAVOUR: dwarf
514     TEST_ENV: "x86_64-linux-deb9"
515   artifacts:
516     when: always
517     expire_in: 2 week
518   cache:
519     key: linux-x86_64-deb9
520
521
522 #################################
523 # x86_64-linux-deb8
524 #################################
525
526 release-x86_64-linux-deb8:
527   extends: .validate-linux
528   stage: full-build
529   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV"
530   variables:
531     TEST_ENV: "x86_64-linux-deb8"
532     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz"
533   only:
534     - tags
535   cache:
536     key: linux-x86_64-deb8
537   artifacts:
538     when: always
539     expire_in: 2 week
540
541 #################################
542 # x86_64-linux-centos7
543 #################################
544
545 release-x86_64-linux-centos7:
546   extends: .validate-linux
547   stage: full-build
548   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV"
549   variables:
550     # The sphinx release shipped with Centos 7 fails to build out documentation
551     BUILD_SPHINX_HTML: "NO"
552     BUILD_SPHINX_PDF: "NO"
553     TEST_ENV: "x86_64-linux-centos7"
554     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz"
555   only:
556     - tags
557   cache:
558     key: linux-x86_64-centos7
559   artifacts:
560     when: always
561     expire_in: 2 week
562
563 #################################
564 # x86_64-linux-fedora27
565 #################################
566
567 validate-x86_64-linux-fedora27:
568   extends: .validate-linux
569   stage: full-build
570   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV"
571   variables:
572     TEST_ENV: "x86_64-linux-fedora27"
573     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz"
574   cache:
575     key: linux-x86_64-fedora27
576   artifacts:
577     when: always
578     expire_in: 2 week
579
580 ############################################################
581 # Validation via Pipelines (Windows)
582 ############################################################
583
584 .build-windows:
585   <<: *only-default
586   before_script:
587     - git clean -xdf
588     - git submodule foreach git clean -xdf
589
590     # Use a local temporary directory to ensure that concurrent builds don't
591     # interfere with one another
592     - |
593       mkdir tmp
594       set TMP=%cd%\tmp
595       set TEMP=%cd%\tmp
596
597     - set PATH=C:\msys64\usr\bin;%PATH%
598     - python .gitlab/fix-submodules.py
599     - git submodule sync --recursive
600     - git submodule update --init --recursive
601     - git checkout .gitmodules
602     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
603     - bash .gitlab/win32-init.sh
604   after_script:
605     - rd /s /q tmp
606     - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache
607     - bash -c 'make clean || true'
608   dependencies: []
609   variables:
610     FORCE_SYMLINKS: 1
611     LANG: "en_US.UTF-8"
612   cache:
613     paths:
614       - cabal-cache
615       - ghc-8.6.5
616       - ghc-tarballs
617
618 .build-windows-hadrian:
619   extends: .build-windows
620   stage: full-build
621   variables:
622     GHC_VERSION: "8.6.5"
623   # due to #16574 this currently fails
624   allow_failure: true
625   script:
626     - |
627       python boot
628       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
629     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist"
630     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
631     # FIXME: Testsuite disabled due to #16156.
632     # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
633   tags:
634     - x86_64-windows
635   artifacts:
636     when: always
637     paths:
638       - ghc.tar.xz
639
640 validate-x86_64-windows-hadrian:
641   extends: .build-windows-hadrian
642   variables:
643     MSYSTEM: MINGW64
644   cache:
645     key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION"
646
647 nightly-i386-windows-hadrian:
648   extends: .build-windows-hadrian
649   variables:
650     MSYSTEM: MINGW32
651   only:
652     variables:
653       - $NIGHTLY
654   cache:
655     key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION"
656
657 .build-windows-make:
658   extends: .build-windows
659   stage: full-build
660   # due to #16084
661   allow_failure: true
662   variables:
663     BUILD_FLAVOUR: "quick"
664     GHC_VERSION: "8.6.5"
665     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz"
666   script:
667     - |
668       python boot
669       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS'
670     - bash -c "echo include mk/flavours/${BUILD_FLAVOUR}.mk > mk/build.mk"
671     - bash -c "echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk"
672     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
673     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make bindisttest"
674     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1"
675     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
676   tags:
677     - x86_64-windows
678   artifacts:
679     when: always
680     expire_in: 2 week
681     reports:
682       junit: junit.xml
683     paths:
684       - ghc-*.tar.xz
685       - junit.xml
686
687 validate-x86_64-windows:
688   extends: .build-windows-make
689   variables:
690     MSYSTEM: MINGW64
691     CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
692   cache:
693     key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION"
694
695 # Normal Windows validate builds are profiled; that won't do for releases.
696 release-x86_64-windows:
697   extends: validate-x86_64-windows
698   variables:
699     MSYSTEM: MINGW64
700     BUILD_FLAVOUR: "perf"
701     CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
702   only:
703     - tags
704
705 release-i386-windows:
706   extends: .build-windows-make
707   only:
708     - tags
709   variables:
710     MSYSTEM: MINGW32
711     BUILD_FLAVOUR: "perf"
712     CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
713     # Due to #15934
714     BUILD_PROF_LIBS: "NO"
715   cache:
716     key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION"
717
718 nightly-i386-windows:
719   extends: .build-windows-make
720   only:
721     variables:
722       - $NIGHTLY
723   variables:
724     MSYSTEM: MINGW32
725     CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
726     # Due to #15934
727     BUILD_PROF_LIBS: "NO"
728   cache:
729     key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION"
730
731 ############################################################
732 # Cleanup
733 ############################################################
734
735 # Note [Cleaning up after shell executor]
736 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
737 #
738 # As noted in [1], gitlab-runner's shell executor doesn't clean up its working
739 # directory after builds. Unfortunately, we are forced to use the shell executor
740 # on Darwin. To avoid running out of disk space we add a stage at the end of
741 # the build to remove the /.../GitLabRunner/builds directory. Since we only run a
742 # single build at a time on Darwin this should be safe.
743 #
744 # We used to have a similar cleanup job on Windows as well however it ended up
745 # being quite fragile as we have multiple Windows builders yet there is no
746 # guarantee that the cleanup job is run on the same machine as the build itself
747 # was run. Consequently we were forced to instead handle cleanup with a separate
748 # cleanup cron job on Windows.
749 #
750 # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856
751
752 # See Note [Cleanup after shell executor]
753 cleanup-darwin:
754   <<: *only-default
755   stage: cleanup
756   tags:
757     - x86_64-darwin
758   when: always
759   dependencies: []
760   before_script:
761     - echo "Time to clean up"
762   script:
763     - echo "Let's go"
764   after_script:
765     - BUILD_DIR=$CI_PROJECT_DIR
766     - echo "Cleaning $BUILD_DIR"
767     - cd $HOME
768     - rm -Rf $BUILD_DIR/*
769     - exit 0
770
771 ############################################################
772 # Packaging
773 ############################################################
774
775 doc-tarball:
776   <<: *only-default
777   stage: packaging
778   tags:
779     - x86_64-linux
780   image: ghcci/x86_64-linux-deb9:0.2
781   dependencies:
782     - validate-x86_64-linux-deb9
783     - validate-x86_64-windows
784   variables:
785     LINUX_BINDIST: "ghc-x86_64-deb9-linux.tar.xz"
786     WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz"
787   # Due to Windows allow_failure
788   allow_failure: true
789   artifacts:
790     paths:
791       - haddock.html.tar.xz
792       - libraries.html.tar.xz
793       - users_guide.html.tar.xz
794       - index.html
795       - "*.pdf"
796   script:
797     - |
798       if [ ! -f "$LINUX_BINDIST" ]; then
799         echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?"
800         exit 1
801       fi
802       if [ ! -f "$WINDOWS_BINDIST" ]; then
803         echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?"
804         exit 1
805       fi
806     - rm -Rf docs
807     - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST
808     - ls -lh
809     - mv docs/*.tar.xz docs/index.html .
810
811 source-tarball:
812   stage: packaging
813   tags:
814     - x86_64-linux
815   image: ghcci/x86_64-linux-deb9:0.2
816   dependencies: []
817   only:
818     - tags
819   artifacts:
820     paths:
821       - ghc-*.tar.xz
822       - version
823   script:
824     - mk/get-win32-tarballs.sh download all
825     - ./boot
826     - ./configure
827     - make sdist
828     - mv sdistprep/*.xz  .
829     - make show VALUE=version > version
830
831
832 ############################################################
833 # Testing via head.hackage
834 ############################################################
835
836 # Triggering jobs in the ghc/head.hackage project requires that we have a job
837 # token for that repository. Furthermore the head.hackage CI job must have
838 # access to an unprivileged access token with the ability to query the ghc/ghc
839 # project such that it can find the job ID of the fedora27 job for the current
840 # pipeline.
841
842 .hackage:
843   <<: *only-default
844   stage: hackage
845   image: ghcci/x86_64-linux-deb9:0.2
846   tags:
847     - x86_64-linux
848   dependencies: []
849   variables:
850     HEAD_HACKAGE_PROJECT_ID: "78"
851   script:
852     - bash .gitlab/start-head.hackage.sh
853
854 hackage:
855   extends: .hackage
856   when: manual
857
858 hackage-label:
859   extends: .hackage
860   only:
861     variables:
862       - $CI_MERGE_REQUEST_LABELS =~ /.*user-facing.*/
863
864 nightly-hackage:
865   extends: .hackage
866   only:
867     variables:
868       - $NIGHTLY
869
870 pages:
871   stage: deploy
872   dependencies:
873     - doc-tarball
874   image: ghcci/x86_64-linux-deb9:0.2
875   # Due to Windows allow_failure
876   allow_failure: true
877   tags:
878     - x86_64-linux
879   script:
880     - mkdir -p public/doc
881     - tar -xf haddock.html.tar.xz -C public/doc
882     - tar -xf libraries.html.tar.xz -C public/doc
883     - tar -xf users_guide.html.tar.xz -C public/doc
884     - |
885       cat >public/index.html <<EOF
886       <!DOCTYPE HTML>
887       <meta charset="UTF-8">
888       <meta http-equiv="refresh" content="1; url=doc/">
889       EOF
890     - cp -f index.html public/doc
891   only:
892     - master
893   artifacts:
894     paths:
895       - public