mirror of
https://github.com/storytold/craft-common-actions.git
synced 2026-11-19 17:05:11 +00:00
gate: opt-in sccache for the workspace's own crates
rust-cache keeps dependencies but not the workspace's crates, so every gate run compiles all of them again. With `sccache: true` the gate wraps rustc in sccache over the GitHub Actions cache. It writes where the dependency cache saves (the default branch, opted-in dispatches) and only reads elsewhere; SCCACHE_GHA_RW_MODE in `env` overrides that. Off by default, so no caller changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
91e2c76173
commit
9746d75ce5
2 files changed
+31
-2
No files matched your search
@@ -78,6 +78,11 @@ on:
|
||||
type: boolean
|
||||
required: false
|
||||
default: true
|
||||
sccache:
|
||||
description: "Also cache the workspace crates' compiled libraries (which rust-cache leaves out) with sccache in the GitHub Actions cache. It writes where the dependency cache is saved (pushes to the default branch, opted-in manual runs); other runs read those entries. SCCACHE_GHA_RW_MODE in `env` overrides that. Test executables are never cached"
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
cache-version:
|
||||
description: "Bump to start the dependency cache afresh"
|
||||
type: string
|
||||
@@ -266,6 +271,25 @@ jobs:
|
||||
save-if: ${{ github.event_name != 'pull_request' && (github.ref_name == github.event.repository.default_branch || (inputs.cache-save-on-dispatch && github.event_name == 'workflow_dispatch')) }}
|
||||
cache-on-failure: true
|
||||
|
||||
# After rust-cache, so its key does not depend on RUSTC_WRAPPER.
|
||||
- name: Install sccache
|
||||
if: inputs.sccache
|
||||
uses: Mozilla-Actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
|
||||
with:
|
||||
version: v0.18.0
|
||||
|
||||
- name: Use sccache
|
||||
if: inputs.sccache
|
||||
shell: bash
|
||||
env:
|
||||
WRITES: ${{ github.event_name != 'pull_request' && (github.ref_name == github.event.repository.default_branch || (inputs.cache-save-on-dispatch && github.event_name == 'workflow_dispatch')) }}
|
||||
run: |
|
||||
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
|
||||
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
|
||||
if [ -z "${SCCACHE_GHA_RW_MODE:-}" ] && [ "$WRITES" != true ]; then
|
||||
echo "SCCACHE_GHA_RW_MODE=READ_ONLY" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
- name: Gate
|
||||
shell: bash
|
||||
env:
|
||||
|
||||
Reference in new issue
Block a user