-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
333 lines (296 loc) · 10.6 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
default:
# Use stable Rust
image: ${CI_REGISTRY}/kaios/sidl:1.49.0_2
tags:
- hk-fantastic4
before_script:
# for those jobs prefixed by "update", restore ssh-setting in order for git-push
- |
if [[ ${CI_JOB_NAME%%:*} == update ]]; then
echo -e "\033[1;33mFor job [${CI_JOB_NAME}], restore ssh-settings for git-push. \033[0m"
eval $(ssh-agent -s)
ssh-add <(echo "$SSH_PRIVATE_KEY")
mkdir -p ~/.ssh
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
fi
- |
echo -e "machine ${CI_SERVER_HOST}\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
git config --global url."${CI_SERVER_URL}/".insteadOf "git@${CI_SERVER_HOST}:"
- |
if ${CI_USE_MIRROR}; then
echo -e "\033[1;33mAlternatively use ${LOCAL_GIT_MIRROR} for git-clone. \033[0m"
git config --global url."${LOCAL_GIT_MIRROR}/KaiOS".insteadOf "git@${CI_SERVER_HOST}:KaiOS"
fi
- echo "${CI_JOB_IMAGE}, Last edited in ${LAST_EDIT_COMMIT}"
- rustc --version && cargo --version
- node --version && yarn --version
- geckodriver --version && firefox --version
# Environment variables
variables:
GIT_SUBMODULE_STRATEGY: normal
CARGO_HOME: $CI_PROJECT_DIR/cargo
BUILD_SIDL_REPO_URL: [email protected]:KaiOS/build-sidl.git
BUILD_SIDL_BRANCH: multi-arch
before_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
stages:
- docker_production
# thanks to the magic provided by `needs:`, jobs marked as build and xbuild will always be in parallel.
#
# here we ensure the priority to acquire runners by making stage `xbuild` prior to `build` since `xbuild`
# always takes longer.
- xbuild
- build
- test-js
- cargo_tests
- production
- dockerBuild
.build_base:
stage: buildDaemon
only:
- merge_requests
except:
variables:
- $CI_COMMIT_MESSAGE =~ /skip-build/
needs: []
build:daemon:
extends: .build_base
tags:
- gecko-dev
script:
- cd $CI_PROJECT_DIR/daemon
# Fail when encountering clippy warnings.
- cargo clippy --all-targets -- -D warnings
- cargo build --release --features=fake-tokens
artifacts:
expire_in: 1 week
paths:
- target/release/api-daemon
- services/accounts/client/generated/accounts_service.js
- services/apps/client/generated/apps_service.js
- services/audiovolumemanager/client/generated/audiovolume_service.js
- services/contacts/client/generated/contacts_service.js
- services/devicecapability/client/generated/devicecapability_service.js
- services/libsignal/client/generated/libsignal_service.js
- services/powermanager/client/generated/powermanager_service.js
- services/procmanager/client/generated/procmanager_service.js
- services/settings/client/generated/settings_service.js
- services/telephony/client/generated/telephony_service.js
- services/tcpsocket/client/generated/tcpsocket_service.js
- services/time/client/generated/time_service.js
- services/fota/client/generated/fota_service.js
build:daemon:test:essentials:
extends: .build_base
variables:
test_essentials: "child-test-daemon tests/driver tests/fota-test-server tests/apps-test-server"
script:
- |
for te in ${test_essentials}; do
echo -e "\033[1;33mBuilding ${te}\033[0m"
cargo build --manifest-path ${CI_PROJECT_DIR}/${te}/Cargo.toml --release
done
artifacts:
expire_in: 1 week
paths:
- target/release/child-test-daemon
- target/release/fota_test_server
- target/release/apps_test_server
- target/release/driver
- services/test/client/generated/test_service.js
.tests_job_base:
only:
- merge_requests
except:
variables:
- $CI_COMMIT_MESSAGE =~ /skip-test/
- $CI_COMMIT_MESSAGE =~ /skip-build/
# Use cargo to test the project
.test_cargo:
extends: .tests_job_base
stage: cargo_tests
script:
# Force build.rs to run despite the cache.
- touch ./services/libsignal/build.rs ./support/libsignal-sys/build.rs ./services/telephony/build.rs ./services/test/build.rs
- cd ${CI_PROJECT_DIR}/$(sed 's/\:/\//' <<< ${CI_JOB_NAME#"test:cargo:"})
- cargo test -- --nocapture
needs:
- job: 'build:daemon'
test:cargo:services:apps:
extends: .test_cargo
test:cargo:daemon:
extends: .test_cargo
test:cargo:common:
extends: .test_cargo
test:cargo:support:android-utils:
extends: .test_cargo
test:cargo:support:kauth:
extends: .test_cargo
test:cargo:support:kus:
extends: .test_cargo
test:cargo:support:hamster:
extends: .test_cargo
test:cargo:support:sqlite-utils:
extends: .test_cargo
test:cargo:support:kota:
extends: .test_cargo
test:cargo:codegen:
extends: .test_cargo
test:cargo:support:libsignal-sys:
extends: .test_cargo
test:cargo:support:updater_client:
extends: .test_cargo
test:cargo:parser:
extends: .test_cargo
test:cargo:telemetry:
extends: .test_cargo
# test:cargo:tcpsocket-service:
# extends: .test_cargo
test:cargo:services:devicecapability:
extends: .test_cargo
test:cargo:services:deviceconfig:
extends: .test_cargo
test:cargo:services:libsignal:
extends: .test_cargo
test:cargo:services:settings:
extends: .test_cargo
test:cargo:services:telephony:
extends: .test_cargo
test:cargo:vhost:
extends: .test_cargo
test:js-clients:
extends: .tests_job_base
stage: test-js
script:
- cd $CI_PROJECT_DIR
- git clone [email protected]:vincent.chang/echo-server.git
- cd echo-server
- cargo build
- ./target/debug/echo-server 7878&
- ./target/debug/echo-server 7879&
- ./target/debug/echo-server 7880&
- cd $CI_PROJECT_DIR/tests/apps-test-server
- $CI_PROJECT_DIR/target/release/apps_test_server &
- cd $CI_PROJECT_DIR
- WITH_TEST_SERVICE=1 ./release_libs.sh
- mkdir -p ./daemon/remote/TestService
- cp ./target/release/child-test-daemon $CI_PROJECT_DIR/daemon/remote/TestService/daemon
- $CI_PROJECT_DIR/tests/webdriver.sh file://$CI_PROJECT_DIR/services/apps/client/test/tests.html
file://$CI_PROJECT_DIR/services/audiovolumemanager/client/test/tests.html
file://$CI_PROJECT_DIR/services/contacts/client/test/tests.html
file://$CI_PROJECT_DIR/services/devicecapability/client/test/tests.html
file://$CI_PROJECT_DIR/services/libsignal/client/test/global_context.html
file://$CI_PROJECT_DIR/services/libsignal/client/test/session_builder_cipher.html
file://$CI_PROJECT_DIR/services/libsignal/client/test/group_messages.html
file://$CI_PROJECT_DIR/services/powermanager/client/test/tests.html
file://$CI_PROJECT_DIR/services/settings/client/test/tests.html
file://$CI_PROJECT_DIR/services/tcpsocket/client/test/tests.html
file://$CI_PROJECT_DIR/services/test/client/test/tests.html
file://$CI_PROJECT_DIR/services/time/client/test/tests.html
# TODO: figure out why tess_no_package.html fails when running grouped.
- $CI_PROJECT_DIR/tests/webdriver_fota.sh file://$CI_PROJECT_DIR/services/fota/client/test/tests_server_error.html
- $CI_PROJECT_DIR/tests/webdriver_fota.sh file://$CI_PROJECT_DIR/services/fota/client/test/tests_no_package.html
- $CI_PROJECT_DIR/tests/webdriver_fota.sh file://$CI_PROJECT_DIR/services/fota/client/test/tests_check_update.html
- $CI_PROJECT_DIR/tests/webdriver_fota.sh file://$CI_PROJECT_DIR/services/fota/client/test/tests_full.html
needs:
- job: 'build:daemon'
- job: 'build:daemon:test:essentials'
.clone_build_sidl: &clone_build_sidl
- |
git clone [email protected]:KaiOS/build-sidl.git -b multi-arch
cd build-sidl
- git log -1 --decorate
.build_targets_base:
stage: xbuild
tags: ['gecko-dev']
script:
- cd $CI_PROJECT_DIR
- git clone [email protected]:kaios/build-sidl.git -b multi-arch
- cd build-sidl
- ./build_api-daemon.sh
artifacts:
expire_in: 1 week
paths:
- production
needs: []
verify:build:targets:
extends: .build_targets_base
only:
- merge_requests
except:
variables:
- $CI_COMMIT_MESSAGE =~ /skip-build/
build:targets:
extends: .build_targets_base
only:
- branches@KaiOS/sidl
update:targets:
stage: production
script:
- *clone_build_sidl
- ./update_api-daemon.sh
only:
- branches@KaiOS/sidl
needs:
- job: 'build:targets'
update:tag:
stage: production
variables:
# source of sidl in this job is absolutely unnecessary
GIT_STRATEGY: none
API_DAEMON_DEST_REPO: KaiOS/api-daemon.git
# unable to acquire CI_BRANCH_NAME from predefined variables when triggered by "tags"
# hence we self-define here
API_DAEMON_DEST_BRANCH: next
before_script:
# re-override as local mirror is unnecessary but write-access here
- |
eval $(ssh-agent -s)
ssh-add <(echo "$SSH_PRIVATE_KEY")
mkdir -p ~/.ssh
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- |
ret=$(git ls-remote --tags --exit-code \
git@${CI_SERVER_HOST}:${API_DAEMON_DEST_REPO} ${CI_COMMIT_TAG})
if [ ${ret} -eq 0 ]; then
echo "${CI_COMMIT_TAG} already exists in ${API_DAEMON_DEST_REPO} !"
exit 1
fi
script:
- echo ${CI_COMMIT_TAG}
- |
git_url="git@${CI_SERVER_HOST}:"
if ${CI_USE_MIRROR}; then
git_url="${LOCAL_GIT_MIRROR}/"
fi
- git clone "${git_url}${API_DAEMON_DEST_REPO}" -b ${API_DAEMON_DEST_BRANCH}
- cd api-daemon
- 'coresponding_commit=$(git rev-list HEAD --grep="Source: ${CI_PROJECT_PATH}@${CI_COMMIT_SHA}" -F -1)'
- |
if [[ -z ${coresponding_commit} ]]; then
echo "Unable to filter out with the pattern \"Source: ${CI_PROJECT_PATH}@${CI_COMMIT_SHA}\""
echo "Alternatively look for the corresponding commit by CI_COMMIT_TITLE"
coresponding_commit=$(git rev-list HEAD --grep="${CI_COMMIT_TITLE}" -F -1)
if [[ -z ${coresponding_commit} ]]; then
echo "Unable to find the coresponding commit by either SHA1 or commit message title."
exit -1
fi
fi
- |
echo
echo "Corresponding commit that was automatically submitted to api-daemon:"
git show ${coresponding_commit} -q
- git remote set-url --push origin "git@${CI_SERVER_HOST}:${API_DAEMON_DEST_REPO}"
- git push origin ${coresponding_commit}:refs/tags/${CI_COMMIT_TAG}
only:
- tags@KaiOS/sidl
include:
- 'ci/base/build.yml'
- 'ci/base/production.yml'
- 'ci/base/test.yml'
- 'ci/jobs/docker.yml'
- 'ci/jobs/build.yml'
- 'ci/jobs/tests.yml'
- 'ci/jobs/update.yml'