Skip to content

Commit b01657d

Browse files
committed
Add support for adding to cache key
When using this action in multiple matrix jobs in the same workflow, the generated cache key is the same for all of them, because they all get the same job ID. This means that all apart from the first job are unable to save the cache, and subsequent runs might restore the wrong cache. The `Swatinem/rust-cache` action which we use for caching has a `key` input which it puts in its cache key. (It doesn't override the key, just adds to it.) Providing this as an input here will allow us to generate a unique cache key for each job in the matrix.
1 parent 1fbea72 commit b01657d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a
5656
| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true |
5757
| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | |
5858
| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true |
59+
| `key` | Propagates the value to [`Swatinem/rust-cache`] | |
5960
| `matcher` | Enable problem matcher to surface build messages and formatting issues | true |
6061
| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" |
6162

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ inputs:
3232
description: "Also cache on workflow failures"
3333
default: "true"
3434
required: false
35+
cache-key:
36+
description: "An additional cache key that is added alongside the automatic `job`-based cache key and can be used to further differentiate jobs."
37+
required: false
3538
matcher:
3639
description: "Enable the Rust problem matcher"
3740
required: false
@@ -181,3 +184,4 @@ runs:
181184
with:
182185
workspaces: ${{inputs.cache-workspaces}}
183186
cache-on-failure: ${{inputs.cache-on-failure}}
187+
key: ${{inputs.cache-key}}

0 commit comments

Comments
 (0)