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