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