Repository navigation
fix: harden release reruns and pin checks - #419
Conversation
Port elixir-cloud-aai/trs-filer#311: - publish: new step "Check release state" right after "Check chart", before Docker login, attestation, signing and tagging. It runs `release_assets.py precheck` (a published release must already have this run's chart and its Sigstore bundle) and, for a published release, requires the `X.Y.Z` image tag to point to the run's digest, so a re-run of all jobs fails before it moves any tag. - check_release_pins.py: also reject `[tool.uv.sources]` overrides, package indexes other than https://pypi.org/simple, `uv.lock` packages from other sources (the app itself excepted) and a missing `uv.lock`. - check_release_pins.py: treat empty chart `dependencies: []` or `{}` as no dependencies (as in trs-filer), so the script is identical in all four repos again. - check_release_pins.py docstring: name the CI job "Release readiness", which runs it too. - Tests and docs (release.yml header, docs/development.md, which now also describes re-runs of the release workflow). Closes #414 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `gh` stand-in of `test_release_state_check_runs` returned the releases for any arguments, so a "Check release state" step that queried the wrong repository or endpoint still passed. It now answers only the step's request (`repos/$GH_REPO/releases?per_page=100`), and `test_release_state_checked_first` checks that the step takes `GH_REPO` from the run. Found by Sourcery on elixir-cloud-aai/drs-filer#135. Co-Authored-By: Claude Opus 5.5 <[email protected]>
In `test_release_state_check_runs`, the `new-digest` case passed for any failure that says "release a new patch version", which the error of a failed image inspection says too. A wrong `docker` invocation in "Check release state" therefore went unnoticed. The case now requires the digest-mismatch error (`points to <digest>`). Found by Sourcery on elixir-cloud-aai/protes#507. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The docstrings of `check_release_pins.py` still said that chart
dependencies in flow style can't be read, but an empty list or map
(`[]`, `{}`) now counts as no dependencies. Found by Sourcery on
elixir-cloud-aai/protes#507.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
"Versioning and releases" already described re-runs of the release workflow further down. Add the published-release case there, as in trs-filer and proTES, instead of in a second paragraph that the old one contradicted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideImplementationExtend the release asset checker with a precheck mode that requires a published release to already contain the expected assets and Sigstore bundles before signing.
Expand release pin validation to reject non-PyPI sources and lockfile packages, while treating empty chart dependency collections as having no dependencies.
ConfigurationAdd an early release-state gate that checks published-release assets and verifies the version tag still points to the run's image digest before login, attestation, signing, or tagging.
DocumentationDocument the early published-release checks, the expanded dependency pin rules, and how reruns behave after publication.
TestsCover empty chart dependencies and the new PyPI-source and lockfile pin checks, including malformed or missing lockfiles and the project-package exemption.
Test precheck behavior for published, draft, and absent releases, including missing, changed, and unexpected assets.
Verify the workflow runs its release-state check before publishing side effects and rejects reruns with a different chart or image digest.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #419 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 28 28
Lines 3546 3615 +69
=========================================
+ Hits 3546 3615 +69 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit 02e148d #414 fix: harden release reruns and pin checks · 4 of 4 met
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/release.yml" line_range="415-419" />
<code_context>
+ releases="$(mktemp)"
+ gh api --paginate --slurp "repos/${GH_REPO}/releases?per_page=100" \
+ > "${releases}"
+ state="$(python scripts/release_assets.py precheck "${TAG}" \
+ --releases "${releases}" dist/*)"
+ state="${state#state=}"
+ echo "Release ${TAG}: ${state}"
+ if [[ "${state}" == "published" ]]; then
+ # A missing tag and a failed request (e.g., a rate limit) both
+ # fail here, apart from a tag on another digest
</code_context>
<issue_to_address>
**Published tag moves during release**
When a manual actor publishes this tag after precheck reports `none` or `draft` but before `Tag image`, `Check release state` skips image inspection for non-published states, so `Tag image` can move `X.Y.Z` and possibly `latest` to this run's new digest. The later `Create release` check can then fail on immutable asset differences, leaving the published release and image tag inconsistent.
Serialize manual publication with the workflow so the release cannot become published between the precheck and image tagging.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if the new lockfile/source checks miss a non-PyPI package, the release workflow could publish an image containing code from an unintended source; reverting the check would not remove that published image. A faulty published-release guard could also let a rerun retag the version, with the changed tag remaining externally visible after a revert.
Blocking findings: .github/workflows/release.yml:419
Summary
Closes #414 (part of elixir-cloud-aai/.github#92). This ports elixir-cloud-aai/trs-filer#311 (fix for trs-filer#310) as is, plus trs-filer's earlier handling of empty chart
dependencies:publishhas a new step, "Check release state", right after "Check chart" and "Set up Docker Buildx" and before "Log in to Docker Hub", "Attest build provenance", "Sign image" and "Tag image". It runsscripts/release_assets.py precheck <tag>, which works likestatebut also requires a published release to have the Sigstore bundle of each asset already. For a published release, it also requiresdocker buildx imagetools inspect "${IMAGE_NAME}:${VERSION}"to point to the run'sDIGEST. Otherwise the step fails and says to release a new patch version. As a result, a re-run of all jobs of a published release no longer movesX.Y.Z/latestto a new digest. Re-running only the failed jobs still passes, and drafts and new releases are unchanged.scripts/check_release_pins.pynow also rejects the following.https://pypi.org/simpleis the only allowed index.[tool.uv.sources]entries of these kinds:git,url,path/editable,workspace, a non-PyPI or undefinedindex, and unknown forms[[tool.uv.index]],index-url,extra-index-url,find-linksuv.lockpackages whose source is not PyPI (the app itself is exempt)uv.lockdependencies: []or{}inChart.yamlnow counts as no dependencies, as in trs-filer. Before, it was reported as an unreadable flow-style dependency. New test:test_chart_dependencies_empty. The docstrings now say so.scripts/release_assets.pyis identical to trs-filer's.scripts/check_release_pins.pymatches it too, apart from repository-specific docstring lines and comments. The module docstring now also names the CI job "Release readiness", which runs the script.The workflow tests match those of the drs-filer and proTES ports (#135, #507). Sourcery found two gaps there, both fixed here too:
ghstand-in answers only the step's own releases request, and the test checks the step'sGH_REPO.new-digestcase requires the digest-mismatch error. Before, any failure passed it, including a failed inspection caused by wrongdockerarguments.Docs: the header comment of
release.yml, the step's own comment, and "Versioning and releases" indocs/development.md. That section now covers the two release-state checks, the new pin-check findings, and the published-release case of re-runs, which is added to the existing re-run paragraph.Effect on
dev: none.devpins released FOCA, everyuv.lockpackage exceptcloud-registryitself comes from PyPI, andpython scripts/check_release_pins.pyexits 0. On pull requests, "Release readiness" reports any findings as warnings, as before.Verification
coverage run -m pytest -W ignore::DeprecationWarning, thencoverage report: total coverage 100%, and all tests outside the Helm tests passed (2295 passed, 11 skipped). The 275 failures are all intests/test_chart.py(204) andtests/test_config.py::TestChartOverlay(71). Each fails with "The library chart is missing: runhelm dependency build deployment", because the library chart isn't built on this machine. CI builds it and runs these tests.pytest tests/test_workflows.py tests/test_check_release_pins.py tests/test_release_assets.py: 211 passed.pytest tests/test_docs_hooks.py tests/test_version_mentions.py: 66 passed.test_chart_dependencies_emptyfailed before the fix (3 cases) and passes after it.per_page=10, all cases oftest_release_state_check_runsfail.--formatargument changed, thenew-digestcase fails.pre-commit run --all-files: every hook passed except semgrep, which exits 2 locally without a finding. Run separately with the hook's arguments, semgrep passes: on the changed files (also throughpre-commit run semgrep --files) and on all tracked files outside.semgrep/(0 findings, exit 0), both as one process and as two in parallel. The exit 2 only appears when pre-commit fans out over the whole repo, so it comes from the local environment. CI's Lint job runs the hook, and it passed.mkdocs build --strict) didn't run locally because the docs extra isn't installed. CI's Docs job runs it, and it passed.DOCKERHUB_ORGset on the fork. No release is planned now.02e148d(run): PR title, Lint, Docs, both Test jobs, Chart, Smoke test, Scan image, Release readiness and CI passed. Push image and Publish image were skipped, as intended on PRs.Review: one round of adversarial and quality review (full lane, since this changes the release workflow). Neither found anything high or medium. The adversarial review's low finding is fixed: the branch first added a second re-run paragraph that the existing one contradicted, and the text now sits in the existing paragraph, as in trs-filer.
Sourcery opened one thread (medium), about a manual publish racing the run between the check and "Tag image". Answered and resolved as on #135 and #507: the race existed before this PR, and this PR narrows its window.
Declined review findings
dependencies: [ ](with spaces),~ornullstill counts as unreadable flow style. Declined, as on #507: the check fails closed with a readable finding, this chart uses block style, and the parsing should change in all four repos at once.release.ymlheader anddocs/development.mdboth describe re-runs and must be kept in sync by hand. Declined: trs-filer, drs-filer and proTES do the same.imagetools inspectbefore the Docker Hub login (the error says to re-run, and nothing has been signed or tagged yet)Open questions
None.
🤖 Generated with Claude Code