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
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ jobs:
IFS=$'\t' read -r tag_object_type tag_object_sha <<< "${tag_ref_output}"
case "${tag_object_type}" in
commit)
tag_commit="${tag_object_sha}"
echo "::error::Tag v${RELEASE_VERSION} is lightweight; the canonical release contract requires an annotated tag. Refusing to resume or replace it." >&2
exit 1
;;
tag)
if ! tag_object_output="$(gh api "repos/${GITHUB_REPOSITORY}/git/tags/${tag_object_sha}" --jq '[.object.type, .object.sha] | @tsv' 2>&1)"; then
Expand Down
21 changes: 21 additions & 0 deletions tests/test_release_workflow_idempotency_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,20 @@ def _tag_state_script(workflow: str) -> str:
exit 1
;;
tag_exists)
printf 'tag\tannotated-tag-object\n'
exit 0
;;
tag_lightweight)
printf 'commit\t%s\n' "${tag_sha}"
exit 0
;;
*) echo "unhandled stub gh api tag mode: ${tag_mode}" >&2; exit 97 ;;
esac
;;
*"/git/tags/"*)
printf 'commit\t%s\n' "${tag_sha}"
exit 0
;;
*"/compare/"*)
case "${compare_mode}" in
identical) echo "identical"; exit 0 ;;
Expand Down Expand Up @@ -582,6 +590,19 @@ def test_simulated_tag_at_the_dispatch_commit_resumes_without_a_compare_call(tmp
assert env_vars == {"TARGET_SHA": _SIM_GITHUB_SHA}


def test_simulated_lightweight_tag_is_rejected(tmp_path: Path) -> None:
"""A lightweight tag cannot become the canonical immutable release tag."""
workflow = _workflow_text()
script = _tag_state_script(workflow)
result, outputs, env_vars = _run_tag_state_script(
tmp_path, script, tag_mode="tag_lightweight", tag_sha=_SIM_GITHUB_SHA
)
assert result.returncode != 0
assert "lightweight" in result.stderr
assert outputs == {}
assert env_vars == {}


def test_simulated_tag_resumes_from_an_older_ancestor_commit_after_main_advanced(tmp_path: Path) -> None:
"""The real bug fix, end-to-end: the tag exists and points at an OLDER
commit than this dispatch's GITHUB_SHA (main has advanced since the tag
Expand Down