Skip to content

Commit 370f784

Browse files
committed
fix(ci): skip directories named like Chainsaw step files
Chainsaw builds step files only from directory entries that are not directories, so a directory named like 01-x.yaml makes nothing a suite. Both selectors listed it as one, and select-install demanded a mapping for it. A symlink still counts, as it does for Chainsaw. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 7e645d5 commit 370f784

4 files changed

Lines changed: 34 additions & 13 deletions

File tree

‎hack/select-e2e.sh‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,22 @@ full_suite_pattern='^(packages/library/|packages/core/|api/|cmd/|internal/|pkg/|
163163
inert_config_pattern='^(examples/|\.github/|\.claude/|\.gemini/|img/|hack/testdata/|packages/tests/|hack/[^/]+\.bats$|hack/boilerplate\.go\.txt$|hack/dcgm-default-counters\.csv$|LICENSE$|\.gitignore$|\.pre-commit-config\.yaml$|\.coderabbit\.yaml$|packages/system/\.gitattributes$|packages/system/(backup-controller|backupstrategy-controller)/definitions/\.gitattributes$)'
164164

165165
# All known Chainsaw suites: every dir directly under hack/e2e-chainsaw/ in
166-
# which Chainsaw v0.2.15 would find a Test (pkg/discovery/load.go). A Test is a
167-
# chainsaw-test.yaml, or chainsaw-test.yml when the .yaml is absent, or, with
168-
# neither, files named like 01-install.yaml, which Chainsaw turns into a Test on
169-
# its own. Chainsaw walks every subdirectory of the dir it is handed, so a Test
170-
# in a top-level dir or anywhere below it belongs to that dir. A suite that
171-
# runs but is never listed is never selected. A parked
172-
# chainsaw-test.yaml.disabled matches none of these.
166+
# which Chainsaw v0.2.15 would find a Test (pkg/discovery/load.go and step.go).
167+
# A Test is a chainsaw-test.yaml, or chainsaw-test.yml when the .yaml is absent,
168+
# or, with neither, files named like 01-install.yaml, which Chainsaw turns into
169+
# a Test on its own. Chainsaw walks every subdirectory of the dir it is handed
170+
# (pkg/utils/fs/discover.go), so a Test in a top-level dir or anywhere below it
171+
# belongs to that dir. A suite that runs but is never listed is never selected.
172+
# A parked chainsaw-test.yaml.disabled matches none of these. `! -type d` rather
173+
# than `-type f` because Chainsaw skips only directories (TryFindStepFiles), so
174+
# a symlinked step file counts.
173175
#
174176
# Captured before the sed/sort rather than piped straight into them: a pipeline
175177
# carries its LAST command's status, so `$(find ... | sed | sort)` would report
176178
# sort's success whatever find did — the same blindness handled for yq below,
177179
# and worse here, because this list is what every escalation prints. Errors go
178180
# to stderr rather than /dev/null for the same reason.
179-
if ! suite_files=$(find hack/e2e-chainsaw -mindepth 2); then
181+
if ! suite_files=$(find hack/e2e-chainsaw -mindepth 2 ! -type d); then
180182
echo "select-e2e: find failed listing the Chainsaw suites under hack/e2e-chainsaw — nothing can be decided without that list" >&2
181183
exit 1
182184
fi

‎hack/select-e2e_test.bats‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# expanded, but not which side is which, and reading a whole-tree diff off a trace
3232
# line is exactly the moment a test stops being worth having.
3333
full_suite_list() {
34-
find hack/e2e-chainsaw -mindepth 2 \
34+
find hack/e2e-chainsaw -mindepth 2 ! -type d \
3535
| sed -nE 's,^hack/e2e-chainsaw/([^/]+)/(.*/)?(chainsaw-test|[0-9]+-[^/]*)\.ya?ml$,\1,p' \
3636
| sort -u | paste -sd ' ' -
3737
}
@@ -830,9 +830,16 @@ assert_full_suite() {
830830
: > "$tmp/tree/hack/e2e-chainsaw/gamma/01-assert.yml"
831831
# Not a step file: the number has to lead the name.
832832
: > "$tmp/tree/hack/e2e-chainsaw/delta/install-01.yaml"
833+
# Not a step file either: Chainsaw skips directories. It keeps a symlink,
834+
# though, because a symlink's directory entry is not a directory.
835+
mkdir -p "$tmp/tree/hack/e2e-chainsaw/theta/01-x.yaml" "$tmp/tree/hack/e2e-chainsaw/iota" \
836+
"$tmp/tree/hack/e2e-chainsaw/kappa"
837+
ln -s ../alpha/chainsaw-test.yaml "$tmp/tree/hack/e2e-chainsaw/iota/01-link.yaml"
838+
# Step files spelled .yml alone make a suite too.
839+
: > "$tmp/tree/hack/e2e-chainsaw/kappa/01-install.yml"
833840
echo go.mod > "$tmp/diff"
834841
output=$(cd "$tmp/tree" && "$script" "$tmp/diff" "$tmp/sources" 2>/dev/null)
835-
assert_selection "the full suite must include a step-file suite" "$output" "alpha gamma"
842+
assert_selection "the full suite must include a step-file suite" "$output" "alpha gamma iota kappa"
836843
echo hack/e2e-chainsaw/gamma/01-install.yaml > "$tmp/diff"
837844
output=$(cd "$tmp/tree" && "$script" "$tmp/diff" "$tmp/sources")
838845
assert_selection "a per-suite edit must select a step-file suite" "$output" "gamma"

‎hack/select-install.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ deps_of() {
108108
# spelled. It is captured on its own because a pipeline reports sort's status,
109109
# and a failed listing must not read as an empty suites dir.
110110
discover_suites() {
111-
found=$(cd "$1" && find . -mindepth 2) || return 1
111+
found=$(cd "$1" && find . -mindepth 2 ! -type d) || return 1
112112
printf '%s\n' "$found" \
113113
| sed -nE 's,^\./([^/]+)/(.*/)?(chainsaw-test|[0-9]+-[^/]*)\.ya?ml$,\1,p' | sort -u
114114
}

‎hack/select-install_test.bats‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,12 @@ YAML
205205

206206
@test "validate sees a suite made only of numbered step files" {
207207
# Chainsaw runs a directory of 01-*.yaml step files as a suite when it holds
208-
# no chainsaw-test.*, so the mapping check has to see that layout too.
208+
# no chainsaw-test.*, so the mapping check has to see that layout too. The
209+
# step file is a symlink because Chainsaw counts one.
209210
tmp=$(mktemp -d)
210211
mkdir -p "$tmp/suites/totally-unmapped-suite"
211-
: > "$tmp/suites/totally-unmapped-suite/00-install.yaml"
212+
: > "$tmp/install.yaml"
213+
ln -s "$tmp/install.yaml" "$tmp/suites/totally-unmapped-suite/00-install.yaml"
212214
err=$(hack/select-install.sh --validate packages/core/platform/sources "$tmp/suites" 2>&1 1>/dev/null) && {
213215
echo "expected validation to fail on an unmapped step-file suite" >&2
214216
exit 1
@@ -217,6 +219,16 @@ YAML
217219
rm -rf "$tmp"
218220
}
219221

222+
@test "validate ignores a directory named like a step file" {
223+
# Chainsaw skips only directory entries that are directories, so a
224+
# directory named 01-x.yaml makes nothing a suite and needs no mapping.
225+
tmp=$(mktemp -d)
226+
mkdir -p "$tmp/suites/postgres" "$tmp/suites/totally-unmapped-suite/01-x.yaml"
227+
: > "$tmp/suites/postgres/chainsaw-test.yaml"
228+
hack/select-install.sh --validate packages/core/platform/sources "$tmp/suites"
229+
rm -rf "$tmp"
230+
}
231+
220232
@test "validate sees a suite nested below a top-level directory" {
221233
# Chainsaw walks every directory under the one it is handed, so a test in a
222234
# subdirectory runs as part of its top-level directory, which then needs a

0 commit comments

Comments
 (0)