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