mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
ci: keep the CI-only Go tools from escalating builds and e2e
cmd/backport-batch and cmd/api-gate are built into no image and run nowhere in the e2e sandbox, yet a change to either rebuilt every image and ran the full Chainsaw suite, and widened a package change made in the same pull request to everything. Every other directory under cmd/ is a shipped binary and keeps escalating. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
4 files changed
+52
-3
No files matched your search
@@ -67,7 +67,13 @@ if [ -z "$CHANGED" ] || [ "$CHANGED" = "FULL" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if grep -qE "$full_rebuild_pattern" "$CHANGED"; then
|
||||
# CI-only Go tools that no image builds. Dropped before the full-rebuild check,
|
||||
# whose cmd/ would otherwise rebuild everything for an edit no image contains.
|
||||
# hack/select-e2e.sh skips the same two, and a diff made only of them and docs/
|
||||
# never reaches this script's build jobs (the plan job's `code` is false).
|
||||
tooling_pattern='^cmd/(backport-batch|api-gate)/'
|
||||
|
||||
if grep -vE "$tooling_pattern" "$CHANGED" | grep -qE "$full_rebuild_pattern"; then
|
||||
emit_json "$units"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -97,6 +97,23 @@ load test_helper
|
||||
rm -f "$tmp"
|
||||
}
|
||||
|
||||
@test "the CI-only tools do not force the full matrix" {
|
||||
tmp=$(mktemp)
|
||||
# No image builds cmd/backport-batch or cmd/api-gate, so they select nothing
|
||||
# and leave the rest of the diff to its own rules.
|
||||
printf '%s\n' cmd/backport-batch/report_test.go cmd/api-gate/main.go > "$tmp"
|
||||
out=$(hack/build-matrix.sh "$tmp")
|
||||
[ "$out" = '[]' ]
|
||||
printf '%s\n' cmd/backport-batch/main.go packages/apps/mariadb/Makefile > "$tmp"
|
||||
out=$(hack/build-matrix.sh "$tmp")
|
||||
[ "$out" = '["packages/apps/mariadb"]' ]
|
||||
# Every other cmd/ directory is a shipped binary and still rebuilds all.
|
||||
printf '%s\n' cmd/backport-batch/main.go cmd/cozystack-api/main.go > "$tmp"
|
||||
out=$(hack/build-matrix.sh "$tmp")
|
||||
[ "$out" = "$(hack/build-matrix.sh)" ]
|
||||
rm -f "$tmp"
|
||||
}
|
||||
|
||||
@test "a package with no image target selects nothing" {
|
||||
tmp=$(mktemp)
|
||||
# postgres ships no in-repo image build, so it is not a build unit.
|
||||
|
||||
+11
-2
@@ -8,8 +8,9 @@
|
||||
# Output:
|
||||
# - empty no E2E impact, decided by one of the rules that select
|
||||
# nothing: step 1 for docs/, dashboards/ and *.md, step 2 for
|
||||
# a *.disabled Chainsaw suite and for an
|
||||
# examples/backups/<app>/ with no suite, and
|
||||
# a *.disabled Chainsaw suite, for an
|
||||
# examples/backups/<app>/ with no suite and for the CI-only
|
||||
# tools cmd/backport-batch/ and cmd/api-gate/, and
|
||||
# inert_config_pattern for repo meta and agent config
|
||||
# - <suite names> selected per the PackageSource dependency graph
|
||||
# - full list any path that affects all tests, OR an unrecognised
|
||||
@@ -497,6 +498,14 @@ while IFS= read -r file || [ -n "$file" ]; do
|
||||
echo "select-e2e: '$file' belongs to no single backup walkthrough — escalating to the full suite" >&2
|
||||
trigger_full=1
|
||||
continue ;;
|
||||
cmd/backport-batch/*|cmd/api-gate/*)
|
||||
# CI-only Go tools. No image builds them and nothing in the e2e sandbox
|
||||
# runs them, so an edit cannot regress a suite. Matched here because
|
||||
# full_suite_pattern takes all of cmd/ and is checked before the inert
|
||||
# list. The plan job's `code` output and e2e-fork.yaml skip e2e for a
|
||||
# diff made only of these and docs/; this arm keeps them from escalating
|
||||
# a diff that also touches something else.
|
||||
continue ;;
|
||||
esac
|
||||
|
||||
# 3. Full-suite trigger
|
||||
|
||||
@@ -202,6 +202,23 @@ assert_full_suite() {
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
@test "the CI-only tools select nothing and do not escalate the rest" {
|
||||
tmp=$(mktemp -d)
|
||||
cp -r packages/core/platform/sources "$tmp/sources"
|
||||
printf '%s\n' cmd/backport-batch/report_test.go cmd/api-gate/main.go > "$tmp/diff"
|
||||
output=$(hack/select-e2e.sh "$tmp/diff" "$tmp/sources")
|
||||
[ -z "$output" ]
|
||||
# Beside a package, the package alone decides the selection.
|
||||
printf '%s\n' cmd/backport-batch/main.go packages/apps/postgres/values.yaml > "$tmp/diff"
|
||||
output=$(hack/select-e2e.sh "$tmp/diff" "$tmp/sources")
|
||||
assert_selection "a CI-only tool must not widen a package selection" "$output" "postgres"
|
||||
# Any other cmd/ directory is a shipped binary and still escalates.
|
||||
echo "cmd/cozystack-api/main.go" > "$tmp/diff"
|
||||
output=$(hack/select-e2e.sh "$tmp/diff" "$tmp/sources" 2>/dev/null)
|
||||
assert_full_suite "$output"
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
@test "kubernetes-application maps to the two kubernetes suites" {
|
||||
tmp=$(mktemp -d)
|
||||
cp -r packages/core/platform/sources "$tmp/sources"
|
||||
|
||||
Reference in new issue
Block a user