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