Skip to content

ci: test the release version logic - #159

Merged
uniqueg merged 5 commits into
devfrom
ci/release-version-script
Oct 21, 2026
Merged

uniqueg merged 5 commits into
devfrom
ci/release-version-script

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

The release workflow derived the version, chart version, kind of release and the latest image tag from the tag in inline bash, untested. This moves that logic into a typed, documented, stdlib-only script, scripts/release_version.py, tested with pytest over a table of tags:

  • outputs <tag> prints version, chart_version, stable and prerelease as GITHUB_OUTPUT lines (job prepare).
  • latest <tag> reads the tags on main from stdin and prints latest (job publish, after fetching the tags as before).
  • Tags on main that aren't UTF-8 are ignored like other invalid tags (Sourcery review).
  • Invalid tags fail with the same ::error:: annotation as before, and print no outputs.

Other changes:

  • Both release jobs set up Python 3.12 (one of the versions in the test matrix).
  • The unused stable job output is removed.
  • scripts is added to mypy's files and coverage's source (pyproject and CI). !/scripts/ overrides the virtualenv [Ss]cripts pattern of .gitignore.
  • The script is documented in docs/development.md and in the coverage rule of docs/contributing.md.

Behaviour for valid tags is unchanged.

Closes #153

Verification

  • pytest tests/test_release_version.py: 59 passed. Covers valid tags (v0.3.0, v0.3.0rc1, v1.0.0a1, v1.0.0b2, …), invalid tags (no v, leading zeros, local/post/dev versions, non-ASCII digits, garbage), latest ordering, and the CLI in process and as a subprocess.
  • coverage run --source cloud_registry,scripts -m pytest: 643 passed, 100% total (helm tests skipped locally).
  • The removed bash block and the script give identical outputs over a table of 19 tags (also checked by the reviewer over 149 tags), and identical latest results.
  • ruff check and format, mypy, ast-grep, actionlint 1.7.12 with shellcheck 0.11.0, and mkdocs build --strict: all pass.
  • CI: all checks pass (static analysis, tests on 3.10 and 3.12, Helm chart, docs, Docker Compose smoke test, Read the Docs, codecov patch and project).

Declined review findings

  • The tests load the script with importlib, so its attributes are untyped for mypy. Declined, for consistency with tests/test_docs_hooks.py, which loads docs/hooks.py the same way.
  • The coverage --source in checks.yaml duplicates pyproject.toml. This duplication already existed; both are updated.
  • Rewrite is_latest with a generator. Declined: the current form keeps the membership check explicit.
  • The docstring Commands: section is not a Google section. ruff accepts it, and scripts are not part of the API reference.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 3 commits October 21, 2026 23:03
Move the release workflow's tag logic (version, chart version, stable,
pre-release and latest image) from inline bash into
scripts/release_version.py, tested with pytest over a table of valid
and invalid tags. Behaviour is unchanged for valid tags; invalid tags
fail with the same error annotation. Coverage and mypy now include
scripts/.

Closes #153

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Run the script as the release workflow calls it (exit status, stdout and
stderr), check the release number, and read the tags before the error
handling, so that only invalid tags give the release version error.
Give the script its own paragraph in the development docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The release workflow now delegates version derivation and latest-image selection to a typed, documented Python script, with table-driven unit and subprocess tests preserving existing behavior while bringing the script into mypy, coverage, and project documentation.

Sequence diagram for release version output generation

sequenceDiagram
    participant Workflow as ReleaseWorkflow
    participant Script as release_version.py
    participant Parser as parse_tag
    participant Release as Release

    Workflow->>Script: main([outputs, TAG])
    Script->>Parser: parse_tag(TAG)
    Parser-->>Script: Release
    Script->>Release: outputs()
    Release-->>Script: version, chart_version, stable, prerelease
    Script-->>Workflow: GITHUB_OUTPUT lines
Loading

Sequence diagram for latest image tag selection

sequenceDiagram
    participant Workflow as PublishJob
    participant Git as GitTagsOnMain
    participant Script as release_version.py
    participant Selector as is_latest

    Workflow->>Git: fetch tags on main
    Git-->>Workflow: stable and nonstable tags
    Workflow->>Script: main([latest, TAG]) with tags on stdin
    Script->>Selector: is_latest(TAG, tags)
    Selector->>Selector: parse_tag(TAG)
    Selector->>Selector: parse_tag(each tag)
    Selector-->>Script: latest boolean
    Script-->>Workflow: latest=true or latest=false
Loading

Flow diagram for release tag validation and outputs

flowchart TD
    Tag[Release tag] --> Parse[parse_tag]
    Parse --> Valid{Canonical tag?}
    Valid -->|No| Error[GitHub error annotation and exit 1]
    Valid -->|Yes| Release[Build Release]
    Release --> Outputs[outputs]
    Outputs --> Workflow[GITHUB_OUTPUT]
Loading

File-Level Changes

Change Details Files
Extract release-tag interpretation and latest-image selection from inline workflow Bash into a typed, stdlib-only Python CLI.
  • Parse and validate canonical release tags, deriving app and Helm versions plus stable/prerelease flags.
  • Implement outputs and stdin-driven latest commands with GitHub output lines and matching error annotations.
  • Update both release jobs to invoke the script under Python 3.12 while preserving tag fetching and release checks.
scripts/release_version.py
.github/workflows/release.yaml
Add comprehensive automated coverage for release-version behavior and command-line integration.
  • Test valid and invalid canonical tags, version normalization, release classification, latest ordering, ignored tags, and invalid-input behavior.
  • Exercise the module directly and as an isolated subprocess, including stdin and GitHub-style stderr annotations.
tests/test_release_version.py
Include the new script in project quality tooling and document its ownership and coverage requirements.
  • Add scripts to mypy and coverage configuration and CI coverage collection.
  • Document that release-version rules belong in the script and update contribution coverage guidance.
  • Adjust gitignore so the scripts directory is tracked.
pyproject.toml
.github/workflows/checks.yaml
docs/development.md
docs/contributing.md
.gitignore

Assessment against linked issues

Issue Objective Addressed Explanation
#153 Move release-tag parsing and release-output logic from inline workflow Bash into a typed, documented Python script, and have the workflow use it. ✅
#153 Add table-driven tests covering valid and invalid tags, release outputs, latest image-tag selection, and CLI behavior, with full coverage of the script’s branches. ✅
#153 Preserve release behavior for valid tags and fail clearly for invalid tags. ✅

Possibly linked issues


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 Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #159   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9        10    +1     
  Lines          785       837   +52     
=========================================
+ Hits           785       837   +52     

☔ 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 October 21, 2026 21:28

@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="scripts/release_version.py" line_range="142" />
<code_context>
+    args = parser.parse_args(argv)
+    # Read before `try`, so that only invalid tags give its error (decoding
+    # errors are `ValueError`s too)
+    tags = sys.stdin.read().splitlines() if args.command == "latest" else []
+    try:
+        if args.command == "outputs":
</code_context>
<issue_to_address>
**Undecodable tag bytes abort releases**

When a tag on `main` matching `v*` contains bytes that Python cannot decode using stdin’s encoding, `sys.stdin.read()` raises `UnicodeDecodeError` before `main` reaches its error handling, so the invalid tag is not ignored and the `latest` step fails, preventing the release from being published.

Read the piped tag listing using an error-handling strategy that lets undecodable tag names be ignored as invalid tags.

Also at `.github/workflows/release.yaml:221`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and the release workflow decides whether to publish an image under the externally consumed latest tag by comparing the release against stable tags on main. If that comparison is wrong, consumers may pull the wrong image before the tag is corrected; reverting the workflow cannot undo pulls or deployments that already happened.

Blocking findings: scripts/release_version.py:142


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

Comment thread scripts/release_version.py Resolved
Read the tags on main as bytes and replace undecodable ones, so that a
stray tag with such bytes is ignored as an invalid tag instead of
failing the release with a UnicodeDecodeError (Sourcery review).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg merged commit 9686b56 into dev Oct 21, 2026
12 checks passed
@uniqueg
uniqueg deleted the ci/release-version-script branch October 21, 2026 21:46
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.

ci: test the release version logic

1 participant