Repository navigation
ci: make CI pass in forks - #328
Conversation
Forks have neither the Codecov token nor the Docker Hub secrets, so a push to a fork's `dev` failed the Codecov upload and the `push` job, and with them the `CI passed` gate, although all checks passed. As in FOCA: - Codecov upload errors fail CI only on pushes to this repository. - `push` and `publish` run only on pushes that publish the image: to this repository, or to a fork that sets `DOCKERHUB_ORG`. - Otherwise `scan` builds and scans the image locally, as for pull requests; code scanning uploads happen in this repository only. - The gate allows `push` and `publish` to be skipped whenever the run doesn't publish. Closes #327 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Release readiness: findings are warnings in forks, which often lack the upstream repository's later tags, so released versions would look unreleased and fail the run. - The gate allows skips of `push` and `publish` only if `PUBLISH` is exactly "false" (fails closed). - A test checks that `push` and `publish` use the `PUBLISH` condition. - Docs: the `dev-images` environment for forks that publish; rewrap. Refs #327 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR adapts CI to run reliably in forks by conditionally disabling credential-dependent publishing and uploads, locally building and scanning images when needed, preserving strict upstream checks, and adding tests and documentation to keep the conditions consistent. It also includes test-isolation and Trivy-ignore maintenance required to restore the development branch CI baseline. Sequence diagram for fork CI gate evaluationsequenceDiagram
participant GitHubActions
participant Jobs
participant Gate as CIpassed
GitHubActions->>Jobs: Run lint, test, chart, docs, smoke, push, scan, publish
Jobs-->>Gate: Return job results
alt PUBLISH is false
Gate->>Gate: Allow push and publish skipped
else PUBLISH is true
Gate->>Gate: Reject push or publish skipped
end
Gate->>Gate: Reject failed, cancelled, or unintended skipped jobs
Gate-->>GitHubActions: Report CI passed or failed
Flow diagram for fork-aware CI publishing and scanningflowchart TD
A["Push workflow starts"] --> B{"PUBLISH is true?"}
B -- "yes: upstream or fork with DOCKERHUB_ORG" --> C["push builds and publishes image by digest"]
B -- "no: fork without DOCKERHUB_ORG" --> D["scan builds image locally"]
C --> E["scan scans published digest"]
D --> E
E --> F{"Scan passes?"}
F -- "yes" --> G["publish attests, signs, and tags image"]
F -- "no" --> H["CI fails; image is not published"]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
With pytest 9.2.0, `monkeypatch.setattr(celery.conf, "foca", ...)` records the setting as missing (Celery's settings are a mapping that resolves keys as attributes), so its undo calls `delattr`, which fails and leaks the patched config into later tests: three errors on `dev` since 2026-10-28. `monkeypatch.setitem` restores the item on every pytest version. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CVE-2026-114613 (HIGH, memory leak in map deserialization) affects msgpack 1.1.2, which pip 26.2.2, the latest release, vendors. It failed the image scans on `dev` and every pull request. pip runs only at build time, so the app is not affected; the entry expires like the other pip-vendored ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #328 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 29 29
Lines 2470 2470
=========================================
Hits 2470 2470 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/test_workflows.py" line_range="100-102" />
<code_context>
+ (e.g., release readiness findings to warnings).
+ """
+ text = (WORKFLOWS / "ci.yml").read_text()
+ owners = re.findall(r"github\.repository_owner\s*==\s*'([^']*)'", text)
+ assert owners
+ assert set(owners) == {"elixir-cloud-aai"}
+ assert (
+ '$publish == "false"'
</code_context>
<issue_to_address>
**Inverted owner checks go unnoticed**
When one owner comparison is inverted while the other owner checks remain unchanged, one owner comparison changes from `==` to `!=`, so `test_upstream_owner` line 100 omits that comparison from `owners`; the unchanged comparisons still satisfy lines 101–102, and the test passes despite the inverted behavior.
Check that every owner comparison is accounted for and uses the expected equality operator and owner.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, the security scan did not finish, and the new Trivy ignore entry suppresses CVE-2026-114613 for msgpack vendored by pip, so an affected image could pass the vulnerability gate and be published. Reverting restores the gate, but already published image digests or tags would remain and may need to be replaced or removed.
Blocking findings: tests/test_workflows.py:102
`test_upstream_owner` found only `==` comparisons, so an owner check inverted to `!=` went unnoticed (Sourcery). It now requires every `github.repository_owner` in `ci.yml` to be compared with `==` to `elixir-cloud-aai`. Refs #327 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Makes CI pass in forks exactly when the code is good, as in FOCA (elixir-cloud-aai/foca#547). Forks have neither the Codecov token nor the Docker Hub secrets, so a push to a fork's
devfailed the Codecov upload andpush(Docker Hub login), and with them theCI passedgate.github.repository_owner == 'elixir-cloud-aai'); the upload is still attempted everywhere.push/publish: only where the run publishes (PUBLISH, workflow env): pushes to this repository, or to a fork that sets the repository variableDOCKERHUB_ORG(already documented as the way forks publish; they also need the secrets in an environmentdev-images).scan: runs ifpushpassed or was skipped; where nothing is published, it builds and scans the image locally, as for pull requests, so the scan still gates. Code scanning uploads only in this repository.CI passed:push/publishmay be skipped only wherePUBLISHis exactly "false" (fails closed); any failed, cancelled or other skipped job still fails it.release.ymlrepeats these checks and still fails hard.tests/test_workflows.pychecks thatpush/publishuse thePUBLISHcondition, that every owner check nameselixir-cloud-aai, and that the gate fails closed.docs/development.mddescribes the fork behaviour.Unchanged: job names and IDs, tests, coverage, linters, builds, and every upstream path.
release.yml(tags) andscan.yml(schedule/manual) audited: in a fork they fail safely at the first credential, as a release dry run in a fork expects; see #327.Closes #327
Verification
tests/test_workflows.py: 6 passed locally (with--noconftest, as the full test environment wasn't set up); ruff check and format pass.fork-ci-checkinuniqueg/proTES(this branch plus a fork-only commit adding the branch to the push trigger, as the fork'sdevis its default branch): run 40639981491 (push) passed: lint, tests, chart, docs, readiness, smoke test and scan green,Push image/Publish imageskipped and allowed byCI passed. The first fork run (40637909397) failed only on the unrelated failures below, asdevdoes.Full review (adversarial-reviewer + quality-reviewer, two rounds): round 1 found one medium (release readiness in forks, outside the diff), fixed; lows fixed (gate fails closed, consistency tests, docs). Round 2: no high or medium findings.
Unrelated fixes
devhas been red since 2026-10-28 for two reasons, fixed in separate commits (reviewed by me only, after the two review rounds):test: patch Celery's FOCA config as an item: with pytest 9.2.0,monkeypatch.setattr(celery.conf, "foca", ...)records the setting as missing (Celery's settings resolve keys as attributes), so its undo callsdelattr, which fails and leaks the patched config into later tests (3 errors).monkeypatch.setitemrestores it on every pytest version; reproduced and verified locally with pytest 9.2.0.build: accept pip's vendored msgpack CVE: CVE-2026-114613 (HIGH) in msgpack 1.1.2, vendored by pip 26.2.2 (the latest release; pip's main branch has 1.2.3), failed the image scan. Accepted in.trivyignore.yamllike the other pip-vendored findings (the app doesn't install msgpack; pip runs only at build time), expiring 2027-01-31. Same as in ci: make CI pass in forks foca#547.Declined review findings
DOCKERHUB_ORG: the docs already describeDOCKERHUB_ORGas the setting of forks that publish; a fork that sets it without the secrets gets a clear login failure.planjob to computePUBLISHonce: adds a job and check for an expression now guarded by a test.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Make fork CI mirror upstream validation while safely skipping credential-dependent publishing and uploads unless explicitly configured.
Bug Fixes:
Enhancements:
Build:
CI:
Documentation:
Tests: