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