Skip to content

Commit fc08057

Browse files
noreplyclaude
andcommitted
fork-follow: guard per run attempt, refuse the branch move while a new upstream workflow is unlisted
"Re-run failed jobs" and "Re-run job" keep the Guard job's result from an earlier attempt without running it again. The guard now outputs the attempt it passed in (set only after the guard script), and plan and advance run only when that is this attempt: a job-level if, so a skipped job never reaches the Environment. The report says to re-run all jobs. Before the branch move, advance checks the Environment's rule again (fork-follow-guard.sh --environment-only), because the release can take an hour or more. The Environment ties the token to the branch main, not to fork-follow.yml, so any workflow file on main may ask for it. The plan names the upstream workflow files that are new on the target release (a rename counts as new). Advance sweeps before the push, and refuses to move main while one of them is in the candidate and GitHub does not list it, since it cannot be disabled first. The reason says how a person moves main, or that a fork patch can delete the files. The sweep names only the new files as unregistered (with a warning). Unlisted files from earlier releases, most of which only run on events the fork never sends, go to unregistered_old and into a collapsed note in the summary. Tests: the plan's only job-level if is this attempt's guard (always(), !cancelled() and failure() turn it red); advance needs this attempt's guard; a pattern series branch with the matching rule is refused; new vs old unlisted files; the refusal before the move; the report on a stale guard. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b898efc commit fc08057

6 files changed

Lines changed: 227 additions & 28 deletions

File tree

‎.github/scripts/fork-follow-guard.sh‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
# SERIES_BRANCH, written without wildcards. "Protected branches only" is refused, because the
1414
# API cannot prove that no other branch is protected (or becomes protected later).
1515
#
16+
# `fork-follow-guard.sh --environment-only` makes check 2 alone. The job that moves the series
17+
# branch runs it right before the push, because that can be an hour or more after the Guard job
18+
# looked. Check 1 cannot be made there: inside the Environment, `secrets.FORK_PUSH_TOKEN` is the
19+
# Environment's own secret.
20+
#
1621
# Environment: REPOSITORY (owner/name; GITHUB_REPOSITORY in a run), FORK_PUSH_ENVIRONMENT,
1722
# SERIES_BRANCH (default main), REPO_SECRET_PRESENT, REPORT (receives the reason on refusal). Reads
1823
# the Environment with `gh api` (GH_TOKEN: GITHUB_TOKEN with actions: read is enough).
@@ -34,7 +39,13 @@ die() {
3439
exit 1
3540
}
3641

37-
case "${REPO_SECRET_PRESENT:-}" in
42+
case "${1:-}" in
43+
"") secret_check=true ;;
44+
--environment-only) secret_check=false ;;
45+
*) echo "usage: $0 [--environment-only]" >&2; exit 2 ;;
46+
esac
47+
48+
[[ "$secret_check" == false ]] || case "${REPO_SECRET_PRESENT:-}" in
3849
false) ;;
3950
true)
4051
die "A repository or organisation secret named FORK_PUSH_TOKEN exists, so this run does not use the token." \
@@ -84,4 +95,8 @@ if [[ "$rules" != "branch $SERIES_BRANCH" ]] || [[ "$SERIES_BRANCH" == *[][*?]*
8495
"Under $settings keep exactly one rule, branch $SERIES_BRANCH, and delete the others (a tag rule or a pattern lets other refs deploy too)."
8596
fi
8697

87-
echo "FORK_PUSH_TOKEN is only an Environment secret, and only $SERIES_BRANCH may deploy to $env_name."
98+
if [[ "$secret_check" == true ]]; then
99+
echo "FORK_PUSH_TOKEN is only an Environment secret, and only $SERIES_BRANCH may deploy to $env_name."
100+
else
101+
echo "Only $SERIES_BRANCH may deploy to $env_name (the repository secret was checked by the Guard job)."
102+
fi

‎.github/scripts/fork-follow-report.sh‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
# repository has Issues enabled it also opens or comments on one issue, "Fork cannot follow
88
# upstream", and closes it once a run succeeds; with Issues disabled it says so and opens none.
99
#
10-
# Environment (from the run): REPOSITORY, SERIES_BRANCH, RUN_URL, ACTION, GUARD_RESULT, PLAN_RESULT,
11-
# RELEASE_RESULT, ADVANCE_RESULT, BASE_TAG, PREVIOUS_TAG, PREVIOUS_HEAD, CANDIDATE, RELEASED_TAG,
12-
# DROPPED, DISABLED, CANCELLED, FINISHED, UNREGISTERED (from the workflow sweeps), SWEEP_RESULT,
10+
# Environment (from the run): REPOSITORY, SERIES_BRANCH, RUN_URL, ACTION, GUARD_RESULT,
11+
# GUARD_ATTEMPT (the run attempt the guard passed in), RUN_ATTEMPT, PLAN_RESULT, RELEASE_RESULT,
12+
# ADVANCE_RESULT, BASE_TAG, PREVIOUS_TAG, PREVIOUS_HEAD, CANDIDATE, RELEASED_TAG, DROPPED, DISABLED,
13+
# CANCELLED, FINISHED, UNREGISTERED, UNREGISTERED_OLD (from the workflow sweeps), SWEEP_RESULT,
1314
# REPORTS (directory of the jobs' reason files), ORIGIN (git URL of this fork, default GitHub).
1415
# Summary to $GITHUB_STEP_SUMMARY, else stdout.
1516
set -uo pipefail
@@ -31,12 +32,25 @@ done
3132
[[ "$ACTION" != stage ]] || failed=true
3233
[[ "${SWEEP_RESULT:-success}" != failure ]] || failed=true
3334

35+
# A re-run of failed jobs (or of one job) keeps the guard's result from an earlier attempt; the jobs
36+
# that get FORK_PUSH_TOKEN skip themselves then. Say so whenever one of them was skipped for it.
37+
stale_guard=false
38+
if [[ "${GUARD_RESULT:-success}" == success && -n "${GUARD_ATTEMPT:-}" && -n "${RUN_ATTEMPT:-}" \
39+
&& "$GUARD_ATTEMPT" != "$RUN_ATTEMPT" ]]; then
40+
if [[ "${PLAN_RESULT:-}" == skipped ]] \
41+
|| [[ "${ADVANCE_RESULT:-skipped}" == skipped && ( "$ACTION" == advance || "$ACTION" == rebase ) ]]; then
42+
stale_guard=true
43+
failed=true
44+
fi
45+
fi
46+
3447
# The sweeps' lists arrive joined with ','; drop the empty parts and repeats.
3548
tidy() { tr ',' '\n' <<< "$1" | sed '/^$/d' | awk '!seen[$0]++' | paste -sd, -; }
3649
DISABLED="$(tidy "${DISABLED:-}")"
3750
CANCELLED="$(tidy "${CANCELLED:-}")"
3851
FINISHED="$(tidy "${FINISHED:-}")"
3952
UNREGISTERED="$(tidy "${UNREGISTERED:-}")"
53+
UNREGISTERED_OLD="$(tidy "${UNREGISTERED_OLD:-}")"
4054

4155
state=()
4256
row() { state+=("| $1 | $2 |"); }
@@ -98,10 +112,13 @@ fi
98112
[[ -z "${CANCELLED:-}" ]] || row "Their runs cancelled" "${CANCELLED//,/, }"
99113
[[ -z "${FINISHED:-}" ]] || row "**Upstream runs that finished before a sweep could stop them**" "${FINISHED//,/, }"
100114
[[ -z "${UNREGISTERED:-}" ]] \
101-
|| row "**Upstream workflow files GitHub does not list yet, so not disabled** (the sweep after their first run disables them)" "${UNREGISTERED//,/, }"
115+
|| row "**Upstream workflow files new on this release that GitHub does not list yet, so not disabled** (the sweep after an event reaches them disables them; the branch move waits for that)" "${UNREGISTERED//,/, }"
102116
[[ -z "${DROPPED:-}" ]] || row "Patches dropped (empty on $BASE_TAG: upstream has the change)" "${DROPPED//;/, }"
103117

104118
reasons=""
119+
if [[ "$stale_guard" == true ]]; then
120+
reasons+="This is attempt $RUN_ATTEMPT of the run, but the guard passed in attempt $GUARD_ATTEMPT: \"Re-run failed jobs\" and \"Re-run job\" keep the guard's earlier result without checking again, so the jobs that get FORK_PUSH_TOKEN were skipped. Use \"Re-run all jobs\", or start a new run (\`gh workflow run fork-follow.yml --repo $REPOSITORY\`)."$'\n\n'
121+
fi
105122
if [[ -n "$REPORTS" && -d "$REPORTS" ]]; then
106123
for file in "$REPORTS"/*.md; do
107124
[[ -f "$file" ]] && reasons+="$(cat "$file")"$'\n\n'
@@ -116,6 +133,8 @@ case "$ACTION" in
116133
stage) what="Push the candidate on ${BASE_TAG:-?}; its release needs its own workflow files." ;;
117134
*) if [[ "${GUARD_RESULT:-success}" != success ]]; then
118135
what="None: the guard refused, so no job got FORK_PUSH_TOKEN."
136+
elif [[ "$stale_guard" == true ]]; then
137+
what="None: the guard did not run in this attempt, so no job got FORK_PUSH_TOKEN."
119138
else
120139
what="The plan did not finish."
121140
fi ;;
@@ -142,6 +161,14 @@ body="$(mktemp)"
142161
echo "| What | State now |"
143162
echo "|---|---|"
144163
printf '%s\n' "${state[@]}"
164+
if [[ -n "$UNREGISTERED_OLD" ]]; then
165+
echo
166+
echo "<details><summary>Upstream workflow files from earlier releases that GitHub does not list (not a warning)</summary>"
167+
echo
168+
echo "Most of them run only on events this fork never sends (workflow_call, workflow_dispatch, workflow_run), so they stay unlisted. A sweep disables one once an event reaches it: ${UNREGISTERED_OLD//,/, }"
169+
echo
170+
echo "</details>"
171+
fi
145172
} > "$body"
146173

147174
# --- the issue, when the repository has Issues ---------------------------------------------------

‎.github/scripts/fork-follow.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
# dropped subjects of patches that became empty on the new base (';'-separated)
2525
# own_workflows workflow files the series itself adds (','-separated); every other one is
2626
# upstream's and gets disabled
27+
# new_workflows upstream workflow files added between the series' old base and the new one
28+
# (','-separated; empty without a new base). The branch move refuses while one of
29+
# them is not listed by GitHub yet, so it cannot be disabled before main has it.
2730
set -Eeuo pipefail
2831

2932
: "${UPSTREAM:?owner/name of the upstream repository}"
@@ -152,6 +155,10 @@ latest_release() {
152155
own_workflows() {
153156
git diff --name-only --diff-filter=A "$1" "$2" -- .github/workflows | paste -sd, -
154157
}
158+
new_workflows() { # upstream workflow files added from upstream commit $1 to $2 (a rename counts as new)
159+
git diff --no-renames --name-only --diff-filter=A "$1" "$2" -- .github/workflows \
160+
| { grep -E '\.ya?ml$' || true; } | paste -sd, -
161+
}
155162

156163
# The release job runs the reusable workflows of this run's commit (RUN_SHA), not the candidate's.
157164
# They differ after upstream changed them, and on a re-run (or a queued run) of a run whose commit
@@ -214,6 +221,7 @@ if [[ "$target_tag" == "$base_tag" ]]; then
214221
echo "candidate=$head"
215222
echo "released_tag=${released_tag:-}"
216223
echo "own_workflows=$(own_workflows "$base" HEAD)"
224+
echo "new_workflows="
217225
} >> "$OUTPUT"
218226
exit 0
219227
fi
@@ -264,4 +272,5 @@ fi
264272
echo "released_tag=${released_tag:-}"
265273
echo "dropped=$dropped"
266274
echo "own_workflows=$(own_workflows "$target" "$candidate")"
275+
echo "new_workflows=$(new_workflows "$base" "$target")"
267276
} >> "$OUTPUT"

‎.github/scripts/fork-follow.test.sh‎

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,21 @@ work git reset -q --hard "$(series)"
279279
plan
280280
check "plan: a release of different files does not count -> rebase" action_is rebase
281281

282+
# Round 3: upstream workflow files new on the target release are named, so the branch move can
283+
# refuse while GitHub does not list one. A rename counts as new; a same-base plan names none.
284+
new_upstream
285+
(cd "$root/upwork" && git checkout -q main && echo "on: push" > .github/workflows/nightly.yml \
286+
&& git mv .github/workflows/ci.yml .github/workflows/ci-v2.yml && git add -A && git commit -q -m u5 \
287+
&& git tag v0.1.11 && git push -q https://github.com/up/t3code.git main --tags) > /dev/null 2>&1
288+
new_fork v0.1.10
289+
plan
290+
check "plan: a rebase names the upstream workflow files new on the target release (a rename too)" \
291+
eval 'action_is rebase && [[ "$(out new_workflows)" == .github/workflows/ci-v2.yml,.github/workflows/nightly.yml ]]'
292+
new_fork v0.1.11
293+
plan
294+
check "plan: same base -> no new upstream workflow files" \
295+
eval 'action_is release && grep -qx "new_workflows=" "$root/plan.out"'
296+
282297
# Minor: upstream changed a reusable workflow the release calls; the run's own copy is older.
283298
new_upstream
284299
(cd "$root/upwork" && git checkout -q main && echo "on: workflow_call # v2" > .github/workflows/release-desktop.yml \
@@ -412,14 +427,24 @@ echo '{"total_count":1,"branch_policies":[{"id":1,"name":"main*","type":"branch"
412427
check "guard: a pattern rule (main*) -> refused" eval '! guard && has "main\*" "$root/report.md"'
413428
echo '{"total_count":0,"branch_policies":[]}' > "$root/api/branch-policies.json"
414429
check "guard: no rule at all -> refused" eval '! guard && has "(none)" "$root/report.md"'
430+
# Round 3: a series branch that is itself a pattern, with the matching rule, is still refused.
431+
echo '{"total_count":1,"branch_policies":[{"id":1,"name":"main*","type":"branch"}]}' > "$root/api/branch-policies.json"
432+
check "guard: a series branch that is a pattern (main*), even with the rule 'branch main*' -> refused" \
433+
eval '! SERIES_BRANCH="main*" guard && has "must let only the branch main\*" "$root/report.md"'
434+
good_env
435+
check "guard: --environment-only (before the branch move) passes without the secret answer" \
436+
eval 'REPO_SECRET_PRESENT= REPORT="$root/report.md" FORK_PUSH_ENVIRONMENT=fork-push bash "$dir/fork-follow-guard.sh" --environment-only > "$root/out" 2>&1'
437+
echo '{"name":"fork-push","deployment_branch_policy":null}' > "$root/api/environment.json"
438+
check "guard: --environment-only still refuses an Environment any branch may deploy to" \
439+
eval '! REPORT="$root/report.md" FORK_PUSH_ENVIRONMENT=fork-push bash "$dir/fork-follow-guard.sh" --environment-only > "$root/out" 2>&1 && has "Any branch may deploy" "$root/report.md"'
415440
good_env
416441
touch "$root/api/fail_environments"
417442
check "guard: the Environment cannot be read -> refused with gh's reason" \
418443
eval '! guard && has "Could not read the Environment" "$root/report.md" && has "502" "$root/report.md"'
419444
unset REPO_SECRET_PRESENT
420445

421446
# --- workflows: fork-workflows.sh ------------------------------------------------------------
422-
sweep() { REPORT="$root/report.md" GITHUB_OUTPUT="$root/sweep.out" bash "$dir/fork-workflows.sh" > "$root/out" 2>&1; }
447+
sweep() { rm -f "$root/sweep.out"; REPORT="$root/report.md" GITHUB_OUTPUT="$root/sweep.out" bash "$dir/fork-workflows.sh" > "$root/out" 2>&1; }
423448
reset_api
424449
cat > "$root/api/workflows.json" << 'J'
425450
{"workflows":[
@@ -454,8 +479,18 @@ check "workflows: an upstream run from another event and commit (pull_request_ta
454479
eval 'has "runs/14/cancel" "$root/api/writes" && [[ $(grep -c cancel "$root/api/writes") == 2 ]]'
455480
check "workflows: upstream runs that finished before the sweep are named with event and conclusion; own and cancelled ones are not" \
456481
eval '[[ "$(sed -n "s/^finished=//p" "$root/sweep.out")" == "13 (.github/workflows/relay-preview.yml: success after push)" ]]'
457-
check "workflows: upstream workflow files GitHub does not list yet are named, not called disabled" \
458-
eval '[[ "$(sed -n "s/^unregistered=//p" "$root/sweep.out")" == ".github/workflows/release.yml" ]] && has "does not list yet" "$root/out"'
482+
check "workflows: an unlisted upstream file from an earlier release is named apart, with no warning" \
483+
eval '[[ -z "$(sed -n "s/^unregistered=//p" "$root/sweep.out")" && "$(sed -n "s/^unregistered_old=//p" "$root/sweep.out")" == ".github/workflows/release.yml" ]] && hasnt "::warning::.*does not list yet" "$root/out"'
484+
rm -f "$root/api/writes"
485+
OWN_WORKFLOWS=.github/workflows/fork-follow.yml,.github/workflows/fork-tests.yml HEAD_SHA=abc NEW_WORKFLOWS=.github/workflows/release.yml sweep
486+
check "workflows: an unlisted upstream file new on this release is named with a warning, not called disabled" \
487+
eval '[[ "$(sed -n "s/^unregistered=//p" "$root/sweep.out")" == ".github/workflows/release.yml" && -z "$(sed -n "s/^unregistered_old=//p" "$root/sweep.out")" ]] && has "::warning::.*new on this release.*does not list yet" "$root/out"'
488+
rm -f "$root/api/writes" "$root/report.md"
489+
check "workflows: before the move, a new unlisted upstream file refuses it, after disabling the listed ones" \
490+
eval '! OWN_WORKFLOWS=.github/workflows/fork-follow.yml HEAD_SHA=abc NEW_WORKFLOWS=.github/workflows/release.yml REQUIRE_NEW_OFF=true sweep && has "main was not moved" "$root/report.md" && has "release.yml" "$root/report.md" && has "A person decides" "$root/report.md" && has "workflows/2/disable" "$root/api/writes"'
491+
rm -f "$root/report.md"
492+
check "workflows: before the move, a new upstream file GitHub lists (now disabled) and older unlisted ones do not refuse it" \
493+
eval 'OWN_WORKFLOWS=.github/workflows/fork-follow.yml HEAD_SHA=abc NEW_WORKFLOWS=.github/workflows/web-preview.yml REQUIRE_NEW_OFF=true sweep && [[ ! -e "$root/report.md" ]]'
459494
reset_api
460495
OWN_WORKFLOWS="" sweep
461496
check "workflows: an empty own list disables nothing (refusing to guess)" eval '[[ ! -e "$root/api/writes" ]] && has "refusing to guess" "$root/report.md"'
@@ -523,6 +558,24 @@ report ACTION=none PLAN_RESULT=success CANDIDATE="$cand" SWEEP_RESULT=success \
523558
FINISHED="13 (.github/workflows/relay-preview.yml: success after push)" UNREGISTERED=".github/workflows/release.yml"
524559
check "report: names upstream runs that finished first and files GitHub does not list yet" \
525560
eval 'has "finished before a sweep could stop them" "$root/summary.md" && has "relay-preview.yml: success after push" "$root/summary.md" && has "does not list yet" "$root/summary.md" && has "release.yml" "$root/summary.md"'
561+
reset_api false
562+
echo '{"draft":false}' > "$root/api/release-v0.1.10-fork.2"
563+
report ACTION=none PLAN_RESULT=success CANDIDATE="$cand" SWEEP_RESULT=success UNREGISTERED_OLD=".github/workflows/publish-aur.yml"
564+
check "report: unlisted upstream files from earlier releases go in a collapsed note, not a bold row, and pass" \
565+
eval '! failed_run && has "<details>" "$root/summary.md" && has "publish-aur.yml" "$root/summary.md" && hasnt "\*\*.*publish-aur" "$root/summary.md"'
566+
# Round 3: "Re-run failed jobs" keeps the guard's earlier result; the token jobs skip themselves.
567+
rm -rf "$root/reports" && mkdir -p "$root/reports"
568+
reset_api false
569+
report ACTION= GUARD_RESULT=success GUARD_ATTEMPT=1 RUN_ATTEMPT=2 PLAN_RESULT=skipped
570+
check "report: the guard passed in an earlier attempt, the plan skipped -> fails, says to re-run all jobs" \
571+
eval 'failed_run && has "did not run in this attempt" "$root/summary.md" && has "Re-run all jobs" "$root/summary.md"'
572+
report ACTION=rebase GUARD_RESULT=success GUARD_ATTEMPT=1 RUN_ATTEMPT=2 PLAN_RESULT=success RELEASE_RESULT=success \
573+
ADVANCE_RESULT=skipped BASE_TAG=v0.1.10 PREVIOUS_HEAD="$prev" CANDIDATE="$cand"
574+
check "report: released, but the move skipped for an earlier attempt's guard -> fails and says why" \
575+
eval 'failed_run && has "guard passed in attempt 1" "$root/summary.md"'
576+
echo '{"draft":false}' > "$root/api/release-v0.1.10-fork.2"
577+
report ACTION=none GUARD_RESULT=success GUARD_ATTEMPT=1 RUN_ATTEMPT=2 PLAN_RESULT=success CANDIDATE="$cand" RELEASED_TAG=v0.1.10-fork.2
578+
check "report: a re-run of the report alone after a good run does not cry wolf" eval '! failed_run'
526579
rm -rf "$root/reports" && mkdir -p "$root/reports"
527580
echo "A repository or organisation secret named FORK_PUSH_TOKEN exists" > "$root/reports/guard.md"
528581
report ACTION= GUARD_RESULT=failure PLAN_RESULT=skipped
@@ -542,8 +595,24 @@ check "workflow: FORK_PUSH_TOKEN reaches only fork-follow-push.sh steps, never a
542595
guard_job="$(sed -n '/^ guard:$/,/^ [a-z_-]*:$/p' "$workflow" | sed '$d')"
543596
check "workflow: a Guard job without an Environment sees only whether a repository/organisation secret exists, and runs the guard" \
544597
eval '[[ -n "$guard_job" ]] && ! grep -q "environment:" <<< "$guard_job" && [[ $(grep -cF "$presence" "$workflow") == 1 ]] && grep -qF "$presence" <<< "$guard_job" && grep -q "fork-follow-guard.sh" <<< "$guard_job" && grep -q "actions: read" <<< "$guard_job"'
545-
check "workflow: the plan (the first job with the token) waits for the guard; advance waits for the plan" \
546-
eval 'sed -n "/^ plan:$/,/^ steps:$/p" "$workflow" | grep -qx " needs: \[guard\]" && sed -n "/^ advance:$/,/^ steps:$/p" "$workflow" | grep -q "^ needs: \[plan"'
598+
plan_head="$(sed -n "/^ plan:$/,/^ steps:$/p" "$workflow")"
599+
advance_head="$(sed -n "/^ advance:$/,/^ steps:$/p" "$workflow")"
600+
attempt_check="needs.guard.outputs.attempt == github.run_attempt"
601+
check "workflow: the plan (the first job with the token) waits for the guard; advance waits for the guard and the plan" \
602+
eval 'grep -qx " needs: \[guard\]" <<< "$plan_head" && grep -qx " needs: \[guard, plan, release\]" <<< "$advance_head"'
603+
# Round 3: the plan's only job-level condition is this attempt's guard, with the implied success():
604+
# always(), !cancelled() or failure() there would let it run after the guard refused.
605+
check "workflow: the plan runs only after a guard that passed in this attempt (no always/cancelled/failure)" \
606+
eval '[[ "$(grep -c "^ if:" <<< "$plan_head")" == 1 ]] && grep -qxF " if: $attempt_check" <<< "$plan_head" && ! grep -qE "always\(\)|cancelled\(\)|failure\(\)" <<< "$plan_head"'
607+
check "workflow: advance needs the plan's success and this attempt's guard" \
608+
eval 'grep -qF "needs.plan.result == '"'"'success'"'"'" <<< "$advance_head" && grep -qF "$attempt_check" <<< "$advance_head" && ! grep -qE "always\(\)|failure\(\)" <<< "$advance_head"'
609+
check "workflow: the guard's attempt output is set only by a step after the guard script" \
610+
eval 'grep -qF "attempt: \${{ steps.passed.outputs.attempt }}" <<< "$guard_job" && awk "/fork-follow-guard.sh/ { g = NR } /id: passed/ { p = NR } /attempt=\\\$GITHUB_RUN_ATTEMPT/ { a = NR } END { exit !(g && p > g && a > p) }" <<< "$guard_job"'
611+
advance_job="$(sed -n '/^ advance:$/,/^ [a-z_-]*:$/p' "$workflow" | sed '$d')"
612+
check "workflow: before the move, advance checks the Environment again and sweeps, refusing new unlisted files" \
613+
eval 'awk "/fork-follow-guard.sh --environment-only/ { g = NR } /REQUIRE_NEW_OFF: \"true\"/ { r = NR } /NEW_WORKFLOWS: .*new_workflows/ && !n { n = NR } /fork-follow-push.sh advance/ { m = NR } END { exit !(g && r && n && m && g < r && r < m && n < m) }" <<< "$advance_job"'
614+
check "workflow: the move step runs only when the checks before it passed (no if:)" \
615+
eval 'awk "/- name: Move the series branch/ { s = 1; next } s && /^ - / { exit } s && /^ if:/ { bad = 1 } END { exit bad }" <<< "$advance_job"'
547616
check "workflow: action none deletes a leftover candidate branch" \
548617
eval 'grep -B2 -A3 "action == .none." "$workflow" | grep -q "fork-follow-push.sh cleanup"'
549618
check "workflow: the last sweep reports runs since the run began" \

0 commit comments

Comments
 (0)