Repository navigation
ci: test the release version logic - #159
Conversation
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]>
Reviewer's GuideThe 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 generationsequenceDiagram
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
Sequence diagram for latest image tag selectionsequenceDiagram
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
Flow diagram for release tag validation and outputsflowchart 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]
File-Level Changes
Assessment against linked issues
Possibly linked issues
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 #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. 🚀 New features to boost your workflow:
|
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="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
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]>
Summary
The release workflow derived the version, chart version, kind of release and the
latestimage 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>printsversion,chart_version,stableandprereleaseasGITHUB_OUTPUTlines (jobprepare).latest <tag>reads the tags onmainfrom stdin and printslatest(jobpublish, after fetching the tags as before).mainthat aren't UTF-8 are ignored like other invalid tags (Sourcery review).::error::annotation as before, and print no outputs.Other changes:
stablejob output is removed.scriptsis added to mypy's files and coverage's source (pyproject and CI).!/scripts/overrides the virtualenv[Ss]criptspattern of.gitignore.docs/development.mdand in the coverage rule ofdocs/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 (nov, leading zeros, local/post/dev versions, non-ASCII digits, garbage),latestordering, 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).latestresults.mkdocs build --strict: all pass.Declined review findings
importlib, so its attributes are untyped for mypy. Declined, for consistency withtests/test_docs_hooks.py, which loadsdocs/hooks.pythe same way.--sourceinchecks.yamlduplicatespyproject.toml. This duplication already existed; both are updated.is_latestwith a generator. Declined: the current form keeps the membership check explicit.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