-
Notifications
You must be signed in to change notification settings - Fork 15
/
kernelci.org
executable file
·387 lines (328 loc) · 9.65 KB
/
kernelci.org
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
#!/bin/sh
# Tool to update the kernelci.org production instance
set -e
cmd_flush_kernel() {
echo "Flushing all current kernel builds"
python3 job.py --settings data/prod-jenkins.ini \
disable kernel-tree-monitor
python3 job.py --settings data/prod-jenkins.ini \
wait kernel-build-trigger
}
cmd_abort_bisections() {
echo "Aborting any on-going bisections"
python3 job.py --settings data/prod-jenkins.ini \
disable lava-bisection
python3 job.py --settings data/prod-jenkins.ini \
abort lava-bisection
}
_cmd_repo() {
repo="${1:-kernelci-core}"
branch="${2:-kernelci.org}"
# First, manually push to $repo/kernelci.org branch
echo "Getting $branch branch from $repo"
[ -d "checkout/$repo" ] || {
mkdir -p checkout
git clone \
"https://github.com/kernelci/${repo}.git" \
"checkout/$repo" \
-b $branch
cd "checkout/$repo"
git remote \
set-url origin --push \
"[email protected]:kernelci/${repo}.git"
cd -
}
cd "checkout/$repo"
git remote update origin
git checkout origin/$branch
cd -
python3 update.py \
--branch $branch \
--ssh-key=$PWD/keys/id_rsa_kernelci.org \
--push \
"$repo"
}
cmd_core() {
branch="${1:-kernelci.org}"
_cmd_repo kernelci-core "$branch"
}
cmd_api() {
branch="${1:-kernelci.org}"
_cmd_repo kernelci-api "$branch"
}
cmd_jenkins() {
# ToDo
return 0
}
cmd_dsl() {
echo "Running Jenkins DSL seed job"
python3 job.py --settings data/prod-jenkins.ini \
trigger job-dsl --no-params
}
cmd_rootfs_docker() {
echo "Building Docker images used to build rootfs images"
cd checkout/kernelci-core
git remote update origin
git checkout origin/main
core_rev=$(git show --pretty=format:%H -s origin/main)
base_args="build --build-arg core_rev=$core_rev"
args="$base_args --prefix=kernelci/ --push --no-cache"
./kci docker $args buildroot kernelci
./kci docker $args debos kernelci
cd -
}
cmd_rootfs_builds() {
local version="$1"
echo "Starting rootfs build jobs"
[ -n "$version" ] && echo "Pipeline version: $version"
echo "{\
\"PIPELINE_VERSION\": \"$version\",\
\"KCI_CORE_BRANCH\": \"main\",\
\"ROOTFS_TYPE\": \"buildroot debos\"\
}" > rootfs-build-trigger.json
python3 job.py \
--settings=data/prod-jenkins.ini \
--json=rootfs-build-trigger.json \
trigger \
rootfs-build-trigger
rm rootfs-build-trigger.json
}
cmd_rootfs_flush() {
echo "Waiting for rootfs jobs to complete"
python3 job.py --settings data/prod-jenkins.ini \
wait rootfs-build-trigger
}
cmd_rootfs_update() {
local version="$1"
echo "Updating rootfs URLs to $version"
cd checkout/kernelci-core
git fetch origin main
git checkout $FETCH_HEAD
if ./kci_test update_rootfs_urls --release ${version} --output rootfs-images-${version}.yaml --verbose; then
mv rootfs-images-${version}.yaml config/core/rootfs-images.yaml
local branch=rootfs-$version
git checkout -b $branch
git commit -asm "rootfs-images.yaml: update rootfs URLs to $version"
git push -u origin HEAD:$branch
git checkout main
git branch -D $branch
else
echo "Failed to update rootfs URLs"
git reset --hard
git checkout origin/main
fi
cd -
}
cmd_backend() {
# First, manually update kernelci-backend kernelci.org branch
rev="${1:-kernelci.org}"
echo "Updating kernelci-backend to $rev"
./ansible \
kernelci-backend \
api.kernelci.org \
$rev \
main \
$PWD/keys/id_rsa_kernelci.org
}
cmd_frontend() {
# First, manually update kernelci-frontend kernelci.org branch
rev="${1:-kernelci.org}"
echo "Updating kernelci-frontend to $rev"
./ansible \
kernelci-frontend \
linux.kernelci.org \
$rev \
main \
$PWD/keys/id_rsa_kernelci.org
}
cmd_website() {
branch="${1:-kernelci.org}"
[ -d checkout/kernelci-project ] || {
echo "Cloning kernelci-project"
mkdir -p checkout
git clone \
https://github.com/kernelci/kernelci-project.git \
checkout/kernelci-project \
-b $branch
cd checkout/kernelci-project
git remote \
set-url origin --push \
[email protected]:kernelci/kernelci-project.git
cd -
}
echo "Updating sub-modules"
cd checkout/kernelci-project
git checkout main
git pull --ff-only
git submodule update --init --recursive
cd - 2>&1 > /dev/null
for mod in kernelci-core kernelci-api kcidb; do
cd checkout/kernelci-project/kernelci.org/external/$mod
git checkout main
git pull --ff-only
cd - 2>&1 > /dev/null
cd checkout/kernelci-project
git add kernelci.org/external/$mod
cd - 2>&1 > /dev/null
done
cd checkout/kernelci-project
if [ -n "$(git diff --cached | head -1)" ]; then
git commit -asm "kernelci.org: update submodules"
git push
fi
cd - 2>&1 > /dev/null
python3 update.py \
--branch $branch \
--ssh-key=$PWD/keys/id_rsa_kernelci.org \
--push \
kernelci-project
echo "Updating Git LFS and submodules"
cd checkout/kernelci-project/kernelci.org
git-lfs fetch
git-lfs checkout
git submodule update --init --recursive
./docker-hugo -D
rm -rf /data/kernelci.org/*
cp -R public/* /data/kernelci.org/
cd -
}
cmd_docker() {
echo "Re-building Docker images"
# Get API revision to tag the image
cd checkout/kernelci-api
api_rev=$(git show --pretty=format:%H -s origin/kernelci.org)
cd -
cd checkout/kernelci-core
core_rev=$(git show --pretty=format:%H -s origin/kernelci.org)
base_args="build --build-arg core_rev=$core_rev"
args="$base_args --prefix=kernelci/ --push --no-cache"
# KernelCI tools
./kci docker $args kernelci
./kci docker $args k8s kernelci
./kci docker $args kernelci api --version="$api_rev"
# Compiler toolchains
for clang in clang-15 clang-16 clang-17; do
./kci docker $args $clang
done
for clang in clang-15 clang-16 clang-17; do
for arch in arm arm64 armv5 mips riscv64 x86; do
./kci docker $args $clang kselftest kernelci --arch $arch
done
done
for arch in arc arm armv5 arm64 mips riscv64 x86; do
./kci docker $args gcc-12 kselftest kernelci --arch $arch
done
# missing -dev packages for sparc64
./kci docker $args gcc-12 kernelci --arch sparc
# only x86 is useful for KUnit (for now)
./kci docker $args gcc-12 kunit kernelci --arch x86
# additional images for Rust
for rustc in rustc-1.74 rustc-1.75; do
./kci docker $args $rustc kselftest kernelci
for arch in x86; do
./kci docker $args $rustc kselftest kernelci --arch $arch
done
done
# QEMU
./kci docker $args qemu
# Other tools
./kci docker $args cvehound kernelci
./kci docker $args dt-validation # kernelci (PyYAML conflict)
cd -
}
_rebase_upstream() {
repo="$1"
upstream_url="$2"
branch="${3:-master}"
if [ ! -d "checkout/$repo" ]; then
git clone \
https://github.com/kernelci/"$repo".git \
checkout/"$repo"
cd checkout/"$repo"
git remote \
set-url origin --push \
[email protected]:kernelci/"$repo".git
git remote \
add upstream \
"$upstream_url"
git fetch --tags origin
git fetch --tags upstream
cd -
fi
python3 update.py \
--ssh-key=$PWD/keys/id_rsa_kernelci.org \
--branch=kernelci.org \
--origin=upstream \
--origin-branch="$branch" \
--push \
"$repo"
}
cmd_test_definitions() {
_rebase_upstream \
test-definitions \
https://github.com/Linaro/test-definitions.git
_rebase_upstream \
iec-security \
https://gitlab.com/cip-project/cip-testing/cip-security-tests.git
}
cmd_kernel() {
echo "Pushing kernelci.org LTS kernel branch"
python3 kernel.py \
--from-url=git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git \
--from-branch=linux-5.15.y \
--branch=kernelci.org \
--tag-prefix=kernelci- \
--ssh-key=$PWD/keys/id_rsa_kernelci.org \
--push
}
cmd_trigger() {
echo "Starting Jenkins kernel-tree-monitor job"
python3 job.py \
--settings=data/prod-jenkins.ini \
--json=data/prod-monitor.json \
trigger \
kernel-tree-monitor
}
# -----------------------------------------------------------------------------
# Main commands
#
cmd_checkout() {
echo "Updating local repository"
git remote update origin
git checkout origin/main
}
cmd_rootfs() {
local version=$(date +%Y%m%d).0
cmd_rootfs_docker
cmd_rootfs_builds "$version"
sleep 60
cmd_rootfs_flush # It takes a while for the jobs to start...
cmd_rootfs_update "$version"
}
cmd_pause() {
cmd_flush_kernel
cmd_abort_bisections
# ToDo: automate this step with SSH access to the nodes
echo "Now restart Jenkins"
# ToDo: automate waiting for Jenkins to be back online
}
cmd_update() {
cmd_core
cmd_api
cmd_dsl
cmd_backend
cmd_frontend
cmd_test_definitions
cmd_docker
cmd_kernel
cmd_trigger
}
cmd="${1}"
if [ -n "$cmd" ]; then
shift 1
# ToDo: fix issues mentioned in cmd_part1 and cmd_part2
#else
# cmd="all"
fi
"cmd_"$cmd $@
exit 0