Merge pull request #198 from storytold/ci/opt-in-sccache

gate: opt-in sccache; sonarcloud: free disk space in the background in the archive build
This commit is contained in:
FredApps authored and GitHub committed 2026-11-13 22:08:20 +01:00
commit f76646c68b
3 files changed
+48 -3

No files matched your search

+32
View File
@@ -83,6 +83,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. Its cache starts afresh when cache-version, a Cargo.toml or a build.rs changes; bump cache-version when files a procedural macro reads change (see the README)"
type: boolean
required: false
default: false
cache-version:
description: "Bump to start the dependency cache afresh"
type: string
@@ -279,6 +284,33 @@ 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')) }}
# sccache leaves `--check-cfg` out of its key, so after a change to the expected cfgs a
# cached compile would replay its old `unexpected_cfgs` warnings. A change to the files
# that declare them (Cargo.toml lints, build scripts), or to cache-version, starts a
# fresh sccache cache instead.
VERSION: ${{ inputs.cache-version }}-${{ hashFiles('**/Cargo.toml', '**/build.rs') }}
run: |
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
if [ -z "${SCCACHE_GHA_VERSION:-}" ]; then
echo "SCCACHE_GHA_VERSION=$VERSION" >> "$GITHUB_ENV"
fi
if [ -z "${SCCACHE_GHA_RW_MODE:-}" ] && [ "$WRITES" != true ]; then
echo "SCCACHE_GHA_RW_MODE=READ_ONLY" >> "$GITHUB_ENV"
fi
- name: Caller setup
if: inputs.setup-command != ''
shell: bash
+3 -1
View File
@@ -235,8 +235,10 @@ jobs:
run: |
echo "CRAFT_FONTS_DIR=$CRAFT_FONTS_PATH" >> "$GITHUB_ENV"
echo "CRAFT_FONTS_REQUIRED=1" >> "$GITHUB_ENV"
# In the background, as in gate.yml: the space is free before the build needs it.
- name: Free disk space
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
run: |
nohup sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL </dev/null >/dev/null 2>&1 &
- name: Install Linux build dependencies
uses: storytold/craft-common-actions/actions/install-apt-packages@main
with: