mirror of
https://github.com/cozystack/cozystack.git
synced 2026-10-31 00:57:26 +09:00
Two more review passes (Claude + Codex) on the previous commit. Codex found the one that would have broken the very next promotion. The agent reads its own instructions from the working tree, which is the rc tag. Every rc cut before this change carries the old §2 of docs/agents/changelog.md — two valid configurations, "stop" on anything else — and a detached rc-tag checkout is exactly that "anything else". So promoting v1.6.0-rc.4 would have presented a compliant agent with instructions telling it to refuse, silently, producing no changelog on every promotion of an existing rc. Verified against the tag. The same applies to hack/validate-changelog.sh, absent from those trees entirely, which would have failed the Verify step with "command not found" and, in open-pr, taken the promote PR down with it. Both are now overlaid from the dispatch ref, best-effort, in both jobs. The structural validation added last round rejected every PATCH changelog. It asserted a `# Cozystack vX.Y.Z` header and a 20-line floor; patch releases use `# vX.Y.Z (date)` and v1.5.1 is a complete 19-line release. Good AI output would have been discarded and the promote PR mislabelled "generation failed". Measured across the tree: the header form holds for 23 of 115 changelogs, so it was never an invariant. The predicates now live in hack/validate-changelog.sh, tested directly against real changelogs rather than through YAML greps — the reason the defect shipped is that the suite pinned finalize's guard but nothing on the promote-side validator, and stayed green when the validator was mutated away. It accepts both header conventions, has no line floor, and checks the version in the header, the release-link comment and the compare link, so a changelog generated for the wrong version is caught. All 16 current-era changelogs pass; whitespace, empty, truncated and wrong-version inputs are rejected. Also fixed: - A fatal artifact download in open-pr would abort the job before the PR step — the same wedge as a skipped job, one step lower. Download is now best-effort and the commit and PR body key off what is on disk, not an upstream job output that says nothing about whether the transfer worked. - A pre-existing changelog (hand-written, or preserved across the force-push) reached the PR without ever being validated, was advertised with ✅ and published verbatim. It now goes through the same validator, as does the tags.yaml backstop. - `gh pr view <branch>` matches closed PRs, so re-dispatching after closing an abandoned promote PR edited the dead PR and opened nothing. Branch on state explicitly. - `gh pr edit --body` unconditionally overwrote the PR body, destroying the upstream breaking-change notes docs/release.md instructs reviewers to paste there. Refresh only while the body is still the generated one. - open-pr consumed raw dispatch input while its siblings used the validated parse; the changelog job's bash parse did not trim, so an input with a stray space passed promote and failed there. Both fixed. - The prompt and §2 said "trailing release-link comment"; it is the first thing in every changelog. Tests grow to 16, each mutation-checked: dropping the overlay, making the download fatal, reverting the existing-changelog check to `-s`, and removing the backstop validator each fail the suite. Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
63 lines
3.0 KiB
Bash
Executable File
63 lines
3.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# Usage: hack/validate-changelog.sh <changelog-file> <version-without-v>
|
|
#
|
|
# Decides whether a changelog file is publishable as a GitHub Release body.
|
|
#
|
|
# promote-rc.yaml lets the AI generation step fail (a Copilot outage must never
|
|
# block a release), which means a run can die mid-stream and leave a fragment
|
|
# behind. Without this check that fragment would be committed, advertised as a
|
|
# valid changelog in the promote PR body, and published verbatim by finalize as
|
|
# the release notes — worse than having no changelog, because nobody is told.
|
|
#
|
|
# The assertions are deliberately narrow: only invariants every shipped changelog
|
|
# in docs/changelogs/ actually satisfies. Two forms exist and both are valid —
|
|
# minor releases use `# Cozystack vX.Y.Z`, patch releases use `# vX.Y.Z (date)` —
|
|
# so the header check accepts either. There is deliberately NO line-count floor:
|
|
# v1.5.1 is a complete, shipped, 19-line patch changelog, and a floor set above
|
|
# it would reject good output and mislabel it as a generation failure.
|
|
#
|
|
# The version is checked into the header, the release-link comment and the
|
|
# compare link, so a changelog generated for the wrong version (an rc string, or
|
|
# a stale version carried over from a retry) is caught rather than published.
|
|
#
|
|
# Exit 0 = publishable. Exit 1 = not publishable, with the reason on stderr.
|
|
|
|
set -eu
|
|
|
|
CL="${1:?usage: validate-changelog.sh <file> <version>}"
|
|
VERSION="${2:?usage: validate-changelog.sh <file> <version>}"
|
|
|
|
fail() {
|
|
echo "$1" >&2
|
|
exit 1
|
|
}
|
|
|
|
[ -f "$CL" ] || fail "file absent: $CL"
|
|
[ -s "$CL" ] || fail "file empty: $CL"
|
|
grep -q '[^[:space:]]' "$CL" || fail "file is only whitespace: $CL"
|
|
|
|
# Both header conventions. \b is not portable in POSIX grep -E, so anchor on
|
|
# "end of line or a non-version character" instead: that keeps v1.5.1 from
|
|
# satisfying a check for v1.5.11.
|
|
grep -qE "^# (Cozystack )?v${VERSION}([^0-9.]|\$)" "$CL" \
|
|
|| fail "missing an H1 for v${VERSION}: expected '# Cozystack v${VERSION}' (minor) or '# v${VERSION} (<date>)' (patch)"
|
|
|
|
# Leading HTML comment pointing at the release. Present in every shipped
|
|
# changelog and the first thing a truncated write would still have, so on its
|
|
# own it is weak — it is the version check here that earns its keep.
|
|
grep -qF "releases/tag/v${VERSION}" "$CL" \
|
|
|| fail "missing the release-link comment for v${VERSION}"
|
|
|
|
# A truncated stream loses the tail, so assert something that only exists at the
|
|
# end. The compare link must also name this version, catching a changelog
|
|
# generated against the rc tag or a stale version.
|
|
grep -qE "compare/.*\.\.\.v${VERSION}([^0-9.]|\$)" "$CL" \
|
|
|| fail "missing the 'Full Changelog' compare link ending in v${VERSION} (likely truncated, or generated for the wrong version)"
|
|
|
|
# At least one section. Distinguishes a real changelog from a header plus a
|
|
# stub line, without assuming which sections a given release happens to have.
|
|
grep -qE '^## ' "$CL" \
|
|
|| fail "no '## ' sections — not a complete changelog"
|
|
|
|
echo "OK: $CL is publishable as the v${VERSION} release body ($(wc -l < "$CL" | tr -d ' ') lines)"
|