From 226a795b510330e9c0276451cfef186c0ed8af2e Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Mon, 25 Sep 2023 14:22:54 -0700 Subject: [PATCH] Improve cargo example Adds `restore-keys` for cargo - this helps improve build times by allowing the cache to be mostly pre-populated when deps are updated. Adds two missing cache files. Adds a build type parameter to the cache keys to account for different build profiles / targets. --- examples.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples.md b/examples.md index 1bcde91..7632f83 100644 --- a/examples.md +++ b/examples.md @@ -589,14 +589,20 @@ whenever possible: ```yaml - uses: actions/cache@v3 + env: + BUILD_TYPE: debug # adjust when using `--release` or custom targets with: path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-${{ env.BUILD_TYPE }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-${{ env.BUILD_TYPE }}- ``` ## Scala - SBT