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