Update autoconf scripts
[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
443 #################################
444 # x86_64-linux-deb8
445 #################################
446
447 release-x86_64-linux-deb8:
448   extends: .validate-linux
449   stage: full-build
450   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV"
451   variables:
452     TEST_ENV: "x86_64-linux-deb8"
453     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz"
454   only:
455     - tags
456   cache:
457     key: linux-x86_64-deb8
458   artifacts:
459     when: always
460     expire_in: 2 week
461
462 #################################
463 # x86_64-linux-centos7
464 #################################
465
466 release-x86_64-linux-centos7:
467   extends: .validate-linux
468   stage: full-build
469   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV"
470   variables:
471     # The sphinx release shipped with Centos 7 fails to build out documentation
472     BUILD_SPHINX_HTML: "NO"
473     BUILD_SPHINX_PDF: "NO"
474     TEST_ENV: "x86_64-linux-centos7"
475     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz"
476   only:
477     - tags
478   cache:
479     key: linux-x86_64-centos7
480   artifacts:
481     when: always
482     expire_in: 2 week
483
484 #################################
485 # x86_64-linux-fedora27
486 #################################
487
488 validate-x86_64-linux-fedora27:
489   extends: .validate-linux
490   stage: full-build
491   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV"
492   variables:
493     TEST_ENV: "x86_64-linux-fedora27"
494     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz"
495   cache:
496     key: linux-x86_64-fedora27
497   artifacts:
498     when: always
499     expire_in: 2 week
500
501 ############################################################
502 # Validation via Pipelines (Windows)
503 ############################################################
504
505 .build-windows:
506   <<: *only-default
507   before_script:
508     - git clean -xdf
509     - git submodule foreach git clean -xdf
510
511     # Use a local temporary directory to ensure that concurrent builds don't
512     # interfere with one another
513     - |
514       mkdir tmp
515       set TMP=%cd%\tmp
516       set TEMP=%cd%\tmp
517
518     - set PATH=C:\msys64\usr\bin;%PATH%
519     - python .gitlab/fix-submodules.py
520     - git submodule sync --recursive
521     - git submodule update --init --recursive
522     - git checkout .gitmodules
523     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
524     - bash .gitlab/win32-init.sh
525   after_script:
526     - rd /s /q tmp
527     - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache
528     - bash -c 'make clean || true'
529   dependencies: []
530   variables:
531     FORCE_SYMLINKS: 1
532     LANG: "en_US.UTF-8"
533   cache:
534     paths:
535       - cabal-cache
536       - ghc-8.6.2
537       - ghc-tarballs
538
539 .build-windows-hadrian:
540   extends: .build-windows
541   stage: full-build
542   variables:
543     GHC_VERSION: "8.6.2"
544   script:
545     - |
546       python boot
547       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
548     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist"
549     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
550     # FIXME: Testsuite disabled due to #16156.
551     # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
552   tags:
553     - x86_64-windows
554   artifacts:
555     when: always
556     paths:
557       - ghc.tar.xz
558
559 .validate-x86_64-windows-hadrian:
560   extends: .build-windows-hadrian
561   variables:
562     MSYSTEM: MINGW64
563   cache:
564     key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION"
565
566 nightly-i386-windows-hadrian:
567   extends: .build-windows-hadrian
568   variables:
569     MSYSTEM: MINGW32
570   only:
571     variables:
572       - $NIGHTLY
573   cache:
574     key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION"
575
576 .build-windows-make:
577   extends: .build-windows
578   stage: full-build
579   # due to #16084
580   allow_failure: true
581   variables:
582     BUILD_FLAVOUR: "quick"
583     GHC_VERSION: "8.6.2"
584     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz"
585   script:
586     - |
587       python boot
588       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS'
589     - bash -c "echo include mk/flavours/${BUILD_FLAVOUR}.mk > mk/build.mk"
590     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
591     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1"
592     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
593   tags:
594     - x86_64-windows
595   artifacts:
596     when: always
597     expire_in: 2 week
598     reports:
599       junit: junit.xml
600     paths:
601       - ghc-*.tar.xz
602       - junit.xml
603
604 validate-x86_64-windows:
605   extends: .build-windows-make
606   variables:
607     MSYSTEM: MINGW64
608     CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
609   cache:
610     key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION"
611
612 # Normal Windows validate builds are profiled; that won't do for releases.
613 release-x86_64-windows:
614   extends: validate-x86_64-windows
615   variables:
616     MSYSTEM: MINGW64
617     BUILD_FLAVOUR: "perf"
618     CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
619   only:
620     - tags
621
622 release-i386-windows:
623   extends: .build-windows-make
624   only:
625     - tags
626   variables:
627     MSYSTEM: MINGW32
628     BUILD_FLAVOUR: "perf"
629     CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
630     # Due to #15934
631     BUILD_PROF_LIBS: "NO"
632   cache:
633     key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION"
634
635 nightly-i386-windows:
636   extends: .build-windows-make
637   only:
638     variables:
639       - $NIGHTLY
640   variables:
641     MSYSTEM: MINGW32
642     CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
643     # Due to #15934
644     BUILD_PROF_LIBS: "NO"
645   cache:
646     key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION"
647
648 ############################################################
649 # Cleanup
650 ############################################################
651
652 # Note [Cleaning up after shell executor]
653 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
654 #
655 # As noted in [1], gitlab-runner's shell executor doesn't clean up its working
656 # directory after builds. Unfortunately, we are forced to use the shell executor
657 # on Windows. To avoid running out of disk space we add a stage at the end of
658 # the build to remove the \GitLabRunner\builds directory. Since we only run a
659 # single build at a time on Windows this should be safe.
660 #
661 # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856
662
663 # See Note [Cleanup after shell executor]
664 cleanup-windows:
665   <<: *only-default
666   stage: cleanup
667   tags:
668     - x86_64-windows
669   when: always
670   dependencies: []
671   before_script:
672     - echo "Time to clean up"
673   script:
674     - echo "Let's go"
675   after_script:
676     - set "BUILD_DIR=%CI_PROJECT_DIR%"
677     - set "BUILD_DIR=%BUILD_DIR:/=\%"
678     - echo "Cleaning %BUILD_DIR%"
679     - cd \GitLabRunner
680     # This is way more complicated than it should be:
681     # See https://stackoverflow.com/questions/1965787
682     - del %BUILD_DIR%\* /F /Q
683     - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p"
684     - exit /b 0
685
686 # See Note [Cleanup after shell executor]
687 cleanup-darwin:
688   <<: *only-default
689   stage: cleanup
690   tags:
691     - x86_64-darwin
692   when: always
693   dependencies: []
694   before_script:
695     - echo "Time to clean up"
696   script:
697     - echo "Let's go"
698   after_script:
699     - BUILD_DIR=$CI_PROJECT_DIR
700     - echo "Cleaning $BUILD_DIR"
701     - cd $HOME
702     - rm -Rf $BUILD_DIR/*
703     - exit 0
704
705 ############################################################
706 # Packaging
707 ############################################################
708
709 doc-tarball:
710   <<: *only-default
711   stage: packaging
712   tags:
713     - x86_64-linux
714   image: ghcci/x86_64-linux-deb9:0.2
715   dependencies:
716     - validate-x86_64-linux-deb9
717     - validate-x86_64-windows
718   variables:
719     LINUX_BINDIST: "ghc-x86_64-deb9-linux.tar.xz"
720     WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz"
721   # Due to Windows allow_failure
722   allow_failure: true
723   artifacts:
724     paths:
725       - haddock.html.tar.xz
726       - libraries.html.tar.xz
727       - users_guide.html.tar.xz
728       - index.html
729       - "*.pdf"
730   script:
731     - |
732       if [ ! -f "$LINUX_BINDIST" ]; then
733         echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?"
734         exit 1
735       fi
736       if [ ! -f "$WINDOWS_BINDIST" ]; then
737         echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?"
738         exit 1
739       fi
740     - rm -Rf docs
741     - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST
742     - ls -lh
743     - mv docs/*.tar.xz docs/index.html .
744
745 source-tarball:
746   stage: packaging
747   tags:
748     - x86_64-linux
749   image: ghcci/x86_64-linux-deb9:0.2
750   dependencies: []
751   only:
752     - tags
753   artifacts:
754     paths:
755       - ghc-*.tar.xz
756       - version
757   script:
758     - mk/get-win32-tarballs.sh download all
759     - ./boot
760     - ./configure
761     - make sdist
762     - mv sdistprep/*.xz  .
763     - make show VALUE=version > version
764
765
766 ############################################################
767 # Testing via head.hackage
768 ############################################################
769
770 # Triggering jobs in the ghc/head.hackage project requires that we have a job
771 # token for that repository. Furthermore the head.hackage CI job must have
772 # access to an unprivileged access token with the ability to query the ghc/ghc
773 # project such that it can find the job ID of the fedora27 job for the current
774 # pipeline.
775
776 .hackage:
777   <<: *only-default
778   stage: hackage
779   image: ghcci/x86_64-linux-deb9:0.2
780   tags:
781     - x86_64-linux
782   dependencies: []
783   variables:
784     HEAD_HACKAGE_PROJECT_ID: "78"
785   script:
786     - bash .gitlab/start-head.hackage.sh
787
788 hackage:
789   extends: .hackage
790   when: manual
791
792 hackage-label:
793   extends: .hackage
794   only:
795     variables:
796       - $CI_MERGE_REQUEST_LABELS =~ /.*user-facing.*/
797
798 nightly-hackage:
799   extends: .hackage
800   only:
801     variables:
802       - $NIGHTLY
803
804 pages:
805   stage: deploy
806   dependencies:
807     - doc-tarball
808   image: ghcci/x86_64-linux-deb9:0.2
809   # Due to Windows allow_failure
810   allow_failure: true
811   tags:
812     - x86_64-linux
813   script:
814     - mkdir -p public/doc
815     - tar -xf haddock.html.tar.xz -C public/doc
816     - tar -xf libraries.html.tar.xz -C public/doc
817     - tar -xf users_guide.html.tar.xz -C public/doc
818     - cp -f index.html public/doc
819   only:
820     - master
821   artifacts:
822     paths:
823       - public