forked from FCG-LLC/hyena-edge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
416 lines (377 loc) · 9.14 KB
/
.gitlab-ci.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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
image: "docker-registry.cs.int/gitlab/rust"
variables:
RUST_COMPILER: "stable"
before_script:
##
## Run ssh-agent (inside the build environment)
##
- eval $(ssh-agent -s)
##
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
##
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
##
## Create the SSH directory and give it the right permissions
##
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
##
## Move cargo home directory inside project dir
## so it can be cached
##
- export CARGO_HOME="$(realpath ./.cargo)"
- mkdir -p $CARGO_HOME
## Install build prerequisites
- wget http://aptly.cs.int/public/cs-repo.key -O - | sudo apt-key add -
- sudo add-apt-repository "deb http://aptly.cs.int/public xenial int"
- sudo apt-get install -y libnanomsg5 libnanomsg-dev
stages:
- test
- build
- package
- docker
- publish
- deploy
- bench
cache:
paths:
- .cargo
- target
build:master-release:
stage: build
tags:
- rust
- hyena
only:
- master
script:
- cargo build --release
artifacts:
paths:
- target/release/hyena
expire_in: 1 month
build:master-docs:
stage: build
tags:
- rust
- hyena
only:
- master
script:
- cargo doc
artifacts:
paths:
- target/doc/**
expire_in: 1 month
build:docs:
stage: build
tags:
- rust
- hyena
except:
- master
script:
- cargo doc
artifacts:
paths:
- target/doc/**
expire_in: 1 week
build:release:
stage: build
tags:
- rust
- hyena
except:
- master
when: manual
script:
- cargo build --release
artifacts:
paths:
- target/release/hyena
expire_in: 1 day
build:debug:
stage: build
tags:
- rust
- hyena
except:
- master
when: manual
script:
- cargo build
artifacts:
paths:
- target/debug/hyena
expire_in: 1 day
package:master-deb:
stage: package
cache:
paths: []
policy: pull
tags:
- rust
- hyena
only:
- master
script:
- >
export SHORT_COMMIT=${CI_COMMIT_SHA:0:8}
- >
export VERSION="$(date -u +"%Y%m%d%H%M%S")-$SHORT_COMMIT"
- |
if [ $VERSION ]; then
VERSION="-$VERSION"
fi
LAST_VERSION="$(head -n 1 debian/changelog)"
CHANGELOG_MSG=" * hyena development branch"
TRAILER_LINE=" -- DevOps <devops@collective-sense.com> `date -R`"
echo -e "$LAST_VERSION\n\n$CHANGELOG_MSG\n\n$TRAILER_LINE\n\n$(cat debian/changelog)\n" > debian/changelog
sed -i "0,/)/ s/)/$VERSION)/" debian/changelog
- cat debian/changelog
- mkdir -p build/source
- mv debian build/source/debian
- cp -rvf target/release/hyena build/source/hyena
- cp -rvf README.md build/source/
- pushd build/source
- >
debuild --no-tgz-check -i -I -us -uc -b -Zgzip
- popd
artifacts:
paths:
- build/*.deb
- build/*.ddeb
expire_in: 1 week
publish:master-aptly:
stage: publish
variables:
DEST_ENV: int
APTLY_SERVER: aptly.cs.int
allow_failure: true
cache:
paths: []
policy: pull
tags:
- rust
- hyena
only:
- master
script:
- |
APTLY_HTTP="http://${APTLY_SERVER}:8080"
cd build
DEB_PACKAGES=$(ls *.deb)
# upload
for deb in ${DEB_PACKAGES}; do
curl -X POST -F file=@${deb} ${APTLY_HTTP}/api/files/${deb%_amd64.*}
curl -X POST ${APTLY_HTTP}/api/repos/${DEST_ENV}/file/${deb%_amd64.*}
done
# publish
ssh -o StrictHostKeyChecking=no -tt aptly@${APTLY_SERVER}
docker:master-portus:
stage: docker
variables:
DEST_ENV: int
DOCKERFILES_TO_BUILD: Dockerfile
DOCKER_IMAGE_BUILD_DIR: dockerization
LOCAL_DOCKER_IMAGE: "cs/hyena"
PORTUS_DOCKER_IMAGE: "cs-hyena"
cache:
paths: []
policy: pull
tags:
- rust
- hyena
only:
- master
script:
- >
sudo docker login -u "$PORTUS_USERNAME" -p "$PORTUS_PASSWORD" docker-registry.cs.int
- |
DEB_PACKAGES=$(ls build/*.deb)
# copy DEB_PACKAGES
cp -vf $DEB_PACKAGES ${DOCKER_IMAGE_BUILD_DIR}/
cd ${DOCKER_IMAGE_BUILD_DIR}
for dockerfile in ${DOCKERFILES_TO_BUILD}; do
echo "Building ${DOCKER_IMAGE_BUILD_DIR}/${dockerfile}..."
sudo docker build \
--file ${dockerfile} \
--build-arg destEnv="${DEST_ENV}" \
--build-arg commitSha="${CI_COMMIT_SHA}" \
--build-arg commitRef="${CI_COMMIT_REF_NAME}" \
--build-arg ciJobId="${CI_JOB_ID}" \
--no-cache \
-t ${LOCAL_DOCKER_IMAGE} .
sudo docker tag ${LOCAL_DOCKER_IMAGE} docker-registry.cs.int/${DEST_ENV}/${PORTUS_DOCKER_IMAGE}
done
publish:master-portus:
stage: publish
retry: 2
variables:
DEST_ENV: int
DOCKERFILES_TO_BUILD: Dockerfile
DOCKER_IMAGE_BUILD_DIR: dockerization
LOCAL_DOCKER_IMAGE: "cs/hyena"
PORTUS_DOCKER_IMAGE: "cs-hyena"
cache:
paths: []
policy: pull
tags:
- rust
- hyena
only:
- master
script:
- >
sudo docker login -u "$PORTUS_USERNAME" -p "$PORTUS_PASSWORD" docker-registry.cs.int
- >
sudo docker push docker-registry.cs.int/${DEST_ENV}/${PORTUS_DOCKER_IMAGE}
test:clippy:
stage: test
allow_failure: true
tags:
- rust
- hyena
script:
# treat all warnings as errors
- cargo +nightly clippy -- --all -D clippy
test:fmt:
stage: test
allow_failure: true
tags:
- rust
- hyena
script:
- cargo +nightly fmt -- --write-mode=diff --color=always
test:tests:
stage: test
tags:
- rust
- hyena
script:
- cargo test --all
test:protocol:
stage: test
allow_failure: true
tags:
- docker
script:
- sudo docker run --rm --env HYENA_COMMIT="$CI_COMMIT_SHA" --env HYENA_PRIVATE_KEY="$HYENA_PROTOTEST_PRIVATE_KEY" docker-registry.cs.int/dev/hyena-proto-test
bench:criterion:
stage: bench
allow_failure: true
tags:
- hyena-bench
script:
- cargo bench --all
artifacts:
paths:
- target/criterion
expire_in: 1 week
deploy:int01:
stage: deploy
environment:
name: int01
url: https://int01.cs.int
variables:
DEST_ENV: int
HOST_KEY: |
# int01.cs.int:22 SSH-2.0-OpenSSH_7.2p2 CSprobe
int01.cs.int ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn9GzoSQUoOb3e/OWPvvtp9yMUTU4/lRFFnQeKBkaOkeX1181YitPvFqhWcaqOjeVG3fyFCHrLVD3KZ/NAyFzaaZkoQzy6/kL77Y5IatHGwVz8LxvBhyrkv8/dBghrYOOaOmRuG29wBDnMJ1H3H9/5td+14hthZyJ9FJbxawBfBAW81lom+UZPVSNlW51v/dSrIQUvLZOQJulIeJzQjCKNFCYO35VKlZ0lLwYAtBDtYAdaicW9lUCJQ152GZPLTQHBVN9yKN/pLG5uPZKB7z5Eu/izW87bwPl+PAyBnamvNsKmppKa64KPtoKYLwuBnukFkwbD0vkoyzoJLJAqo4MF
cache:
paths: []
policy: pull
tags:
- rust
- hyena
only:
- master
script:
- echo "$HOST_KEY" >> ~/.ssh/known_hosts
- echo "$INT_DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null
- >
echo "Deploying to INT";
ssh -2 jenkins@int01.cs.int hyena;
deploy:int02:
stage: deploy
environment:
name: int02
url: https://int02.cs.int
variables:
DEST_ENV: int
HOST_KEY: |
# int02.cs.int:22 SSH-2.0-OpenSSH_7.2p2 CSprobe
int02.cs.int ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTuXN1Rc/z6dQYm5h8mRjIUNW75Evs4Paw8qrmLKNZBUQbzXgbZ65oJ9o44EP+COnhnzEzHaGukWPuPIBBnGCIKOWeKGzkunsVaXJB/rRw7s8IO7jW3AgXTRaI0kJ40KlSmAthBVB2bId1ddEqgH8jbAzlp96Z7LwMZnoNds2XljVR1Vq3qRmn3lzTWnnk5AF3GNJenLOkBL7ssNldjIHVSIj+AJGP5UDO3a3IfHCpuGESd6WOaLItFXVOTS5ckmyHaVNh/md8Zws0qQmLDKkkk0/ZfBSu8BPTyJu1xgnsqVmyAIZsbLkhMF4KPOM8TdN+croHhpnEPActj+7q9CDX
cache:
paths: []
policy: pull
tags:
- rust
- hyena
only:
- master
script:
- echo "$HOST_KEY" >> ~/.ssh/known_hosts
- echo "$INT_DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null
- >
echo "Deploying to INT2";
ssh -2 jenkins@int02.cs.int hyena;
bench:master-std:
stage: bench
cache:
paths:
- .cargo
- target
- .bench
tags:
- hyena-bench
only:
- master
script:
- mkdir -p .bench
- >
[[ -f .bench/master ]] && cp .bench/master .bench/prev-master
- cargo +nightly bench --all --features=nightly | tee .bench/master
- >
if [[ -f .bench/prev-master ]];
then
echo "This change compared to previous run";
cargo benchcmp .bench/prev-master .bench/master;
else
echo "No previous run found; cannot compare.";
fi
artifacts:
paths:
- .bench/prev-master
- .bench/master
bench:std:
stage: bench
cache:
paths:
- .cargo
- target
- .bench
tags:
- hyena-bench
except:
- master
script:
- mkdir -p .bench
- >
[[ -f ".bench/${CI_COMMIT_REF_NAME}" ]] && cp ".bench/${CI_COMMIT_REF_NAME}" ".bench/prev-${CI_COMMIT_REF_NAME}"
- cargo +nightly bench --all --features=nightly | tee ".bench/${CI_COMMIT_REF_NAME}"
- >
[[ -f .bench/master ]] && echo "This change compared to master"
- >
[[ -f .bench/master ]] && cargo benchcmp .bench/master ".bench/${CI_COMMIT_REF_NAME}"
- >
if [[ -f ".bench/prev-${CI_COMMIT_REF_NAME}" ]];
then
echo "This change compared to previous run";
cargo benchcmp ".bench/prev-${CI_COMMIT_REF_NAME}" ".bench/${CI_COMMIT_REF_NAME}";
else
echo "No previous run found; cannot compare.";
fi