-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
.gitlab-ci.yml
297 lines (270 loc) · 6.52 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
stages:
- prepare-toolchain
- build-toolchain
- deploy-toolchain
- prepare
- test
- build-sysroot
- build-system
- deploy
variables:
VERSION: 0.1.1+${CI_PIPELINE_ID}
KUBERNETES_CPU_REQUEST: 500m
KUBERNETES_CPU_LIMIT: 2
KUBERNETES_MEMORY_REQUEST: 2Gi
KUBERNETES_MEMORY_LIMIT: 3Gi
#############################
# some job templates
.toolchain-job:
only:
changes:
- cmake/project_toolchain.cmake
- CMakeLists.txt
- .gitlab-ci.yml
- src/llvm
- Dockerfile.llvm-ci
.source-job:
image: $CI_REGISTRY_IMAGE/ci/$CI_COMMIT_REF_NAME:latest
only:
changes:
- src/**/*
- cmake/**/*
- util/fatcreate.c
- CMakeLists.txt
- .gitlab-ci.yml
- Dockerfile.ci
needs:
- ci-image
.deploy-job:
stage: deploy
only:
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
.docker-build: &docker-build
image:
name: gcr.io/kaniko-project/executor:v1.9.1-debug
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}, \"https://index.docker.io/v1/\":{\"username\":\"$DOCKERHUB_USER\",\"password\":\"$DOCKERHUB_PASSWORD\"}}}" > /kaniko/.docker/config.json
- >-
/kaniko/executor
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/$DOCKERFILE
--destination $IMAGE_NAME:$IMAGE_TAG
--destination $IMAGE_NAME/$CI_COMMIT_REF_NAME:latest
--cache=true
--cache-repo $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME/kaniko-cache
$BUILD_ARGS
only:
- branches
.cmake-build:
extends:
- .source-job
image: $CI_REGISTRY_IMAGE/ci:$CI_COMMIT_SHA
interruptible: true
before_script: &cmake-build-before-script
- '[ -z "$CCACHE_DIR" ] && export CCACHE_DIR=$(pwd)/.ccache'
script: &cmake-build-script
- cmake -Dsubproject=$SUBPROJECT $CMAKE_DEFINES -G Ninja -DCPACK_PACKAGE_VERSION=$VERSION -DCMAKE_BUILD_TYPE=Release -B build -S .
- ninja -C build ${TARGETS:-package}
- test "$CMAKE_NO_COPY" || mv build/*.deb build/*.tar.xz .
variables:
GIT_STRATEGY: fetch
GIT_SUBMODULE_STRATEGY: recursive
ARTIFACT_COMPRESSION_LEVEL: fastest
KUBERNETES_CPU_LIMIT: 7
cache:
paths:
- .ccache
.apt-deploy:
extends:
- .deploy-job
- .source-job
image: alpine
variables:
GIT_STRATEGY: none
before_script:
- apk add -u --no-cache curl
except:
variables:
- $APT_DEPLOY_TOKEN == ""
script:
- |
for package in *.deb; do
curl -X PUT --data-binary @$package -f \
-H 'Content-Type: application/octet-stream' \
-H 'x-component: lf-os' \
-H 'x-suites: unstable' \
-H "Authorization: Bearer $APT_DEPLOY_TOKEN" \
https://fission.svc.0x0a.network/apt/upload
done
.generic-deploy:
extends:
- .deploy-job
- .source-job
image: alpine
variables:
GIT_STRATEGY: none
before_script:
- apk add -u --no-cache curl
script:
- |
for package in *; do
component=$(echo ${package#lf_os-} | cut -d '_' -f 1)
# component lf_os, but we split by _ so it's only lf here
if [ $component = "lf" ]; then
component="system"
fi
curl -f \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file "$package" \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/$component/${VERSION}/$package"
done
#############################
# then jobs for the toolchain
ci-image-llvm:
extends:
- .docker-build
- .toolchain-job
stage: prepare-toolchain
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE/llvm-ci
IMAGE_TAG: $CI_COMMIT_SHA
DOCKERFILE: Dockerfile.llvm-ci
llvm:
extends:
- .cmake-build
- .toolchain-job
stage: build-toolchain
variables:
SUBPROJECT: toolchain
KUBERNETES_MEMORY_REQUEST: 8Gi
KUBERNETES_MEMORY_LIMIT: 12Gi
needs:
- ci-image-llvm
image: $CI_REGISTRY_IMAGE/llvm-ci:$CI_COMMIT_SHA
artifacts:
paths:
- lf_os-toolchain_${VERSION}_*.deb
- lf_os-toolchain_${VERSION}_*_*.tar.xz
llvm-deploy-apt:
extends:
- .apt-deploy
- .toolchain-job
stage: deploy-toolchain
needs:
- llvm
llvm-deploy-generic:
extends:
- .generic-deploy
- .toolchain-job
stage: deploy-toolchain
needs:
- llvm
ci-image:
extends:
- .docker-build
stage: prepare
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE/ci
IMAGE_TAG: $CI_COMMIT_SHA
DOCKERFILE: Dockerfile.ci
before_script:
- test -f lf_os-toolchain_${VERSION}_amd64.deb && export BUILD_ARGS="--build-arg toolchainSource=local" || true
needs:
- job: llvm
optional: true
#############################
# now actual LF OS jobs
unittest:
extends:
- .cmake-build
stage: test
variables:
CTEST_OUTPUT_ON_FAILURE: "1"
GIT_STRATEGY: fetch
SUBPROJECT: lf_os
TARGETS: tests
CMAKE_NO_COPY: transrightsarehumanrights # any non-empty string
KUBERNETES_CPU_REQUEST: 2
KUBERNETES_CPU_LIMIT: 2
KUBERNETES_MEMORY_REQUEST: 2Gi
KUBERNETES_MEMORY_LIMIT: 2Gi
artifacts:
when: always
reports:
junit:
- build/kernel_tests.xml
- build/runtime-test_*.xml
build-sysroot:
extends: .cmake-build
stage: build-sysroot
variables:
SUBPROJECT: sysroot
artifacts:
paths:
- lf_os-sysroot_${VERSION}_*.deb
- lf_os-sysroot_${VERSION}_*.tar.xz
build-system:
extends: .cmake-build
stage: build-system
variables:
SUBPROJECT: lf_os
CMAKE_DEFINES: -Dlf_os_sysroot=/opt/lf_os/sysroot
TARGETS: package hd.img.xz
needs:
- build-sysroot
before_script:
- *cmake-build-before-script
- dpkg -i lf_os-sysroot*.deb
script:
- *cmake-build-script
- mv build/hd.img.xz lf_os_${VERSION}_amd64.img.xz
artifacts:
paths:
- lf_os_${VERSION}_*.deb
- lf_os_${VERSION}_*.tar.xz
- lf_os_${VERSION}_*.img.xz
apt-deploy:
extends:
- .apt-deploy
needs:
- build-sysroot
- build-system
- unittest
generic-deploy:
extends:
- .generic-deploy
needs:
- build-sysroot
- build-system
- unittest
pages:
extends:
- .cmake-build
- .deploy-job
stage: deploy
needs:
- unittest
only:
changes:
- src/**/*
- cmake/**/*
- CMakeLists.txt
- .gitlab-ci.yml
- Dockerfile.ci
- Doxyfile.in
variables:
TARGETS: doc
SUBPROJECT: lf_os
CMAKE_NO_COPY: blacklivesmatter # any non-empty string
KUBERNETES_CPU_REQUEST: 1
KUBERNETES_CPU_LIMIT: 1
KUBERNETES_MEMORY_REQUEST: 1Gi
KUBERNETES_MEMORY_LIMIT: 1Gi
script:
- *cmake-build-script
- mv build/doc/html public
artifacts:
paths:
- public