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