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