gitlab-ci: Linters, don't allow to fail
[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   stage: lint
53   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
54   script:
55     - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
56     - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)"
57     - "echo Merge base $base"
58     #    - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA)
59     - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA)
60     - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA
61     - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA
62     - .gitlab/linters/check-version-number.sh
63   dependencies: []
64   tags:
65     - lint
66   only:
67     refs:
68       - merge_requests
69
70 # We allow the submodule checker to fail when run on merge requests (to
71 # accomodate, e.g., haddock changes not yet upstream) but not on `master` or
72 # Marge jobs.
73 .lint-submods:
74   stage: lint
75   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
76   script:
77     - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA)
78   dependencies: []
79   tags:
80     - lint
81
82 lint-submods:
83   extends: .lint-submods
84   only:
85     refs:
86       - master
87       - /ghc-[0-9]+\.[0-9]+/
88
89 lint-submods-marge:
90   extends: .lint-submods
91   only:
92     refs:
93       - merge_requests
94     variables:
95       - $CI_MERGE_REQUEST_LABELS =~ /.*wip/marge_bot_batch_merge_job.*/
96
97 lint-submods-mr:
98   extends: .lint-submods
99   allow_failure: true
100   only:
101     refs:
102       - merge_requests
103
104 .lint-changelogs:
105   stage: lint
106   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
107   dependencies: []
108   tags:
109     - lint
110   script:
111     - |
112       grep TBA libraries/*/changelog.md && (
113           echo "Error: Found \"TBA\"s in changelogs."
114           exit 1
115       )
116
117 lint-changelogs:
118   extends: .lint-changelogs
119   allow_failure: true
120   only:
121     refs:
122       - /ghc-[0-9]+\.[0-9]+/
123
124 lint-release-changelogs:
125   extends: .lint-changelogs
126   only:
127     refs:
128       - /ghc-[0-9]+\.[0-9]+\.[0-9]+-.*/
129
130
131 ############################################################
132 # Validation via Pipelines (hadrian)
133 ############################################################
134
135 .validate-hadrian:
136   <<: *only-default
137   allow_failure: true
138   script:
139     - cabal update
140     - git clean -xdf && git submodule foreach git clean -xdf
141     - bash .circleci/prepare-system.sh
142     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
143     - ./boot
144     - ./configure $CONFIGURE_ARGS
145     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist
146     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx test --summary-junit=./junit.xml
147     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
148   cache:
149     key: hadrian
150     paths:
151       - cabal-cache
152   artifacts:
153     reports:
154       junit: junit.xml
155     expire_in: 2 week
156     paths:
157       - ghc.tar.xz
158       - junit.xml
159
160 validate-x86_64-linux-deb9-hadrian:
161   extends: .validate-hadrian
162   stage: build
163   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
164   before_script:
165     # workaround for docker permissions
166     - sudo chown ghc:ghc -R .
167     - python3 .gitlab/fix-submodules.py
168     - git submodule sync --recursive
169     - git submodule update --init --recursive
170     - git checkout .gitmodules
171     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
172   tags:
173     - x86_64-linux
174
175 hadrian-ghc-in-ghci:
176   <<: *only-default
177   stage: build
178   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
179   before_script:
180     # workaround for docker permissions
181     - sudo chown ghc:ghc -R .
182     - python3 .gitlab/fix-submodules.py
183     - git submodule sync --recursive
184     - git submodule update --init --recursive
185     - git checkout .gitmodules
186   tags:
187     - x86_64-linux
188   script:
189     - cabal update
190     - cd hadrian; cabal new-build --project-file=ci.project; cd ..
191     - git clean -xdf && git submodule foreach git clean -xdf
192     - bash .circleci/prepare-system.sh
193     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
194     - ./boot
195     - ./configure $CONFIGURE_ARGS
196     # Load ghc-in-ghci then immediately exit and check the modules loaded
197     - echo ":q" | hadrian/ghci.sh | tail -n2 | grep "Ok,"
198   cache:
199     key: hadrian-ghci
200     paths:
201       - cabal-cache
202
203 ############################################################
204 # Validation via Pipelines (make)
205 ############################################################
206
207 .validate:
208   <<: *only-default
209   variables:
210     TEST_TYPE: test
211   before_script:
212     - git clean -xdf && git submodule foreach git clean -xdf
213   script:
214     - ./boot
215     - ./configure $CONFIGURE_ARGS
216     - |
217       THREADS=`mk/detect-cpu-count.sh`
218       make V=0 -j$THREADS WERROR=-Werror
219     - |
220       make bindisttest
221     - |
222       make binary-dist TAR_COMP_OPTS="-1"
223     - |
224       # Prepare to push git notes.
225       METRICS_FILE=$(mktemp)
226       git config user.email "ben+ghc-ci@smart-cactus.org"
227       git config user.name "GHC GitLab CI"
228     - |
229       THREADS=`mk/detect-cpu-count.sh`
230       make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE
231     - |
232       # Push git notes.
233       METRICS_FILE=$METRICS_FILE .gitlab/push-test-metrics.sh
234   dependencies: []
235   artifacts:
236     reports:
237       junit: junit.xml
238     expire_in: 2 week
239     paths:
240       - ghc-*.tar.xz
241       - junit.xml
242
243 #################################
244 # x86_64-darwin
245 #################################
246
247 validate-x86_64-darwin:
248   extends: .validate
249   stage: full-build
250   tags:
251     - x86_64-darwin
252   variables:
253     GHC_VERSION: 8.6.3
254     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz"
255     MACOSX_DEPLOYMENT_TARGET: "10.7"
256     # Only Sierra and onwards supports clock_gettime. See #12858
257     ac_cv_func_clock_gettime: "no"
258     LANG: "en_US.UTF-8"
259     CONFIGURE_ARGS: --with-intree-gmp
260     TEST_ENV: "x86_64-darwin"
261   before_script:
262     - git clean -xdf && git submodule foreach git clean -xdf
263     - python3 .gitlab/fix-submodules.py
264     - git submodule sync --recursive
265     - git submodule update --init --recursive
266     - git checkout .gitmodules
267     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
268
269     - bash .gitlab/darwin-init.sh
270     - PATH="`pwd`/toolchain/bin:$PATH"
271   after_script:
272     - cp -Rf $HOME/.cabal cabal-cache
273   artifacts:
274     when: always
275     expire_in: 2 week
276   cache:
277     key: darwin
278     paths:
279       - cabal-cache
280       - toolchain
281
282 # Disabled because of OS X CI capacity
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     - |
867       cat >public/index.html <<EOF
868       <!DOCTYPE HTML>
869       <meta charset="UTF-8">
870       <meta http-equiv="refresh" content="1; url=doc/">
871       EOF
872     - cp -f index.html public/doc
873   only:
874     - master
875   artifacts:
876     paths:
877       - public