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