From 8645982dffab25b50f8c6715112722b155bdff24 Mon Sep 17 00:00:00 2001 From: Jason Orendorff Date: Mon, 12 Jun 2023 11:14:05 -0500 Subject: [PATCH] rust-toolchain.toml and incremental build example Changes to rust-toolchain.toml should invalidate the cache. Also, add an example with incremental builds. --- examples.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/examples.md b/examples.md index 1bcde91..2d26193 100644 --- a/examples.md +++ b/examples.md @@ -596,7 +596,26 @@ whenever possible: ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', 'rust-toolchain.toml') }} +``` + +Since Rust compile times are so long, you might want to take advantage of incremental builds. To do this, use the configuration below. +- Include the `run_id` in the key to force `actions/cache` to upload a new snapshot after every build. +- Use `restore-keys:` to load the previous build (when there are multiple partial matches, it selects the most recent). + +```yaml +- uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ~/.rustup/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', 'rust-toolchain.toml') }}-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-cargo-${{ hashFiles(**/'Cargo.lock', 'rust-toolchain.toml') }} ``` ## Scala - SBT