Skip to content

fix: harden release reruns and pin checks - #419

Merged
uniqueg merged 5 commits into
devfrom
fix/414-release-hardening
Nov 19, 2026
Merged

uniqueg merged 5 commits into
devfrom
fix/414-release-hardening

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

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:

  1. Re-runs of a published release. publish has 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 runs scripts/release_assets.py precheck <tag>, which works like state but also requires a published release to have the Sigstore bundle of each asset already. For a published release, it also requires docker buildx imagetools inspect "${IMAGE_NAME}:${VERSION}" to point to the run's DIGEST. 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 moves X.Y.Z/latest to a new digest. Re-running only the failed jobs still passes, and drafts and new releases are unchanged.
  2. Pin check against uv sources and the lock. scripts/check_release_pins.py now also rejects the following. https://pypi.org/simple is the only allowed index.
    • [tool.uv.sources] entries of these kinds: git, url, path/editable, workspace, a non-PyPI or undefined index, and unknown forms
    • non-PyPI indexes: [[tool.uv.index]], index-url, extra-index-url, find-links
    • uv.lock packages whose source is not PyPI (the app itself is exempt)
    • a missing or unreadable uv.lock
  3. Empty chart dependencies. dependencies: [] or {} in Chart.yaml now 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.py is identical to trs-filer's. scripts/check_release_pins.py matches 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:

  • The gh stand-in answers only the step's own releases request, and the test checks the step's GH_REPO.
  • The new-digest case requires the digest-mismatch error. Before, any failure passed it, including a failed inspection caused by wrong docker arguments.

Docs: the header comment of release.yml, the step's own comment, and "Versioning and releases" in docs/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. dev pins released FOCA, every uv.lock package except cloud-registry itself comes from PyPI, and python scripts/check_release_pins.py exits 0. On pull requests, "Release readiness" reports any findings as warnings, as before.

Verification

  • coverage run -m pytest -W ignore::DeprecationWarning, then coverage report: total coverage 100%, and all tests outside the Helm tests passed (2295 passed, 11 skipped). The 275 failures are all in tests/test_chart.py (204) and tests/test_config.py::TestChartOverlay (71). Each fails with "The library chart is missing: run helm 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_empty failed before the fix (3 cases) and passes after it.
  • Mutation checks:
    • With the step's request changed to per_page=10, all cases of test_release_state_check_runs fail.
    • With the step's --format argument changed, the new-digest case 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 through pre-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.
  • The strict MkDocs build (mkdocs build --strict) didn't run locally because the docs extra isn't installed. CI's Docs job runs it, and it passed.
  • No fork dry run now. The release workflow changed, so a fork dry run comes before cloud-registry's next release, as decided on fix: harden release reruns and pin checks #414: publish a test release, re-run all jobs, with DOCKERHUB_ORG set on the fork. No release is planned now.
  • CI passed on 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

  • Adversarial (low): dependencies: [ ] (with spaces), ~ or null still 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.
  • Quality (low): the release.yml header and docs/development.md both describe re-runs and must be kept in sync by hand. Declined: trs-filer, drs-filer and proTES do the same.
  • Quality (low): re-runs are described in two places in the section. Fixed by merging them (see above).
  • Not re-reported, and declined as in trs-filer#311 and #507:
    • the anonymous imagetools inspect before the Docker Hub login (the error says to re-run, and nothing has been signed or tagged yet)
    • the fixed "new patch version" remedy for a digest mismatch on a mutable release (can't be reached in practice)
    • a manual publish racing the run (this race existed before, and this PR narrows its window)

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 5 commits November 19, 2026 00:59
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]>
@uniqueg uniqueg self-assigned this Nov 19, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 19, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Extend the release asset checker with a precheck mode that requires a published release to already contain the expected assets and Sigstore bundles before signing.

  • scripts/release_assets.py L24-29, L118-125, L170-173 (+7 small edits)

Expand release pin validation to reject non-PyPI sources and lockfile packages, while treating empty chart dependency collections as having no dependencies.

  • scripts/check_release_pins.py L15-24, L102-109, L252-380 (+6 small edits)

Configuration

Add 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.

  • .github/workflows/release.yml L13-17, L395-432

Documentation

Document the early published-release checks, the expanded dependency pin rules, and how reruns behave after publication.

  • docs/development.md L282-285, L321-332, L457-463 (+1 small edits)

Tests

Cover empty chart dependencies and the new PyPI-source and lockfile pin checks, including malformed or missing lockfiles and the project-package exemption.

  • tests/test_check_release_pins.py L49-68, L246-260, L623-954 (+3 small edits)

Test precheck behavior for published, draft, and absent releases, including missing, changed, and unexpected assets.

  • tests/test_release_assets.py L317-406

Verify the workflow runs its release-state check before publishing side effects and rejects reruns with a different chart or image digest.

  • tests/test_workflows.py L375-524 (+3 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a71af82) to head (02e148d).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 19, 2026 01:27
@sourcery-ai

sourcery-ai Bot commented Nov 19, 2026

Copy link
Copy Markdown

Linked issues

Checked at commit 02e148d

#414 fix: harden release reruns and pin checks · 4 of 4 met

# Requirement Status Notes
1 A rerun of all jobs for a published release fails before attestation, signing, or tagging; rerunning failed jobs with the same digest still passes. ✅ Met The new “Check release state” step runs after “Check chart” and before Docker login, attestation, signing, and tagging. It checks the chart assets and image digest; workflow tests cover both rerun cases.
2 Reject non-PyPI uv sources and non-PyPI lock sources, while passing PyPI-only locks. ✅ Met The pin check covers the named uv source and index settings, checks lock package sources while exempting the app itself, and reports a missing or unreadable lock; tests cover these cases.
3 Treat empty chart dependencies [] or {} as no dependencies. ✅ Met The chart dependency parser treats both empty flow-style values as having no dependencies, with tests for each.
4 Document the new release behavior in the release workflow header and release documentation. ✅ Met The workflow header and “Versioning and releases” documentation describe the published-release rerun behavior and checks.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread .github/workflows/release.yml Resolved
@uniqueg
uniqueg merged commit 11cfc1d into dev Nov 19, 2026
68 checks passed
@uniqueg
uniqueg deleted the fix/414-release-hardening branch November 19, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: harden release reruns and pin checks

1 participant