Skip to content

ci: make CI pass in forks - #328

Merged
uniqueg merged 5 commits into
devfrom
ci/fork-safe
Oct 28, 2026
Merged

uniqueg merged 5 commits into
devfrom
ci/fork-safe

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

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 dev failed the Codecov upload and push (Docker Hub login), and with them the CI passed gate.

  • Codecov: upload errors fail CI only on pushes to this repository (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 variable DOCKERHUB_ORG (already documented as the way forks publish; they also need the secrets in an environment dev-images).
  • scan: runs if push passed 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/publish may be skipped only where PUBLISH is exactly "false" (fails closed); any failed, cancelled or other skipped job still fails it.
  • Release readiness: findings are warnings in forks (as on pull requests), as forks often lack upstream's later tags, so released versions would look unreleased. release.yml repeats these checks and still fails hard.
  • Tests: tests/test_workflows.py checks that push/publish use the PUBLISH condition, that every owner check names elixir-cloud-aai, and that the gate fails closed.
  • Docs: docs/development.md describes the fork behaviour.

Unchanged: job names and IDs, tests, coverage, linters, builds, and every upstream path. release.yml (tags) and scan.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

  • Full test suite locally (mongomock): 1048 passed, 80 skipped, coverage 100%; mypy on the changed tests passes.
  • tests/test_workflows.py: 6 passed locally (with --noconftest, as the full test environment wasn't set up); ruff check and format pass.
  • Fork, push path: branch fork-ci-check in uniqueg/proTES (this branch plus a fork-only commit adding the branch to the push trigger, as the fork's dev is its default branch): run 40639981491 (push) passed: lint, tests, chart, docs, readiness, smoke test and scan green, Push image/Publish image skipped and allowed by CI passed. The first fork run (40637909397) failed only on the unrelated failures below, as dev does.
  • This PR: CI passed (push/publish skipped as on every pull request).

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

dev has 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 calls delattr, which fails and leaks the patched config into later tests (3 errors). monkeypatch.setitem restores 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.yaml like 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

  • A separate opt-in variable for publishing in forks instead of DOCKERHUB_ORG: the docs already describe DOCKERHUB_ORG as the setting of forks that publish; a fork that sets it without the secrets gets a clear login failure.
  • A plan job to compute PUBLISH once: 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:

  • Allow CI runs in forks to complete successfully without Codecov or Docker Hub credentials.
  • Ensure fork image scans still gate CI by building and scanning images locally when publishing is disabled.
  • Prevent pytest configuration monkeypatches from leaking between tests across pytest versions.

Enhancements:

  • Restrict image publishing and code-scanning uploads to upstream runs or explicitly configured publishing forks.
  • Make release-readiness findings warnings in forks while retaining strict checks in the upstream repository.
  • Make the CI gate fail closed for failed, cancelled, or unexpectedly skipped jobs.

Build:

  • Accept the known pip-vendored msgpack vulnerability through the existing Trivy ignore policy until the specified expiry date.

CI:

  • Add workflow tests that verify publishing conditions, upstream-owner checks, and fail-closed gate behavior.

Documentation:

  • Document fork publishing requirements, local image scanning behavior, and credential handling.

Tests:

  • Update Celery configuration tests to patch mapping entries safely.

uniqueg and others added 2 commits October 28, 2026 05:39
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]>
@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

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

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

Flow diagram for fork-aware CI publishing and scanning

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

File-Level Changes

Change Details Files
Make the main CI workflow credential-aware so fork runs validate code and scans without requiring upstream-only secrets.
  • Gate Codecov failure handling and code-scanning uploads on the upstream repository owner while retaining the uploads where permitted.
  • Introduce the PUBLISH condition for upstream pushes and explicitly configured publishing forks, and apply it consistently to image push and publish jobs.
  • Build and scan fork images locally when publishing is disabled, while scanning the pushed digest for publishing runs.
  • Treat release-readiness findings as warnings in forks because their tag history may differ from upstream.
  • Make the CI passed gate fail closed, allowing skipped image jobs only when PUBLISH is exactly false.
  • Add workflow consistency tests for publish conditions, owner checks, and gate behavior.
.github/workflows/ci.yml
tests/test_workflows.py
Document fork CI behavior and publishing requirements.
  • Explain that forks without DOCKERHUB_ORG build and scan locally without publishing.
  • Document the required Docker Hub organization variable and dev-images secrets for fork publishing.
  • Clarify warning behavior for fork release-readiness checks and the scope of code-scanning uploads.
docs/development.md
Update test isolation and vulnerability allowances for the CI baseline.
  • Patch Celery configuration as a mapping item so pytest restores it reliably.
  • Accept the pip-vendored msgpack CVE through the existing Trivy ignore mechanism with an expiry date.
tests/tasks/test_track_task_progress.py
tests/test_celery_worker.py
.trivyignore.yaml

Assessment against linked issues

Issue Objective Addressed Explanation
#327 Make Codecov upload failures non-fatal for fork pushes while continuing to attempt uploads, and keep them fatal for upstream pushes. ✅
#327 Avoid Docker Hub credential failures in forks that do not publish, while still building and scanning their image locally; allow publishing only on upstream pushes or fork pushes configured with DOCKERHUB_ORG, and upload scan findings to code scanning only in the upstream repository. ✅
#327 Keep the CI gate passing for intentionally skipped push/publish jobs only when the run is not publishing, while still failing for failed, cancelled, or unexpectedly skipped jobs. ✅

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

@read-the-docs-community

read-the-docs-community Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35461457 | 📁 Comparing e01d72e against latest (3d8ed5d)

  🔍 Preview build  

1 file changed
± development/index.html

uniqueg and others added 2 commits October 28, 2026 06:41
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

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (296e8f8) to head (1810cc8).
⚠️ Report is 2 commits behind head on dev.

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.
📢 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 28, 2026 06:00

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


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

Comment thread tests/test_workflows.py Resolved
`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]>
@uniqueg
uniqueg merged commit 5f8b35c into dev Oct 28, 2026
17 checks passed
@uniqueg
uniqueg deleted the ci/fork-safe branch October 28, 2026 06:10
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.

CI fails in forks (Codecov, image push)

1 participant