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