Repository navigation
Expand file tree
/
Copy pathktest-deploy
More file actions
executable file
·83 lines (74 loc) · 3.02 KB
/
Copy pathktest-deploy
File metadata and controls
executable file
·83 lines (74 loc) · 3.02 KB
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
#!/usr/bin/env bash
#
# ktest-deploy — force-sync the ktest checkout on every CI worker node.
#
# Push-mode CI runs jobs out of each worker's ~/ktest, but nothing keeps
# those checkouts current. This resets every configured worker's ~/ktest
# to origin/master. The worker list is the ktest-ci.json5 executor map —
# the same hosts ci-daemon dispatches jobs to.
#
# Quick and dirty for now; longer term ktest should be a proper nix
# package and this goes away.
set -o nounset
set -o errexit
set -o errtrace
CONFIG_PATH="${KTEST_CI_CONFIG:-$HOME/.ktest/ktest-ci.json5}"
# -n is load-bearing: ssh runs inside a `while read` loop over the worker
# list, and without it the first ssh reads (and swallows) the rest of that
# list off stdin. accept-new: head node -> worker may be first contact.
SSH="ssh -n -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new"
# JSON5 -> JSON via perl: strip // comments (preceded by whitespace, so
# git://, http:// inside strings survive), drop trailing commas, quote
# unquoted object keys. Same reader as kernel-store-push.
json5_to_json() {
perl -0777 -pe '
s{(^|\s)//[^\n]*}{$1}gm;
s/,(\s*[}\]])/$1/g;
s/([\{,\[]\s*|^\s*)([A-Za-z_][A-Za-z0-9_]*)(\s*):/$1"$2"$3:/gm;
' "$1"
}
if [[ ! -f $CONFIG_PATH ]]; then
echo "ktest-deploy: no config at $CONFIG_PATH" >&2
exit 1
fi
workers=$(json5_to_json "$CONFIG_PATH" | jq -r '.executors | keys[]')
# Worker-side sync. Resets ~/ktest to origin/master, then refreshes the
# push-deployed test-infra dependencies.
#
# require-git (tests/prelude.sh) clones a dependency once and never updates
# it, so without this a worker keeps whatever xfstests it first cloned — a
# fix pushed to the xfstests fork would never reach CI. We deliberately do
# NOT touch the repos under test (bcachefs-tools, linux): ci-daemon checks
# those out per job to the exact commit being tested, and their git rev
# feeds the build cache keys.
#
# Deps live per-slot under ~/ktest-ci/<slot>/ on workers, and in the default
# ~/.ktest/deps/ for non-CI runs; refresh both. fstests.sh builds and runs
# xfstests from ~/ktest/tests/fs/xfstests, though, not the clone require-git
# made - untracked inside ktest, so the reset above doesn't touch it: refresh
# that too. Unmatched globs / missing checkouts are skipped by the -d guard.
read -r -d '' remote_cmd <<'REMOTE' || true
set -e
cd ktest && git fetch -q origin && git reset --hard -q origin/master
git log -1 --format=' ktest %h %s'
for d in ~/ktest-ci/*/xfstests ~/.ktest/deps/xfstests ~/ktest/tests/fs/xfstests; do
[ -d "$d/.git" ] || continue
git -C "$d" fetch -q origin && git -C "$d" reset --hard -q origin/master
echo " xfstests $d -> $(git -C "$d" rev-parse --short HEAD)"
done
REMOTE
failed=0
while IFS= read -r host; do
[[ -n $host ]] || continue
echo "ktest-deploy: $host"
if $SSH "$host" "$remote_cmd"; then
:
else
echo " FAILED" >&2
failed=$((failed + 1))
fi
done <<<"$workers"
if [[ $failed -gt 0 ]]; then
echo "ktest-deploy: $failed worker(s) failed" >&2
exit 1
fi