primops: haddock: Fix typo in referenced function.
[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: e517150438cd9df9564fb91adc4b42e2667b2bc1
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   # Disable shallow clones; they break our linting rules
12   GIT_DEPTH: 0
13
14 before_script:
15   - python3 .gitlab/fix-submodules.py
16   - git submodule sync --recursive
17   - git submodule update --init --recursive
18   - git checkout .gitmodules
19   - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
20
21 stages:
22   - lint       # Source linting
23   - build      # A quick smoke-test to weed out broken commits
24   - full-build # Build all the things
25   - cleanup    # See Note [Cleanup after the shell executor]
26   - packaging  # Source distribution, etc.
27   - testing    # head.hackage correctness and compiler performance testing
28   - deploy     # push documentation
29
30 # N.B.Don't run on wip/ branches, instead on run on merge requests.
31 .only-default: &only-default
32   only:
33     - master
34     - /ghc-[0-9]+\.[0-9]+/
35     - merge_requests
36     - tags
37     - web
38
39 ############################################################
40 # Runner Tags
41 ############################################################
42 #
43 # * x86_64-linux: Any Docker-capable x86_64 Linux machine
44 # * aarch64-linux: Any Docker-capable AArch64 Linux machine
45 # * x86_64-windows: A x86_64 Windows machine
46 # * lint: Any Docker-capable x86_64 Linux machine; distinct from
47 #         x86_64-linux to ensure low-latency availability.
48 #
49
50
51 ############################################################
52 # Linting
53 ############################################################
54
55 ghc-linters:
56   stage: lint
57   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
58   script:
59     - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
60     - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)"
61     - "echo Linting changes between $base..$CI_COMMIT_SHA"
62     #    - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA)
63     - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA)
64     - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA
65     - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA
66     - .gitlab/linters/check-version-number.sh
67   dependencies: []
68   tags:
69     - lint
70   only:
71     refs:
72       - merge_requests
73
74 # Run mypy Python typechecker on linter scripts.
75 lint-linters:
76   <<: *only-default
77   stage: lint
78   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
79   script:
80     - mypy .gitlab/linters/*.py
81   dependencies: []
82   tags:
83     - lint
84
85 # Check that .T files all parse by listing broken tests.
86 lint-testsuite:
87   <<: *only-default
88   stage: lint
89   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
90   script:
91     - make -Ctestsuite list_broken TEST_HC=ghc
92   dependencies: []
93   tags:
94     - lint
95
96 # Run mypy Python typechecker on testsuite driver
97 typecheck-testsuite:
98   <<: *only-default
99   stage: lint
100   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
101   script:
102     - mypy testsuite/driver/runtests.py
103   dependencies: []
104   tags:
105     - lint
106
107 # We allow the submodule checker to fail when run on merge requests (to
108 # accomodate, e.g., haddock changes not yet upstream) but not on `master` or
109 # Marge jobs.
110 .lint-submods:
111   <<: *only-default
112   stage: lint
113   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
114   script:
115     - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
116     - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)"
117     - "echo Linting submodule changes between $base..$CI_COMMIT_SHA"
118     - git submodule foreach git remote update
119     - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA)
120   dependencies: []
121   tags:
122     - lint
123
124 lint-submods-marge:
125   extends: .lint-submods
126   only:
127     refs:
128       - merge_requests
129     variables:
130       - $CI_MERGE_REQUEST_LABELS =~ /.*wip/marge_bot_batch_merge_job.*/
131
132 lint-submods-mr:
133   extends: .lint-submods
134   # Allow failure since any necessary submodule patches may not be upstreamed
135   # yet.
136   allow_failure: true
137   only:
138     refs:
139       - merge_requests
140   except:
141     variables:
142       - $CI_MERGE_REQUEST_LABELS =~ /.*wip/marge_bot_batch_merge_job.*/
143
144 lint-submods-branch:
145   extends: .lint-submods
146   script:
147     - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"
148     - git submodule foreach git remote update
149     - submodchecker .git $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA)
150   only:
151     refs:
152       - master
153       - /ghc-[0-9]+\.[0-9]+/
154
155 .lint-changelogs:
156   <<: *only-default
157   stage: lint
158   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
159   dependencies: []
160   tags:
161     - lint
162   script:
163     - |
164       grep TBA libraries/*/changelog.md && (
165           echo "Error: Found \"TBA\"s in changelogs."
166           exit 1
167       )
168
169 lint-changelogs:
170   extends: .lint-changelogs
171   # Allow failure since this isn't a final release.
172   allow_failure: true
173   only:
174     refs:
175       - /ghc-[0-9]+\.[0-9]+/
176
177 lint-release-changelogs:
178   extends: .lint-changelogs
179   only:
180     refs:
181       - /ghc-[0-9]+\.[0-9]+\.[0-9]+-.*/
182
183
184 ############################################################
185 # Validation via Pipelines (hadrian)
186 ############################################################
187
188 .validate-hadrian:
189   <<: *only-default
190   script:
191     - cabal update
192     - git clean -xdf && git submodule foreach git clean -xdf
193     - .gitlab/prepare-system.sh
194     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
195     - ./boot
196     - ./configure $CONFIGURE_ARGS
197     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist
198     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx test --summary-junit=./junit.xml
199     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
200   cache:
201     key: hadrian
202     paths:
203       - cabal-cache
204   artifacts:
205     reports:
206       junit: junit.xml
207     expire_in: 2 week
208     paths:
209       - ghc.tar.xz
210       - junit.xml
211
212 validate-x86_64-linux-deb9-hadrian:
213   extends: .validate-hadrian
214   stage: build
215   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
216   before_script:
217     # workaround for docker permissions
218     - sudo chown ghc:ghc -R .
219     - python3 .gitlab/fix-submodules.py
220     - git submodule sync --recursive
221     - git submodule update --init --recursive
222     - git checkout .gitmodules
223     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
224   tags:
225     - x86_64-linux
226
227 hadrian-ghc-in-ghci:
228   <<: *only-default
229   stage: build
230   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
231   before_script:
232     # workaround for docker permissions
233     - sudo chown ghc:ghc -R .
234     - python3 .gitlab/fix-submodules.py
235     - git submodule sync --recursive
236     - git submodule update --init --recursive
237     - git checkout .gitmodules
238   tags:
239     - x86_64-linux
240   script:
241     - cabal update
242     - cd hadrian; cabal new-build --project-file=ci.project; cd ..
243     - git clean -xdf && git submodule foreach git clean -xdf
244     - .gitlab/prepare-system.sh
245     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
246     - ./boot
247     - ./configure $CONFIGURE_ARGS
248     # Load ghc-in-ghci then immediately exit and check the modules loaded
249     - echo ":q" | hadrian/ghci.sh | tail -n2 | grep "Ok,"
250   cache:
251     key: hadrian-ghci
252     paths:
253       - cabal-cache
254
255 ############################################################
256 # Validation via Pipelines (make)
257 ############################################################
258
259 .validate:
260   <<: *only-default
261   variables:
262     TEST_TYPE: test
263   before_script:
264     - git clean -xdf && git submodule foreach git clean -xdf
265   script:
266     - ./boot
267     - ./configure $CONFIGURE_ARGS
268     - |
269       THREADS=`mk/detect-cpu-count.sh`
270       make V=0 -j$THREADS WERROR=-Werror
271     - |
272       make bindisttest
273     - |
274       make binary-dist TAR_COMP_OPTS="-1"
275     - |
276       # Prepare to push git notes.
277       METRICS_FILE=$(mktemp)
278       git config user.email "ben+ghc-ci@smart-cactus.org"
279       git config user.name "GHC GitLab CI"
280     - |
281       THREADS=`mk/detect-cpu-count.sh`
282       make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE
283     - |
284       # Push git notes.
285       METRICS_FILE=$METRICS_FILE .gitlab/push-test-metrics.sh
286   dependencies: []
287   artifacts:
288     reports:
289       junit: junit.xml
290     expire_in: 2 week
291     paths:
292       - ghc-*.tar.xz
293       - junit.xml
294
295 #################################
296 # x86_64-darwin
297 #################################
298
299 validate-x86_64-darwin:
300   extends: .validate
301   stage: full-build
302   tags:
303     - x86_64-darwin
304   variables:
305     GHC_VERSION: 8.6.3
306     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz"
307     MACOSX_DEPLOYMENT_TARGET: "10.7"
308     # Only Sierra and onwards supports clock_gettime. See #12858
309     ac_cv_func_clock_gettime: "no"
310     LANG: "en_US.UTF-8"
311     CONFIGURE_ARGS: --with-intree-gmp
312     TEST_ENV: "x86_64-darwin"
313   before_script:
314     - git clean -xdf && git submodule foreach git clean -xdf
315     - python3 .gitlab/fix-submodules.py
316     - git submodule sync --recursive
317     - git submodule update --init --recursive
318     - git checkout .gitmodules
319     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
320
321     - bash .gitlab/darwin-init.sh
322     - PATH="`pwd`/toolchain/bin:$PATH"
323   after_script:
324     - cp -Rf $HOME/.cabal cabal-cache
325   artifacts:
326     when: always
327     expire_in: 2 week
328   cache:
329     key: darwin
330     paths:
331       - cabal-cache
332       - toolchain
333
334 # Disabled because of OS X CI capacity
335 .validate-x86_64-darwin-hadrian:
336   <<: *only-default
337   stage: full-build
338   tags:
339     - x86_64-darwin
340   variables:
341     GHC_VERSION: 8.6.3
342     MACOSX_DEPLOYMENT_TARGET: "10.7"
343     ac_cv_func_clock_gettime: "no"
344     LANG: "en_US.UTF-8"
345     CONFIGURE_ARGS: --with-intree-gmp
346     TEST_ENV: "x86_64-darwin"
347   before_script:
348     - git clean -xdf && git submodule foreach git clean -xdf
349     - python3 .gitlab/fix-submodules.py
350     - git submodule sync --recursive
351     - git submodule update --init --recursive
352     - git checkout .gitmodules
353     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
354
355     - bash .gitlab/darwin-init.sh
356     - PATH="`pwd`/toolchain/bin:$PATH"
357   script:
358     - cabal update
359     - ./boot
360     - ./configure $CONFIGURE_ARGS
361     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist
362     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx test --summary-junit=./junit.xml
363     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
364   after_script:
365     - cp -Rf $HOME/.cabal cabal-cache
366   artifacts:
367     when: always
368     expire_in: 2 week
369     reports:
370       junit: junit.xml
371     paths:
372       - ghc.tar.xz
373       - junit.xml
374
375 .validate-linux:
376   extends: .validate
377   tags:
378     - x86_64-linux
379   before_script:
380     - git clean -xdf && git submodule foreach git clean -xdf
381     - python3 .gitlab/fix-submodules.py
382     - git submodule sync --recursive
383     - git submodule update --init --recursive
384     - git checkout .gitmodules
385     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
386       # Build hyperlinked sources for documentation when building releases
387     - |
388       if [[ -n "$CI_COMMIT_TAG" ]]; then
389         echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk
390       fi
391
392     - .gitlab/prepare-system.sh
393     # workaround for docker permissions
394     - sudo chown ghc:ghc -R .
395   after_script:
396     - cp -Rf $HOME/.cabal cabal-cache
397   cache:
398     key: linux
399     paths:
400       - cabal-cache
401       - toolchain
402
403 #################################
404 # aarch64-linux-deb9
405 #################################
406
407 .build-aarch64-linux-deb9:
408   extends: .validate-linux
409   stage: full-build
410   image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb9:$DOCKER_REV"
411   allow_failure: true
412   variables:
413     TEST_ENV: "aarch64-linux-deb9"
414     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz"
415     # Inexplicably makeindex fails
416     BUILD_SPHINX_PDF: "NO"
417   cache:
418     key: linux-aarch64-deb9
419   tags:
420     - aarch64-linux
421
422 validate-aarch64-linux-deb9:
423   extends: .build-aarch64-linux-deb9
424   artifacts:
425     when: always
426     expire_in: 2 week
427
428 nightly-aarch64-linux-deb9:
429   extends: .build-aarch64-linux-deb9
430   artifacts:
431     expire_in: 2 year
432   variables:
433     TEST_TYPE: slowtest
434   only:
435     variables:
436       - $NIGHTLY
437
438 #################################
439 # i386-linux-deb9
440 #################################
441
442 .build-i386-linux-deb9:
443   extends: .validate-linux
444   stage: full-build
445   image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV"
446   variables:
447     TEST_ENV: "i386-linux-deb9"
448     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz"
449   cache:
450     key: linux-i386-deb9
451
452 validate-i386-linux-deb9:
453   extends: .build-i386-linux-deb9
454   artifacts:
455     when: always
456     expire_in: 2 week
457
458 nightly-i386-linux-deb9:
459   extends: .build-i386-linux-deb9
460   variables:
461     TEST_TYPE: slowtest
462   artifacts:
463     when: always
464     expire_in: 2 week
465   only:
466     variables:
467       - $NIGHTLY
468
469 #################################
470 # x86_64-linux-deb9
471 #################################
472
473 .build-x86_64-linux-deb9:
474   extends: .validate-linux
475   stage: full-build
476   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
477   variables:
478     TEST_ENV: "x86_64-linux-deb9"
479     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz"
480   cache:
481     key: linux-x86_64-deb9
482
483 # Disabled to reduce CI load
484 .validate-x86_64-linux-deb9:
485   extends: .build-x86_64-linux-deb9
486   artifacts:
487     when: always
488     expire_in: 2 week
489
490 nightly-x86_64-linux-deb9:
491   extends: .build-x86_64-linux-deb9
492   artifacts:
493     expire_in: 2 year
494   variables:
495     TEST_TYPE: slowtest
496   only:
497     variables:
498       - $NIGHTLY
499
500 # N.B. Has DEBUG assertions enabled in stage2
501 validate-x86_64-linux-deb9-debug:
502   extends: .build-x86_64-linux-deb9
503   stage: build
504   variables:
505     BUILD_FLAVOUR: validate
506     # Override validate flavour default; see #16890.
507     BUILD_SPHINX_PDF: "YES"
508     TEST_TYPE: slowtest
509     TEST_ENV: "x86_64-linux-deb9-debug"
510   artifacts:
511     when: always
512     expire_in: 2 week
513
514 # Disabled to alleviate CI load
515 .validate-x86_64-linux-deb9-llvm:
516   extends: .build-x86_64-linux-deb9
517   stage: full-build
518   variables:
519     BUILD_FLAVOUR: perf-llvm
520     TEST_ENV: "x86_64-linux-deb9-llvm"
521
522 nightly-x86_64-linux-deb9-llvm:
523   extends: .build-x86_64-linux-deb9
524   stage: full-build
525   variables:
526     BUILD_FLAVOUR: perf-llvm
527     TEST_ENV: "x86_64-linux-deb9-llvm"
528   only:
529     variables:
530       - $NIGHTLY
531
532 validate-x86_64-linux-deb9-integer-simple:
533   extends: .build-x86_64-linux-deb9
534   stage: full-build
535   variables:
536     INTEGER_LIBRARY: integer-simple
537     TEST_ENV: "x86_64-linux-deb9-integer-simple"
538     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz"
539
540 nightly-x86_64-linux-deb9-integer-simple:
541   extends: .build-x86_64-linux-deb9
542   stage: full-build
543   variables:
544     INTEGER_LIBRARY: integer-simple
545     TEST_ENV: "x86_64-linux-deb9-integer-simple"
546     TEST_TYPE: slowtest
547   artifacts:
548     expire_in: 2 year
549   only:
550     variables:
551       - $NIGHTLY
552
553 validate-x86_64-linux-deb9-unreg:
554   extends: .build-x86_64-linux-deb9
555   stage: full-build
556   variables:
557     CONFIGURE_ARGS: --enable-unregisterised
558     TEST_ENV: "x86_64-linux-deb9-unreg"
559
560 release-x86_64-linux-deb9-dwarf:
561   extends: .validate-linux
562   stage: build
563   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
564   variables:
565     CONFIGURE_ARGS: "--enable-dwarf-unwind"
566     BUILD_FLAVOUR: dwarf
567     TEST_ENV: "x86_64-linux-deb9-dwarf"
568   artifacts:
569     when: always
570     expire_in: 2 week
571   cache:
572     key: linux-x86_64-deb9
573
574
575 #################################
576 # x86_64-linux-deb8
577 #################################
578
579 release-x86_64-linux-deb8:
580   extends: .validate-linux
581   stage: full-build
582   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV"
583   variables:
584     TEST_ENV: "x86_64-linux-deb8"
585     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz"
586   only:
587     - tags
588   cache:
589     key: linux-x86_64-deb8
590   artifacts:
591     when: always
592     expire_in: 2 week
593
594 #################################
595 # x86_64-linux-alpine
596 #################################
597
598 .build-x86_64-linux-alpine:
599   extends: .validate-linux
600   stage: full-build
601   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV"
602   # There are currently a few failing tests
603   allow_failure: true
604   variables:
605     BUILD_SPHINX_PDF: "NO"
606     TEST_ENV: "x86_64-linux-alpine"
607     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-alpine-linux.tar.xz"
608     # Can't use ld.gold due to #13958.
609     CONFIGURE_ARGS: "--disable-ld-override"
610   cache:
611     key: linux-x86_64-alpine
612   artifacts:
613     when: always
614     expire_in: 2 week
615
616 release-x86_64-linux-alpine:
617   extends: .build-x86_64-linux-alpine
618   only:
619     - tags
620
621 nightly-x86_64-linux-alpine:
622   extends: .build-x86_64-linux-alpine
623   only:
624     variables:
625       - $NIGHTLY
626
627 #################################
628 # x86_64-linux-centos7
629 #################################
630
631 release-x86_64-linux-centos7:
632   extends: .validate-linux
633   stage: full-build
634   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV"
635   variables:
636     # The sphinx release shipped with Centos 7 fails to build out documentation
637     BUILD_SPHINX_HTML: "NO"
638     BUILD_SPHINX_PDF: "NO"
639     TEST_ENV: "x86_64-linux-centos7"
640     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz"
641   only:
642     - tags
643   cache:
644     key: linux-x86_64-centos7
645   artifacts:
646     when: always
647     expire_in: 2 week
648
649 #################################
650 # x86_64-linux-fedora27
651 #################################
652
653 validate-x86_64-linux-fedora27:
654   extends: .validate-linux
655   stage: full-build
656   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV"
657   variables:
658     TEST_ENV: "x86_64-linux-fedora27"
659     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz"
660   cache:
661     key: linux-x86_64-fedora27
662   artifacts:
663     when: always
664     expire_in: 2 week
665
666 ############################################################
667 # Validation via Pipelines (Windows)
668 ############################################################
669
670 .build-windows:
671   <<: *only-default
672   before_script:
673     - git clean -xdf
674     - git submodule foreach git clean -xdf
675
676     # Use a local temporary directory to ensure that concurrent builds don't
677     # interfere with one another
678     - |
679       mkdir tmp
680       set TMP=%cd%\tmp
681       set TEMP=%cd%\tmp
682
683     - set PATH=C:\msys64\usr\bin;%PATH%
684     - python .gitlab/fix-submodules.py
685     - git submodule sync --recursive
686     - git submodule update --init --recursive
687     - git checkout .gitmodules
688     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
689     - bash .gitlab/win32-init.sh
690   after_script:
691     - rd /s /q tmp
692     - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache
693     - bash -c 'make clean || true'
694   dependencies: []
695   variables:
696     FORCE_SYMLINKS: 1
697     LANG: "en_US.UTF-8"
698   cache:
699     paths:
700       - cabal-cache
701       - ghc-8.6.5
702       - ghc-tarballs
703
704 .build-windows-hadrian:
705   extends: .build-windows
706   stage: full-build
707   variables:
708     GHC_VERSION: "8.6.5"
709   # due to #16574 this currently fails
710   allow_failure: true
711   script:
712     - |
713       python boot
714       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
715     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist"
716     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
717     # FIXME: Testsuite disabled due to #16156.
718     # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
719   tags:
720     - x86_64-windows
721   artifacts:
722     when: always
723     paths:
724       - ghc.tar.xz
725
726 validate-x86_64-windows-hadrian:
727   extends: .build-windows-hadrian
728   variables:
729     MSYSTEM: MINGW64
730   cache:
731     key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION"
732
733 nightly-i386-windows-hadrian:
734   extends: .build-windows-hadrian
735   variables:
736     MSYSTEM: MINGW32
737   only:
738     variables:
739       - $NIGHTLY
740   cache:
741     key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION"
742
743 .build-windows-make:
744   extends: .build-windows
745   stage: full-build
746   # due to #16084
747   allow_failure: true
748   variables:
749     BUILD_FLAVOUR: "quick"
750     GHC_VERSION: "8.6.5"
751     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz"
752   script:
753     - |
754       python boot
755       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS'
756     - bash -c "echo include mk/flavours/${BUILD_FLAVOUR}.mk > mk/build.mk"
757     - bash -c "echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk"
758     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
759     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make bindisttest"
760     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1"
761     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
762   tags:
763     - x86_64-windows
764   artifacts:
765     when: always
766     expire_in: 2 week
767     reports:
768       junit: junit.xml
769     paths:
770       - ghc-*.tar.xz
771       - junit.xml
772
773 validate-x86_64-windows:
774   extends: .build-windows-make
775   variables:
776     MSYSTEM: MINGW64
777     CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
778   cache:
779     key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION"
780
781 # Normal Windows validate builds are profiled; that won't do for releases.
782 release-x86_64-windows:
783   extends: validate-x86_64-windows
784   variables:
785     MSYSTEM: MINGW64
786     BUILD_FLAVOUR: "perf"
787     CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
788   only:
789     - tags
790
791 release-i386-windows:
792   extends: .build-windows-make
793   only:
794     - tags
795   variables:
796     MSYSTEM: MINGW32
797     BUILD_FLAVOUR: "perf"
798     CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
799     # Due to #15934
800     BUILD_PROF_LIBS: "NO"
801   cache:
802     key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION"
803
804 nightly-i386-windows:
805   extends: .build-windows-make
806   only:
807     variables:
808       - $NIGHTLY
809   variables:
810     MSYSTEM: MINGW32
811     CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
812     # Due to #15934
813     BUILD_PROF_LIBS: "NO"
814   cache:
815     key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION"
816
817 ############################################################
818 # Cleanup
819 ############################################################
820
821 # Note [Cleaning up after shell executor]
822 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
823 #
824 # As noted in [1], gitlab-runner's shell executor doesn't clean up its working
825 # directory after builds. Unfortunately, we are forced to use the shell executor
826 # on Darwin. To avoid running out of disk space we add a stage at the end of
827 # the build to remove the /.../GitLabRunner/builds directory. Since we only run a
828 # single build at a time on Darwin this should be safe.
829 #
830 # We used to have a similar cleanup job on Windows as well however it ended up
831 # being quite fragile as we have multiple Windows builders yet there is no
832 # guarantee that the cleanup job is run on the same machine as the build itself
833 # was run. Consequently we were forced to instead handle cleanup with a separate
834 # cleanup cron job on Windows.
835 #
836 # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856
837
838 # See Note [Cleanup after shell executor]
839 cleanup-darwin:
840   <<: *only-default
841   stage: cleanup
842   tags:
843     - x86_64-darwin
844   when: always
845   dependencies: []
846   before_script:
847     - echo "Time to clean up"
848   script:
849     - echo "Let's go"
850   after_script:
851     - BUILD_DIR=$CI_PROJECT_DIR
852     - echo "Cleaning $BUILD_DIR"
853     - cd $HOME
854     - rm -Rf $BUILD_DIR/*
855     - exit 0
856
857 ############################################################
858 # Packaging
859 ############################################################
860
861 doc-tarball:
862   <<: *only-default
863   stage: packaging
864   tags:
865     - x86_64-linux
866   image: ghcci/x86_64-linux-deb9:0.2
867   dependencies:
868     - validate-x86_64-linux-deb9-debug
869     - validate-x86_64-windows
870   variables:
871     LINUX_BINDIST: "ghc-x86_64-deb9-linux.tar.xz"
872     WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz"
873   # Due to Windows allow_failure
874   allow_failure: true
875   artifacts:
876     paths:
877       - haddock.html.tar.xz
878       - libraries.html.tar.xz
879       - users_guide.html.tar.xz
880       - index.html
881       - "*.pdf"
882   script:
883     - |
884       if [ ! -f "$LINUX_BINDIST" ]; then
885         echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?"
886         exit 1
887       fi
888       if [ ! -f "$WINDOWS_BINDIST" ]; then
889         echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?"
890         exit 1
891       fi
892     - rm -Rf docs
893     - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST
894     - ls -lh
895     - mv docs/*.tar.xz docs/index.html .
896
897 source-tarball:
898   stage: packaging
899   tags:
900     - x86_64-linux
901   image: ghcci/x86_64-linux-deb9:0.2
902   dependencies: []
903   only:
904     - tags
905   artifacts:
906     paths:
907       - ghc-*.tar.xz
908       - version
909   script:
910     - mk/get-win32-tarballs.sh download all
911     - ./boot
912     - ./configure
913     - make sdist
914     - mv sdistprep/*.xz  .
915     - make show VALUE=version > version
916
917
918 ############################################################
919 # Testing via head.hackage
920 ############################################################
921
922 # Triggering jobs in the ghc/head.hackage project requires that we have a job
923 # token for that repository. Furthermore the head.hackage CI job must have
924 # access to an unprivileged access token with the ability to query the ghc/ghc
925 # project such that it can find the job ID of the fedora27 job for the current
926 # pipeline.
927
928 .hackage:
929   <<: *only-default
930   stage: testing
931   image: ghcci/x86_64-linux-deb9:0.2
932   tags:
933     - x86_64-linux
934   dependencies: []
935   variables:
936     HEAD_HACKAGE_PROJECT_ID: "78"
937   script:
938     - bash .gitlab/start-head.hackage.sh
939
940 hackage:
941   extends: .hackage
942   when: manual
943
944 hackage-label:
945   extends: .hackage
946   only:
947     variables:
948       - $CI_MERGE_REQUEST_LABELS =~ /.*user-facing.*/
949
950 nightly-hackage:
951   extends: .hackage
952   only:
953     variables:
954       - $NIGHTLY
955
956 ############################################################
957 # Nofib testing
958 ############################################################
959
960 perf-nofib:
961   stage: testing
962   dependencies:
963     - release-x86_64-linux-deb9-dwarf
964   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
965   only:
966     refs:
967       - merge_requests
968       - master
969       - /ghc-[0-9]+\.[0-9]+/
970   tags:
971     - x86_64-linux
972   script:
973     - root=$(pwd)/ghc
974     - |
975       mkdir tmp
976       tar -xf ghc-*-x86_64-unknown-linux.tar.xz -C tmp
977       pushd tmp/ghc-*/
978       ./configure --prefix=$root
979       make install
980       popd
981       rm -Rf tmp
982     - export BOOT_HC=$(which ghc)
983     - cabal update; cabal install -w $BOOT_HC regex-compat
984     - export PATH=$root/bin:$PATH
985     - make -C nofib boot mode=fast -j$CPUS
986     - "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log"
987   artifacts:
988     expire_in: 12 week
989     when: always
990     paths:
991       - nofib.log
992
993 ############################################################
994 # Documentation deployment via GitLab Pages
995 ############################################################
996
997 pages:
998   stage: deploy
999   dependencies:
1000     - doc-tarball
1001   image: ghcci/x86_64-linux-deb9:0.2
1002   # Due to Windows allow_failure
1003   allow_failure: true
1004   tags:
1005     - x86_64-linux
1006   script:
1007     - mkdir -p public/doc
1008     - tar -xf haddock.html.tar.xz -C public/doc
1009     - tar -xf libraries.html.tar.xz -C public/doc
1010     - tar -xf users_guide.html.tar.xz -C public/doc
1011     - |
1012       cat >public/index.html <<EOF
1013       <!DOCTYPE HTML>
1014       <meta charset="UTF-8">
1015       <meta http-equiv="refresh" content="1; url=doc/">
1016       EOF
1017     - cp -f index.html public/doc
1018   only:
1019     - master
1020   artifacts:
1021     paths:
1022       - public