From 8959ac06acb65b7090b2396891c90ea1da23c830 Mon Sep 17 00:00:00 2001 From: Tom Foster Date: Mon, 22 Sep 2025 17:05:21 +0100 Subject: [PATCH] ci: Split Rust build cache into dependencies and incremental caches Replace single large build cache with separate dependencies and incremental caches. Dependencies cache survives source code changes and uses tiered restore keys. Removes build directory from caching to improve CI performance while maintaining effective compilation caching with sccache. --- .forgejo/actions/setup-rust/action.yml | 31 ++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/.forgejo/actions/setup-rust/action.yml b/.forgejo/actions/setup-rust/action.yml index d1a070a5..4640f581 100644 --- a/.forgejo/actions/setup-rust/action.yml +++ b/.forgejo/actions/setup-rust/action.yml @@ -92,23 +92,36 @@ runs: - name: Setup sccache uses: https://git.tomfos.tr/tom/sccache-action@v1 - - name: Cache build artifacts - id: build-cache + - name: Cache dependencies + id: deps-cache uses: actions/cache@v4 with: path: | - target/**/deps - !target/**/deps/*.rlib - target/**/build target/**/.fingerprint - target/**/incremental + target/**/deps target/**/*.d + target/**/.cargo-lock + target/**/CACHEDIR.TAG + target/**/.rustc_info.json /timelord/ - # Build artifacts - cache per code change, restore from deps when code changes + # Dependencies cache - based on Cargo.lock, survives source code changes key: >- - continuwuity-build-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }}-${{ hashFiles('**/*.rs', '**/Cargo.toml') }} + continuwuity-deps-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }} restore-keys: | - continuwuity-build-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }}- + continuwuity-deps-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}- + + - name: Cache incremental compilation + id: incremental-cache + uses: actions/cache@v4 + with: + path: | + target/**/incremental + # Incremental cache - based on source code changes + key: >- + continuwuity-incremental-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }}-${{ hashFiles('**/*.rs', '**/Cargo.toml') }} + restore-keys: | + continuwuity-incremental-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }}- + continuwuity-incremental-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}- - name: End cache restore group shell: bash