Skip to content

Commit b9d3b4a

Browse files
groupskyclaude
andcommitted
test: fix review findings: timer race, version check, wider README check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 6005b49 commit b9d3b4a

5 files changed

Lines changed: 41 additions & 12 deletions

File tree

‎.github/workflows/install-release.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ jobs:
4343
steps:
4444
- name: The version
4545
id: version
46+
shell: bash
4647
run: |
4748
set -eu
4849
v="${INPUT_VERSION:-${RELEASE_TAG#v}}"
49-
if ! printf '%s\n' "$v" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
50-
echo "::error::'$v' is not a version X.Y.Z. Give the version without the v."
50+
# The whole string, so a value with a newline does not pass.
51+
if ! [[ "$v" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
52+
echo "::error::The version is not X.Y.Z. Give the version without the v, for example 0.3.0."
5153
exit 1
5254
fi
5355
echo "version=$v" >>"$GITHUB_OUTPUT"

‎DESIGN.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,9 @@ and on `main`) is the path a user takes, as root on the throwaway runner:
760760
`setup`, `start`) before its `sh` block, and the script runs the block
761761
as written, with `NAME` set to `config-repo`.
762762
`test/units/readme-block.sh --check` fails when a block is missing, or
763-
when an install command (`useradd`, `install -d`,
764-
`cp contrib/systemd`, `systemctl enable`) is in an unmarked block. So
763+
when an install command (`useradd`, `groupadd`, `install -X`, `chown`,
764+
`chmod`, `cp contrib/systemd`, `systemctl enable`) is in an unmarked
765+
fenced block. So
765766
the README cannot drift from what CI runs.
766767
2. A local bare repo is the remote. A fake Telegram on `127.0.0.1`
767768
(`test/units/faketg.py --tap`) records each message and taps Apply on

‎docs/releasing.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ workflow checks it.
4545
of the tag, and a full loop under the units (`test/units/full-loop.sh`).
4646
A failure here does not undo the release: fix it in a `fix:` pull
4747
request and make a new release. You can also start this workflow by
48-
hand, with a version from 0.3.0 on.
48+
hand, with a version from 0.3.0 on. The Release run keeps its
49+
concurrency group until this job ends (up to 20 minutes): do not merge
50+
other pull requests in that time, so no Release run waits and gets
51+
cancelled.
4952

5053
If `build` or `publish` fails, the release stays a draft. Fix the problem
5154
in a new `fix:` pull request and merge the next release pull request.

‎test/units/full-loop.sh‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ step() {
7676
# readme NAME: run the README block NAME as written, with NAME=config-repo.
7777
readme() {
7878
cmds="$(sh "$here/readme-block.sh" "$1" "$top/README.md")" || die "README.md has no install-test:$1 block"
79-
echo "$cmds" | sed 's/^/README> /'
80-
echo "$cmds" | sed "s/NAME/$name/g" | sh -eu || die "the README block install-test:$1 failed (see the output above)"
79+
printf '%s\n' "$cmds" | sed 's/^/README> /'
80+
printf '%s\n' "$cmds" | sed "s/NAME/$name/g" | sh -eu || die "the README block install-test:$1 failed (see the output above)"
8181
}
8282

8383
# wait_text TEXT SECONDS: wait until the fake Telegram got a message with TEXT.
@@ -109,6 +109,10 @@ outbox_empty() {
109109
# unit_quiet UNIT: the unit logged no error and no warning.
110110
unit_quiet() {
111111
journalctl --sync || true
112+
# No log line at all would make the check below pass without checking.
113+
if ! journalctl --no-pager -o cat -u "$1" | grep -q 'level=INFO'; then
114+
err "$1: no log line found in the journal, so its errors cannot be checked"
115+
fi
112116
if journalctl --no-pager -o cat -u "$1" | grep -E 'level=(ERROR|WARN)'; then
113117
err "$1 logged an error or a warning (above)"
114118
fi
@@ -126,6 +130,22 @@ listener_read_all() {
126130
fi
127131
}
128132

133+
# run_until_tip SHA: start runs until one has fetched SHA. A run that the
134+
# timer started before the push is joined by `systemctl start` and does
135+
# not see the new commit, so one start is not enough.
136+
run_until_tip() {
137+
i=0
138+
while [ "$i" -lt 10 ]; do
139+
systemctl start "pullgate-run@$name.service" || err "pullgate-run@$name.service failed"
140+
if pullgate status "$name" | grep -q "^last tip: *$1\$"; then
141+
return 0
142+
fi
143+
i=$((i + 1))
144+
sleep 1
145+
done
146+
die "after 10 runs, pullgate status does not show the last tip $1"
147+
}
148+
129149
# applied_sha: the applied SHA that `pullgate status` shows.
130150
applied_sha() {
131151
pullgate status "$name" | sed -n 's/^applied: *//p'
@@ -263,7 +283,7 @@ readme start
263283

264284
step "5. A good commit: ask, tap, apply"
265285
# The timer may have started a run already; start waits for it.
266-
systemctl start "pullgate-run@$name.service" || err "pullgate-run@$name.service failed"
286+
run_until_tip "$sha1"
267287
if ! wait_text "✅ Applied" 90; then
268288
journalctl --no-pager -o cat -u "pullgate-run@$name.service" -u pullgate-listen.service -u "pullgate-apply@$name.service" || true
269289
die "no 'Applied' message reached the fake Telegram"
@@ -296,7 +316,7 @@ systemctl is-active --quiet pullgate-listen.service || err "the listener is not
296316

297317
step "7. A commit whose apply fails: rollback"
298318
sha2="$(commit 'fail = true' 'a commit whose apply fails')"
299-
systemctl start "pullgate-run@$name.service" || err "pullgate-run@$name.service failed"
319+
run_until_tip "$sha2"
300320
if ! wait_text "Rolled back to" 90; then
301321
journalctl --no-pager -o cat -u "pullgate-run@$name.service" -u pullgate-listen.service -u "pullgate-apply@$name.service" || true
302322
die "no 'Rolled back' notice reached the fake Telegram"

‎test/units/readme-block.sh‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ if [ "$1" = --check ]; then
5959
# Install commands in ```sh blocks that are not marked: CI would not
6060
# run them. The "Update from 0.1.0" steps use "reenable", which is
6161
# not matched here.
62+
# Every fenced block counts, indented or not, in any language.
6263
out="$(awk '
6364
/^<!-- install-test:[a-z]+ -->$/ { marked = 1; next }
64-
/^```sh$/ { inblock = 1; next }
65-
/^```$/ { inblock = 0; marked = 0; next }
66-
inblock && !marked && /(^|[[:space:]])(useradd|install -d|cp contrib\/systemd|systemctl( --?[A-Za-z-]+)* enable)([[:space:]]|$)/ { print FILENAME ":" NR ": " $0 }
65+
/^[[:space:]]*```/ {
66+
if (inblock) { inblock = 0; marked = 0 } else { inblock = 1 }
67+
next
68+
}
69+
inblock && !marked && /(^|[[:space:]])(useradd|groupadd|install -[a-zA-Z]|chown|chmod|cp contrib\/systemd|systemctl( --?[A-Za-z-]+)* enable)([[:space:]]|$)/ { print FILENAME ":" NR ": " $0 }
6770
' "$readme")"
6871
if [ -n "$out" ]; then
6972
echo "$out" >&2

0 commit comments

Comments
 (0)