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