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