gitlab-ci: Disable deb9-llvm job, introduce nightly LLVM job
[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: 88e952f165f48cfb956ac9a2486a9263aa4f777c
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   script:
155     - cabal update
156     - git clean -xdf && git submodule foreach git clean -xdf
157     - .gitlab/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     - .gitlab/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     - .gitlab/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     # Inexplicably makeindex fails
380     BUILD_SPHINX_PDF: "NO"
381   cache:
382     key: linux-aarch64-deb9
383   tags:
384     - aarch64-linux
385
386 validate-aarch64-linux-deb9:
387   extends: .build-aarch64-linux-deb9
388   artifacts:
389     when: always
390     expire_in: 2 week
391
392 nightly-aarch64-linux-deb9:
393   extends: .build-aarch64-linux-deb9
394   artifacts:
395     expire_in: 2 year
396   variables:
397     TEST_TYPE: slowtest
398   only:
399     variables:
400       - $NIGHTLY
401
402 #################################
403 # i386-linux-deb9
404 #################################
405
406 .build-i386-linux-deb9:
407   extends: .validate-linux
408   stage: full-build
409   image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV"
410   variables:
411     TEST_ENV: "i386-linux-deb9"
412     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz"
413   cache:
414     key: linux-i386-deb9
415
416 validate-i386-linux-deb9:
417   extends: .build-i386-linux-deb9
418   artifacts:
419     when: always
420     expire_in: 2 week
421
422 nightly-i386-linux-deb9:
423   extends: .build-i386-linux-deb9
424   variables:
425     TEST_TYPE: slowtest
426   artifacts:
427     when: always
428     expire_in: 2 week
429   only:
430     variables:
431       - $NIGHTLY
432
433 #################################
434 # x86_64-linux-deb9
435 #################################
436
437 .build-x86_64-linux-deb9:
438   extends: .validate-linux
439   stage: full-build
440   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
441   variables:
442     TEST_ENV: "x86_64-linux-deb9"
443     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz"
444   cache:
445     key: linux-x86_64-deb9
446
447 validate-x86_64-linux-deb9:
448   extends: .build-x86_64-linux-deb9
449   artifacts:
450     when: always
451     expire_in: 2 week
452
453 nightly-x86_64-linux-deb9:
454   extends: .build-x86_64-linux-deb9
455   artifacts:
456     expire_in: 2 year
457   variables:
458     TEST_TYPE: slowtest
459   only:
460     variables:
461       - $NIGHTLY
462
463 # N.B. Has DEBUG assertions enabled in stage2
464 validate-x86_64-linux-deb9-debug:
465   extends: .build-x86_64-linux-deb9
466   stage: build
467   variables:
468     BUILD_FLAVOUR: validate
469     TEST_TYPE: slowtest
470     TEST_ENV: "x86_64-linux-deb9-debug"
471
472 # Disabled to alleviate CI load
473 .validate-x86_64-linux-deb9-llvm:
474   extends: .build-x86_64-linux-deb9
475   stage: full-build
476   variables:
477     BUILD_FLAVOUR: perf-llvm
478     TEST_ENV: "x86_64-linux-deb9-llvm"
479
480 nightly-x86_64-linux-deb9-llvm:
481   extends: .build-x86_64-linux-deb9
482   stage: full-build
483   variables:
484     BUILD_FLAVOUR: perf-llvm
485     TEST_ENV: "x86_64-linux-deb9-llvm"
486   only:
487     variables:
488       - $NIGHTLY
489
490 validate-x86_64-linux-deb9-integer-simple:
491   extends: .build-x86_64-linux-deb9
492   stage: full-build
493   variables:
494     INTEGER_LIBRARY: integer-simple
495     TEST_ENV: "x86_64-linux-deb9-integer-simple"
496     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz"
497
498 nightly-x86_64-linux-deb9-integer-simple:
499   extends: .build-x86_64-linux-deb9
500   stage: full-build
501   variables:
502     INTEGER_LIBRARY: integer-simple
503     TEST_ENV: "x86_64-linux-deb9-integer-simple"
504     TEST_TYPE: slowtest
505   artifacts:
506     expire_in: 2 year
507   only:
508     variables:
509       - $NIGHTLY
510
511 validate-x86_64-linux-deb9-unreg:
512   extends: .build-x86_64-linux-deb9
513   stage: full-build
514   variables:
515     CONFIGURE_ARGS: --enable-unregisterised
516     TEST_ENV: "x86_64-linux-deb9-unreg"
517
518 release-x86_64-linux-deb9-dwarf:
519   extends: .validate-linux
520   stage: build
521   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
522   allow_failure: true
523   variables:
524     CONFIGURE_ARGS: "--enable-dwarf-unwind"
525     BUILD_FLAVOUR: dwarf
526     TEST_ENV: "x86_64-linux-deb9"
527   artifacts:
528     when: always
529     expire_in: 2 week
530   cache:
531     key: linux-x86_64-deb9
532
533
534 #################################
535 # x86_64-linux-deb8
536 #################################
537
538 release-x86_64-linux-deb8:
539   extends: .validate-linux
540   stage: full-build
541   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV"
542   variables:
543     TEST_ENV: "x86_64-linux-deb8"
544     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz"
545   only:
546     - tags
547   cache:
548     key: linux-x86_64-deb8
549   artifacts:
550     when: always
551     expire_in: 2 week
552
553 #################################
554 # x86_64-linux-centos7
555 #################################
556
557 release-x86_64-linux-centos7:
558   extends: .validate-linux
559   stage: full-build
560   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV"
561   variables:
562     # The sphinx release shipped with Centos 7 fails to build out documentation
563     BUILD_SPHINX_HTML: "NO"
564     BUILD_SPHINX_PDF: "NO"
565     TEST_ENV: "x86_64-linux-centos7"
566     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz"
567   only:
568     - tags
569   cache:
570     key: linux-x86_64-centos7
571   artifacts:
572     when: always
573     expire_in: 2 week
574
575 #################################
576 # x86_64-linux-fedora27
577 #################################
578
579 validate-x86_64-linux-fedora27:
580   extends: .validate-linux
581   stage: full-build
582   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV"
583   variables:
584     TEST_ENV: "x86_64-linux-fedora27"
585     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz"
586   cache:
587     key: linux-x86_64-fedora27
588   artifacts:
589     when: always
590     expire_in: 2 week
591
592 ############################################################
593 # Validation via Pipelines (Windows)
594 ############################################################
595
596 .build-windows:
597   <<: *only-default
598   before_script:
599     - git clean -xdf
600     - git submodule foreach git clean -xdf
601
602     # Use a local temporary directory to ensure that concurrent builds don't
603     # interfere with one another
604     - |
605       mkdir tmp
606       set TMP=%cd%\tmp
607       set TEMP=%cd%\tmp
608
609     - set PATH=C:\msys64\usr\bin;%PATH%
610     - python .gitlab/fix-submodules.py
611     - git submodule sync --recursive
612     - git submodule update --init --recursive
613     - git checkout .gitmodules
614     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
615     - bash .gitlab/win32-init.sh
616   after_script:
617     - rd /s /q tmp
618     - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache
619     - bash -c 'make clean || true'
620   dependencies: []
621   variables:
622     FORCE_SYMLINKS: 1
623     LANG: "en_US.UTF-8"
624   cache:
625     paths:
626       - cabal-cache
627       - ghc-8.6.5
628       - ghc-tarballs
629
630 .build-windows-hadrian:
631   extends: .build-windows
632   stage: full-build
633   variables:
634     GHC_VERSION: "8.6.5"
635   # due to #16574 this currently fails
636   allow_failure: true
637   script:
638     - |
639       python boot
640       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
641     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist"
642     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
643     # FIXME: Testsuite disabled due to #16156.
644     # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
645   tags:
646     - x86_64-windows
647   artifacts:
648     when: always
649     paths:
650       - ghc.tar.xz
651
652 validate-x86_64-windows-hadrian:
653   extends: .build-windows-hadrian
654   variables:
655     MSYSTEM: MINGW64
656   cache:
657     key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION"
658
659 nightly-i386-windows-hadrian:
660   extends: .build-windows-hadrian
661   variables:
662     MSYSTEM: MINGW32
663   only:
664     variables:
665       - $NIGHTLY
666   cache:
667     key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION"
668
669 .build-windows-make:
670   extends: .build-windows
671   stage: full-build
672   # due to #16084
673   allow_failure: true
674   variables:
675     BUILD_FLAVOUR: "quick"
676     GHC_VERSION: "8.6.5"
677     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz"
678   script:
679     - |
680       python boot
681       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS'
682     - bash -c "echo include mk/flavours/${BUILD_FLAVOUR}.mk > mk/build.mk"
683     - bash -c "echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk"
684     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
685     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make bindisttest"
686     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1"
687     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
688   tags:
689     - x86_64-windows
690   artifacts:
691     when: always
692     expire_in: 2 week
693     reports:
694       junit: junit.xml
695     paths:
696       - ghc-*.tar.xz
697       - junit.xml
698
699 validate-x86_64-windows:
700   extends: .build-windows-make
701   variables:
702     MSYSTEM: MINGW64
703     CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
704   cache:
705     key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION"
706
707 # Normal Windows validate builds are profiled; that won't do for releases.
708 release-x86_64-windows:
709   extends: validate-x86_64-windows
710   variables:
711     MSYSTEM: MINGW64
712     BUILD_FLAVOUR: "perf"
713     CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
714   only:
715     - tags
716
717 release-i386-windows:
718   extends: .build-windows-make
719   only:
720     - tags
721   variables:
722     MSYSTEM: MINGW32
723     BUILD_FLAVOUR: "perf"
724     CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
725     # Due to #15934
726     BUILD_PROF_LIBS: "NO"
727   cache:
728     key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION"
729
730 nightly-i386-windows:
731   extends: .build-windows-make
732   only:
733     variables:
734       - $NIGHTLY
735   variables:
736     MSYSTEM: MINGW32
737     CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
738     # Due to #15934
739     BUILD_PROF_LIBS: "NO"
740   cache:
741     key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION"
742
743 ############################################################
744 # Cleanup
745 ############################################################
746
747 # Note [Cleaning up after shell executor]
748 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
749 #
750 # As noted in [1], gitlab-runner's shell executor doesn't clean up its working
751 # directory after builds. Unfortunately, we are forced to use the shell executor
752 # on Darwin. To avoid running out of disk space we add a stage at the end of
753 # the build to remove the /.../GitLabRunner/builds directory. Since we only run a
754 # single build at a time on Darwin this should be safe.
755 #
756 # We used to have a similar cleanup job on Windows as well however it ended up
757 # being quite fragile as we have multiple Windows builders yet there is no
758 # guarantee that the cleanup job is run on the same machine as the build itself
759 # was run. Consequently we were forced to instead handle cleanup with a separate
760 # cleanup cron job on Windows.
761 #
762 # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856
763
764 # See Note [Cleanup after shell executor]
765 cleanup-darwin:
766   <<: *only-default
767   stage: cleanup
768   tags:
769     - x86_64-darwin
770   when: always
771   dependencies: []
772   before_script:
773     - echo "Time to clean up"
774   script:
775     - echo "Let's go"
776   after_script:
777     - BUILD_DIR=$CI_PROJECT_DIR
778     - echo "Cleaning $BUILD_DIR"
779     - cd $HOME
780     - rm -Rf $BUILD_DIR/*
781     - exit 0
782
783 ############################################################
784 # Packaging
785 ############################################################
786
787 doc-tarball:
788   <<: *only-default
789   stage: packaging
790   tags:
791     - x86_64-linux
792   image: ghcci/x86_64-linux-deb9:0.2
793   dependencies:
794     - validate-x86_64-linux-deb9
795     - validate-x86_64-windows
796   variables:
797     LINUX_BINDIST: "ghc-x86_64-deb9-linux.tar.xz"
798     WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz"
799   # Due to Windows allow_failure
800   allow_failure: true
801   artifacts:
802     paths:
803       - haddock.html.tar.xz
804       - libraries.html.tar.xz
805       - users_guide.html.tar.xz
806       - index.html
807       - "*.pdf"
808   script:
809     - |
810       if [ ! -f "$LINUX_BINDIST" ]; then
811         echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?"
812         exit 1
813       fi
814       if [ ! -f "$WINDOWS_BINDIST" ]; then
815         echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?"
816         exit 1
817       fi
818     - rm -Rf docs
819     - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST
820     - ls -lh
821     - mv docs/*.tar.xz docs/index.html .
822
823 source-tarball:
824   stage: packaging
825   tags:
826     - x86_64-linux
827   image: ghcci/x86_64-linux-deb9:0.2
828   dependencies: []
829   only:
830     - tags
831   artifacts:
832     paths:
833       - ghc-*.tar.xz
834       - version
835   script:
836     - mk/get-win32-tarballs.sh download all
837     - ./boot
838     - ./configure
839     - make sdist
840     - mv sdistprep/*.xz  .
841     - make show VALUE=version > version
842
843
844 ############################################################
845 # Testing via head.hackage
846 ############################################################
847
848 # Triggering jobs in the ghc/head.hackage project requires that we have a job
849 # token for that repository. Furthermore the head.hackage CI job must have
850 # access to an unprivileged access token with the ability to query the ghc/ghc
851 # project such that it can find the job ID of the fedora27 job for the current
852 # pipeline.
853
854 .hackage:
855   <<: *only-default
856   stage: hackage
857   image: ghcci/x86_64-linux-deb9:0.2
858   tags:
859     - x86_64-linux
860   dependencies: []
861   variables:
862     HEAD_HACKAGE_PROJECT_ID: "78"
863   script:
864     - bash .gitlab/start-head.hackage.sh
865
866 hackage:
867   extends: .hackage
868   when: manual
869
870 hackage-label:
871   extends: .hackage
872   only:
873     variables:
874       - $CI_MERGE_REQUEST_LABELS =~ /.*user-facing.*/
875
876 nightly-hackage:
877   extends: .hackage
878   only:
879     variables:
880       - $NIGHTLY
881
882 pages:
883   stage: deploy
884   dependencies:
885     - doc-tarball
886   image: ghcci/x86_64-linux-deb9:0.2
887   # Due to Windows allow_failure
888   allow_failure: true
889   tags:
890     - x86_64-linux
891   script:
892     - mkdir -p public/doc
893     - tar -xf haddock.html.tar.xz -C public/doc
894     - tar -xf libraries.html.tar.xz -C public/doc
895     - tar -xf users_guide.html.tar.xz -C public/doc
896     - |
897       cat >public/index.html <<EOF
898       <!DOCTYPE HTML>
899       <meta charset="UTF-8">
900       <meta http-equiv="refresh" content="1; url=doc/">
901       EOF
902     - cp -f index.html public/doc
903   only:
904     - master
905   artifacts:
906     paths:
907       - public