Repository navigation
build: test against FOCA 0.17 from dev - #184
Conversation
Pin FOCA to commit db6998c on FOCA's dev branch (spec and policy patches, foca#396), with FOCA's development image of that commit as the base image, pinned by digest; the image build doesn't reinstall FOCA, and the tests check that the Dockerfile records the pinned commit. The pins are temporary (#179): the release workflow fails while a dependency is a direct reference, the base image has no release tag, or a chart dependency is a pre-release (scripts/check_release_pins.py). The chart stays on foca-common 0.1.0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fail the image build unless the base image has FOCA of the pinned commit, as the dated tag of FOCA's development image moves with later commits; Dependabot ignores the base image meanwhile. Parse the chart dependencies by section, share the version pattern, catch more spellings of direct references, and test main() without the repository state. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move the check of the base image's FOCA from an inline python -c in the Dockerfile to scripts/image_requirements.py, with tests. It now refuses direct references of FOCA other than to a full commit SHA of FOCA's repository, and matches the abbreviated commit of the installed version (any length, any further local part) as a prefix of the pin. Also check chart dependencies listed without indentation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR enables testing against unreleased FOCA 0.17 development code by pairing a Git commit dependency with a digest-pinned development image, validates that pairing during builds and tests, and adds release-workflow safeguards and documentation to ensure the temporary pins cannot ship. Sequence diagram for validating the FOCA development pin during image buildsequenceDiagram
participant Docker as Docker build
participant Requirements as image_requirements.py
participant Base as FOCA base image
participant Pip as pip
Docker->>Requirements: image_requirements(pyproject.toml)
Requirements->>Base: importlib.metadata.version(foca)
Base-->>Requirements: FOCA version with +g<commit>
alt commit matches pinned FOCA reference
Requirements-->>Docker: non-FOCA requirements
Docker->>Pip: pip install requirements
else commit mismatch or invalid reference
Requirements-->>Docker: ValueError and exit 1
Docker-->>Docker: Build fails
end
Flow diagram for blocking unreleased dependencies at release timeflowchart TD
Release[Release workflow] --> Guard[check_release_pins.py]
Guard --> App{Direct dependency reference?}
App -- Yes --> Block[Fail release]
App -- No --> Image{Release-tagged FOCA image?}
Image -- No --> Block
Image -- Yes --> Chart{Release chart dependency versions?}
Chart -- No --> Block
Chart -- Yes --> ReleaseAllowed[Release checks continue]
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 #184 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 12 14 +2
Lines 820 906 +86
=========================================
+ Hits 820 906 +86 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="Dockerfile" line_range="26" />
<code_context>
-COPY pyproject.toml /tmp/src/
-RUN python -c "import tomllib; print('\n'.join(tomllib.load(open('/tmp/src/pyproject.toml', 'rb'))['project']['dependencies']))" \
- > /tmp/src/requirements.txt \
+COPY pyproject.toml scripts/image_requirements.py /tmp/src/
+RUN python /tmp/src/image_requirements.py /tmp/src/pyproject.toml > /tmp/src/requirements.txt \
&& pip install --no-cache-dir -r /tmp/src/requirements.txt
</code_context>
<issue_to_address>
**Image build cannot copy helper**
When the Docker build uses this repository’s `.dockerignore`, docker cannot copy `/tmp/src/image_requirements.py` because the `.dockerignore` excludes `scripts/` via `*` and only re-includes the file, not its parent directory. The `COPY` step fails, so the image does not build.
Re-include the `scripts/` directory in `.dockerignore` before re-including `scripts/image_requirements.py`.
</issue_to_address>
### Comment 2
<location path="scripts/check_release_pins.py" line_range="75" />
<code_context>
+ pins = []
+ pyproject = tomllib.loads((root / "pyproject.toml").read_text())
+ for requirement in pyproject["project"]["dependencies"]:
+ if DIRECT_REFERENCE.match(requirement):
+ pins.append(
+ f"pyproject.toml: dependency '{requirement}' is a direct reference"
</code_context>
<issue_to_address>
**Prerelease runtime dependencies pass**
When a production or runtime dependency pins a prerelease with an ordinary version specifier instead of a direct URL, `DIRECT_REFERENCE.match` recognizes only direct URLs, so the release guard accepts the prerelease requirement and the image build installs it; the published release ships that prerelease dependency.
Extend the release check to reject prerelease version specifiers in production dependencies.
</issue_to_address>
### Comment 3
<location path="scripts/check_release_pins.py" line_range="36" />
<code_context>
+RELEASE_IMAGE_TAG = re.compile(SEMVER + r"-py3\.[0-9]+")
+# A chart dependency's version (`version: <version>`, in a list item of
+# `dependencies`); the chart is read line by line, without a YAML parser
+CHART_VERSION = re.compile(r"^\s+(?:-\s+)?version:\s*[\"']?(?P<version>[^\"'\s#]+)")
+RELEASE_CHART_VERSION = re.compile(SEMVER)
+
</code_context>
<issue_to_address>
**Chart prereleases bypass the guard**
When `Chart.yaml` uses an inline comment on `dependencies:` or a flow-style dependency mapping, `_chart_dependency_versions` and `CHART_VERSION` miss dependency versions in these valid YAML forms, so `find_dev_pins` sees no prerelease and the release guard allows the chart through.
Parse `Chart.yaml` as YAML and inspect versions in its dependencies.
Also at `scripts/check_release_pins.py:56-57`.
</issue_to_address>
### Comment 4
<location path="scripts/check_release_pins.py" line_range="74" />
<code_context>
+ """
+ pins = []
+ pyproject = tomllib.loads((root / "pyproject.toml").read_text())
+ for requirement in pyproject["project"]["dependencies"]:
+ if DIRECT_REFERENCE.match(requirement):
+ pins.append(
</code_context>
<issue_to_address>
**Optional extras bypass release guard**
When a direct reference is added to a published optional dependency group, `find_dev_pins` never scans `project.optional-dependencies`, so a direct reference there is published in the package metadata without failing the release check; callers installing that extra receive the unreleased dependency.
Scan the values of `project.optional-dependencies` as well as `project.dependencies` when checking for direct references.
</issue_to_address>
### Comment 5
<location path="scripts/check_release_pins.py" line_range="36" />
<code_context>
+RELEASE_IMAGE_TAG = re.compile(SEMVER + r"-py3\.[0-9]+")
+# A chart dependency's version (`version: <version>`, in a list item of
+# `dependencies`); the chart is read line by line, without a YAML parser
+CHART_VERSION = re.compile(r"^\s+(?:-\s+)?version:\s*[\"']?(?P<version>[^\"'\s#]+)")
+RELEASE_CHART_VERSION = re.compile(SEMVER)
+
</code_context>
<issue_to_address>
**Chart ranges can hide prereleases**
When a chart dependency uses a whitespace-separated constraint whose first alternative is a release and a later alternative is a prerelease, `CHART_VERSION` captures only through the first whitespace, so a valid Helm constraint such as `0.2.0 || 0.2.1-rc1` is reduced to `0.2.0`; `RELEASE_CHART_VERSION` accepts that prefix and the release check passes with a prerelease still allowed.
Parse the complete dependency version constraint and reject it unless the entire value is exactly a released version.
</issue_to_address>Sourcery assessment
Approval pending. 5 findings to address first.
Blocking findings: Dockerfile:26, scripts/check_release_pins.py:75, scripts/check_release_pins.py:36, scripts/check_release_pins.py:74, scripts/check_release_pins.py:36
Address review of the release pin check: also check optional dependencies, report version specifiers naming pre-releases, read the whole version of chart dependencies (e.g., alternatives) up to a comment, accept a comment after `dependencies:` and report dependencies in flow style, which the check can't read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
This PR tests cloud-registry against FOCA 0.17 from dev, ahead of the FOCA 0.17.0 release. The pins are temporary and #179 replaces them with the release.
pyproject.tomlpinsfoca @ git+https://github.com/elixir-cloud-aai/foca@db6998cae4e1f1fbbbaafd7a26795f3bbfa4511a, marked TEMPORARY.DockerfilebuildsFROM elixircloud/foca:20261022-py3.13@sha256:cb33b4df…. That is FOCA's development image of the same commit, which the comment## FOCA commit: <sha>records.scripts/image_requirements.pyfails the build unless the base image's FOCA version (+g<abbreviated commit>, set by setuptools-scm) matches the pinned commit. It also fails for any other direct reference of FOCA.scripts/check_release_pins.pyruns inrelease.yaml("Check that dependencies are releases"). It blocks a release while any of these is present:project.dependenciesorproject.optional-dependencies;<X.Y.Z>-py<X.Y>);elixircloud/foca, so it does not move the dated dev tag.tests/test_config.py::test_base_image_focachecks that the base image matches thefocarequirement, for both a release and a commit pin.docs/development.mddescribes the temporary pins.Closes #178
How it was verified
coverage run -m pytest: 1063 passed, 100% coverage (after merging the current dev, including feat(config)!: drop identity provider defaults #183).pre-commit run --all-files, plus--hook-stage manual gitleaks-all: passed.mkdocs build --strict: passed.docker build .passed. The image has FOCA0.16.1.dev7+gdb6998cae.docker buildwith the pin changed to another commit fails inscripts/image_requirements.py, as intended.Sourcery review
Sourcery opened 5 threads. All are replied to and resolved:
0.2.0 || 0.2.1-rc1), and a comment afterdependencies:. Dependencies in flow style are now reported as not checkable, so the check fails safe. It still uses no YAML parser, because the release workflow runs it with the standard library only..dockerignoreblocks the helper". Docker matches!scripts/image_requirements.pyagainst full paths, and the image builds both locally and in CI.Declined review findings
docs/development.md.test_base_image_focainto a release test and a commit-pin test (quality, low). Kept as one test: only one of the two branches can apply at a time, and with one test the repository is checked whichever state it is in.Open questions
None.
Notes for the user and deployers
Docker Hub retention: the base image is pinned by digest. Once FOCA's dated dev tag moves, the old digest is untagged and could eventually be cleaned up. build: require FOCA 0.17.0 and foca-common 0.2.0 #179 removes this pin before that matters.
build: require FOCA 0.17.0 and foca-common 0.2.0 #179 must:
0.17.0-py3.13;## FOCA commitcomment and the temporary Dependabot ignore;The release guard fails until then.
🤖 Generated with Claude Code