From 4792c9975f99a692936a6db3628e49c7f204e187 Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Sat, 1 Aug 2026 23:30:52 +0200 Subject: [PATCH] chore(ci): speed up nightly builds --- .github/actions/setup-rust/action.yml | 10 +++++++++- .github/workflows/oneclient_nightly.yml | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml index 6d034932..b216f6de 100644 --- a/.github/actions/setup-rust/action.yml +++ b/.github/actions/setup-rust/action.yml @@ -13,6 +13,14 @@ inputs: description: Whether to restore the Rust cache required: false default: 'true' + cache-namespace: + description: > + Cache namespace. Workflows that compile with different profile settings + MUST use different namespaces — cargo fingerprints every dependency by its + profile, so sharing one would mean each workflow evicts artifacts the other + cannot use. + required: false + default: release-cache runs: using: composite steps: @@ -29,7 +37,7 @@ runs: with: key: ${{ inputs.target }} save-if: ${{ inputs.save-cache }} - shared-key: release-cache + shared-key: ${{ inputs.cache-namespace }} # Release builds are long and can fail late (signing, notarization, # upload). Without this the whole compile is thrown away on those runs. cache-on-failure: true diff --git a/.github/workflows/oneclient_nightly.yml b/.github/workflows/oneclient_nightly.yml index 9724c13a..be98d49f 100644 --- a/.github/workflows/oneclient_nightly.yml +++ b/.github/workflows/oneclient_nightly.yml @@ -10,6 +10,22 @@ concurrency: group: oneclient-nightly-${{ github.ref }} cancel-in-progress: true +# Nightlies are unsigned test builds, so they do not need the release profile's +# whole-program optimization — and that optimization is exactly what makes them +# slow. `lto = "fat"` + `codegen-units = 1` force a single-threaded re-optimization +# of the entire dependency graph at link time, on every run, which no cache can +# ever skip. Thin LTO keeps nearly all of the runtime benefit at a fraction of the +# link cost, and 16 codegen units lets the whole compile use every runner core. +# +# These are cargo's documented profile overrides, so `target/release` stays the +# output directory and every path below is unaffected. The shipped release binary +# is untouched: oneclient_release.yml still builds the fat-LTO profile from +# Cargo.toml. That difference is why the two workflows must not share a cache +# namespace — see `cache-namespace` on the Setup Rust step. +env: + CARGO_PROFILE_RELEASE_LTO: thin + CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '16' + jobs: build: permissions: @@ -55,6 +71,10 @@ jobs: target: ${{ matrix.target }} save-cache: true restore-cache: true + # Separate namespace: nightly's thin-LTO dependency artifacts have + # different cargo fingerprints than the release workflow's fat-LTO ones, + # so a shared cache would just thrash between the two. + cache-namespace: nightly-cache - name: (Linux) Install system dependencies if: matrix.platform == 'ubuntu-22.04'