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