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
21 changes: 16 additions & 5 deletions .github/scripts/fork-follow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,26 @@ schema_check() { # schema_check BASE WHAT: fails with the check's output, a refu
schema_check "$base" "The series"

# Fork lines in upstream files (.github/fork-seams.json): only the pinned seams, so every fork
# setting stays in the fork's own files. Exit 1 is a refusal; anything else is a crash. After a
# rebase (--after-rebase), a "pending" ceiling above the file's fork lines is only a note: upstream
# taking a fork line drops it in the rebase, and the next run (from the new base) refuses it.
# setting stays in the fork's own files. Exit 1 is a refusal; anything else is a crash. BASE is an
# upstream commit, which --from-upstream says (the series' own list judges it, even when upstream
# is a fork with a list of its own). After a rebase (--after-rebase), a "pending" ceiling or "lost"
# count above the file's lines is only a note: upstream taking a fork line drops it in the rebase,
# and the next run (from the new base) refuses it.
seam_refusal="Fork changes to upstream files must stay within the seam lines"
seam_check() { # seam_check BASE WHAT [--after-rebase]
local status=0
node .github/scripts/fork-seam-check.cjs ${3:+"$3"} "$1" HEAD > "$logs/seam-check.log" 2>&1 || status=$?
node .github/scripts/fork-seam-check.cjs --from-upstream ${3:+"$3"} "$1" HEAD > "$logs/seam-check.log" 2>&1 || status=$?
if ((status == 0)); then
grep '^Note: ' "$logs/seam-check.log" >&2 || true
local notes
notes="$(grep '^Note: ' "$logs/seam-check.log" || true)"
[[ -n "$notes" ]] || return 0
printf '%s\n' "$notes" >&2
# The log is seen only when the plan fails: the notes go to the run's summary too.
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
printf '%s\n' "### Seam check notes: $2" "" "$(sed 's/^Note: /- /' <<< "$notes")" "" \
"A ceiling or count named here is refused by the next run; lower it with a pull request to main." \
"" >> "$GITHUB_STEP_SUMMARY"
fi
return 0
fi
if ((status == 1)) && grep -qF "$seam_refusal" "$logs/seam-check.log"; then
Expand Down
15 changes: 11 additions & 4 deletions .github/scripts/fork-follow.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ new_fork() {
work() { (cd "$root/work" && "$@" > /dev/null 2>&1); }
fork_tag() { work git tag -f "$1" "${2:-HEAD}" && work git push -q --force origin "refs/tags/$1"; }

plan() { # runs the plan in $root/work; output in $root/plan.out, report in $root/report.md
rm -f "$root/report.md" "$root/plan.out"
(cd "$root/work" && REPORT="$root/report.md" GITHUB_OUTPUT="$root/plan.out" bash "$dir/fork-follow.sh") > "$root/out" 2>&1
plan() { # runs the plan in $root/work; output in $root/plan.out, report in $root/report.md, step summary in $root/summary.md (first $summary_before, if set)
rm -f "$root/report.md" "$root/plan.out" "$root/summary.md"
[[ -z "${summary_before:-}" ]] || printf '%s\n' "$summary_before" > "$root/summary.md"
(cd "$root/work" && REPORT="$root/report.md" GITHUB_OUTPUT="$root/plan.out" GITHUB_STEP_SUMMARY="$root/summary.md" \
bash "$dir/fork-follow.sh") > "$root/out" 2>&1
}
out() { sed -n "s/^$1=//p" "$root/plan.out" 2> /dev/null | tail -n1; }
action_is() { [[ "$(out action)" == "$1" ]]; }
Expand Down Expand Up @@ -439,9 +441,14 @@ new_fork v0.1.10
(cd "$root/work" && echo '{"files":{},"pending":{"u2.txt":1}}' > .github/fork-seams.json && echo "fork pending line" >> u2.txt \
&& git add -A && git commit -q --amend --no-edit && git push -q --force origin main) > /dev/null 2>&1
up_release v0.1.11 'echo "fork pending line" >> u2.txt'
plan
summary_before="earlier step line" plan
check "plan: upstream taking a pending fork line rebases, noting the ceiling" \
eval 'action_is rebase && grep -q "Note: u2.txt: \"pending\" with no fork lines left" "$root/out"'
# The plan log is seen only on a failure; the note also goes to the run's summary.
check "plan: the after-rebase note is also in the step summary" \
eval 'has "u2.txt: \"pending\" with no fork lines left" "$root/summary.md" && has "lower it with a pull request to main" "$root/summary.md"'
# The runner's summary file may already hold lines: the notes are added, never written over.
check "plan: the step summary notes are added after what was there" has "earlier step line" "$root/summary.md"
work git reset -q --hard "$(out candidate)"
work git push -q --force origin HEAD:main
plan
Expand Down
Loading
Loading