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