Add `-haddock` to prepare-system.sh and .gitlab-ci.yml
[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   # due to #16574 this currently fails
564   allow_failure: true
565   script:
566     - |
567       python boot
568       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
569     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist"
570     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
571     # FIXME: Testsuite disabled due to #16156.
572     # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
573   tags:
574     - x86_64-windows
575   artifacts:
576     when: always
577     paths:
578       - ghc.tar.xz
579
580 validate-x86_64-windows-hadrian:
581   extends: .build-windows-hadrian
582   variables:
583     MSYSTEM: MINGW64
584   cache:
585     key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION"
586
587 nightly-i386-windows-hadrian:
588   extends: .build-windows-hadrian
589   variables:
590     MSYSTEM: MINGW32
591   only:
592     variables:
593       - $NIGHTLY
594   cache:
595     key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION"
596
597 .build-windows-make:
598   extends: .build-windows
599   stage: full-build
600   # due to #16084
601   allow_failure: true
602   variables:
603     BUILD_FLAVOUR: "quick"
604     GHC_VERSION: "8.6.2"
605     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz"
606   script:
607     - |
608       python boot
609       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS'
610     - bash -c "echo include mk/flavours/${BUILD_FLAVOUR}.mk > mk/build.mk"
611     - bash -c "echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk"
612     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
613     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1"
614     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
615   tags:
616     - x86_64-windows
617   artifacts:
618     when: always
619     expire_in: 2 week
620     reports:
621       junit: junit.xml
622     paths:
623       - ghc-*.tar.xz
624       - junit.xml
625
626 validate-x86_64-windows:
627   extends: .build-windows-make
628   variables:
629     MSYSTEM: MINGW64
630     CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
631   cache:
632     key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION"
633
634 # Normal Windows validate builds are profiled; that won't do for releases.
635 release-x86_64-windows:
636   extends: validate-x86_64-windows
637   variables:
638     MSYSTEM: MINGW64
639     BUILD_FLAVOUR: "perf"
640     CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
641   only:
642     - tags
643
644 release-i386-windows:
645   extends: .build-windows-make
646   only:
647     - tags
648   variables:
649     MSYSTEM: MINGW32
650     BUILD_FLAVOUR: "perf"
651     CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
652     # Due to #15934
653     BUILD_PROF_LIBS: "NO"
654   cache:
655     key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION"
656
657 nightly-i386-windows:
658   extends: .build-windows-make
659   only:
660     variables:
661       - $NIGHTLY
662   variables:
663     MSYSTEM: MINGW32
664     CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
665     # Due to #15934
666     BUILD_PROF_LIBS: "NO"
667   cache:
668     key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION"
669
670 ############################################################
671 # Cleanup
672 ############################################################
673
674 # Note [Cleaning up after shell executor]
675 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
676 #
677 # As noted in [1], gitlab-runner's shell executor doesn't clean up its working
678 # directory after builds. Unfortunately, we are forced to use the shell executor
679 # on Darwin. To avoid running out of disk space we add a stage at the end of
680 # the build to remove the /.../GitLabRunner/builds directory. Since we only run a
681 # single build at a time on Darwin this should be safe.
682 #
683 # We used to have a similar cleanup job on Windows as well however it ended up
684 # being quite fragile as we have multiple Windows builders yet there is no
685 # guarantee that the cleanup job is run on the same machine as the build itself
686 # was run. Consequently we were forced to instead handle cleanup with a separate
687 # cleanup cron job on Windows.
688 #
689 # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856
690
691 # See Note [Cleanup after shell executor]
692 cleanup-darwin:
693   <<: *only-default
694   stage: cleanup
695   tags:
696     - x86_64-darwin
697   when: always
698   dependencies: []
699   before_script:
700     - echo "Time to clean up"
701   script:
702     - echo "Let's go"
703   after_script:
704     - BUILD_DIR=$CI_PROJECT_DIR
705     - echo "Cleaning $BUILD_DIR"
706     - cd $HOME
707     - rm -Rf $BUILD_DIR/*
708     - exit 0
709
710 ############################################################
711 # Packaging
712 ############################################################
713
714 doc-tarball:
715   <<: *only-default
716   stage: packaging
717   tags:
718     - x86_64-linux
719   image: ghcci/x86_64-linux-deb9:0.2
720   dependencies:
721     - validate-x86_64-linux-deb9
722     - validate-x86_64-windows
723   variables:
724     LINUX_BINDIST: "ghc-x86_64-deb9-linux.tar.xz"
725     WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz"
726   # Due to Windows allow_failure
727   allow_failure: true
728   artifacts:
729     paths:
730       - haddock.html.tar.xz
731       - libraries.html.tar.xz
732       - users_guide.html.tar.xz
733       - index.html
734       - "*.pdf"
735   script:
736     - |
737       if [ ! -f "$LINUX_BINDIST" ]; then
738         echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?"
739         exit 1
740       fi
741       if [ ! -f "$WINDOWS_BINDIST" ]; then
742         echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?"
743         exit 1
744       fi
745     - rm -Rf docs
746     - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST
747     - ls -lh
748     - mv docs/*.tar.xz docs/index.html .
749
750 source-tarball:
751   stage: packaging
752   tags:
753     - x86_64-linux
754   image: ghcci/x86_64-linux-deb9:0.2
755   dependencies: []
756   only:
757     - tags
758   artifacts:
759     paths:
760       - ghc-*.tar.xz
761       - version
762   script:
763     - mk/get-win32-tarballs.sh download all
764     - ./boot
765     - ./configure
766     - make sdist
767     - mv sdistprep/*.xz  .
768     - make show VALUE=version > version
769
770
771 ############################################################
772 # Testing via head.hackage
773 ############################################################
774
775 # Triggering jobs in the ghc/head.hackage project requires that we have a job
776 # token for that repository. Furthermore the head.hackage CI job must have
777 # access to an unprivileged access token with the ability to query the ghc/ghc
778 # project such that it can find the job ID of the fedora27 job for the current
779 # pipeline.
780
781 .hackage:
782   <<: *only-default
783   stage: hackage
784   image: ghcci/x86_64-linux-deb9:0.2
785   tags:
786     - x86_64-linux
787   dependencies: []
788   variables:
789     HEAD_HACKAGE_PROJECT_ID: "78"
790   script:
791     - bash .gitlab/start-head.hackage.sh
792
793 hackage:
794   extends: .hackage
795   when: manual
796
797 hackage-label:
798   extends: .hackage
799   only:
800     variables:
801       - $CI_MERGE_REQUEST_LABELS =~ /.*user-facing.*/
802
803 nightly-hackage:
804   extends: .hackage
805   only:
806     variables:
807       - $NIGHTLY
808
809 pages:
810   stage: deploy
811   dependencies:
812     - doc-tarball
813   image: ghcci/x86_64-linux-deb9:0.2
814   # Due to Windows allow_failure
815   allow_failure: true
816   tags:
817     - x86_64-linux
818   script:
819     - mkdir -p public/doc
820     - tar -xf haddock.html.tar.xz -C public/doc
821     - tar -xf libraries.html.tar.xz -C public/doc
822     - tar -xf users_guide.html.tar.xz -C public/doc
823     - cp -f index.html public/doc
824   only:
825     - master
826   artifacts:
827     paths:
828       - public