Skip to content

docs: take the version from one source - #299

Merged
uniqueg merged 2 commits into
devfrom
docs/290-version-source
Oct 24, 2026
Merged

uniqueg merged 2 commits into
devfrom
docs/290-version-source

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Ports cloud-registry's single version source (elixir-cloud-aai/cloud-registry#224) to proTES, before its first release:

  • Source: the release tag and, on dev, version in CITATION.cff (new citation.release_version).
  • Docs and chart README: placeholders {{ version }} and {{ chart_version }} (SemVer form used in chart file names, e.g., 1.2.3-rc1). docs/hooks.py replaces them with the version of CITATION.cff, also in code blocks and in the included chart README; scripts/chart_readme.py replaces them in the packaged chart README. Other {{ ... }} (Helm and Go templates) are left alone.
  • Only deviation from cloud-registry: proTES has no release yet, so CITATION.cff has no version. The docs hook then substitutes X.Y.Z (UNRELEASED) instead of failing the build (cloud-registry raises, as it always has a version). Once the citation PR for 0.3.0 is merged, the docs show 0.3.0.
  • Comments, templates and tests: placeholders (1.2.3) instead of 0.3.0 (Dockerfile, values.yaml, values.schema.json $comment, test_chart.py, test_docs_hooks.py); the verify commands in docs/operations.md and the image examples in deployment/README.md and docs/upgrading.md use the placeholders.
  • Drift guard: tests/test_version_mentions.py (patterns adapted to proTES: protes/pro_tes/proTES, also pro_tes==X, protes@X and compare ranges) fails when the current release version is mentioned as a release of the app outside the allowlist (CITATION.cff, docs/releases/, the tests of the release tooling, links to release notes and assets, migration headings).
  • Docs: "Versioning and releases" in docs/development.md describes the rule.

Closes #290

How it was verified

  • coverage run -m pytest -W ignore::DeprecationWarning: 1019 passed, 82 skipped (Helm is not installed locally, so CI runs the chart tests); coverage 100%.

  • pre-commit run --all-files: all hooks pass.

  • mkdocs build --strict passes, with no placeholder left in the site (protes:X.Y.Z before the release).

  • Simulated release: with python scripts/citation.py set 0.3.0 (not committed), the drift guard passes, the strict docs build passes, and the site shows protes:0.3.0 and protes-0.3.0.tgz. A planted elixircloud/protes:0.3.0 line in docs/api.md makes the guard fail.

  • Review: two rounds of adversarial and quality reviewer subagents; no high findings. Fixed: the dead error path next to the fallback (medium), the chart-version sentence in docs/upgrading.md, pip-style and compare-range mentions in the guard, the wording of the verify commands, docstrings, a duplicate test.

  • CI: all checks pass (tests with mongomock and MongoDB 7.0, Helm chart, docs, release readiness, Compose, image scan, CodeQL, Codecov).

Declined review findings

  • Sourcery: placeholders in the release-download URLs of deployment/README.md: those commands describe installing any release (X.Y.Z template), as in cloud-registry.

  • Sourcery: read CITATION.cff once per build: builds run on one commit; the file never changes during a build.

  • The drift guard skips while CITATION.cff has no version (medium): by design (docs: take the version from one source #290: "a no-op while CITATION.cff has no version"). It becomes active with the citation PR right before the tag; the local simulation with 0.3.0 passes.

  • Raw placeholders in files read on GitHub (e.g., deployment/README.md): by design, as in cloud-registry.

  • Shared test helper for loading scripts, and the redundant early return in substitute_version: kept identical to cloud-registry; a refactor belongs in the shared CI tooling.

  • The guard would flag GA4GH spec versions (e.g., 1.0.0, 1.1.0) once the app reaches those numbers: not relevant for 0.3.0; the guard's message says to extend the allowlist, as in cloud-registry.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 2 commits October 24, 2026 06:16
Port cloud-registry's single version source (cloud-registry#224): the
release tag and, on dev, the version in CITATION.cff.

- docs/hooks.py replaces {{ version }} and {{ chart_version }} in the
  docs and the included chart README with the CITATION.cff version;
  before the first release, CITATION.cff has none and the docs show
  X.Y.Z (the only deviation from cloud-registry, which has releases).
- scripts/chart_readme.py replaces them in the packaged chart README.
- citation.release_version() reads the version.
- Comments, templates and tests use placeholders (1.2.3) instead of
  0.3.0.
- tests/test_version_mentions.py fails when the current release version
  is mentioned as a release of the app outside the allowlist.
- "Versioning and releases" in docs/development.md describes the rule.

Closes #290

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Address round 2 review lows: note the ValueError of on_page_markdown,
clarify the UNRELEASED wording, fold a duplicate test into the
parametrization.

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

sourcery-ai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR establishes CITATION.cff and release tags as the single version source, dynamically substitutes release and chart versions in documentation and packaged chart content, replaces hard-coded examples with placeholders, and adds tests plus a drift guard to prevent version divergence.

Sequence diagram for version substitution in documentation

sequenceDiagram
    participant MkDocs
    participant Hooks as docs/hooks.py
    participant Citation as CITATION.cff
    participant Chart as scripts/chart_readme.py

    MkDocs->>Hooks: on_page_markdown(markdown, page, config, files)
    Hooks->>Hooks: uses_placeholders(markdown)
    Hooks->>Citation: release_version(text)
    Citation-->>Hooks: version or None
    Hooks->>Chart: substitute(markdown, version or X.Y.Z)
    Chart->>Chart: chart_version(version)
    Chart-->>Hooks: rendered Markdown
    Hooks-->>MkDocs: Markdown with version placeholders replaced
Loading

Flow diagram for single-source release versioning

flowchart LR
    Source[CITATION.cff version on dev<br/>or release tag] --> Extract[release_version]
    Extract --> Substitute[Replace version placeholders]
    Substitute --> Docs[Rendered documentation]
    Substitute --> Chart[Packaged chart README]
    Extract --> Guard[Version drift guard]
    Guard --> Result{Hard-coded release mention?}
    Result -->|No| Pass[Pass]
    Result -->|Yes| Fail[Fail with location]
Loading

File-Level Changes

Change Details Files
Centralize release-version extraction and substitution across documentation and chart packaging.
  • Read the top-level version from CITATION.cff, validating release-version format while allowing an unreleased state.
  • Replace exact {{ version }} and {{ chart_version }} placeholders in MkDocs content, included chart README content, and packaged chart README files.
  • Convert prerelease versions such as 1.2.3rc1 to chart SemVer 1.2.3-rc1, while preserving unrelated Helm and Go template expressions.
  • Use X.Y.Z as the docs fallback before the first release.
scripts/citation.py
scripts/chart_readme.py
docs/hooks.py
CITATION.cff
Replace hard-coded release examples with version placeholders and document the single-source release workflow.
  • Update deployment, operations, upgrade, Docker, and chart-related documentation examples to use dynamic release and chart-version placeholders.
  • Document how citation metadata, release tags, docs hooks, chart packaging, and repository-visible placeholders interact.
Dockerfile
deployment/README.md
deployment/values.yaml
deployment/values.schema.json
docs/development.md
docs/operations.md
docs/upgrading.md
Add a drift guard that detects hard-coded application release versions outside approved locations.
  • Scan tracked text files for release and chart-version mentions across tags, images, charts, package forms, prose, and comparison ranges.
  • Allow citation metadata, release notes, release-tool tests, release links/assets, and migration headings.
  • Skip the guard until CITATION.cff contains a release version.
tests/test_version_mentions.py
Expand tests for version parsing, placeholder substitution, prerelease chart formatting, documentation rendering, and drift detection.
  • Cover missing, valid, duplicate, and invalid citation versions.
  • Verify substitutions inside code blocks and included README content without altering unrelated template syntax.
  • Test release and chart version forms and representative allowed or forbidden hard-coded mentions.
tests/test_citation.py
tests/test_chart.py
tests/test_chart_readme.py
tests/test_docs_hooks.py
tests/test_version_mentions.py

Assessment against linked issues

Issue Objective Addressed Explanation
#290 Use the release tag and the version in CITATION.cff on dev as the single source of truth, with docs and the included chart README substituting release and chart-version placeholders, and packaged chart READMEs receiving the same substitutions. ✅
#290 Remove hard-coded release numbers from documentation, comments, templates, and tests, and add a CI drift guard that flags current release-version mentions outside the specified allowlist while doing nothing before a citation version exists. ✅
#290 Document the single-source release-versioning workflow and ensure the strict docs build and chart README substitution are covered by tests. ✅

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

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35371893 | 📁 Comparing 4fb4395 against latest (e1f868a)

  🔍 Preview build  

4 files changed
± deployment/index.html
± development/index.html
± operations/index.html
± upgrading/index.html

@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #299   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           29        29           
  Lines         2438      2451   +13     
=========================================
+ Hits          2438      2451   +13     

☔ 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 24, 2026 04:33

@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="89" />
<code_context>
+        The Markdown with `version` in place of `VARIABLE` and its chart
+        version in place of `CHART_VARIABLE`.
+    """
+    return markdown.replace(VARIABLE, version).replace(
+        CHART_VARIABLE, chart_version(version)
+    )
</code_context>
<issue_to_address>
**Packaged chart commands retain placeholder URLs**

When a user follows the packaged chart README’s release install or upgrade command, when a chart is packaged, `substitute` replaces only `{{ version }}` and `{{ chart_version }}`, leaving the `X.Y.Z` release-download URLs in `deployment/README.md` unchanged. Users following the packaged README’s install or upgrade commands get a URL that does not identify the packaged chart.

Use `v{{ version }}` and `protes-{{ chart_version }}.tgz` in those URLs so chart packaging can substitute the release versions.
</issue_to_address>

### Comment 2
<location path="docs/hooks.py" line_range="197" />
<code_context>
-    return "\n".join(
-        content if line == INCLUDE else line for line in markdown.splitlines()
-    )
+    version = citation.release_version((root / CITATION).read_text(encoding="utf-8"))
+    return substitute_version(markdown, version)
</code_context>
<issue_to_address>
**Pages show different release versions**

When a docs build overlaps a release-preparation update to `CITATION.cff`, `on_page_markdown` reads `CITATION.cff` separately for each page, so callbacks before and after the release-preparation script replaces the file substitute different versions into one build. The generated docs then show inconsistent release versions.

Read the release version once per MkDocs build and reuse that snapshot for every page.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: scripts/chart_readme.py:89, docs/hooks.py:197


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

Comment thread scripts/chart_readme.py Resolved
Comment thread docs/hooks.py Resolved
@uniqueg
uniqueg merged commit 5d239a4 into dev Oct 24, 2026
19 checks passed
@uniqueg
uniqueg deleted the docs/290-version-source branch October 24, 2026 04:36
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.

docs: take the version from one source

1 participant