Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
96a8d65
Only run macOsWorkaround() on macOS (#206)
heksesang Sep 17, 2024
8f842c2
Support Cargo.lock format cargo-lock v4 (#211)
NobodyXu Oct 8, 2024
598fe25
update dependencies, rebuild
Swatinem Oct 12, 2024
82a92a6
2.7.5
Swatinem Oct 12, 2024
68b3cb7
Updated artifact upload action to v4 (#212)
guylamar2006 Oct 17, 2024
c00f302
Adds an option to do lookup-only of the cache (#217)
danlec Nov 8, 2024
9a2e0d3
add runner OS in cache key (#220)
rnbguy Dec 9, 2024
e8e63cd
Allow opting out of caching $CARGO_HOME/bin. (#216)
benjyw Dec 10, 2024
4b1f006
update dependencies, in particular `@actions/cache`
Swatinem Dec 28, 2024
720f7e4
2.7.6
Swatinem Dec 28, 2024
008623f
also cache `cargo install` metadata
Swatinem Dec 29, 2024
f0deed1
2.7.7
Swatinem Dec 29, 2024
27b8ea9
Include CPU arch in the cache key (#228)
rhysd Feb 8, 2025
9d47c6a
2.7.8
Swatinem Mar 19, 2025
901019c
Update the test lockfiles
Swatinem Jun 20, 2025
eaa85be
Add cache-workspace-crates feature (#246)
jbransen Jun 22, 2025
52ea143
support warpbuild cache provider (#247)
stegaBOB Jun 24, 2025
14d3bc3
update Changelog
Swatinem Jun 25, 2025
98c8021
2.8.0
Swatinem Jun 25, 2025
7e1e2d0
Set empty `CARGO_ENCODED_RUSTFLAGS` in workspace metadata retrieval (…
ark0f Jun 27, 2025
a8b36e3
chore(deps): update dependencies (#251)
reneleonhardt Jul 26, 2025
203c9eb
chore: fix dependabot groups (#253)
reneleonhardt Aug 14, 2025
46cb408
Bump the prd-patch group with 2 updates
dependabot[bot] Aug 14, 2025
267a8a9
Merge pull request #254 from Swatinem/dependabot/npm_and_yarn/prd-pat…
github-actions[bot] Aug 14, 2025
d8c5063
chore(dependabot): regenerate and commit dist/ (#257)
reneleonhardt Aug 15, 2025
c4f0bbd
Bump @types/node from 22.16.3 to 24.2.1 in the dev-major group (#255)
dependabot[bot] Aug 15, 2025
cb8ffc2
Bump typescript from 5.8.3 to 5.9.2 in the dev-minor group (#256)
dependabot[bot] Aug 15, 2025
17e60e6
Merge remote-tracking branch 'upstream/master' into sync-upstream
PrashantRaj18198 Aug 25, 2025
1cf9fcb
trigger tests
PrashantRaj18198 Aug 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/optimizing-pr-creation-version-updates#setting-up-a-cooldown-period-for-dependency-updates

version: 2
updates:
- package-ecosystem: cargo
directories:
- tests
- tests/wasm-workspace
schedule:
interval: weekly
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference#groups--
# 1 PR per week and group
groups:
cargo-major:
update-types: ["major"]
cargo-minor:
update-types: ["minor"]
cargo-patch:
update-types: ["patch"]
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
actions:
# Combine all images of the last week
patterns: ["*"]
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
groups:
prd-major:
dependency-type: "production"
update-types: ["major"]
prd-minor:
dependency-type: "production"
update-types: ["minor"]
prd-patch:
dependency-type: "production"
update-types: ["patch"]
dev-major:
dependency-type: "development"
update-types: ["major"]
dev-minor:
dependency-type: "development"
update-types: ["minor"]
dev-patch:
dependency-type: "development"
update-types: ["patch"]
5 changes: 3 additions & 2 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ on:

jobs:
check-dist:
if: github.repository == 'WarpBuilds/rust-cache'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Setup Node.js 20.x
uses: actions/setup-node@v4
Expand All @@ -38,7 +39,7 @@ jobs:
fi
id: diff

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
coverage:
if: github.repository == 'WarpBuilds/rust-cache'
strategy:
fail-fast: false
matrix:
Expand All @@ -16,7 +17,7 @@ jobs:
CARGO_TERM_COLOR: always

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- run: rustup toolchain install stable --profile minimal --component llvm-tools-preview --no-self-update

Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enabling-automerge-on-a-pull-request

name: Dependabot Automation
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
automerge:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'WarpBuilds/rust-cache'
steps:
- name: Fetch metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v5
with:
fetch-depth: 2
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
- name: Check if package-lock.json has been changed
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
id: npm
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
if ! git diff --quiet HEAD~1.. -- package-lock.json; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "changed=true, checking out $PR_URL to allow amend"
gh pr checkout "$PR_URL"
fi
- name: Setup node if necessary
if: steps.npm.outputs.changed != ''
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Re-generate and commit dist/ if changed
id: amend
if: steps.npm.outputs.changed != ''
run: |
npm ci
npm run prepare
if ! git diff --quiet dist/*/index.js; then
echo "dist/ changed, amending last commit"
export $(git log -1 --pretty=format:'GIT_COMMITTER_NAME=%cn GIT_COMMITTER_EMAIL=%ce GIT_AUTHOR_NAME=%an GIT_AUTHOR_EMAIL=%ae')
git fetch --unshallow
echo "Before amend:" && git show --name-only --pretty=
git commit --amend --no-edit --no-reset-author -- dist/*/index.js
echo "After amend:" && git show --name-only --pretty=
git push --force-with-lease origin HEAD
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Auto-merge Patch PRs
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
3 changes: 2 additions & 1 deletion .github/workflows/git-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
git-registry:
if: github.repository == 'WarpBuilds/rust-cache'
strategy:
fail-fast: false
matrix:
Expand All @@ -17,7 +18,7 @@ jobs:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- run: rustup toolchain install stable --profile minimal --no-self-update

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
install:
if: github.repository == 'WarpBuilds/rust-cache'
strategy:
fail-fast: false
matrix:
Expand All @@ -16,7 +17,7 @@ jobs:
CARGO_TERM_COLOR: always

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- run: rustup toolchain install stable --profile minimal --no-self-update

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
simple:
if: github.repository == 'WarpBuilds/rust-cache'
strategy:
fail-fast: false
matrix:
Expand All @@ -16,7 +17,7 @@ jobs:
CARGO_TERM_COLOR: always

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- run: rustup toolchain install stable --profile minimal --no-self-update

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/target-dir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
target-dir:
if: github.repository == 'WarpBuilds/rust-cache'
strategy:
fail-fast: false
matrix:
Expand All @@ -16,7 +17,7 @@ jobs:
CARGO_TERM_COLOR: always

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- run: rustup toolchain install stable --profile minimal --no-self-update

Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/workspaces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
workspaces:
if: github.repository == 'WarpBuilds/rust-cache'
strategy:
fail-fast: false
matrix:
Expand All @@ -16,7 +17,7 @@ jobs:
CARGO_TERM_COLOR: always

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- run: rustup toolchain install stable --profile minimal --target wasm32-unknown-unknown --no-self-update

Expand All @@ -26,8 +27,10 @@ jobs:
tests
tests/wasm-workspace

- run: cargo check
- name: cargo check (tests)
working-directory: tests
run: cargo check

- run: cargo check
- name: cargo check (tests/wasm-workspace)
working-directory: tests/wasm-workspace
run: cargo check
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## 2.8.0

- Add support for `warpbuild` cache provider
- Add new `cache-workspace-crates` feature

## 2.7.8

- Include CPU arch in the cache key

## 2.7.7

- Also cache `cargo install` metadata

## 2.7.6

- Allow opting out of caching $CARGO_HOME/bin
- Add runner OS in cache key
- Adds an option to do lookup-only of the cache

## 2.7.5

- Support Cargo.lock format cargo-lock v4
- Only run macOsWorkaround() on macOS

## 2.7.3

- Work around upstream problem that causes cache saving to hang for minutes.
Expand Down
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ sensible defaults.
## Example usage

```yaml
- uses: actions/checkout@v4
- uses: actions/checkout@v5

# selecting a toolchain either by action or manual `rustup` calls should happen
# before the plugin, as the cache uses the current rustc version as its cache key
- run: rustup toolchain install stable --profile minimal

- uses: Swatinem/rust-cache@v2
- uses: WarpBuilds/rust-cache@v2
with:
# The prefix cache key, this can be changed to start a new cache manually.
# default: "v0-rust"
Expand Down Expand Up @@ -60,7 +60,13 @@ sensible defaults.
# default: "false"
cache-all-crates: ""

# Determiners whether the cache should be saved.
# Similar to cache-all-crates.
# If `true` the workspace crates will be cached.
# Useful if the workspace contains libraries that are only updated sporadically.
# default: "false"
cache-workspace-crates: ""

# Determines whether the cache should be saved.
# If `false`, the cache is only restored.
# Useful for jobs where the matrix is additive e.g. additional Cargo features,
# or when only runs from `master` should be saved to the cache.
Expand All @@ -69,6 +75,20 @@ sensible defaults.
# To only cache runs from `master`:
save-if: ${{ github.ref == 'refs/heads/master' }}

# Determines whether the cache should be restored.
# If `true` the cache key will be checked and the `cache-hit` output will be set
# but the cache itself won't be restored
# default: "false"
lookup-only: ""

# Specifies what to use as the backend providing cache
# Can be set to "github", "buildjet", or "warpbuild"
# default: "github"
cache-provider: ""

# Determines whether to cache the ~/.cargo/bin directory.
# default: "true"
cache-bin: ""
```

Further examples are available in the [.github/workflows](./.github/workflows/) directory.
Expand Down Expand Up @@ -119,7 +139,7 @@ Before being persisted, the cache is cleaned of:
- Any build artifacts with an `mtime` older than one week.

In particular, the workspace crates themselves are not cached since doing so is
[generally not effective](https://github.com/Swatinem/rust-cache/issues/37#issuecomment-944697938).
[generally not effective](https://github.com/WarpBuilds/rust-cache/issues/37#issuecomment-944697938).
For this reason, this action automatically sets `CARGO_INCREMENTAL=0` to disable
incremental compilation, so that the Rust compiler doesn't waste time creating
the additional artifacts required for incremental builds.
Expand Down Expand Up @@ -165,4 +185,7 @@ to see those details as well as further details related to caching operations.
## Known issues

- The cache cleaning process currently removes all the files from `~/.cargo/bin`
that were present before the action ran (for example `rustc`).
that were present before the action ran (for example `rustc`), by default.
This can be an issue on long-running self-hosted runners, where such state
is expected to be preserved across runs. You can work around this by setting
`cache-bin: "false"`.
17 changes: 16 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,26 @@ inputs:
description: "Determines which crates are cached. If `true` all crates will be cached, otherwise only dependent crates will be cached."
required: false
default: "false"
cache-workspace-crates:
description: "Similar to cache-all-crates. If `true` the workspace crates will be cached."
required: false
default: "false"
save-if:
description: "Determiners whether the cache should be saved. If `false`, the cache is only restored."
required: false
default: "true"

cache-provider:
description: "Determines which provider to use for caching. Options are github, buildjet, or warpbuild. Defaults to github."
required: false
default: "github"
cache-bin:
description: "Determines whether to cache ${CARGO_HOME}/bin."
required: false
default: "true"
lookup-only:
description: "Check if a cache entry exists without downloading the cache"
required: false
default: "false"
outputs:
cache-hit:
description: "A boolean value that indicates an exact match was found."
Expand Down
Loading
Loading