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