circleci: Simplify Hadrian build
[ghc.git] / .circleci / config.yml
1 version: 2
2
3 aliases:
4   - &defaults
5     working_directory: ~/ghc
6
7   # Make sure we have proper openssh before checkout: CircleCI git
8   # does not check the repository out properly without it and also
9   # takes 20 times longer than it should be.
10   - &precheckout
11     run:
12       name: Install OpenSSH client
13       command: |
14         apt-get update -qq
15         apt-get install -qy openssh-client
16   - &prepare
17     run:
18       name: prepare-system
19       command: .circleci/prepare-system.sh
20   - &submodules
21     run:
22       name: submodules
23       command: .circleci/fetch-submodules.sh
24   - &buildenv
25     THREADS: 9
26     SKIP_PERF_TESTS: YES
27     VERBOSE: 2
28   - &boot
29     run:
30       name: Boot
31       command: |
32         ./boot
33
34         cat <<EOF >> mk/build.mk
35         BuildFlavour=$BUILD_FLAVOUR
36         ifneq "\$(BuildFlavour)" ""
37         include mk/flavours/\$(BuildFlavour).mk
38         endif
39         EOF
40   - &configure_unix
41     run:
42       name: Configure
43       command: ./configure
44   - &configure_bsd
45     run:
46       name: Configure
47       command: ./configure --target=x86_64-unknown-freebsd10
48   - &configure_unreg
49     run:
50       name: Configure
51       command: ./configure --enable-unregisterised
52   - &make
53     run:
54       name: Build
55       command: "make -j$THREADS"
56   - &build_hadrian
57     run:
58       name: Build GHC using Hadrian
59       command: |
60         cabal update
61         hadrian/build.sh -j$THREADS
62   - &test
63     run:
64       name: Test
65       command: make test SKIP_PERF_TESTS=YES
66   - &slowtest
67     run:
68       name: Full Test
69       command: make slowtest SKIP_PERF_TESTS=YES
70   - &bindist
71     run:
72       name: Create bindist
73       command: make binary-dist
74       # Building bindist takes ~15 minutes without output, account for
75       # that.
76       no_output_timeout: "30m"
77   - &collectartifacts
78     run:
79       name: Collect artifacts
80       # We need this because CircleCI expects a path without
81       # wildcards but bindist archive name is not static
82       command: |
83         mkdir -p /tmp/artifacts
84         pwd
85         find .
86         cp ghc*.tar.xz /tmp/artifacts
87   - &storeartifacts
88     store-artifacts:
89       path: /tmp/artifacts
90
91 jobs:
92   "validate-x86_64-linux":
93     resource_class: xlarge
94     docker:
95       - image: haskell:8.2
96     environment:
97       <<: *buildenv
98     steps:
99       - *precheckout
100       - checkout
101       - *prepare
102       - *submodules
103       - *boot
104       - *configure_unix
105       - *make
106       - *test
107       - *bindist
108       - *collectartifacts
109       - *storeartifacts
110
111   "validate-x86_64-freebsd":
112     resource_class: xlarge
113     docker:
114       - image: tweag/toolchain-x86_64-freebsd
115     environment:
116       TARGET: FreeBSD
117       <<: *buildenv
118     steps:
119       - *precheckout
120       - checkout
121       - *prepare
122       - *submodules
123       - *boot
124       - *configure_bsd
125       - *make
126       - *test
127       - *bindist
128       - *collectartifacts
129       - *storeartifacts
130
131   "validate-x86_64-darwin":
132     macos:
133       xcode: "9.0"
134     environment:
135       MACOSX_DEPLOYMENT_TARGET: "10.7"
136       # Only Sierra and onwards supports clock_gettime. See #12858
137       ac_cv_func_clock_gettime: "no"
138     environment:
139       <<: *buildenv
140     steps:
141       - checkout
142       - *prepare
143       - *submodules
144       - *boot
145       - *configure_unix
146       - *make
147       - *test
148       - *bindist
149       - *collectartifacts
150       - *storeartifacts
151
152   "validate-hadrian-x86_64-linux":
153     resource_class: xlarge
154     docker:
155       - image: haskell:8.2
156     environment:
157       <<: *buildenv
158     steps:
159       - *precheckout
160       - checkout
161       - *prepare
162       - *submodules
163       - *boot
164       - *configure_unix
165       - *build_hadrian
166
167   "validate-x86_64-linux-unreg":
168     resource_class: xlarge
169     docker:
170       - image: haskell:8.2
171     environment:
172       <<: *buildenv
173     steps:
174       - *precheckout
175       - checkout
176       - *prepare
177       - *submodules
178       - *boot
179       - *configure_unreg
180       - *make
181       - *test
182
183   "validate-x86_64-linux-llvm":
184     resource_class: xlarge
185     docker:
186       - image: haskell:8.2
187     environment:
188       <<: *buildenv
189       BUILD_FLAVOUR: perf-llvm
190     steps:
191       - run:
192           name: Install LLVM
193           command: |
194             apt-get update
195             apt-get install -y curl xz-utils
196             curl http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-x86_64-linux-gnu-debian8.tar.xz | tar -xJC ..
197             # See https://discuss.circleci.com/t/how-to-add-a-path-to-path-in-circle-2-0/11554/3
198             echo "export PATH=`pwd`/../clang+llvm-5.0.0-x86_64-linux-gnu-debian8/bin:\$PATH" >> $BASH_ENV
199       - run:
200           name: Verify that llc works
201           command: llc
202       - *precheckout
203       - checkout
204       - *prepare
205       - *submodules
206       - *boot
207       - *configure_unix
208       - *make
209       - *slowtest
210
211   # Nightly build with -DDEBUG using devel2 flavour
212   "validate-x86_64-linux-debug":
213     resource_class: xlarge
214     docker:
215       - image: haskell:8.2
216     environment:
217       BUILD_FLAVOUR: devel2
218       <<: *buildenv
219     steps:
220       - *precheckout
221       - checkout
222       - *prepare
223       - *submodules
224       - *boot
225       - *configure_unreg
226       - *make
227       - *test
228
229 workflows:
230   version: 2
231   validate:
232     jobs:
233     - validate-x86_64-linux
234     # FreeBSD disabled: https://github.com/haskell/unix/issues/102
235     # - validate-x86_64-freebsd
236     - validate-x86_64-darwin
237     - validate-x86_64-linux-llvm
238     - validate-hadrian-x86_64-linux
239
240   nightly:
241     triggers:
242       - schedule:
243           cron: "0 0 * * *"
244           filters:
245             branches:
246               only:
247                 - master
248     jobs:
249     - validate-x86_64-linux-unreg
250     - validate-x86_64-linux-llvm
251     - validate-x86_64-linux-debug
252
253 notify:
254   webhooks:
255     - url: https://phabricator.haskell.org/harbormaster/hook/circleci/