Revert "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: 2 week
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: 2 week
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     expire_in: 2 week
173   cache:
174     key: linux-aarch64-deb9
175   tags:
176     - aarch64-linux
177
178 nightly-aarch64-linux-deb9:
179   extends: validate-aarch64-linux-deb9
180   stage: full-build
181   artifacts:
182     expire_in: 2 year
183   variables:
184     TEST_TYPE: slowtest
185   only:
186     variables:
187       - $NIGHTLY
188
189 validate-i386-linux-deb9:
190   extends: .validate-linux
191   stage: full-build
192   image: ghcci/i386-linux-deb9:0.1
193   allow_failure: true
194   artifacts:
195     when: always
196     expire_in: 2 week
197   cache:
198     key: linux-i386-deb9
199
200 nightly-i386-linux-deb9:
201   extends: .validate-linux
202   stage: full-build
203   image: ghcci/i386-linux-deb9:0.1
204   allow_failure: true
205   variables:
206     TEST_TYPE: slowtest
207   artifacts:
208     when: always
209     expire_in: 2 week
210   only:
211     variables:
212       - $NIGHTLY
213   cache:
214     key: linux-i386-deb9
215
216 # N.B. Has DEBUG assertions enabled in stage2
217 validate-x86_64-linux-deb9-debug:
218   extends: .validate-linux
219   stage: build
220   image: ghcci/x86_64-linux-deb9:0.2
221   variables:
222     BUILD_FLAVOUR: devel2
223   cache:
224     key: linux-x86_64-deb9
225
226 validate-x86_64-linux-deb9:
227   extends: .validate-linux
228   stage: build
229   image: ghcci/x86_64-linux-deb9:0.2
230   artifacts:
231     when: always
232     expire_in: 2 week
233   cache:
234     key: linux-x86_64-deb9
235
236 nightly-x86_64-linux-deb9:
237   extends: validate-x86_64-linux-deb9
238   stage: build
239   artifacts:
240     expire_in: 2 year
241   variables:
242     TEST_TYPE: slowtest
243   only:
244     variables:
245       - $NIGHTLY
246
247 validate-x86_64-linux-deb9-llvm:
248   extends: .validate-linux
249   stage: full-build
250   image: ghcci/x86_64-linux-deb9:0.2
251   variables:
252     BUILD_FLAVOUR: perf-llvm
253   cache:
254     key: linux-x86_64-deb9
255
256 validate-x86_64-linux-deb8:
257   extends: .validate-linux
258   stage: full-build
259   image: ghcci/x86_64-linux-deb8:0.1
260   cache:
261     key: linux-x86_64-deb8
262   artifacts:
263     when: always
264     expire_in: 2 week
265
266 validate-x86_64-linux-fedora27:
267   extends: .validate-linux
268   stage: full-build
269   image: ghcci/x86_64-linux-fedora27:0.1
270   cache:
271     key: linux-x86_64-fedora27
272   artifacts:
273     when: always
274     expire_in: 2 week
275
276 validate-x86_64-linux-deb9-integer-simple:
277   extends: .validate-linux
278   stage: full-build
279   variables:
280     INTEGER_LIBRARY: integer-simple
281   image: ghcci/x86_64-linux-deb9:0.2
282   cache:
283     key: linux-x86_64-deb9
284
285 nightly-x86_64-linux-deb9-integer-simple:
286   extends: validate-x86_64-linux-deb9-integer-simple
287   stage: full-build
288   artifacts:
289     expire_in: 2 year
290   variables:
291     TEST_TYPE: slowtest
292   only:
293     variables:
294       - $NIGHTLY
295
296 validate-x86_64-linux-deb9-unreg:
297   extends: .validate-linux
298   stage: full-build
299   variables:
300     CONFIGURE_ARGS: --enable-unregisterised
301   image: ghcci/x86_64-linux-deb9:0.2
302   cache:
303     key: linux-x86_64-deb9
304
305 ############################################################
306 # Validation via Pipelines (Windows)
307 ############################################################
308
309 .validate-windows:
310   before_script:
311     - git clean -xdf
312     - git submodule foreach git clean -xdf
313
314     # Use a local temporary directory to ensure that concurrent builds don't
315     # interfere with one another
316     - |
317       mkdir tmp
318       set TMP=%cd%\tmp
319       set TEMP=%cd%\tmp
320
321     - set PATH=C:\msys64\usr\bin;%PATH%
322     - python .gitlab/fix-submodules.py
323     - git submodule sync --recursive
324     - git submodule update --init --recursive
325     - git checkout .gitmodules
326     - bash .gitlab/win32-init.sh
327   after_script:
328     - rd /s /q tmp
329     - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache
330     - bash -c 'make clean || true'
331   dependencies: []
332   cache:
333     paths:
334       - cabal-cache
335       - ghc-8.6.2
336       - ghc-tarballs
337
338 validate-x86_64-windows-hadrian:
339   extends: .validate-windows
340   stage: full-build
341   variables:
342     GHC_VERSION: "8.6.2"
343     LANG: "en_US.UTF-8"
344   script:
345     - |
346       set MSYSTEM=MINGW64
347       python boot
348       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
349       mkdir -p _build
350       cp -R inplace/mingw _build/mingw
351     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick"
352     # FIXME: Bindist disabled due to #16073
353     #- bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh binary-dist"
354     # FIXME: Testsuite disabled due to #16156.
355     #- bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
356   cache:
357     key: x86_64-windows
358   tags:
359     - x86_64-windows
360
361 validate-x86_64-windows:
362   extends: .validate-windows
363   stage: full-build
364   # due to #16084
365   allow_failure: true
366   variables:
367     GHC_VERSION: "8.6.2"
368     LANG: "en_US.UTF-8"
369   script:
370     - |
371       set MSYSTEM=MINGW64
372       python boot
373       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
374     - bash -c "echo include mk/flavours/quick.mk > mk/build.mk"
375     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
376     - |
377       bash -c "make binary-dist TAR_COMP_OPTS=-1"
378       mv ghc-*.tar.xz ghc.tar.xz
379     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
380   cache:
381     key: x86_64-windows
382   tags:
383     - x86_64-windows
384   artifacts:
385     when: always
386     reports:
387       junit: junit.xml
388     paths:
389       - ghc.tar.xz
390       - junit.xml
391
392 # Note [Cleaning up after shell executor]
393 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
394 #
395 # As noted in [1], gitlab-runner's shell executor doesn't clean up its working
396 # directory after builds. Unfortunately, we are forced to use the shell executor
397 # on Windows. To avoid running out of disk space we add a stage at the end of
398 # the build to remove the \GitLabRunner\builds directory. Since we only run a
399 # single build at a time on Windows this should be safe.
400 #
401 # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856
402
403 # See Note [Cleanup after shell executor]
404 cleanup-windows:
405   stage: cleanup
406   tags:
407     - x86_64-windows
408   when: always
409   dependencies: []
410   before_script:
411     - echo "Time to clean up"
412   script:
413     - echo "Let's go"
414   after_script:
415     - set "BUILD_DIR=%CI_PROJECT_DIR%"
416     - set "BUILD_DIR=%BUILD_DIR:/=\%"
417     - echo "Cleaning %BUILD_DIR%"
418     - cd \GitLabRunner
419     # This is way more complicated than it should be:
420     # See https://stackoverflow.com/questions/1965787
421     - del %BUILD_DIR%\* /F /Q
422     - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p"
423     - exit /b 0
424
425 # See Note [Cleanup after shell executor]
426 cleanup-darwin:
427   stage: cleanup
428   tags:
429     - x86_64-darwin
430   when: always
431   before_script:
432     - echo "Time to clean up"
433   script:
434     - echo "Let's go"
435   after_script:
436     - BUILD_DIR=$CI_PROJECT_DIR
437     - echo "Cleaning $BUILD_DIR"
438     - cd $HOME
439     - rm -Rf $BUILD_DIR/*
440     - exit 0
441