Skip to content

ci: version links in the packaged chart - #161

Merged
uniqueg merged 11 commits into
devfrom
ci/version-chart-links
Oct 21, 2026
Merged

uniqueg merged 11 commits into
devfrom
ci/version-chart-links

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Builds on #159 (#153, merged), whose scripts/ setup it reuses.

deployment/README.md is packaged into every released chart, and its links point to /en/latest/ docs and blob/dev/ files. Users of an old chart therefore read docs for newer versions. This PR changes the release workflow's "Package chart" step:

  • It copies the chart to a fresh temporary directory and runs scripts/chart_readme.py on the copy's README. The script rewrites https://cloud-registry.readthedocs.io/en/latest/ to /en/v<version>/ and https://github.com/elixir-cloud-aai/cloud-registry/blob/dev/ to blob/v<version>/.
  • The script fails the release, with one annotation per line, if any link to a moving version is left. This covers the latest/stable docs, blob/tree/raw/edit/blame/commits on dev/main/HEAD (also via refs/heads/), raw.githubusercontent, the latest GitHub release (Sourcery review), and forms that aren't rewritten, such as http:// or a missing trailing slash.
  • The chart is packaged from the copy. A tar | cmp check confirms that the README in the .tgz is the checked one.
  • The README in the repository and the docs (docs/hooks.py) are unchanged.
  • Documented in "Versioning and releases" of 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 of scripts/chart_readme.py. It covers rewrites, flagged and non-flagged links, the real deployment/README.md (no moving links left after the rewrite), path-changing tags, and the script as a subprocess.
  • Full suite with Helm 3.22.1: 825 passed, 100% coverage (before the review fixes; the script tests were rerun after them).
  • Ran the "Package chart" step locally with Helm v3.22.1 and VERSION=0.3.0rc1. It packaged cloud-registry-0.3.0-rc1.tgz, cmp confirmed the packaged README matches the checked copy, and the README contains v0.3.0rc1 links.
  • ruff check and format, mypy, 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

  • Use the strict tag grammar of release_version.py in chart_readme.py instead 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/...dev links (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 release environment. 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

uniqueg and others added 9 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]>
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]>
@sourcery-ai

sourcery-ai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The 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 packaging

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Version released chart README links to immutable release-specific documentation and repository paths during packaging.
  • Added a stdlib-only script that rewrites supported latest/dev links to the release tag.
  • Detects remaining links to moving docs, branches, and GitHub URL variants and emits per-line workflow annotations.
  • Added comprehensive unit and subprocess coverage, including invalid tags and the repository README.
  • Documented the packaging behavior and required Read the Docs tag automation.
scripts/chart_readme.py
tests/test_chart_readme.py
docs/development.md
Changed the release workflow to package a validated temporary chart copy and verify its README contents.
  • Copies the chart to a temporary directory before rewriting its README.
  • Runs link validation before Helm packaging and packages the rewritten copy.
  • Compares the README extracted from the chart archive with the checked temporary copy.
.github/workflows/release.yaml

Assessment against linked issues

Issue Objective Addressed Explanation
#155 Rewrite links in the packaged chart README so documentation and repository-file links point to the release version, without changing the README in the repository. ✅
#155 Fail the release if the packaged README still contains links to moving documentation or branches, and verify the checked README is the one included in the chart package. ✅
#155 Document the release-link versioning behavior and the Read the Docs tag-version automation requirement in the development documentation. ✅

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 (9686b56) to head (7d8b197).

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

# Conflicts:
#	.github/workflows/release.yaml
@uniqueg
uniqueg marked this pull request as ready for review October 21, 2026 21:53

@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 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


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

Comment thread scripts/chart_readme.py Resolved
Comment thread scripts/chart_readme.py Resolved
Links to the repository's latest release move with new releases too
(Sourcery review).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg merged commit 72b2b21 into dev Oct 21, 2026
12 checks passed
@uniqueg
uniqueg deleted the ci/version-chart-links branch October 21, 2026 22:02
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: version links in the packaged chart

1 participant