This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
/
config.yml
448 lines (407 loc) · 12.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
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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
version: 2.1
commands:
install_rust:
steps:
- run:
name: Install rust
command: |
curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
chmod 755 rustup.sh
./rustup.sh -y
. /root/.cargo/env
cat /root/.cargo/env >> $BASH_ENV
rustup default nightly
rustup target add x86_64-unknown-linux-musl
rustup component add rustfmt
cargo_build:
parameters:
type:
type: enum
enum: ["release", "debug"]
flags:
type: string
default: ""
binary:
type: string
default: "target/release/ingraind"
condition:
type: string
default: "true"
steps:
- run:
name: Build
command: |
mkdir -p /build/binaries
if ! << parameters.condition >>; then
exit 0;
fi
if [ "<< parameters.type >>" = "release" ]; then
cargo test << parameters.flags >> --release || exit 1
cargo build << parameters.flags >> --release || exit 1
cp << parameters.binary >> /build/binaries/ingraind
sha256sum /build/binaries/ingraind
else
cargo test << parameters.flags >> || exit 1
cargo build << parameters.flags >> || exit 1
cp << parameters.binary >> /build/binaries/ingraind-debug
sha256sum /build/binaries/ingraind-debug
fi
/usr/local/cargo/bin/sccache -s || true
- store_artifacts:
path: /build/binaries
destination: ingraind-binaries
jobs:
terraform:
parameters:
ami:
type: string
default: "latest"
binary:
type: string
default: "target/x86_64-unknown-linux-musl/release/ingraind"
working_directory: /build
docker:
- image: hashicorp/terraform:light
steps:
- checkout
- attach_workspace:
# Must be absolute path or relative path from working_directory
at: /build
- run:
name: Deploy
command: |
cd tests/terraform
cp /build/<< parameters.binary >> ./ingraind
./run-amd64.sh << parameters.ami >>
terraform_arm:
parameters:
ami:
type: string
default: "ubuntu-arm64-1910"
working_directory: /build
docker:
- image: hashicorp/terraform:light
steps:
- checkout
- attach_workspace:
# Must be absolute path or relative path from working_directory
at: /build
- run:
name: Deploy
command: |
cd tests/terraform
./run-arm64.sh << parameters.ami >>
ubuntu:
parameters:
tag:
type: string
default: "latest"
kernel_version:
type: string
default: "$(uname -r)"
working_directory: /build
resource_class: large
docker:
- image: quay.io/redsift/ingraind-build:18.04
steps:
- checkout
- cargo_build:
type: release
# only do release builds for terraform workflows
condition: "[ -n \"$AWS_EC2_SSH_KEY_ID\" ]"
flags: --target=x86_64-unknown-linux-musl
binary: target/x86_64-unknown-linux-musl/release/ingraind
- persist_to_workspace:
root: "./"
paths:
- "target/x86_64-unknown-linux-musl/release/ingraind"
fedora:
working_directory: /build
resource_class: large
docker:
- image: fedora:31
steps:
- checkout
- run:
name: Install deps
command: |
yum install -y clang-9.0.0 llvm-9.0.0 llvm-libs-9.0.0 llvm-devel-9.0.0 llvm-static-9.0.0 capnproto kernel kernel-devel elfutils-libelf-devel ca-certificates
- install_rust
- run:
name: Configure env vars
command: |
echo export KERNEL_SOURCE=/usr/src/kernels/$(rpm -qa kernel-devel |cut -d- -f3-)/ >> $BASH_ENV
echo export LLC=llc >> $BASH_ENV
- cargo_build:
type: debug
binary: target/debug/ingraind
- cargo_build:
type: release
# only do release builds for terraform workflows
condition: "[ -n \"$AWS_EC2_SSH_KEY_ID\" ]"
binary: target/release/ingraind
- persist_to_workspace:
root: "./"
paths:
- "target/release/ingraind"
gke:
working_directory: /build
resource_class: large
docker:
- image: ubuntu
steps:
- checkout
- run:
name: Install some deps
command: |
apt-get update
apt-get install -y curl wget gnupg2 software-properties-common lsb-release
- run:
name: Configure llvm 9 repo
command: |
curl https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
- run:
name: Install more deps
command: |
apt-get update
apt-get install -y build-essential bc kmod cpio flex cpio libncurses5-dev
apt-get install -y clang llvm llvm-9 musl-tools capnproto libelf-dev ca-certificates{,-java}
- run:
name: Configure kernel tree
command: |
mkdir cos-kernel && cd cos-kernel
wget -O kernel.tgz https://chromium.googlesource.com/chromiumos/third_party/kernel/+archive/8549f18963962124c0f0d73667e59dbfc17c5218.tar.gz
tar -xf kernel.tgz
zcat /build/tests/gke/config-gke-4.14.138+.gz > .config
make olddefconfig
make prepare
echo export KERNEL_SOURCE=/build/cos-kernel >> $BASH_ENV
cd ..
- install_rust
- cargo_build:
type: debug
flags: --target=x86_64-unknown-linux-musl
binary: target/x86_64-unknown-linux-musl/debug/ingraind
- cargo_build:
type: release
flags: --target=x86_64-unknown-linux-musl
binary: target/x86_64-unknown-linux-musl/release/ingraind
- persist_to_workspace:
root: "./"
paths:
- "target/x86_64-unknown-linux-musl/release/ingraind"
run_test_gke:
environment:
GCLOUD_PROJECT: ingrain-playground
GCLOUD_PRIMARY_ZONE: europe-west1-b
GCLOUD_PRIMARY_CLUSTER: ingraind-test-cluster
working_directory: /build
docker:
- image: google/cloud-sdk:latest
steps:
- checkout
- run:
name: Setup credentials
command: |
if [ -z "$GCLOUD_SERVICE_KEY" ]; then
circleci-agent step halt
fi
gcloud auth activate-service-account --key-file <(echo ${GCLOUD_SERVICE_KEY})
gcloud config set project ${GCLOUD_PROJECT}
gcloud container clusters get-credentials ${GCLOUD_PRIMARY_CLUSTER} --zone ${GCLOUD_PRIMARY_ZONE}
- run:
name: Deploy
command: |
cd tests/gke
./run-test.sh $DOCKER_IMAGE:${CIRCLE_SHA1:0:7}-gke
build_docker_image:
parameters:
binary:
type: string
default: "target/x86_64-unknown-linux-musl/release/ingraind"
tags:
type: string
working_directory: /build
resource_class: large
docker:
- image: docker:latest
steps:
- checkout
- attach_workspace:
at: /build
- setup_remote_docker
- run:
name: Login to the registry
command: |
echo ${DOCKER_PASSWORD} | docker login --username ${DOCKER_USERNAME} --password-stdin ${DOCKER_SERVER}
- run:
name: Build Docker image
command: |
cd /build
cp << parameters.binary >> .
docker build --build-arg BINARY_PATH=./ingraind \
$(for tag in << parameters.tags >>; do
echo -t $DOCKER_IMAGE:$tag
done) \
/build
echo "Total sizes"
docker images $DOCKER_IMAGE
docker push $DOCKER_IMAGE
build_rh_binary:
parameters:
yum_repo:
type: string
kernel_pkg:
type: string
default: kernel-devel
working_directory: /build
resource_class: large
docker:
- image: quay.io/redsift/ingraind-build:19.10
steps:
- checkout
- attach_workspace:
at: /build
- run:
name: Set up kernel for environment
command: |
yumdownloader --disablerepo=* --enablerepo=<< parameters.yum_repo >> << parameters.kernel_pkg >>
rpm --nodeps -i << parameters.kernel_pkg >>*.rpm
echo KERNEL_SOURCE=/usr/src/kernels/$(ls /usr/src/kernels |head -n1) >> $BASH_ENV
- cargo_build:
type: release
flags: --target=x86_64-unknown-linux-musl
binary: target/x86_64-unknown-linux-musl/release/ingraind
- persist_to_workspace:
root: "./"
paths:
- "target"
workflows:
version: 2.1
build:
jobs:
- terraform_arm:
name: 'terraform - ubuntu/arm64'
- terraform:
name: 'terraform - ubuntu 18.04'
ami: 'ubuntu-1804'
requires:
- ubuntu 18.04
filters:
branches:
only:
- master
- terraform:
name: 'terraform - fedora 31'
ami: 'fedora-31'
binary: 'target/release/ingraind'
requires:
- fedora 31
filters:
branches:
only:
- master
- ubuntu:
name: "ubuntu 18.04"
tag: "18.04"
- build_docker_image:
name: build ubuntu 18.04 image
tags: latest-ubuntu-18.04 ${CIRCLE_SHA1:0:7}-ubuntu-18.04 ${CIRCLE_TAG/%/-ubuntu-18.04}
requires:
- ubuntu 18.04
- fedora:
name: "fedora 31"
elrepo7_docker:
jobs:
- build_rh_binary:
context: org-global
name: build elrepo7
yum_repo: elrepo7
kernel_pkg: kernel-ml-devel
- build_docker_image:
tags: latest-elrepo7 ${CIRCLE_SHA1:0:7}-elrepo7 ${CIRCLE_TAG/%/-elrepo7}
requires:
- build elrepo7
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
elrepo8_docker:
jobs:
- build_rh_binary:
context: org-global
name: build elrepo8
yum_repo: elrepo8
kernel_pkg: kernel-ml-devel
- build_docker_image:
tags: latest-elrepo8 ${CIRCLE_SHA1:0:7}-elrepo8 ${CIRCLE_TAG/%/-elrepo7}
requires:
- build elrepo8
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
amzn2_docker:
jobs:
- build_rh_binary:
context: org-global
name: build amzn2
yum_repo: amzn2-core
- build_docker_image:
tags: latest-amzn2 ${CIRCLE_SHA1:0:7}-amzn2 ${CIRCLE_TAG/%/-amzn2}
requires:
- build amzn2
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
centos8_docker:
jobs:
- build_rh_binary:
context: org-global
name: build centos8
yum_repo: centos8
- build_docker_image:
tags: latest-centos8 ${CIRCLE_SHA1:0:7}-centos8 ${CIRCLE_TAG/%/-centos8}
requires:
- build centos8
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
fedora31_docker:
jobs:
- build_rh_binary:
context: org-global
name: build fedora31
yum_repo: fedora
- build_docker_image:
tags: latest-fedora31 ${CIRCLE_SHA1:0:7}-fedora31 ${CIRCLE_TAG/%/-fedora31}
requires:
- build fedora31
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
gke_docker:
jobs:
- gke
- build_docker_image:
name: build gke image
tags: latest-gke ${CIRCLE_SHA1:0:7}-gke ${CIRCLE_TAG/%/-gke}
requires:
- gke
- run_test_gke:
requires:
- build gke image
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/