Repository navigation
ci: version links in the packaged chart - #161
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]>
Package the chart from a copy whose README links to the docs and files of the release (/en/v<version>/, blob/v<version>/) instead of the latest docs and branch dev, with scripts/chart_readme.py. The script fails the release if any link to the latest docs or to branch dev is left, and the workflow checks that the packaged README is the checked one. The README in the repository is unchanged. Closes #155 Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # .github/workflows/release.yaml
Also flag links to stable docs and to branches main and HEAD, and edit, blame and commits views; derive the patterns from the docs host and the repository. Package from a fresh temporary directory, pass the validated version, test the script as a process, and clarify the docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe release process now packages charts from a temporary, validated copy whose README links target the release tag rather than moving documentation or development branches, with automated failure annotations, archive verification, tests, and release documentation. Sequence diagram for versioned chart packagingsequenceDiagram
participant ReleaseWorkflow
participant ChartCopy
participant chart_readme.py
participant Helm
participant PackageArchive
ReleaseWorkflow->>ChartCopy: cp -R deployment
ReleaseWorkflow->>chart_readme.py: main(readme, tag)
chart_readme.py->>ChartCopy: version_links(markdown, tag)
chart_readme.py->>ChartCopy: unversioned_links(markdown)
alt moving links remain or tag is invalid
chart_readme.py-->>ReleaseWorkflow: exit 1 with ::error annotations
ReleaseWorkflow-->>ReleaseWorkflow: stop release
else README is validated
chart_readme.py-->>ReleaseWorkflow: exit 0
ReleaseWorkflow->>Helm: helm package chart copy
Helm-->>PackageArchive: create chart .tgz
ReleaseWorkflow->>PackageArchive: tar -xzOf README.md
ReleaseWorkflow->>PackageArchive: cmp packaged README with checked copy
end
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 #161 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 11 +1
Lines 837 868 +31
=========================================
+ Hits 837 868 +31 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
# Conflicts: # .github/workflows/release.yaml
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="scripts/chart_readme.py" line_range="63-65" />
<code_context>
+ files on branch `dev` (`FILES` + `dev/`) pointed to `tag`, also in
+ code blocks; other links unchanged.
+ """
+ return markdown.replace(f"{DOCS}latest/", f"{DOCS}{tag}/").replace(
+ f"{FILES}dev/", f"{FILES}{tag}/"
+ )
+
+
</code_context>
<issue_to_address>
**Packaged docs links return 404**
When the Read the Docs tag activation or build has not completed successfully before release publication, the release workflow rewrites README URLs to `/en/<tag>/` and publishes the chart without confirming that Read the Docs built that version, so chart users see 404s until the build completes, or indefinitely if it fails.
Gate chart publication on a successful Read the Docs build for the release tag.
Also at `docs/development.md:151`.
</issue_to_address>
### Comment 2
<location path="scripts/chart_readme.py" line_range="37-44" />
<code_context>
+# Links to versions that move (also forms that aren't rewritten, and `stable`
+# and branch `main`), which must not be left in the packaged README
+_MOVING = r"(?![\w.-])"
+UNVERSIONED = re.compile(
+ rf"{re.escape(DOCS_HOST)}/(?:en/)?(?:latest|stable){_MOVING}"
+ rf"|github\.com/{re.escape(REPOSITORY)}/"
+ rf"(?:blob|tree|raw|edit|blame|commits)/(?:refs/heads/)?(?:dev|main|HEAD)"
+ rf"{_MOVING}"
+ rf"|raw\.githubusercontent\.com/{re.escape(REPOSITORY)}/"
+ rf"(?:refs/heads/)?(?:dev|main|HEAD){_MOVING}",
+ re.ASCII | re.IGNORECASE,
+)
+# Guard against tags that would change the paths of the links (e.g., with
</code_context>
<issue_to_address>
**Latest release links pass unchecked**
When the packaged README contains a link to `https://github.com/elixir-cloud-aai/cloud-registry/releases/latest`, `UNVERSIONED` only checks Read the Docs aliases and GitHub branch/ref paths, so a GitHub `/releases/latest` link passes and users of an older chart can land on newer release information.
Add the repository’s moving `/releases/latest` endpoint to `UNVERSIONED` and cover it with a test.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and if the rewritten links point to a docs version that has not been published, users of the released chart may get broken links; that README remains in the packaged release after a revert and would need a corrected package or release. No application data or access decisions are changed.
Blocking findings: scripts/chart_readme.py:65, scripts/chart_readme.py:44
Links to the repository's latest release move with new releases too (Sourcery review). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Builds on #159 (#153, merged), whose
scripts/setup it reuses.deployment/README.mdis packaged into every released chart, and its links point to/en/latest/docs andblob/dev/files. Users of an old chart therefore read docs for newer versions. This PR changes the release workflow's "Package chart" step:scripts/chart_readme.pyon the copy's README. The script rewriteshttps://cloud-registry.readthedocs.io/en/latest/to/en/v<version>/andhttps://github.com/elixir-cloud-aai/cloud-registry/blob/dev/toblob/v<version>/.blob/tree/raw/edit/blame/commitsondev/main/HEAD(also viarefs/heads/), raw.githubusercontent, the latest GitHub release (Sourcery review), and forms that aren't rewritten, such ashttp://or a missing trailing slash.tar | cmpcheck confirms that the README in the.tgzis the checked one.docs/hooks.py) are unchanged.docs/development.md, together with the Read the Docs automation rule for version tags (set by the maintainer).Closes #155
Verification
pytest tests/test_chart_readme.py: 52 passed, with 100% coverage ofscripts/chart_readme.py. It covers rewrites, flagged and non-flagged links, the realdeployment/README.md(no moving links left after the rewrite), path-changing tags, and the script as a subprocess.VERSION=0.3.0rc1. It packagedcloud-registry-0.3.0-rc1.tgz,cmpconfirmed the packaged README matches the checked copy, and the README containsv0.3.0rc1links.mkdocs build --strict: all pass.Declined review findings
Use the strict tag grammar of
release_version.pyinchart_readme.pyinstead of its own looser one (quality reviewer, medium). Kept as a documented guard against tags that would change link paths (/,..), which the adversarial reviewer found useful. The strict validation runs earlier in the same job (release_version.py outputs).Check every file of the chart, not only the README (adversarial reviewer, low). No other chart file has such links today, and the script's docstring says only the README is versioned.
Also flag
compare/...devlinks (adversarial reviewer, optional). Such links are rare in a chart README.Gate publishing on a successful Read the Docs build of the tag (Sourcery, medium). Read the Docs builds the tag on push (webhook plus the automation rule), well before the manual approval in the
releaseenvironment. Gating would need polling Read the Docs and would fail releases on slow builds, a separate design decision.Open questions
None.
🤖 Generated with Claude Code