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