Repository navigation
ci: align release jobs, absolute README images - #588
Conversation
Rename the release jobs as in cloud-registry and proTES: build to
prepare ("Prepare release"), the PyPI job to "Release package", and
publish-image to release-image ("Release image"); needs and outputs
follow. Rewrite the relative image paths of the README to URLs pinned
to the release tag before building, as PyPI cannot resolve them
(scripts/readme_images.py, with tests). The rewrite makes the work
tree dirty, so the build pins the version from the tag.
Closes #572
Closes #573
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 GuideThe PR aligns release workflow naming and dependency wiring with related workflows, and adds a tested pre-build README image rewrite that uses release-tagged raw GitHub URLs while pinning the build version to keep setuptools-scm release versions stable. Sequence diagram for release preparation and artifact publishingsequenceDiagram
participant GitHub
participant Prepare as prepare: Prepare release
participant Push as push: Push release image
participant Scan as scan: Scan release image
participant PyPI as pypi: Release package
participant ReleaseImage as release-image: Release image
participant Publish as publish: Publish release
GitHub->>Prepare: Trigger on version tag
Prepare->>Prepare: rewrite
Prepare->>Prepare: check
Prepare->>Prepare: python -m build
Prepare->>Push: needs.prepare.outputs.version
Push->>Scan: Image digests
Prepare->>PyPI: Distributions
Scan->>PyPI: Scan passed
Prepare->>ReleaseImage: needs.prepare.outputs.version
Scan->>ReleaseImage: Scanned digests
PyPI->>ReleaseImage: Package released
Prepare->>Publish: Release metadata
PyPI->>Publish: Package dependency
ReleaseImage->>Publish: Tagged images
Flow diagram for rewriting README image paths before release buildflowchart LR
A[README.md with relative image paths] --> B[rewrite]
B --> C[Release-tagged raw GitHub URLs]
C --> D[check]
D --> E[python -m build]
E --> F[Package long description with resolvable images]
E --> G[SETUPTOOLS_SCM_PRETEND_VERSION]
G --> H[Release version remains stable]
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 #588 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 56 56
Lines 7068 7068
=========================================
Hits 7068 7068
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:
|
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]>
There was a problem hiding this comment.
Hey - I've found 3 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="37" />
<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>
**Image paths are truncated**
When an unbracketed Markdown image destination contains balanced parentheses, `_MARKDOWN_IMAGE` stops at the first `)`, so `rewrite` changes only a prefix and `check` can pass on that prefix. The resulting image URL is truncated, and traversal segments after the parentheses can escape the release-tag path.
Parse the full balanced-parenthesis destination before rewriting or checking the image path.
</issue_to_address>
### Comment 2
<location path="scripts/readme_images.py" line_range="166" />
<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 broken**
When a valid reference-style image and its definition use labels that differ only in repeated internal whitespace or tabs, the label set uses `strip().lower()` without collapsing internal whitespace, so `rewrite` and `check` fail to match the definition. The relative URL remains in the package README, `check` passes, and the image does not render on PyPI.
Collapse internal whitespace in reference labels according to CommonMark before comparing them.
</issue_to_address>
### Comment 3
<location path="scripts/readme_images.py" line_range="53" />
<code_context>
+# `src="..."`, `srcset='...'` or `src=a.png` (not `data-src`); the value is
+# group 3, 4 or 5
+_HTML_ATTRIBUTE = re.compile(
+ r"""((?<![\w-])(src|srcset)\s*=\s*)(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))""",
+ re.IGNORECASE,
+)
</code_context>
<issue_to_address>
**Alt text gets rewritten**
When a quoted HTML attribute value contains text resembling `src=` or `srcset=` followed by a relative path, `_HTML_ATTRIBUTE.sub` scans the whole tag without tracking quoted attribute values, so `rewrite` treats that text as an actual image attribute and changes displayed or accessible text in the packaged README.
Parse HTML tag attributes while respecting quoted value boundaries before rewriting image sources.
</issue_to_address>Linked issues
#572 ci: align the release job names · 3 of 4 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Add a prepare job named “Prepare release” and make the other jobs depend on it. |
✅ Met | The release jobs use prepare directly or depend on it through push. |
| 2 | Ensure CI passed for the tagged commit. | ❌ Not addressed | The prepare job checks the tag, branch ancestry, citation metadata, and release notes, but does not check CI status for the tagged commit. |
| 3 | Name registry-publishing jobs after what they release, with names unique across workflows. | ✅ Met | The jobs are named “Release package,” “Push release image,” and “Release image,” distinct from the corresponding CI job names. |
| 4 | Use publish / “Publish release” to create the GitHub release. |
✅ Met | The publish job retains that name and creates the release after the package and images are released. |
#573 ci: rewrite README image paths for PyPI · 3 of 3 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Before building, rewrite relative README image paths to absolute raw GitHub URLs pinned to the release tag. | ✅ Met | The prepare job passes the repository and tag to the rewrite command, then runs check before python -m build. |
| 2 | Test that the rewritten README has no relative image paths left. | ✅ Met | The test rewrites the repository README and asserts that relative_paths returns no paths. |
| 3 | Keep the build backend as setuptools with setuptools-scm. | ✅ Met | The change does not alter the build backend. |
Sourcery assessment
Needs a human reviewer. 3 findings to address first, and if the README rewrite or release-job wiring is wrong, the workflow could publish a package whose long description has incorrect image URLs. Reverting stops future runs but cannot replace the already-published immutable PyPI version.
Blocking findings: scripts/readme_images.py:37, scripts/readme_images.py:166, scripts/readme_images.py:53
There was a problem hiding this comment.
Linked issues
#572 ci: align the release job names · 3 of 4 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | The prepare stage checks the tag, version, citation metadata, and that CI passed for the commit. | 🟡 Partly met | The workflow checks the tag/version, citation metadata, and release notes, but does not check whether CI passed for the tagged commit. |
| 2 | Use a prepare job named “Prepare release,” with the other jobs depending on it. |
✅ Met | The downstream jobs depend on prepare directly or through push. |
| 3 | Name registry-publishing jobs after what they release, with names unique across the repository’s workflows. | ✅ Met | The package, image-push, scan, and image-release job names follow the requested naming pattern. |
| 4 | Keep publish / “Publish release” for creating the GitHub release. |
✅ Met |
#573 ci: rewrite README image paths for PyPI · 3 of 3 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Before building, rewrite relative README image paths to absolute URLs pinned to the release tag, using the repository from the run context. | ✅ Met | The workflow runs the rewrite and check before the build, passing github.repository and github.ref_name. |
| 2 | Test that the rewritten README has no relative image paths left. | ✅ Met | The real-README test asserts that relative_paths finds none after rewriting. |
| 3 | Keep the build backend as setuptools with setuptools-scm. | ✅ Met | The change does not alter the build backend configuration. |
Summary
buildbecomesprepare("Prepare release"), the PyPI job is named "Release package" (IDpypi),publish-imagebecomesrelease-image("Release image (Python X)");push,scanandpublishkeep their IDs and names. Allneeds:andneeds.<job>.outputsreferences follow. Environment, permissions, attestations, signing and trusted publishing are unchanged.README.mdtohttps://raw.githubusercontent.com/${{ github.repository }}/<tag>/<path>(scripts/readme_images.py, stdlib only; handles Markdown, reference-style and HTML<img>/<source>images incl.srcset), then runscheck. Tests include the real README.SETUPTOOLS_SCM_PRETEND_VERSIONis set for the build: the rewritten README makes the work tree dirty, which I verified makes setuptools-scm produce0.19.2.dev0+...instead of the release version (the existing version check would have failed the release).docs/contributing/index.mdnames the new jobs and the README rewrite.Closes #572
Closes #573
Verification
ruff check,ruff format --check,actionlint .github/workflows/release.yml: clean. mypy clean for the new files (the rest of the repo needs the full dev install, not run).pytest tests/test_readme_images.py tests/test_repository.py tests/test_version_mentions.py tests/test_docs_hooks.py tests/test_release_assets.py tests/test_citation.py tests/test_release_notes.py --noconftest: passed (full suite with MongoDB not run locally; CI does).python -m build(with and without the pinned version),twine check --strictpassed; the sdistPKG-INFOhas the absolute logo URLs.uniqueg/focadoes not exist. The workflow was only linted (actionlint), not run end to end.Review
Regular lane (release workflow): adversarial and quality review, two rounds. Fixed: hardening of the rewrite (unquoted attributes,
data-src,srcsetedge cases,>in attributes, reference-style and shortcut images, angle-bracket paths, leading slash, non-UTF-8), step comment and re-wrapping.Declined review findings
ci.yml(dry run): the unit test over the real README covers the rewrite; running it in the CI build job would dirty the tree there as well.Open questions
None. Note for the maintainer: only images are rewritten, relative links (e.g.
docs/...md) in the README still do not resolve on PyPI.🤖 Generated with Claude Code
Summary by Sourcery
Align the release workflow and ensure packaged README images resolve correctly on PyPI.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: