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