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