Skip to content

Commit

Permalink
Add support for adding to cache key
Browse files Browse the repository at this point in the history
When using this action in multiple jobs in the same workflow, the
generated cache key is the same for all of them. 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.
  • Loading branch information
iainlane committed Jul 12, 2024
1 parent 1fbea72 commit d4e5302
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a
| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true |
| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | |
| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true |
| `key` | Propagates the value to [`Swatinem/rust-cache`] | |
| `matcher` | Enable problem matcher to surface build messages and formatting issues | true |
| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" |

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ inputs:
description: "Also cache on workflow failures"
default: "true"
required: false
key:
description: "An additional cache key that is added alongside the automatic `job`-based cache key and can be used to further differentiate jobs."
required: false
matcher:
description: "Enable the Rust problem matcher"
required: false
Expand Down Expand Up @@ -181,3 +184,4 @@ runs:
with:
workspaces: ${{inputs.cache-workspaces}}
cache-on-failure: ${{inputs.cache-on-failure}}
key: ${{inputs.key}}

0 comments on commit d4e5302

Please sign in to comment.