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