Skip to content

Commit 79f61e6

Browse files
committed
fix(gate): changelog_reachability accepts untagged releases above the newest tag
clojurewasm/ClojureWasm main CI failed on the PR #19 merge (runs 39701804074, 39701800082): the mirror has no v1.15.2 tag (its release job died on a homebrew-tap 403 before tagging), and the CI run raced the release workflow that tags v1.15.3 on that same merge. The newest reachable tag was v1.15.1, the script skipped only the pending [1.15.3] heading, then refused [1.15.2]. Every heading between [Unreleased] and the newest tag's heading is now checked on its own: dated, newer than the newest tag, no newer than build.zig.zon's version, and untagged. A stray or out-of-range heading still fails, and so does a missing heading for the newest tag.
1 parent fdee538 commit 79f61e6

1 file changed

Lines changed: 32 additions & 28 deletions

File tree

‎scripts/check_changelog_reachability.sh‎

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# 1. A shipped release has no heading of its own. v1.14.9, v1.14.10 and
77
# v1.14.11 appended their entries under `## [1.14.8]` and nothing noticed
88
# (fixed by bba2e79f). Every `vX.Y.Z` tag reachable from HEAD, from v1.0.0
9-
# on, must have a `## [X.Y.Z] - YYYY-MM-DD` heading, and the newest tag's
10-
# heading must be the first one after `## [Unreleased]`, or the second when
11-
# the first is the untagged release build.zig.zon names.
9+
# on, must have a `## [X.Y.Z] - YYYY-MM-DD` heading, and only untagged
10+
# releases between the newest tag and the version build.zig.zon names may
11+
# sit between `## [Unreleased]` and the newest tag's heading.
1212
#
1313
# 2. `[Unreleased]` describes something that has already shipped. An entry
1414
# that is also present in the newest tag's own `[Unreleased]` section went
@@ -55,10 +55,10 @@ newest_tag="$(printf '%s\n' "$release_tags" | sed -n 1p)"
5555

5656
# Version of each `## [X.Y.Z] - YYYY-MM-DD` heading, in file order.
5757
dated_headings="$(sed -nE 's/^## \[([0-9]+\.[0-9]+\.[0-9]+)\] - [0-9]{4}-[0-9]{2}-[0-9]{2}$/\1/p' "$CHANGELOG")"
58-
# The first `## ` heading after `## [Unreleased]`, verbatim.
59-
first_after_unreleased="$(awk '
58+
# Every `## ` heading after `## [Unreleased]`, verbatim, in file order.
59+
headings_after_unreleased="$(awk '
6060
/^## \[Unreleased\]/ { seen = 1; next }
61-
seen && /^## / { print; exit }
61+
seen && /^## / { print }
6262
' "$CHANGELOG")"
6363

6464
if [ -z "$newest_tag" ]; then
@@ -82,31 +82,35 @@ else
8282

8383
newest_v="${newest_tag#v}"
8484

85-
# A hand-stamped MINOR/MAJOR heading precedes its tag: allowed only while
86-
# build.zig.zon names that version, it is newer, and no such tag exists.
85+
# A heading above the newest tag's names a release this clone has no tag
86+
# for: the pending one build.zig.zon names (stamped before the release
87+
# workflow tags it, which on a mirror races the CI run on the same merge),
88+
# or one a mirror never tagged (clojurewasm/ClojureWasm has no v1.15.2, its
89+
# release job failed first). Each must be dated, newer than the newest tag,
90+
# no newer than build.zig.zon, and untagged.
8791
pending_v="$(sed -nE 's/^[[:space:]]*\.version = "([0-9]+\.[0-9]+\.[0-9]+)",[[:space:]]*$/\1/p' build.zig.zon 2>/dev/null | sed -n 1p)"
88-
if [ -n "$pending_v" ] \
89-
&& ! git rev-parse -q --verify "refs/tags/v$pending_v" >/dev/null \
90-
&& [ "$(printf '%s\n%s\n' "$newest_v" "$pending_v" | sort -V | sed -n 2p)" = "$pending_v" ] \
91-
&& [ "$pending_v" != "$newest_v" ]; then
92-
case "$first_after_unreleased" in
93-
"## [$pending_v] - "*)
94-
first_after_unreleased="$(awk '
95-
/^## \[Unreleased\]/ { seen = 1; next }
96-
seen && /^## / { n++; if (n == 2) { print; exit } }
97-
' "$CHANGELOG")"
98-
echo "check_changelog_reachability: ok, [$pending_v] is the pending release build.zig.zon names (no v$pending_v tag yet)"
99-
;;
92+
found_newest=0
93+
while IFS= read -r heading; do
94+
[ -n "$heading" ] || continue
95+
case "$heading" in
96+
"## [$newest_v] - "*) found_newest=1; break ;;
10097
esac
98+
hv="$(sed -nE 's/^## \[([0-9]+\.[0-9]+\.[0-9]+)\] - [0-9]{4}-[0-9]{2}-[0-9]{2}$/\1/p' <<<"$heading")"
99+
if [ -n "$hv" ] && [ -n "$pending_v" ] \
100+
&& ! git rev-parse -q --verify "refs/tags/v$hv" >/dev/null \
101+
&& [ "$(printf '%s\n%s\n' "$newest_v" "$hv" | sort -V | sed -n 2p)" = "$hv" ] \
102+
&& [ "$(printf '%s\n%s\n' "$hv" "$pending_v" | sort -V | sed -n 2p)" = "$pending_v" ]; then
103+
echo "check_changelog_reachability: ok, [$hv] is an untagged release between $newest_tag and build.zig.zon's $pending_v"
104+
continue
105+
fi
106+
violation "'$heading' sits above $newest_tag's dated heading but is not an untagged release between $newest_tag and build.zig.zon's ${pending_v:-<none>}."
107+
echo " The newest release goes directly under [Unreleased]." >&2
108+
found_newest=1
109+
break
110+
done <<< "$headings_after_unreleased"
111+
if [ "$found_newest" -eq 0 ]; then
112+
violation "no '## [$newest_v] - YYYY-MM-DD' heading after [Unreleased]."
101113
fi
102-
103-
case "$first_after_unreleased" in
104-
"## [$newest_v] - "*) ;;
105-
*)
106-
violation "the first heading after [Unreleased] is '${first_after_unreleased:-<none>}', not $newest_tag's dated heading."
107-
echo " The newest release goes directly under [Unreleased]." >&2
108-
;;
109-
esac
110114
fi
111115

112116
# ---- 2. nothing under [Unreleased] has already shipped ----------------------

0 commit comments

Comments
 (0)