-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathconfig.yml
342 lines (294 loc) · 11.4 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
version: 2
jobs:
build:
working_directory: ~/buendia
docker:
- image: projectbuendia/debian-stretch:1.1.0
steps:
- checkout # check out the code in the project directory
- restore_cache:
keys:
- buendia-v1-{{ .Branch }}-{{ .Revision }}
- buendia-v1-{{ .Branch }}
- buendia-v1-
- run:
name: Determine package version number
command: |
tools/get_package_version | tee /tmp/buendia-version
- run:
name: Restore file mtimes for later package comparison
command: git restore-mtime
- run:
name: Build all Debian packages
command: make -C packages PACKAGE_VERSION=$(cat /tmp/buendia-version)
- save_cache:
key: buendia-v1-{{ .Branch }}-{{ .Revision }}
paths:
- ~/.m2
- /tmp/buendia-fetched
- run:
name: Collect and store test results
# https://circleci.com/docs/2.0/collect-test-data/#maven-surefire-plugin-for-java-junit-results
command: |
mkdir -p /tmp/artifacts/tests/junit
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} /tmp/artifacts/tests/junit/ \;
when: always
- store_test_results:
path: /tmp/artifacts/tests
- run:
name: Collect and store built packages
command: mkdir -p /tmp/artifacts/packages && cp $(find packages -name '*.deb') /tmp/artifacts/packages
- store_artifacts:
path: /tmp/artifacts
- persist_to_workspace:
root: /tmp/artifacts
paths:
- packages
apt-archive:
working_directory: ~/buendia
docker:
- image: circleci/buildpack-deps:stretch
steps:
- run:
name: Determine build branch and package suite
# Decide which branch of projectbuendia/buendia to build from, by
# checking $TARGET_BRANCH and then falling back to $CIRCLE_BRANCH.
#
# Then, choose the target Debian package suite based on the given
# branch.
#
# See `tools/trigger_archive_update` for a usage example.
#
# https://circleci.com/docs/2.0/env-vars/#using-bash_env-to-set-environment-variables
command: |
# Maybe we're building in CircleCI from a specific branch, or
# else we were given a target branch by an API call.
TARGET_BRANCH=${BUENDIA_BRANCH:-$CIRCLE_BRANCH}
# If neither of those is the case, maybe we're building a release from a tag
if [ -z "$TARGET_BRANCH" ] && ( echo "$CIRCLE_TAG" | grep -Eq '^v([0-9]+\.?)+$' ); then
TARGET_BRANCH=master
fi
echo "export BUENDIA_BRANCH=${TARGET_BRANCH}" >> $BASH_ENV
if [ "${TARGET_BRANCH}" = "master" ]; then
echo "export BUENDIA_SUITE=stable" >> $BASH_ENV
elif [ "${TARGET_BRANCH}" = "dev" ]; then
echo "export BUENDIA_SUITE=unstable" >> $BASH_ENV
else
echo "Attempting to build on the ${TARGET_BRANCH} branch, but "
echo "can only rebuild the apt archive for the 'master' or 'dev' branch!"
exit 1
fi
source $BASH_ENV
echo "Target branch is ${BUENDIA_BRANCH}; target suite is ${BUENDIA_SUITE}"
- checkout # check out the code in the project directory
- attach_workspace:
at: /tmp/artifacts
- run:
name: Fetch latest artifacts (if not already present)
command: |
PACKAGES=/tmp/artifacts/packages
if [ ! -d $PACKAGES -a -n "${CIRCLE_API_TOKEN}" ]; then
echo -n "Build triggered manually by ${CIRCLE_USERNAME}; "
mkdir -p $PACKAGES && cd $PACKAGES
if [ -n "${BUENDIA_TARGET_JOB}" ]; then
echo "fetching artifacts from job #${BUENDIA_TARGET_JOB}"
else
echo "fetching artifacts from latest ${BUENDIA_BRANCH} build."
BUENDIA_TARGET_JOB=latest
fi
$HOME/buendia/tools/fetch_circleci_artifacts -j ${BUENDIA_TARGET_JOB} -g '*.deb' projectbuendia/buendia ${BUENDIA_BRANCH}
fi
- restore_cache:
keys:
- buendia-builds-v1-{{ .Branch }}-{{ .Revision }}
- buendia-builds-v1-{{ .Branch }}
- buendia-builds-v1-
- add_ssh_keys:
fingerprints:
# github.com/projectbuendia/builds read-write key
- "18:e2:e2:8e:12:49:a1:ca:e6:6f:e1:30:08:02:ae:43"
# staging.buendia.org deploy key
- "99:7c:11:11:e7:7b:e8:de:c4:0c:4e:6d:1d:cc:2e:1a"
- run:
name: Get the latest builds repository
### NOTE: this job must have a key that can read AND write to
### github.com/projectbuendia/builds
command: |
[ -d builds ] || git clone git@github.com:projectbuendia/builds
cd builds && \
git fetch --force origin gh-pages && \
git reset --hard origin/gh-pages && \
git checkout -q -B gh-pages
- run:
name: Configure the Git user
command: |
git config --global user.name "CircleCI Build Process"
git config --global user.email "zestybuendia@gmail.com"
- run:
name: Install apt-utils
command: sudo apt-get update && sudo apt-get -y install apt-utils
- run:
name: Update the package archive
command: tools/update_apt_archive builds/packages ${BUENDIA_SUITE} /tmp/artifacts/packages
- save_cache:
key: buendia-builds-v1-{{ .Branch }}-{{ .Revision }}
paths:
- ~/buendia/builds/.git
- store_artifacts:
# Carry forward the artifacts from the previous build job
path: /tmp/artifacts
deploy-download:
docker:
- image: projectbuendia/debian-stretch:1.1.0
steps:
- add_ssh_keys:
fingerprints:
# staging.buendia.org deploy key
- "99:7c:11:11:e7:7b:e8:de:c4:0c:4e:6d:1d:cc:2e:1a"
- deploy:
name: Deploy to download host
command: |
ssh-keyscan $DOWNLOAD_HOST >> $HOME/.ssh/known_hosts
ssh $SSH_USER@$DOWNLOAD_HOST "cd builds && \
git fetch --force origin gh-pages && \
git reset --hard origin/gh-pages && \
git checkout -q -B gh-pages && \
mkdir /var/www/html/deb.new && \
git archive gh-pages | tar -C/var/www/html/deb.new --strip-components 1 -xf - packages && \
rm -r /var/www/html/deb && \
mv /var/www/html/deb.new /var/www/html/deb"
deploy-staging:
docker:
- image: projectbuendia/debian-stretch:1.1.0
steps:
- add_ssh_keys:
fingerprints:
# staging.buendia.org deploy key
- "99:7c:11:11:e7:7b:e8:de:c4:0c:4e:6d:1d:cc:2e:1a"
- deploy:
name: Run buendia-update on staging
command: |
ssh-keyscan $STAGING_HOST >> $HOME/.ssh/known_hosts
ssh $SSH_USER@$STAGING_HOST "sudo buendia-update"
- deploy:
name: Run all integration tests on staging
command: ssh $SSH_USER@$STAGING_HOST "sudo buendia-run-tests --unsafe"
purge-unstable-repo:
working_directory: ~/buendia
docker:
- image: circleci/openjdk:stretch
steps:
- checkout # check out the code in the project directory
- restore_cache:
keys:
- buendia-builds-v1-{{ .Branch }}-{{ .Revision }}
- buendia-builds-v1-{{ .Branch }}
- buendia-builds-v1-
- add_ssh_keys:
fingerprints:
# github.com/projectbuendia/builds read-write key
- "18:e2:e2:8e:12:49:a1:ca:e6:6f:e1:30:08:02:ae:43"
- run:
name: Get the latest builds repository
### NOTE: this job must have a key that can read AND write to
### github.com/projectbuendia/builds
command: |
[ -d builds ] || git clone git@github.com:projectbuendia/builds
cd builds && \
git fetch --force origin gh-pages && \
git reset --hard origin/gh-pages && \
git checkout -q -B gh-pages
- run:
name: Configure the Git user
command: |
git config --global user.name "CircleCI Build Process"
git config --global user.email "zestybuendia@gmail.com"
- run:
name: Install apt-utils
# The double `apt-get update` seems to fix an issue with the CircleCI image:
# https://github.com/CircleCI-Public/gcp-cli-orb/issues/5#issuecomment-467616061
# ¯\_(ツ)_/¯
command: ( sudo apt-get update || sudo apt-get update ) && sudo apt-get -y install apt-utils
- run:
### NOTE: this step requires Java 8
name: Purge older unstable packages
command: tools/purge_older_packages builds packages/unstable
- run:
name: Re-index the unstable package suite
command: |
cd builds
../tools/index_debs packages unstable
git add packages/dists/unstable
git commit -m "Automated re-indexing from CircleCI build #${CIRCLE_BUILD_NUM} (${CIRCLE_BUILD_URL})"
- run:
name: Force-push the package repo
command: cd builds && git push --force --all origin
- save_cache:
key: buendia-builds-v1-{{ .Branch }}-{{ .Revision }}
paths:
- ~/buendia/builds/.git
- /tmp/buendia-fetched
workflows:
version: 2
normal-build:
jobs:
- build:
filters:
branches:
# Don't do a normal build for master; instead let the
# release-build job do the builds off master iff that branch is
# tagged as part of the documented release process.
ignore:
- master
- apt-archive:
requires:
- build
filters:
branches:
only:
- dev
tags:
ignore: /.*/
- deploy-download:
requires:
- apt-archive
- deploy-staging:
requires:
- deploy-download
release-build:
# Ensure that tagged releases get their own CircleCI build:
# https://circleci.com/docs/2.0/workflows/#executing-workflows-for-a-git-tag
jobs:
- build:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- apt-archive:
requires:
- build
filters:
tags:
only: /^v.*/
- deploy-download:
requires:
- apt-archive
filters:
tags:
only: /^v.*/
clean-apt-archive:
# Eliminate older unstable packages every night at 2am. This is intended to
# keep the projectbuendia.github.io/builds repo from spiraling out of
# control in size.
#
# https://circleci.com/docs/2.0/workflows/#nightly-example
triggers:
- schedule:
cron: "0 2 * * *"
filters:
branches:
only:
- dev
jobs:
- purge-unstable-repo