Repository navigation
ci: align release jobs, absolute README images - #50
Conversation
Rename the release jobs as in cloud-registry and proTES: build to
prepare ("Prepare release") and the PyPI job to "Release package"; needs
and outputs follow. Rewrite the relative image paths of the package
README to URLs pinned to the release tag before building, as PyPI cannot
resolve them (scripts/readme_images.py, with tests).
Closes #27
Closes #28
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Handle unquoted attributes, data-src, commas in srcset URLs, paths in angle brackets and reference-style images (through their definitions); rename the PyPI upload step; re-wrap comments. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Find images in quoted attributes with a ">", srcset candidates without a space after the comma, and shortcut reference images; refuse paths with a leading slash; report non-UTF-8 READMEs as errors. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Reviewer's GuideAligns release workflow job naming with the organization’s standard stages and adds a deterministic pre-build step that converts package README image references into release-tagged absolute GitHub URLs, with comprehensive tests and updated release documentation. Sequence diagram for release README image rewriting and publicationsequenceDiagram
participant GitHub as GitHub Actions
participant Prepare as prepare: Prepare release
participant Images as scripts.readme_images
participant PyPI as PyPI
participant Publish as publish: Publish release
GitHub->>Prepare: Validate tag and package
Prepare->>Images: rewrite(base URL, package README)
Images-->>Prepare: README with tag-pinned image URLs
Prepare->>Images: check(package README)
Images-->>Prepare: Verify no relative image paths
Prepare->>Prepare: uv build and check distributions
GitHub->>PyPI: attest distributions
GitHub->>PyPI: pypi: Upload to PyPI
GitHub->>Publish: Create GitHub release with distributions
Flow diagram for renamed release workflow stagesflowchart LR
prepare[Prepare release]
attest[Attest distributions]
pypi[Release package]
publish[Publish release]
prepare --> attest
prepare --> pypi
attest --> pypi
prepare --> publish
pypi --> publish
File-Level Changes
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 #50 +/- ##
=======================================
Coverage ? 100.00%
=======================================
Files ? 6
Lines ? 553
Branches ? 71
=======================================
Hits ? 553
Misses ? 0
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="scripts/readme_images.py" line_range="40" />
<code_context>
+# Paths with a scheme (`https:`, `data:`), `//host/...` and `#fragment`
+_ABSOLUTE = re.compile(r"^(?:[A-Za-z][A-Za-z0-9+.\-]*:|//|#)")
+# `` or ``; the path is group 3
+_MARKDOWN_IMAGE = re.compile(r"(!\[[^\]]*\]\(\s*)(<?)(?:(?<=<)([^>]+)|([^)\s>]+))")
+# `![alt][ref]` (or `![ref][]`), whose path is in a definition (`[ref]: path`);
+# the label is group 1 or 2
</code_context>
<issue_to_address>
**Invalid image paths pass checks**
When a Markdown image destination contains escaped or balanced parentheses, especially followed by enough `../` segments to leave the repository, `_MARKDOWN_IMAGE` stops at the first `)`, so `convert_images` rewrites only a destination prefix and leaves malformed Markdown; `check` can also treat the rewritten destination as absolute and miss a path that escapes the repository. The image fails to render or an escaping path passes the workflow check.
Parse Markdown image destinations with support for escaped and balanced parentheses before rewriting or validating them.
Also at `scripts/readme_images.py:100-102`.
</issue_to_address>
### Comment 2
<location path="scripts/readme_images.py" line_range="101-102" />
<code_context>
+ " README"
+ )
+ normalized = posixpath.normpath(path)
+ if normalized == ".." or normalized.startswith("../"):
+ raise ImagePathError(f"Image path '{path}' leaves the repository")
+ return f"{base.rstrip('/')}/{normalized}"
+
</code_context>
<issue_to_address>
**Valid parent paths abort releases**
When a package README uses `../` to reference an image elsewhere inside the repository, `absolute()` normalizes the image path without the package directory, so a path such as `../images/logo.png` is rejected even when it resolves to a file inside the repository from the package README. The `prepare` job then fails instead of building the release.
Validate the normalized path after resolving it against the package directory, and reject it only if that resolved path escapes the repository.
</issue_to_address>
### Comment 3
<location path="scripts/readme_images.py" line_range="169" />
<code_context>
+
+ # Labels of reference-style images, normalized as in CommonMark
+ labels = {
+ (ref or alt).strip().lower() for alt, ref in _REFERENCE_IMAGE.findall(text)
+ }
+ text = _DEFINITION.sub(definition, text)
</code_context>
<issue_to_address>
**Reference images stay relative**
When a reference-style image and its definition have labels that CommonMark considers equivalent after whitespace collapsing or Unicode case folding, `convert_images` and `relative_paths` compare labels using only `strip().lower()`, so they miss the equivalent definition; the relative image URL remains unchanged, `check` passes, and the image does not render on PyPI.
Apply the same CommonMark label normalization, including whitespace collapsing and Unicode case folding, when collecting, matching, and checking reference labels.
Also at `scripts/readme_images.py:162`, `scripts/readme_images.py:170`.
</issue_to_address>
### Comment 4
<location path="tests/test_readme_images.py" line_range="119" />
<code_context>
+ text = (ROOT / package.path / "README.md").read_text(encoding="utf-8")
+ base = f"{BASE}/{package.path}"
+ rewritten = readme_images.rewrite(text, base)
+ assert readme_images.relative_paths(rewritten) == []
+
+
</code_context>
<issue_to_address>
**Package rewrite check is vacuous**
When all discovered package READMEs contain no recognized image paths, when the discovered package READMEs contain no recognized images, `test_readmes_have_no_relative_image_paths_after_rewrite` at lines 118–119 passes even if `rewrite` is a no-op: `relative_paths` finds nothing in the unchanged text, so this package-level check gives no evidence that release README rewriting works.
Add a relative image to a package README fixture and assert its exact rewritten URL, including the package path.
</issue_to_address>Linked issues
#27 ci: align the release job names · 3 of 3 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Add a prepare job named “Prepare release” for the checks, and make the other jobs depend on it. |
✅ Met | The prepare job holds the release checks; attest, pypi, and publish depend on it directly or through their dependency chain. |
| 2 | Name registry-publishing jobs after what they release, uniquely across the repository’s workflows. | ✅ Met | The PyPI job is named “Release package”; that name is unique among the repository’s workflow jobs. |
| 3 | Keep publish / “Publish release” for creating the GitHub release. |
✅ Met |
#28 ci: rewrite README image paths for PyPI · 3 of 3 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Before building, rewrite relative package README image paths to absolute, release-tag-pinned GitHub URLs, using the repository from the run context and paths relative to the package directory. | ✅ Met | The workflow rewrites ${PACKAGE}/README.md using the repository and tag from the run context, then checks it before uv build. |
| 2 | Test that rewritten READMEs have no relative image paths left. | ✅ Met | The test applies the rewrite and checks for remaining relative image paths in every discovered package README. |
| 3 | Keep the setuptools + setuptools-scm build backend. | ✅ Met | The diff does not change the build backend. |
Sourcery assessment
Needs a human reviewer. 4 findings to address first, and the release build rewrites README image paths before packaging, so an incorrect rewrite could ship in the PyPI distribution and its published description. Reverting the workflow would not change versions already released; the bounded issue would need a corrected release.
Blocking findings: scripts/readme_images.py:40, scripts/readme_images.py:102, scripts/readme_images.py:169, tests/test_readme_images.py:119
Collapse whitespace and fold case when matching reference-style images with their definitions, as CommonMark does. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Summary
buildbecomesprepare("Prepare release"), the PyPI job is named "Release package" (IDpypi) and its step "Upload to PyPI";attest("Attest distributions") andpublish("Publish release") stay.needs:andneeds.<job>.outputsfollow. Environment, permissions, attestations and trusted publishing are unchanged (the trusted publishers name the workflow file and the environment, not the jobs).uv build, the release workflow rewrites the relative image paths of the package'sREADME.md(${PACKAGE}/README.md) tohttps://raw.githubusercontent.com/${{ github.repository }}/<tag>/<package path>/<path>(paths resolve from the package directory, as on GitHub) withpython -m scripts.readme_images(stdlib only), then runscheck. Versions here are static, so the dirty tree does not matter; the rewrite is deterministic, so builds stay reproducible.tests/test_readme_images.py, 100% branch coverage) include every package's README.docs/releasing.mduses the new job names and mentions the rewrite.Closes #27
Closes #28
Verification
ruff check,ruff format --check,mypy scripts tests docs/hooks.py,actionlint .github/workflows/release.yml: clean.coverage run --branch --source scripts,docs -m pytest tests(138 passed),coverage report: 100%.meta/README.md: rewrite + check, thenuv build --package foca-plugins; the wheel'sMETADATAhas the absolute URL with the package path.uniqueg/foca-pluginsdoes not exist; the workflow was only linted.Review
Regular lane (release workflow): adversarial and quality review, two rounds. Fixed: step order/comments, hardening of the rewrite (unquoted attributes,
data-src,srcsetedge cases,>in attributes, reference-style and shortcut images, leading slash, non-UTF-8).Declined review findings
scripts.release release.Open questions
None. Only images are rewritten; relative links in package READMEs still do not resolve on PyPI.
🤖 Generated with Claude Code
Summary by Sourcery
Align the release workflow with the organisation’s standard job naming and make package README images render reliably on PyPI.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: