Skip to content

build: test against FOCA 0.17 from dev - #184

Merged
uniqueg merged 6 commits into
devfrom
build/foca-dev-pins
Oct 23, 2026
Merged

uniqueg merged 6 commits into
devfrom
build/foca-dev-pins

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

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.

  • App: pyproject.toml pins foca @ git+https://github.com/elixir-cloud-aai/foca@db6998cae4e1f1fbbbaafd7a26795f3bbfa4511a, marked TEMPORARY.
  • Image: the Dockerfile builds FROM elixircloud/foca:20261022-py3.13@sha256:cb33b4df…. That is FOCA's development image of the same commit, which the comment ## FOCA commit: <sha> records.
    • The image has no Git, so the build leaves the FOCA pin out of the requirements it installs.
    • scripts/image_requirements.py fails 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.
  • Chart: stays on foca-common 0.1.0.
  • Release guard: scripts/check_release_pins.py runs in release.yaml ("Check that dependencies are releases"). It blocks a release while any of these is present:
    • a direct reference or a pre-release specifier in project.dependencies or project.optional-dependencies;
    • a base image tag that is not a release tag (<X.Y.Z>-py<X.Y>);
    • a chart dependency version that is not exactly a release version, or dependencies in flow style, which it can't read.
  • Dependabot: temporarily ignores elixircloud/foca, so it does not move the dated dev tag.
  • Tests and docs:
    • tests/test_config.py::test_base_image_foca checks that the base image matches the foca requirement, for both a release and a commit pin.
    • docs/development.md describes 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 FOCA 0.16.1.dev7+gdb6998cae.
  • docker build with the pin changed to another commit fails in scripts/image_requirements.py, as intended.
  • CI: all checks passed, including the image scan (Trivy) of the image built on the dev base image, Docker Compose, the Helm chart checks and Read the Docs.

Sourcery review

Sourcery opened 5 threads. All are replied to and resolved:

  • Fixed in ca6578c: pre-release specifiers, optional dependencies, chart versions with alternatives (0.2.0 || 0.2.1-rc1), and a comment after dependencies:. 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.
  • Answered as not applicable: ".dockerignore blocks the helper". Docker matches !scripts/image_requirements.py against full paths, and the image builds both locally and in CI.

Declined review findings

  • Pre-release versions are blocked, too (adversarial, round 1, low). The release guard also refuses rc versions of FOCA or foca-common. This is intended: releases depend on released versions only. It is documented in docs/development.md.
  • Split test_base_image_foca into 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

🤖 Generated with Claude Code

uniqueg and others added 5 commits October 23, 2026 01:10
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]>
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

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

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

Flow diagram for blocking unreleased dependencies at release time

flowchart 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]
Loading

File-Level Changes

Change Details Files
Temporarily pins FOCA to a development commit and aligns the Docker base image with that exact commit.
  • Replace the released FOCA requirement with a full Git commit reference.
  • Use the dated, digest-pinned FOCA development image and record its commit.
  • Exclude the direct FOCA reference during image dependency installation because the base image already contains it.
  • Validate that the image’s installed FOCA commit matches the pinned commit and reject unsupported FOCA references.
pyproject.toml
Dockerfile
scripts/image_requirements.py
tests/test_image_requirements.py
tests/test_config.py
Adds release-time enforcement to prevent development dependency pins from being released.
  • Detect direct project dependency references, non-release FOCA image tags, and non-release chart dependency versions.
  • Emit GitHub Actions error annotations and fail the release workflow when such pins are found.
  • Cover released, development, malformed, and multiple chart dependency cases with tests.
scripts/check_release_pins.py
.github/workflows/release.yaml
tests/test_check_release_pins.py
Documents and preserves the temporary development-pin workflow across repository automation.
  • Document required FOCA commit/image pairing and the requirement to replace temporary pins before release.
  • Temporarily ignore FOCA image updates in Dependabot so a moving dated tag does not alter the tested commit.
  • Add Docker ignore changes associated with the image build context.
docs/development.md
.github/dependabot.yml
.dockerignore

Assessment against linked issues

Issue Objective Addressed Explanation
#178 Temporarily pin the app to a specific FOCA dev commit, use a matching FOCA development base image pinned by digest, and keep the chart on foca-common 0.1.0. ✅
#178 Adapt Cloud Registry to FOCA 0.17 changes and ensure the project’s checks pass against the dev version. ✅
#178 Prevent temporary development pins from being included in a release by adding a release-time check. ✅

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 22, 2026 •

Copy link
Copy Markdown

Codecov Report

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

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.
📢 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 22, 2026 23:44

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


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

Comment thread Dockerfile Resolved
Comment thread scripts/check_release_pins.py Resolved
Comment thread scripts/check_release_pins.py Resolved
Comment thread scripts/check_release_pins.py Resolved
Comment thread scripts/check_release_pins.py Resolved
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]>

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

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit 6515e55 into dev Oct 23, 2026
17 checks passed
@uniqueg
uniqueg deleted the build/foca-dev-pins branch October 23, 2026 00:09
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.

build: test against FOCA 0.17 from dev

1 participant