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