Skip to content

ci: pass build artifacts between jobs via upload/download-artifact#28

Merged
hawkff merged 1 commit into
mainfrom
chore/ci-artifact-bus
Jun 18, 2026
Merged

ci: pass build artifacts between jobs via upload/download-artifact#28
hawkff merged 1 commit into
mainfrom
chore/ci-artifact-bus

Conversation

@hawkff

@hawkff hawkff commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

Proper fix for the cross-job cache-poisoning vector (the follow-up tracked from #18/#27).

Problem

The build job needs: the libcore and sidecars jobs and restored their caches to assemble the APK — using the cache as a cross-job artifact bus. That means an untrusted pull_request run could populate a cache key that a later trusted (push/main) run restores. Simply gating save to non-PR events (attempted in #27) breaks the bus, because PR runs then can't pass artifacts between jobs at all.

Fix

Use the right tool for each purpose:

  • Cross-job passing → artifacts: each producer job (libcore, sidecars) now upload-artifacts its output (libcore.aar, executableSo); the build job download-artifacts them. Artifacts are scoped to a single workflow run, so there's no cross-run trust boundary.
  • Speed → job-local caches only: the remaining actions/cache steps are each produced and consumed within the same job (libcore.aar in libcore, executableSo in sidecars, ~/.gradle in build). No job restores a cache another job wrote, so there's nothing to poison — and caches keep working on PR runs (no save-gating needed).

Applied uniformly across build/ci/preview/release (the release publish job is unchanged).

Verification

  • All 4 workflows valid YAML; 3 job-local caches each, 0 cross-job cache restores.
  • Upload/download artifact names match within each workflow.

The real test is CI on this PR exercising the new artifact bus.

Greptile Summary

This PR replaces the cross-job actions/cache artifact bus with upload-artifact/download-artifact, fixing the cache-poisoning vector where a PR run could write a cache entry later consumed by a trusted push run. The change is applied uniformly across all four workflows.

  • Each producer job (libcore, sidecars) now uploads its output via upload-artifact (with if-no-files-found: error for early failure), and the build job downloads them; artifacts are scoped to a single workflow run so no cross-run trust boundary exists.
  • Job-local caches are retained within libcore and sidecars for build speed; the build job no longer restores any cache written by another job.
  • Artifact names are workflow-scoped (-build, -ci, -preview, -release), and the build/preview/release workflows' libcore cache keys remain shared (all are workflow_dispatch/push-only, never triggered by PRs).

Confidence Score: 5/5

The change is safe to merge; it removes the cross-job cache bus and replaces it with run-scoped artifacts without disrupting any build logic.

The upload/download artifact names match within each workflow, the download paths reconstruct the directory layout that the Gradle build and sidecar-verification step expect, if-no-files-found: error ensures a missing artifact surfaces as a job failure rather than a silent stale-file issue, and the residual within-job caches are content-addressed and never consumed across jobs. No functional regressions are apparent.

No files require special attention.

Important Files Changed

Filename Overview
.github/workflows/build.yml Cross-job cache steps in the build job replaced with download-artifact; libcore and sidecars jobs gain matching upload-artifact steps. Logic is consistent and artifact names are unique within the run.
.github/workflows/ci.yml Same artifact bus refactor as build.yml. Artifact names use the -ci suffix, keeping them separate from the other three workflows' artifact namespaces within their own runs.
.github/workflows/preview.yml Same pattern applied correctly with -preview artifact names. Libcore cache key is shared with build.yml and release.yml (intentional design for workflow_dispatch-only workflows).
.github/workflows/release.yml Same refactor applied with -release artifact names. The publish job's existing download-artifact (for the final APK) is unchanged and unaffected.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant LC as libcore job
    participant SC as sidecars job
    participant AS as Artifact Store (run-scoped)
    participant BJ as build job

    LC->>LC: actions/cache restore (job-local)
    alt cache miss
        LC->>LC: Install Golang + ./run lib core
    end
    LC->>AS: "upload-artifact (libcore-aar-{workflow})"
    SC->>SC: actions/cache restore (job-local)
    alt cache miss
        SC->>SC: Build Mieru/Hysteria2/MDVPN/Naive
    end
    SC->>AS: "upload-artifact (sidecars-so-{workflow})"
    BJ->>AS: "download-artifact (libcore-aar-{workflow})"
    BJ->>AS: "download-artifact (sidecars-so-{workflow})"
    BJ->>BJ: Verify sidecar .so files
    BJ->>BJ: Gradle Build (APK)
    BJ->>AS: upload-artifact (final APK)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant LC as libcore job
    participant SC as sidecars job
    participant AS as Artifact Store (run-scoped)
    participant BJ as build job

    LC->>LC: actions/cache restore (job-local)
    alt cache miss
        LC->>LC: Install Golang + ./run lib core
    end
    LC->>AS: "upload-artifact (libcore-aar-{workflow})"
    SC->>SC: actions/cache restore (job-local)
    alt cache miss
        SC->>SC: Build Mieru/Hysteria2/MDVPN/Naive
    end
    SC->>AS: "upload-artifact (sidecars-so-{workflow})"
    BJ->>AS: "download-artifact (libcore-aar-{workflow})"
    BJ->>AS: "download-artifact (sidecars-so-{workflow})"
    BJ->>BJ: Verify sidecar .so files
    BJ->>BJ: Gradle Build (APK)
    BJ->>AS: upload-artifact (final APK)
Loading

Reviews (1): Last reviewed commit: "ci: pass build artifacts between jobs vi..." | Re-trigger Greptile

Fixes the cross-job cache-poisoning vector properly. The build/APK job used to
restore the libcore + sidecars caches produced by other jobs, so an untrusted
pull_request run could populate a cache that a later trusted run restored.

Now each producer job (libcore, sidecars) uploads its output as a workflow
artifact, and the build job downloads them. Caches that remain are strictly
job-local (libcore.aar in the libcore job, executableSo in the sidecars job,
~/.gradle in the build job) — each is produced and consumed within the same
job, so there is no cross-job/cross-run cache trust boundary to poison.

This also lets caches keep working on pull_request runs (no save-gating needed),
since they are no longer the cross-job bus.
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@hawkff, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 1 hour, 30 minutes, and 41 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 901ea19b-a644-4756-8acb-12e8393fd66e

📥 Commits

Reviewing files that changed from the base of the PR and between 332c29e and d281225.

📒 Files selected for processing (4)
  • .github/workflows/build.yml
  • .github/workflows/ci.yml
  • .github/workflows/preview.yml
  • .github/workflows/release.yml

Comment @coderabbitai help to get the list of available commands and usage tips.

@hawkff

hawkff commented Jun 18, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hawkff hawkff merged commit bf38a0e into main Jun 18, 2026
5 checks passed
@hawkff hawkff deleted the chore/ci-artifact-bus branch June 23, 2026 00:45
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.

1 participant