The headless browser for AI agents and web scraping
ci: populate trusted dependency caches for PR checks
SGavrl43399c25766b
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 6edb81f3..0582ef27 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -2,6 +2,8 @@ name: PR checkson:pull_request:+ push:+ branches: [main]# Pull requests execute contributor-controlled build scripts, proc macros,# tests, and binaries. They must never receive a write token or repository@@ -22,6 +24,7 @@ env:jobs:policy:name: PR / Policy+ if: github.event_name == 'pull_request'runs-on: ubuntu-22.04timeout-minutes: 20outputs:@@ -79,6 +82,7 @@ jobs:audit=true;;.github/workflows/ci.yml)+ runtime=trueaudit=true;;scripts/ci/*)@@ -113,7 +117,11 @@ jobs:core:name: PR / Coreneeds: policy- if: needs.policy.outputs.runtime == 'true'+ # A successful main build warms dependencies for read-only PR jobs.+ if: >-+ !cancelled() &&+ ((github.event_name == 'push' && github.ref == 'refs/heads/main') ||+ (needs.policy.result == 'success' && needs.policy.outputs.runtime == 'true'))runs-on: ubuntu-22.04timeout-minutes: 90steps:@@ -140,9 +148,10 @@ jobs:- name: Restore Rust dependency cacheuses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2with:- # PR caches are restored but never saved. A contributor therefore- # cannot poison a cache later consumed by a release.- save-if: false+ shared-key: obscura-ci-dependencies+ # Only successful main builds save. PRs remain restore-only and+ # release workflows do not consume this cache.+ save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}- name: Build render releaserun: cargo build --release -p obscura-cli --bins --features render@@ -202,10 +211,10 @@ jobs:runs-on: ubuntu-22.04timeout-minutes: 75steps:- - name: Checkout merge result+ - name: Checkout trusted base revisionuses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6with:- fetch-depth: 0+ ref: ${{ needs.policy.outputs.base-sha }}persist-credentials: false- name: Checkout pinned obstacle course@@ -234,6 +243,7 @@ jobs:- name: Restore Rust dependency cacheuses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2with:+ shared-key: obscura-ci-dependenciessave-if: false- name: Build base revision@@ -242,21 +252,15 @@ jobs:BASE_SHA: ${{ needs.policy.outputs.base-sha }}run: |set -euo pipefail- base_root="$RUNNER_TEMP/obscura-base"script_root="$RUNNER_TEMP/obscura-ci-scripts"- git worktree add --detach "$base_root" "$BASE_SHA"mkdir -p "$script_root"git show "$BASE_SHA:scripts/ci/perf_smoke.py" > "$script_root/perf_smoke.py"git show "$BASE_SHA:scripts/ci/compare_obstacle.py" > "$script_root/compare_obstacle.py"- # Run from the trusted worktree so a PR-supplied .cargo/config.toml in- # the merge checkout cannot alter the compiler or wrapper for the base.- (- cd "$base_root"- CARGO_TARGET_DIR="$RUNNER_TEMP/obscura-base-target" \- cargo build --release -p obscura-cli --bins --features render- )+ # Checkout and cache metadata both belong to the trusted base. Build+ # in the restored target directory, not a separate empty worktree.+ cargo build --release -p obscura-cli --bins --features renderinstall -D -m 0755 \- "$RUNNER_TEMP/obscura-base-target/release/obscura" \+ target/release/obscura \"$RUNNER_TEMP/obscura-ci/obscura-base"chmod 0755 "$RUNNER_TEMP/obscura-ci/obscura-pr"