mirror of
https://github.com/storytold/craft-common-actions.git
synced 2026-11-15 15:02:24 +00:00
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:
3 files changed
+48
-3
No files matched your search
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -527,7 +527,17 @@ The quality gate for an app's pull requests and pushes to main. It runs `command
|
||||
`cache-save-on-dispatch: true`. The restore prefix includes the canonical root `[profile]`
|
||||
table; dependency, version and comment edits do not discard reusable dependency artifacts.
|
||||
rust-cache still keys on lockfiles, member manifests, toolchain and build environment, and
|
||||
Cargo validates restored fingerprints. Bump `cache-version` to start afresh.
|
||||
Cargo validates restored fingerprints. Bump `cache-version` to start afresh;
|
||||
- with `sccache: true`, sccache (through the GitHub Actions cache) for the workspace's own
|
||||
library crates, which rust-cache doesn't keep. It writes where the dependency cache saves and
|
||||
only reads elsewhere; set `SCCACHE_GHA_RW_MODE` in `env` to choose. Test, binary and
|
||||
proc-macro crates aren't cacheable, so it mainly helps workspaces with many library crates.
|
||||
sccache's cache starts afresh when `cache-version` or any `Cargo.toml` or `build.rs` changes,
|
||||
because its key leaves out `--check-cfg`: a cached compile would replay its old
|
||||
`unexpected_cfgs` warnings after the expected cfgs change. It also can't see files a procedural
|
||||
macro reads without rustc tracking them (some asset-embedding macros): don't opt in while
|
||||
such files change often, or bump `cache-version` when they do. `SCCACHE_GHA_VERSION` in
|
||||
`env` sets the cache's version instead;
|
||||
|
||||
After the gate, the job fails if `Cargo.lock` changed. Legs run with `fail-fast: false`; each has
|
||||
`timeout-minutes` (default 60). A job only some apps need, such as a web build or a Windows-only
|
||||
@@ -923,7 +933,8 @@ Ordinary test failures still allow coverage and static analysis to upload, but t
|
||||
fail the scan job. Missing shard status also fails closed; a green analysis job
|
||||
must not conceal failed tests. The single-shard Rust path is unchanged.
|
||||
|
||||
The scan job frees unused runner SDKs before either Rust coverage path. Sharded
|
||||
The scan job frees unused runner SDKs before either Rust coverage path. The archive build
|
||||
frees them in the background, so the build starts at once. Sharded
|
||||
coverage merges and removes the shard profiles before extracting the test archive, then
|
||||
releases the compressed archive and temporary binaries as they are consumed.
|
||||
Disk-space snapshots in the logs show headroom before cleanup and aggregation.
|
||||
|
||||
Reference in new issue
Block a user