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