8eb13627d76367ba0800f88b03b25323e14263ac
[ghc.git] / .circleci / config.yml
1 # Questions about this file?
2 # See https://ghc.haskell.org/trac/ghc/wiki/ContinuousIntegration/Usage.
3
4 version: 2
5
6 aliases:
7   - &defaults
8     working_directory: ~/ghc
9   - &prepare
10     run:
11       name: prepare-system
12       command: .circleci/prepare-system.sh
13   - &submodules
14     run:
15       name: submodules
16       command: .circleci/fetch-submodules.sh
17   - &buildenv
18     # ideally we would simply set THREADS here instead of re-detecting it every
19     # time we need it below. Unfortunately, there is no way to set an environment
20     # variable with the result of a shell script.
21     SKIP_PERF_TESTS: NO
22     VERBOSE: 2
23   - &boot
24     run:
25       name: Boot
26       command: |
27         ./boot
28
29         cat <<EOF >> mk/build.mk
30         BuildFlavour=$BUILD_FLAVOUR
31         ifneq "\$(BuildFlavour)" ""
32         include mk/flavours/\$(BuildFlavour).mk
33         endif
34         EOF
35   - &set_git_identity
36       run:
37         name: Set Git Identity
38         command: |
39           git config user.email "ghc-circleci@haskell.org"
40           git config user.name "GHC CircleCI"
41   - &configure_unix
42     run:
43       name: Configure
44       command: ./configure 
45   - &configure_unix_32
46     run:
47       name: Configure
48       command: |
49         setarch i386 ./configure --with-ghc=/opt/ghc-i386/8.4.2/bin/ghc
50   - &configure_bsd
51     run:
52       name: Configure
53       command: ./configure --target=x86_64-unknown-freebsd10
54   - &configure_unreg
55     run:
56       name: Configure
57       command: ./configure --enable-unregisterised
58   - &make
59     run:
60       name: Build
61       command: "make -j`mk/detect-cpu-count.sh` V=0"
62   - &build_hadrian
63     run:
64       name: Build GHC using Hadrian
65       command: |
66         cabal update
67         hadrian/build.sh -j`mk/detect-cpu-count.sh`
68   - &test
69     run:
70       name: Test
71       command: |
72         mkdir -p test-results
73         METRICS_FILE=$(mktemp)
74         echo "export METRICS_FILE=$METRICS_FILE" >> $BASH_ENV
75         make test THREADS=`mk/detect-cpu-count.sh` SKIP_PERF_TESTS=$SKIP_PERF_TESTS TEST_ENV=$TEST_ENV JUNIT_FILE=../../test-results/junit.xml METRICS_FILE=$METRICS_FILE
76   - &store_test_results
77     store_test_results:
78       path: test-results
79   - &push_perf_note
80     run:
81       name: Push Performance Git Notes
82       command: .circleci/push-test-metrics.sh
83   - &store_test_artifacts
84     store_artifacts:
85       # we might want to add the whole output of the test phase
86       # too at some point
87       path: test-results/junit.xml
88   - &slowtest
89     run:
90       name: Full Test
91       command: |
92         mkdir -p test-results
93         make slowtest SKIP_PERF_TESTS=YES THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../test-results/junit.xml
94   - &bindist
95     run:
96       name: Create bindist
97       # Reduce compression effort to 3
98       command: make binary-dist TAR_COMP_OPTS="-2" && mv ghc*.tar.xz ghc.tar.xz
99       # Building bindist takes ~15 minutes without output, account for
100       # that.
101       no_output_timeout: "30m"
102   - &store_bindist
103     store_artifacts:
104       path: ghc.tar.xz
105   - &trigger_on_tags
106     filters:
107       tags:
108         only: /^ghc-.*/
109
110 jobs:
111   "validate-x86_64-freebsd":
112     resource_class: xlarge
113     docker:
114       - image: ghcci/x86_64-freebsd
115     environment:
116       TARGET: FreeBSD
117       <<: *buildenv
118       GHC_COLLECTOR_FLAVOR: x86_64-freebsd
119       TEST_ENV: x86_64-freebsd
120     steps:
121       - checkout
122       - *set_git_identity
123       - *prepare
124       - *submodules
125       - *boot
126       - *configure_bsd
127       - *make
128       - *bindist
129       - *store_bindist
130       - *test
131       - *store_test_results
132       - *store_test_artifacts
133       - *push_perf_note
134
135   "validate-x86_64-darwin":
136     macos:
137       xcode: "9.0"
138     environment:
139       # Disable sphinx PDF output as MacTeX apparently doesn't provide xelatex
140       BUILD_SPHINX_PDF: "NO"
141       MACOSX_DEPLOYMENT_TARGET: "10.7"
142       # Only Sierra and onwards supports clock_gettime. See #12858
143       ac_cv_func_clock_gettime: "no"
144       GHC_COLLECTOR_FLAVOR: x86_64-darwin
145       <<: *buildenv
146       TEST_ENV: x86_64-darwin
147     steps:
148       - checkout
149       - *set_git_identity
150       - *prepare
151       - *submodules
152       - *boot
153       - *configure_unix
154       - *make
155       - *bindist
156       - *store_bindist
157       - *test
158       - *store_test_results
159       - *store_test_artifacts
160       - *push_perf_note
161
162   "validate-x86_64-linux-deb8":
163     resource_class: xlarge
164     docker:
165       - image: ghcci/x86_64-linux-deb8:0.1
166     environment:
167       <<: *buildenv
168       GHC_COLLECTOR_FLAVOR: x86_64-linux
169       TEST_ENV: x86_64-linux-deb8
170     steps:
171       - checkout
172       - *set_git_identity
173       - *prepare
174       - *submodules
175       - *boot
176       - *configure_unix
177       - *make
178       - *bindist
179       - *store_bindist
180       - *test
181       - *store_test_results
182       - *store_test_artifacts
183       - *push_perf_note
184
185   "validate-x86_64-linux-deb9":
186     resource_class: xlarge
187     docker:
188       - image: ghcci/x86_64-linux-deb9:0.1
189     environment:
190       <<: *buildenv
191       GHC_COLLECTOR_FLAVOR: x86_64-linux-deb9
192       TEST_ENV: x86_64-linux
193     steps:
194       - checkout
195       - *set_git_identity
196       - *prepare
197       - *submodules
198       - *boot
199       - *configure_unix
200       - *make
201       - *bindist
202       - *store_bindist
203       - *test
204       - *store_test_results
205       - *store_test_artifacts
206       - *push_perf_note
207
208   "validate-hadrian-x86_64-linux-deb8":
209     resource_class: xlarge
210     docker:
211       - image: ghcci/x86_64-linux-deb8:0.1
212     environment:
213       <<: *buildenv
214     steps:
215       - checkout
216       - *set_git_identity
217       - *prepare
218       - *submodules
219       - *boot
220       - *configure_unix
221       - *build_hadrian
222
223   "validate-x86_64-linux-deb8-unreg":
224     resource_class: xlarge
225     docker:
226       - image: ghcci/x86_64-linux-deb8:0.1
227     environment:
228       <<: *buildenv
229       TEST_ENV: x86_64-linux-deb8-unreg
230     steps:
231       - checkout
232       - *set_git_identity
233       - *prepare
234       - *submodules
235       - *boot
236       - *configure_unreg
237       - *make
238       - *test
239       - *store_test_results
240       - *push_perf_note
241       - *store_test_artifacts
242
243   "validate-x86_64-linux-deb8-llvm":
244     resource_class: xlarge
245     docker:
246       - image: ghcci/x86_64-linux-deb8:0.1
247     environment:
248       <<: *buildenv
249       BUILD_FLAVOUR: perf-llvm
250       TEST_ENV: x86_64-linux-deb8-llvm
251     steps:
252       - run:
253           name: Install LLVM
254           command: |
255             curl http://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-linux-gnu-debian8.tar.xz | tar -xJC ..
256             echo "export PATH=`pwd`/../clang+llvm-6.0.0-x86_64-linux-gnu-debian8/bin:\$PATH" >> $BASH_ENV
257       - run:
258           name: Verify that llc works
259           command: llc
260       - checkout
261       - *set_git_identity
262       - *prepare
263       - *submodules
264       - *boot
265       - *configure_unix
266       - *make
267       - *test
268       - *store_test_results
269       - *store_test_artifacts
270       - *push_perf_note
271
272   # Nightly build with -DDEBUG using devel2 flavour
273   "validate-x86_64-linux-deb8-debug":
274     resource_class: xlarge
275     docker:
276       - image: ghcci/x86_64-linux-deb8:0.1
277     environment:
278       BUILD_FLAVOUR: devel2
279       <<: *buildenv
280       TEST_ENV: x86_64-linux-deb8-debug
281       SKIP_PERF_TESTS: YES
282     steps:
283       - checkout
284       - *set_git_identity
285       - *prepare
286       - *submodules
287       - *boot
288       - *configure_unix
289       - *make
290       - *test
291       - *store_test_results
292       - *store_test_artifacts
293       - *push_perf_note
294
295   "validate-i386-linux-deb9":
296     resource_class: xlarge
297     docker:
298       - image: ghcci/i386-linux-deb9:0.1
299     environment:
300       <<: *buildenv
301       GHC_COLLECTOR_FLAVOR: i386-linux-deb9
302       TEST_ENV: i386-linux-deb9
303     steps:
304       - checkout
305       - *set_git_identity
306       - *prepare
307       - *submodules
308       - *boot
309       - *configure_unix_32
310       - *make
311       - *bindist
312       - *store_bindist
313       - *test
314       - *store_test_results
315       - *store_test_artifacts
316       - *push_perf_note
317
318   "validate-i386-linux-deb8":
319     resource_class: xlarge
320     docker:
321       - image: ghcci/i386-linux-deb8:0.1
322     environment:
323       <<: *buildenv
324       GHC_COLLECTOR_FLAVOR: i386-linux
325       TEST_ENV: i386-linux-deb8
326     steps:
327       - checkout
328       - *set_git_identity
329       - *prepare
330       - *submodules
331       - *boot
332       - *configure_unix_32
333       - *make
334       - *bindist
335       - *store_bindist
336       - *test
337       - *store_test_results
338       - *store_test_artifacts
339       - *push_perf_note
340
341   "validate-x86_64-linux-centos7":
342     resource_class: xlarge
343     docker:
344       - image: ghcci/x86_64-linux-centos7:0.1
345     environment:
346       <<: *buildenv
347       GHC_COLLECTOR_FLAVOR: x86_64-centos7
348       LANG: en_US.UTF-8
349       TEST_ENV: x86_64-centos7
350       # Sphinx is too old
351       BUILD_SPHINX_PDF: NO
352     steps:
353       - checkout
354       - *set_git_identity
355       - *prepare
356       - *submodules
357       - *boot
358       - *configure_unix
359       - *make
360       - *bindist
361       - *store_bindist
362       - *test
363       - *store_test_results
364       - *store_test_artifacts
365       - *push_perf_note
366
367   "validate-x86_64-linux-fedora27":
368     resource_class: xlarge
369     docker:
370       - image: ghcci/x86_64-linux-fedora27:0.1
371     environment:
372       <<: *buildenv
373       GHC_COLLECTOR_FLAVOR: x86_64-fedora
374       TEST_ENV: x86_64-linux-fedora27
375     steps:
376       - checkout
377       - *set_git_identity
378       - *prepare
379       - *submodules
380       - *boot
381       - *configure_unix
382       - *make
383       - *bindist
384       - *store_bindist
385       - *test
386       - *store_test_results
387       - *store_test_artifacts
388       - *push_perf_note
389
390   "slow-validate-x86_64-linux-deb8":
391     resource_class: xlarge
392     docker:
393       - image: ghcci/x86_64-linux-deb8:0.1
394     environment:
395       <<: *buildenv
396       GHC_COLLECTOR_FLAVOR: x86_64-linux-deb8
397     steps:
398       - checkout
399       - *prepare
400       - *submodules
401       - *boot
402       - *configure_unix
403       - *make
404       - *slowtest
405       - *store_test_results
406       - *store_test_artifacts
407       - *push_perf_note
408
409 workflows:
410   version: 2
411   validate:
412     jobs:
413     - validate-x86_64-linux-deb8:
414         *trigger_on_tags
415     # FreeBSD disabled: https://github.com/haskell/unix/issues/102
416     # - validate-x86_64-freebsd
417     - validate-x86_64-darwin:
418         *trigger_on_tags
419     - validate-x86_64-linux-deb8-llvm
420     - validate-i386-linux-deb8:
421         *trigger_on_tags
422     - validate-x86_64-linux-deb9:
423         *trigger_on_tags
424     - validate-i386-linux-deb9:
425         *trigger_on_tags
426     - validate-x86_64-linux-centos7:
427         *trigger_on_tags
428     - validate-hadrian-x86_64-linux-deb8
429     - validate-x86_64-linux-fedora27:
430         *trigger_on_tags
431
432   nightly:
433     triggers:
434       - schedule:
435           cron: "0 0 * * *"
436           filters:
437             branches:
438               only:
439                 - master
440     jobs:
441     - validate-x86_64-linux-deb8-unreg
442     - validate-x86_64-linux-deb8-llvm
443     - validate-x86_64-linux-deb8-debug
444     - slow-validate-x86_64-linux-deb8
445
446 notify:
447   webhooks:
448     - url: https://phabricator.haskell.org/harbormaster/hook/circleci/