gitlab-ci: Explicitly set bindist tarball name
[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: 6d19c3adc1f5c28c82aed8c5b1ac40931ac60f3f
6
7 before_script:
8   - python3 .gitlab/fix-submodules.py
9   - git submodule sync --recursive
10   - git submodule update --init --recursive
11   - git checkout .gitmodules
12   - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
13
14 stages:
15   - lint
16   - build
17   - full-build
18   - cleanup # See Note [Cleanup on Windows]
19
20 ############################################################
21 # Runner Tags
22 ############################################################
23 #
24 # * x86_64-linux: Any Docker-capable x86_64 Linux machine
25 # * aarch64-linux: Any Docker-capable AArch64 Linux machine
26 # * x86_64-windows: A x86_64 Windows machine
27 # * lint: Any Docker-capable x86_64 Linux machine; distinct from
28 #         x86_64-linux to ensure low-latency availability.
29 #
30
31
32 ############################################################
33 # Linting
34 ############################################################
35
36 ghc-linters:
37   stage: lint
38   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
39   script:
40     - |
41       if [ -n "$CI_MERGE_REQUEST_ID" ]; then
42         base="$(git merge-base $CI_MERGE_REQUEST_BRANCH_NAME HEAD)"
43         validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA)
44         submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA)
45         validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA)
46         .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA
47         .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA
48       fi
49   dependencies: []
50   tags:
51     - lint
52
53 ############################################################
54 # Validation via Pipelines (hadrian)
55 ############################################################
56
57 .validate-hadrian:
58   allow_failure: true
59   script:
60     - cabal update
61     - git clean -xdf && git submodule foreach git clean -xdf
62     - bash .circleci/prepare-system.sh
63     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
64     - ./boot
65     - ./configure $CONFIGURE_ARGS
66     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist
67     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
68   cache:
69     key: hadrian
70     paths:
71       - cabal-cache
72   artifacts:
73     when: always
74     paths:
75       - ghc.tar.xz
76
77 validate-x86_64-linux-deb8-hadrian:
78   extends: .validate-hadrian
79   stage: build
80   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV"
81   before_script:
82     # workaround for docker permissions
83     - sudo chown ghc:ghc -R .
84     - python3 .gitlab/fix-submodules.py
85     - git submodule sync --recursive
86     - git submodule update --init --recursive
87     - git checkout .gitmodules
88     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
89   tags:
90     - x86_64-linux
91
92 hadrian-ghc-in-ghci:
93   stage: build
94   image: ghcci/x86_64-linux-deb8:0.1
95   before_script:
96     # workaround for docker permissions
97     - sudo chown ghc:ghc -R .
98     - python3 .gitlab/fix-submodules.py
99     - git submodule sync --recursive
100     - git submodule update --init --recursive
101     - git checkout .gitmodules
102   tags:
103     - x86_64-linux
104   script:
105     - cabal update
106     - git clean -xdf && git submodule foreach git clean -xdf
107     - bash .circleci/prepare-system.sh
108     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
109     - ./boot
110     - ./configure $CONFIGURE_ARGS
111     # Load ghc-in-ghci then immediately exit
112     - echo ":q" | hadrian/ghci.sh
113   cache:
114     key: hadrian-ghci
115     paths:
116       - cabal-cache
117
118 ############################################################
119 # Validation via Pipelines (make)
120 ############################################################
121
122 .validate:
123   variables:
124     TEST_TYPE: test
125   before_script:
126     - git clean -xdf && git submodule foreach git clean -xdf
127   script:
128     - ./boot
129     - ./configure $CONFIGURE_ARGS
130     - |
131       THREADS=`mk/detect-cpu-count.sh`
132       make V=0 -j$THREADS WERROR=-Werror
133     - |
134       make binary-dist TAR_COMP_OPTS="-1"
135     - |
136       # Prepare to push git notes.
137       METRICS_FILE=$(mktemp)
138       git config user.email "ben+ghc-ci@smart-cactus.org"
139       git config user.name "GHC GitLab CI"
140     - |
141       THREADS=`mk/detect-cpu-count.sh`
142       make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE
143     - |
144       # Push git notes.
145       METRICS_FILE=$METRICS_FILE .gitlab/push-test-metrics.sh
146   dependencies: []
147   artifacts:
148     reports:
149       junit: junit.xml
150     expire_in: 2 week
151     paths:
152       - ghc-*.tar.xz
153       - junit.xml
154
155 #################################
156 # x86_64-darwin
157 #################################
158
159 validate-x86_64-darwin:
160   extends: .validate
161   stage: full-build
162   tags:
163     - x86_64-darwin
164   variables:
165     GHC_VERSION: 8.6.3
166     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz"
167     MACOSX_DEPLOYMENT_TARGET: "10.7"
168     # Only Sierra and onwards supports clock_gettime. See #12858
169     ac_cv_func_clock_gettime: "no"
170     LANG: "en_US.UTF-8"
171     CONFIGURE_ARGS: --with-intree-gmp
172     TEST_ENV: "x86_64-darwin"
173   before_script:
174     - git clean -xdf && git submodule foreach git clean -xdf
175     - python3 .gitlab/fix-submodules.py
176     - git submodule sync --recursive
177     - git submodule update --init --recursive
178     - git checkout .gitmodules
179     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
180
181     - bash .gitlab/darwin-init.sh
182     - PATH="`pwd`/toolchain/bin:$PATH"
183   after_script:
184     - cp -Rf $HOME/.cabal cabal-cache
185   artifacts:
186     when: always
187     expire_in: 2 week
188   cache:
189     key: darwin
190     paths:
191       - cabal-cache
192       - toolchain
193
194 .validate-linux:
195   extends: .validate
196   tags:
197     - x86_64-linux
198   before_script:
199     - git clean -xdf && git submodule foreach git clean -xdf
200     - python3 .gitlab/fix-submodules.py
201     - git submodule sync --recursive
202     - git submodule update --init --recursive
203     - git checkout .gitmodules
204     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
205
206     - bash .circleci/prepare-system.sh
207     # workaround for docker permissions
208     - sudo chown ghc:ghc -R .
209   after_script:
210     - cp -Rf $HOME/.cabal cabal-cache
211   cache:
212     key: linux
213     paths:
214       - cabal-cache
215       - toolchain
216
217 #################################
218 # aarch64-linux-deb9
219 #################################
220
221 .build-aarch64-linux-deb9:
222   extends: .validate-linux
223   stage: full-build
224   image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb9:$DOCKER_REV"
225   allow_failure: true
226   variables:
227     TEST_ENV: "aarch64-linux-deb9"
228     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz"
229   cache:
230     key: linux-aarch64-deb9
231   tags:
232     - aarch64-linux
233
234 validate-aarch64-linux-deb9:
235   extends: .build-aarch64-linux-deb9
236   artifacts:
237     when: always
238     expire_in: 2 week
239
240 nightly-aarch64-linux-deb9:
241   extends: .build-aarch64-linux-deb9
242   artifacts:
243     expire_in: 2 year
244   variables:
245     TEST_TYPE: slowtest
246   only:
247     variables:
248       - $NIGHTLY
249
250 #################################
251 # i386-linux-deb9
252 #################################
253
254 .build-i386-linux-deb9:
255   extends: .validate-linux
256   stage: full-build
257   image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV"
258   variables:
259     TEST_ENV: "i386-linux-deb9"
260     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz"
261   cache:
262     key: linux-i386-deb9
263
264 validate-i386-linux-deb9:
265   extends: .build-i386-linux-deb9
266   artifacts:
267     when: always
268     expire_in: 2 week
269
270 nightly-i386-linux-deb9:
271   extends: .build-i386-linux-deb9
272   variables:
273     TEST_TYPE: slowtest
274   artifacts:
275     when: always
276     expire_in: 2 week
277   only:
278     variables:
279       - $NIGHTLY
280
281 #################################
282 # x86_64-linux-deb9
283 #################################
284
285 .build-x86_64-linux-deb9:
286   extends: .validate-linux
287   stage: build
288   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
289   variables:
290     TEST_ENV: "x86_64-linux-deb9"
291     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz"
292   cache:
293     key: linux-x86_64-deb9
294
295 validate-x86_64-linux-deb9:
296   extends: .build-x86_64-linux-deb9
297   artifacts:
298     when: always
299     expire_in: 2 week
300
301 nightly-x86_64-linux-deb9:
302   extends: .build-x86_64-linux-deb9
303   artifacts:
304     expire_in: 2 year
305   variables:
306     TEST_TYPE: slowtest
307   only:
308     variables:
309       - $NIGHTLY
310
311 # N.B. Has DEBUG assertions enabled in stage2
312 validate-x86_64-linux-deb9-debug:
313   extends: .build-x86_64-linux-deb9
314   variables:
315     BUILD_FLAVOUR: validate
316     TEST_ENV: "x86_64-linux-deb9-debug"
317
318 validate-x86_64-linux-deb9-llvm:
319   extends: .build-x86_64-linux-deb9
320   stage: full-build
321   variables:
322     BUILD_FLAVOUR: perf-llvm
323     TEST_ENV: "x86_64-linux-deb9-llvm"
324
325 validate-x86_64-linux-deb9-integer-simple:
326   extends: .build-x86_64-linux-deb9
327   stage: full-build
328   variables:
329     INTEGER_LIBRARY: integer-simple
330     TEST_ENV: "x86_64-linux-deb9-integer-simple"
331     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz"
332
333 nightly-x86_64-linux-deb9-integer-simple:
334   extends: .build-x86_64-linux-deb9
335   stage: full-build
336   variables:
337     INTEGER_LIBRARY: integer-simple
338     TEST_ENV: "x86_64-linux-deb9-integer-simple"
339     TEST_TYPE: slowtest
340   artifacts:
341     expire_in: 2 year
342   only:
343     variables:
344       - $NIGHTLY
345
346 validate-x86_64-linux-deb9-unreg:
347   extends: .build-x86_64-linux-deb9
348   stage: full-build
349   variables:
350     CONFIGURE_ARGS: --enable-unregisterised
351     TEST_ENV: "x86_64-linux-deb9-unreg"
352
353
354 #################################
355 # x86_64-linux-deb8
356 #################################
357
358 release-x86_64-linux-deb8:
359   extends: .validate-linux
360   stage: full-build
361   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV"
362   variables:
363     TEST_ENV: "x86_64-linux-deb8"
364     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz"
365   only:
366     - tags
367   cache:
368     key: linux-x86_64-deb8
369   artifacts:
370     when: always
371     expire_in: 2 week
372
373
374 #################################
375 # x86_64-linux-fedora27
376 #################################
377
378 release-x86_64-linux-fedora27:
379   extends: .validate-linux
380   stage: full-build
381   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV"
382   variables:
383     TEST_ENV: "x86_64-linux-fedora27"
384     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz"
385   only:
386     - tags
387   cache:
388     key: linux-x86_64-fedora27
389   artifacts:
390     when: always
391     expire_in: 2 week
392
393 ############################################################
394 # Validation via Pipelines (Windows)
395 ############################################################
396
397 .validate-windows:
398   before_script:
399     - git clean -xdf
400     - git submodule foreach git clean -xdf
401
402     # Use a local temporary directory to ensure that concurrent builds don't
403     # interfere with one another
404     - |
405       mkdir tmp
406       set TMP=%cd%\tmp
407       set TEMP=%cd%\tmp
408
409     - set PATH=C:\msys64\usr\bin;%PATH%
410     - python .gitlab/fix-submodules.py
411     - git submodule sync --recursive
412     - git submodule update --init --recursive
413     - git checkout .gitmodules
414     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
415     - bash .gitlab/win32-init.sh
416   after_script:
417     - rd /s /q tmp
418     - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache
419     - bash -c 'make clean || true'
420   dependencies: []
421   variables:
422     FORCE_SYMLINKS: 1
423   cache:
424     paths:
425       - cabal-cache
426       - ghc-8.6.2
427       - ghc-tarballs
428
429 validate-x86_64-windows-hadrian:
430   extends: .validate-windows
431   stage: full-build
432   variables:
433     GHC_VERSION: "8.6.2"
434     LANG: "en_US.UTF-8"
435   script:
436     - |
437       set MSYSTEM=MINGW64
438       python boot
439       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
440     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist"
441     - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
442     # FIXME: Testsuite disabled due to #16156.
443     # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
444   cache:
445     key: x86_64-windows
446   tags:
447     - x86_64-windows
448   artifacts:
449     when: always
450     paths:
451       - ghc.tar.xz
452
453 validate-x86_64-windows:
454   extends: .validate-windows
455   stage: full-build
456   # due to #16084
457   allow_failure: true
458   variables:
459     GHC_VERSION: "8.6.2"
460     LANG: "en_US.UTF-8"
461     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz"
462   script:
463     - |
464       set MSYSTEM=MINGW64
465       python boot
466       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
467     - bash -c "echo include mk/flavours/quick.mk > mk/build.mk"
468     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
469     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1"
470     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
471   cache:
472     key: x86_64-windows
473   tags:
474     - x86_64-windows
475   artifacts:
476     when: always
477     reports:
478       junit: junit.xml
479     paths:
480       - ghc-*.tar.xz
481       - junit.xml
482
483 ############################################################
484 # Cleanup
485 ############################################################
486
487 # Note [Cleaning up after shell executor]
488 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
489 #
490 # As noted in [1], gitlab-runner's shell executor doesn't clean up its working
491 # directory after builds. Unfortunately, we are forced to use the shell executor
492 # on Windows. To avoid running out of disk space we add a stage at the end of
493 # the build to remove the \GitLabRunner\builds directory. Since we only run a
494 # single build at a time on Windows this should be safe.
495 #
496 # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856
497
498 # See Note [Cleanup after shell executor]
499 cleanup-windows:
500   stage: cleanup
501   tags:
502     - x86_64-windows
503   when: always
504   dependencies: []
505   before_script:
506     - echo "Time to clean up"
507   script:
508     - echo "Let's go"
509   after_script:
510     - set "BUILD_DIR=%CI_PROJECT_DIR%"
511     - set "BUILD_DIR=%BUILD_DIR:/=\%"
512     - echo "Cleaning %BUILD_DIR%"
513     - cd \GitLabRunner
514     # This is way more complicated than it should be:
515     # See https://stackoverflow.com/questions/1965787
516     - del %BUILD_DIR%\* /F /Q
517     - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p"
518     - exit /b 0
519
520 # See Note [Cleanup after shell executor]
521 cleanup-darwin:
522   stage: cleanup
523   tags:
524     - x86_64-darwin
525   when: always
526   dependencies: []
527   before_script:
528     - echo "Time to clean up"
529   script:
530     - echo "Let's go"
531   after_script:
532     - BUILD_DIR=$CI_PROJECT_DIR
533     - echo "Cleaning $BUILD_DIR"
534     - cd $HOME
535     - rm -Rf $BUILD_DIR/*
536     - exit 0
537