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