Skip to content

ci: make CI pass in forks - #547

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

uniqueg merged 4 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. 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 (Docker Hub login), and with them the CI passed gate.

  • Codecov: fail_ci_if_error only in this repository (github.repository_owner == 'elixir-cloud-aai'); the upload is still attempted everywhere. Pull requests from forks to this repository upload tokenless and still fail on errors, as before.
  • 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, which docs/contributing.md already documented as the way forks publish to their own organization.
  • scan: runs if push passed or was skipped; where nothing is published, it builds and scans the images locally, as for pull requests, so the scan still gates. Code scanning uploads only in this repository.
  • CI passed: push/publish may be skipped whenever PUBLISH is not "true"; any failed, cancelled or other skipped job still fails it.
  • Docs: docs/contributing.md describes the fork behaviour.

Unchanged: job names and IDs, all tests, coverage threshold (fail_under = 100), linters, builds, and every upstream path. Audit of the other workflows (release.yml, release-chart.yml, scan.yml): tag/schedule-triggered; in a fork they fail safely at the first credential (as a release dry run in a fork expects), see #546.

Closes #546

Verification

  • Fork, push path: branch fork-ci-check in uniqueg/foca (this branch plus a fork-only commit adding the branch to the push trigger, as the fork's dev is its default branch): run 40637344704 (push) passed: all lint, test, integration, chart, readiness and scan jobs green, Push image/Publish image skipped and allowed by CI passed; the Codecov step logs Token required - not valid tokenless upload without failing the job. The first fork run (40634429332) failed only on the scans, on the msgpack finding below, the same as upstream: the scan still gates in forks.
  • This PR (upstream, same-repository PR path): CI passed (27 checks green; push/publish skipped as on every pull request).
  • actionlint could not run locally (downloading its binary was denied); CI validates the workflow.

Full review (adversarial-reviewer + quality-reviewer, two rounds): round 1 found one medium (the publish condition repeated, also negated in scan's if:), fixed by simplifying scan's condition; lows fixed (code scanning uploads decoupled from the publishing opt-in, comments and docs wording, wrapping). Round 2: no high or medium findings.

Unrelated fixes

  • 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 every image scan, also on dev since 2026-10-28. Accepted in .trivyignore.yaml like the other pip-vendored findings (pip runs only at build time), expiring 2027-01-31.

Later commits

  • ci: warn on release readiness in forks: found by the proTES review (CI fails in forks (Codecov, image push) protes#327): forks often lack upstream's later tags, so released versions looked unreleased and could fail fork pushes; findings are now warnings there. The gate also fails closed (PUBLISH must be exactly "false" to allow the skips). Reviewed by me only, as the two review rounds were used up.

Declined review findings

  • A separate plan job that outputs publish to remove the remaining copies of the condition (in PUBLISH and the push and publish if: lines): it adds a job, a runner start and a check name for an expression that is now repeated only in two identical job conditions next to its env definition.
  • Relaxing fail_ci_if_error for pull requests from forks to this repository: they upload tokenless, which Codecov supports for public repositories; this keeps upstream strict, as before.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Make CI pass reliably in forks without credentials while preserving the upstream publishing, scanning, and quality gates.

Bug Fixes:

  • Allow fork CI runs to complete successfully without Codecov or Docker Hub credentials while continuing to enforce tests, builds, and vulnerability scans.

Enhancements:

  • Make image publishing opt-in for forks through the DOCKERHUB_ORG repository variable and keep code-scanning uploads limited to the upstream repository.
  • Run local image builds and scans when fork runs do not publish images, while treating only intentional publishing skips as acceptable in the CI gate.
  • Downgrade release-readiness findings to warnings in forks that may not have the upstream repository's complete tag history.

Build:

  • Accept the current pip-vendored msgpack vulnerability in Trivy scans until the documented expiry date.

Documentation:

  • Document fork CI behavior, optional image publishing, required Docker Hub configuration, and upstream-only reporting.

uniqueg and others added 2 commits October 28, 2026 04:20
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.

- Codecov upload errors fail CI only in this repository.
- `push` and `publish` run only on pushes that publish images: to this
  repository, or to a fork that sets `DOCKERHUB_ORG` (as documented).
- Otherwise `scan` builds and scans the images locally, as for pull
  requests, and uploads to code scanning only where images are
  published (or for same-repository pull requests here).
- The gate allows `push` and `publish` to be skipped whenever the run
  doesn't publish.

Closes #546

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- `scan` runs if `push` passed or was skipped (it is skipped only by
  its own condition), instead of repeating that condition negated.
- Code scanning uploads only in the upstream repository, independent
  of the opt-in to publishing.
- Comments and docs: Codecov behaviour of fork PRs, the upstream
  marker, line wrapping.

Refs #546

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 workflow now distinguishes runs that can publish images from fork runs without credentials: publishing jobs are conditionally skipped, local image builds and vulnerability scans still gate CI, uploads requiring upstream permissions are restricted, and the gate fails closed for unexpected results. Documentation and an expiring Trivy exception complete the fork-CI changes.

Sequence diagram for fork CI execution without publishing credentials

sequenceDiagram
    participant GitHub as GitHub Actions
    participant Push as Push image
    participant Scan as Scan image
    participant Gate as CI passed

    GitHub->>Push: Evaluate publish condition
    Push-->>GitHub: skipped when PUBLISH is false
    GitHub->>Scan: Run because push result is skipped
    Scan->>Scan: Build image locally
    Scan->>Scan: Run Trivy scan
    Scan-->>Gate: success or failure
    Gate->>Gate: Allow only intentional push/publish skips
Loading

Flow diagram for fork-aware CI publishing and scanning

flowchart TD
    Start[CI run] --> PublishCheck{PUBLISH is true}
    PublishCheck -->|Yes| Push[Push image by digest]
    Push --> Scan[Scan image]
    PublishCheck -->|No| LocalBuild[Build image locally]
    LocalBuild --> Scan
    Scan --> ScanResult{Scan passed}
    ScanResult -->|Yes and publishing| Publish[Publish image]
    ScanResult -->|Yes without publishing| Gate[CI passed]
    Publish --> Gate
    ScanResult -->|No| Failed[CI failed]
Loading

File-Level Changes

Change Details Files
Make fork CI credential-safe while preserving tests, scans, and the required CI gate.
  • Add a PUBLISH workflow flag for upstream pushes and forks configured with DOCKERHUB_ORG.
  • Skip image push and publish jobs when publishing is not configured, while allowing the gate to treat only those intentional skips as successful.
  • Build and scan fork images locally when no publish job runs, and restrict code-scanning uploads to the upstream repository.
  • Make Codecov upload failures non-blocking outside the upstream repository while retaining strict upstream behavior.
  • Treat release-readiness findings as warnings in forks, which may not have upstream tags.
.github/workflows/ci.yml
Document fork publishing, scanning, credential, and release-readiness behavior.
  • Explain that forks without Docker Hub configuration build and scan locally without publishing.
  • Document DOCKERHUB_ORG, DOCKERHUB_LOGIN, and DOCKERHUB_TOKEN as the fork publishing configuration.
  • Clarify that Codecov errors and release-readiness findings do not fail fork CI.
docs/contributing.md
Allow the current pip-vendored msgpack vulnerability during image scanning until the dependency is updated.
  • Add an expiring Trivy exception for CVE-2026-114613 affecting pip-vendored msgpack.
.trivyignore.yaml

Assessment against linked issues

Issue Objective Addressed Explanation
#546 Make Codecov upload failures non-fatal for fork runs that lack a Codecov token, while retaining the upload attempt and keeping upstream CI strict. ✅
#546 Avoid Docker Hub push and publish jobs in forks that are not configured to publish, while still building and scanning images locally so security scans continue to gate CI. ✅
#546 Allow the CI gate to pass when push and publish are intentionally skipped for non-publishing runs, while continuing to fail for other 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

@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 (9670cee) to head (3fa4651).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #547   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           55        55           
  Lines         6667      6667           
=========================================
  Hits          6667      6667           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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 and others added 2 commits October 28, 2026 06:13
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]>
Forks often lack the upstream repository's later tags, so the release
readiness check took released versions for unreleased ones and could
fail pushes in forks; its findings are now warnings there, as on pull
requests. The gate also allows the `push`/`publish` skips only if
`PUBLISH` is exactly "false", so that it fails closed.

Refs #546

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg marked this pull request as ready for review October 28, 2026 05:55

@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 reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. The security scan did not finish, and the new Trivy exception can let an image containing the flagged msgpack version pass the vulnerability gate and be published; reverting restores the finding, but does not retract images already pushed or tagged. The CI fork changes otherwise gate publishing on pushes and a configured Docker Hub organization.


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

@uniqueg
uniqueg merged commit 7032aa5 into dev Oct 28, 2026
31 checks passed
@uniqueg
uniqueg deleted the ci/fork-safe branch October 28, 2026 06:00
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