Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,12 @@ https://semver.org/spec/v2.0.0.html[Semantic Versioning].

==== Fixed

* **A `CI/gate` publisher may not filter `workflow_run` by branch.**
GitHub applies `branches` and `branches-ignore` to the triggering run's
branch, so a filtered publisher never posts the status on a PR head and the
PR waits for ever. `check-required-contexts.sh` now refuses any such filter
except `branches: ["**"]`; negative fixtures cover both keys. Ported from
rsr-template-repo#481.
* Julia mints start with Lock Sync green. The julia-library overlay
shipped its own `actions.lock`, which replaced the spine's at mint, so
every spine workflow lost its records. The records now ship beside the
Expand Down
12 changes: 12 additions & 0 deletions scripts/check-required-contexts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ function verifyStatusPublisher(ctx, relWf, fullWf) {
if (!Array.isArray(types) || !types.includes("completed")) {
fail(`status context '${ctx}' publisher '${relWf}' workflow_run types do not include 'completed' (types: ${JSON.stringify(types ?? null)})`);
}
// GitHub applies workflow_run branch filters to the TRIGGERING run's branch, so a filter
// keeps the publisher from running for PR-branch workflows and strands the PR head
// without the status (#219 defect class). Only an all-branches filter is harmless.
if (wr && typeof wr === "object" && Object.hasOwn(wr, "branches")) {
const b = wr.branches;
if (!(Array.isArray(b) && b.length === 1 && b[0] === "**")) {
fail(`status context '${ctx}' publisher '${relWf}' filters workflow_run by branches (${JSON.stringify(b ?? null)}) — strands PR heads whose workflows run on other branches`);
}
}
if (wr && typeof wr === "object" && Object.hasOwn(wr, "branches-ignore")) {
fail(`status context '${ctx}' publisher '${relWf}' filters workflow_run by branches-ignore (${JSON.stringify(wr["branches-ignore"] ?? null)}) — strands PR heads on the ignored branches`);
}
}
const jobs = doc?.jobs && typeof doc.jobs === "object" ? doc.jobs : {};
const callers = [];
Expand Down
9 changes: 9 additions & 0 deletions tests/workflows/squabble_gate_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ fresh_status "$SUITE_REUSABLE@$SUITE_PIN" 'CI/gate' $'on:\n pull_request:'
assert_rc 1 'status mapping: no workflow_run trigger fails' check_status
fresh_status "$SUITE_REUSABLE@$SUITE_PIN" 'CI/gate' $'on:\n workflow_run:\n workflows: ["**"]\n types: [in_progress]'
assert_rc 1 'status mapping: workflow_run without the completed type fails' check_status
# A workflow_run branch filter applies to the triggering run's branch: it strands PR heads.
fresh_status "$SUITE_REUSABLE@$SUITE_PIN" 'CI/gate' $'on:\n workflow_run:\n workflows: ["**", "!CI gate"]\n types: [completed]\n branches: [main]'
assert_rc 1 'status mapping: a completed-only publisher filtered to main fails' check_status
fresh_status "$SUITE_REUSABLE@$SUITE_PIN" 'CI/gate' $'on:\n workflow_run:\n workflows: ["**", "!CI gate"]\n types: [completed]\n branches-ignore: ["dependabot/**"]'
assert_rc 1 'status mapping: a publisher with workflow_run branches-ignore fails' check_status
fresh_status "$SUITE_REUSABLE@$SUITE_PIN" 'CI/gate' $'on:\n workflow_run:\n workflows: ["**", "!CI gate"]\n types: [completed]\n branches: ["**"]'
assert_rc 0 'status mapping: an all-branches workflow_run filter passes' check_status
fresh_status "$SUITE_REUSABLE@$SUITE_PIN" 'CI/other'
assert_rc 1 'status mapping: a wrong with.context fails' check_status
fresh_status "$SUITE_REUSABLE@$SUITE_PIN" 'CI/gate '
Expand Down Expand Up @@ -420,6 +427,8 @@ status_says 'wrong context' 'wrong with.context' "$SUITE_REUSABLE@$SUITE_PIN" 'C
status_says 'foreign reusable' 'has no job whose uses:' "hyperpolymath/other-repo/.github/workflows/ci-gate.yml@$SUITE_PIN"
status_says 'no workflow_run' 'does not trigger on workflow_run' "$SUITE_REUSABLE@$SUITE_PIN" 'CI/gate' $'on:\n pull_request:'
status_says 'no completed type' "do not include 'completed'" "$SUITE_REUSABLE@$SUITE_PIN" 'CI/gate' $'on:\n workflow_run:\n workflows: ["**"]\n types: [in_progress]'
status_says 'branch filter' 'filters workflow_run by branches' "$SUITE_REUSABLE@$SUITE_PIN" 'CI/gate' $'on:\n workflow_run:\n workflows: ["**"]\n types: [completed]\n branches: [main]'
status_says 'branches-ignore filter' 'filters workflow_run by branches-ignore' "$SUITE_REUSABLE@$SUITE_PIN" 'CI/gate' $'on:\n workflow_run:\n workflows: ["**"]\n types: [completed]\n branches-ignore: [main]'
fresh_status
rm "$status_tree/.github/workflows/ci-gate.yml"
check_status >"$WORK/status-msg" 2>&1 || true
Expand Down
Loading