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
35 changes: 32 additions & 3 deletions .github/scripts/fork-follow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,39 @@ schema_check "$base" "The series"
# 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.
# and the next run (from the new base) would refuse it. So the series gets a commit that lowers each
# one (#325); a count that rose is still refused, as raising one is the owner's review.
seam_refusal="Fork changes to upstream files must stay within the seam lines"
seam_run() { # seam_run BASE [--after-rebase]: the check's exit status; its output in seam-check.log
local status=0 lower=()
rm -f "$logs/seam-lowered.json"
[[ -z "${2:-}" ]] || lower=("$2" --lowered-list "$logs/seam-lowered.json")
node .github/scripts/fork-seam-check.cjs --from-upstream ${lower[@]+"${lower[@]}"} "$1" HEAD > "$logs/seam-check.log" 2>&1 || status=$?
return "$status"
}
seam_check() { # seam_check BASE WHAT [--after-rebase]
local status=0
node .github/scripts/fork-seam-check.cjs --from-upstream ${3:+"$3"} "$1" HEAD > "$logs/seam-check.log" 2>&1 || status=$?
seam_run "$1" ${3:+"$3"} || status=$?
if ((status == 0)) && [[ -f "$logs/seam-lowered.json" ]]; then
local lowered
lowered="$(grep '^Lowered: ' "$logs/seam-check.log" | sed 's/^Lowered: /- /')"
cp "$logs/seam-lowered.json" .github/fork-seams.json
git add -- .github/fork-seams.json
as_fork commit -q -m "fork seams: lower counts after the rebase onto $target_tag" -m "$lowered"
printf '%s\n' "$2 lowered the seam list (.github/fork-seams.json) in a commit of its own:" "$lowered" >&2
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
printf '%s\n' "### Seam list lowered: $2" "" "$lowered" "" \
"Committed into the series; the fork lines or upstream lines these counted are gone." \
"" >> "$GITHUB_STEP_SUMMARY"
fi
# The lowered list is judged again: it must pass and lower nothing more.
status=0
seam_run "$1" ${3:+"$3"} || status=$?
if ((status == 0)) && [[ -f "$logs/seam-lowered.json" ]]; then
fail "The seam list fork-follow lowered still lowers again, so it was not committed as checked:" \
"$(quoted "$(cat "$logs/seam-check.log")")" "" "The series was left as it is."
fi
fi
if ((status == 0)); then
local notes
notes="$(grep '^Note: ' "$logs/seam-check.log" || true)"
Expand All @@ -206,7 +234,7 @@ seam_check() { # seam_check BASE WHAT [--after-rebase]
# 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." \
"A ceiling or count still named here (one fork-follow could not lower) is refused by the next run; fix it with a pull request to main (docs/fork/updates.md)." \
"" >> "$GITHUB_STEP_SUMMARY"
fi
return 0
Expand Down Expand Up @@ -555,6 +583,7 @@ candidate="$(git rev-parse HEAD)"
# says what to do about a workflow.
refuse_upstream_fork_named "$target" "$target_tag" "$candidate"
seam_check "$target" "After rebasing onto $target_tag, the series" --after-rebase
candidate="$(git rev-parse HEAD)" # The seam check may have committed a lowered list.
refuse_outside_workflows "$base" "$target" "$target_tag" "$candidate"
dropped="$(comm -23 <(sort <<< "$before") <(git log --format=%s "$target..HEAD" | sort) | paste -sd ';' -)"

Expand Down
28 changes: 17 additions & 11 deletions .github/scripts/fork-follow.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -629,26 +629,32 @@ for yes in yes on 1; do
done

# Upstream adopts a "pending" fork line word for word: the rebase drops it, so the series is below
# its ceiling. Lowering the ceiling first fails the check on the old base, so after a rebase the
# ceiling is only a note; the next run, from the new base, refuses it (a pull request lowers it).
# its ceiling. Lowering the ceiling first fails the check on the old base, and left as it is the
# next run (from the new base) refuses it: so after a rebase the plan commits the lowered list into
# the series (#325), and the next run passes.
new_upstream
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
(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'
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"'
lowered_list() { git -C "$root/work" show "$(out candidate):.github/fork-seams.json"; }
check "plan: upstream taking a pending fork line rebases, lowering the list in a commit of its own" \
eval 'action_is rebase && grep -q "lowered the seam list" "$root/out" \
&& [[ "$(git -C "$root/work" log -1 --format=%s "$(out candidate)")" == "fork seams: lower counts after the rebase onto v0.1.11" ]] \
&& [[ "$(node -e "console.log(JSON.stringify(JSON.parse(process.argv[1])))" "$(lowered_list)")" == "{\"files\":{},\"pending\":{}}" ]]'
check "plan: the lowering commit names each change in its body" \
eval 'grep -qx -- "- u2.txt: \"pending\" 1 removed (no fork line left)" <<< "$(git -C "$root/work" log -1 --format=%b "$(out candidate)")"'
# The plan log is seen only on a failure; what was lowered also goes to the run's summary.
check "plan: the lowered list is also in the step summary" \
eval 'has "### Seam list lowered" "$root/summary.md" && has "u2.txt: \"pending\" 1 removed" "$root/summary.md" && hasnt "lower it with a pull request" "$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
check "plan: the next run from the new base refuses the ceiling, naming the fix" \
eval 'has "u2.txt: \"pending\" with no fork lines left" "$root/report.md" && has "Lower each \"pending\" ceiling" "$root/report.md" && hasnt "a file of the fork" "$root/report.md" && [[ -z "$(out action)" ]]'
check "plan: the next run from the new base passes the lowered list" \
eval 'action_is release && [[ ! -e "$root/report.md" ]] && hasnt "Note: " "$root/out"'

in_candidate() { git -C "$root/work" cat-file -e "$(out candidate):.github/workflows/$1" 2> /dev/null; }

Expand Down
Loading
Loading