Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,24 @@ runs:
safe_abi="${descriptor//[^A-Za-z0-9_.-]/-}"
printf 'value=%s\n' "${safe_abi:0:80}" >> "$GITHUB_OUTPUT"

- name: Install sccache
- name: Configure Google-backed sccache
if: ${{ inputs.use-sccache == 'true' }}
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
uses: ./.github/actions/setup-sccache
with:
version: v0.17.0

- name: Configure sccache
if: ${{ inputs.use-sccache == 'true' }}
shell: bash
run: |
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
backend: auto
rust-toolchain: ${{ inputs.toolchain }}
allow-gha-fallback: "false"

- name: Cache Cargo
uses: Swatinem/rust-cache@23869a5bd66c73db3c0ac40331f3206eb23791dc # v2.9.1
with:
workspaces: ${{ steps.rust-paths.outputs.cache-workspaces }}
shared-key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.host-abi.outputs.value }}-target-path-v2-${{ inputs.cache-group }}
shared-key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.host-abi.outputs.value }}-cargo-inputs-v3-${{ inputs.cache-group }}
add-job-id-key: "false"
# Compiler outputs belong in the Google-backed sccache bucket. Keep the
# GitHub cache limited to Cargo inputs/tooling rather than duplicating target/.
cache-targets: "false"
# The action always hashes Cargo/Rust variables. The home paths above are
# normalized, and these prefixes add the remaining build-affecting inputs.
env-vars: "CARGO_BUILD_TARGET CARGO_ENCODED_RUSTFLAGS CARGO_INCREMENTAL CARGO_PROFILE RUSTC_WRAPPER RUSTFLAGS CC CFLAGS CXX CMAKE"
Expand Down
64 changes: 64 additions & 0 deletions .github/actions/setup-sccache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Setup sccache
description: >
Install sccache and select a backend. GCS on ARC when GCE metadata
identity is present and an objects.list probe of evalops-prod-ci-sccache
succeeds. Else local disk when the runner service exports
SCCACHE_LOCAL_DIR to an absolute writable path (WSL:
/var/cache/evalops-sccache, SCCACHE_CACHE_SIZE default 40G). GitHub
Actions cache is an opt-out fallback for callers that still require it.
Callers compile with RUSTC_WRAPPER=sccache.

inputs:
version:
description: sccache release tag consumed by mozilla-actions/sccache-action.
required: false
default: v0.15.0
backend:
description: >
sccache storage backend. `auto` (default) probes the GCE metadata
server and uses `gcs` when the runner identity answers and an
objects.list probe of the sccache prefix returns HTTP 200; else
`local` when SCCACHE_LOCAL_DIR is an absolute writable directory;
else `gha`. The GCS probe is GET .../b/<bucket>/o?maxResults=1&prefix=...
(storage.objects.list), not buckets.get, because the runner GSA
is roles/storage.objectUser. A 404 or 403 warns and falls back to
local disk if configured, else `gha`. `gcs`, `local`, and `gha`
force a backend, but `gcs` still falls back if the prefix is
unusable and `local` still falls back if the dir is missing.
required: false
default: auto
gcs-bucket:
description: GCS bucket for the sccache compiler cache on ARC runners.
required: false
default: evalops-prod-ci-sccache
rust-toolchain:
description: >
Rust toolchain used to namespace compiler objects. Callers that install
a toolchain explicitly should pass the same value; repository
rust-toolchain.toml or mise.toml remains the fallback.
required: false
default: ""
allow-gha-fallback:
description: >
Permit auto/local selection to fall back to GitHub Actions cache when
neither GCS nor persistent local disk is available. When false, use an
ephemeral local cache instead and reject an explicit gha backend.
required: false
default: "true"

runs:
using: composite
steps:
- name: Install sccache
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
with:
version: ${{ inputs.version }}
disable_annotations: true
- name: Configure sccache backend
shell: bash
env:
SCCACHE_BACKEND: ${{ inputs.backend }}
SCCACHE_GCS_BUCKET_NAME: ${{ inputs.gcs-bucket }}
SCCACHE_RUST_TOOLCHAIN: ${{ inputs.rust-toolchain }}
SCCACHE_ALLOW_GHA_FALLBACK: ${{ inputs.allow-gha-fallback }}
run: bash "${GITHUB_ACTION_PATH}/configure.sh"
Loading
Loading