Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
426e06d
enhancement: Add option to specify rust-toolchain.toml path (#47)
Sanielia Aug 27, 2025
40ca850
Bump actions/checkout from 4 to 5
dependabot[bot] Aug 28, 2025
7659442
Merge pull request #71 from actions-rust-lang/dependabot/github_actio…
robjtede Aug 28, 2025
0be57f1
combine rust-src-dir presence and rust_toolchain file presence checks
Sanielia Aug 28, 2025
4222ef9
Set workspaces in `Swatinem/rust-cache` to rust-src-dir if cache-work…
Sanielia Aug 28, 2025
fd2478f
README should direct users to actions/checkout@5.
martinfrances107 Sep 3, 2025
1812c7d
Merge pull request #72 from martinfrances107/README
robjtede Sep 3, 2025
89d3d96
Merge pull request #69 from Kubaryt/main
jonasbb Sep 14, 2025
2fcdc49
Update readme and changelog for 1.15.0
jonasbb Sep 14, 2025
183cfeb
Bump Swatinem/rust-cache from 2.8.0 to 2.8.1
dependabot[bot] Sep 22, 2025
69e4802
Merge pull request #73 from actions-rust-lang/dependabot/github_actio…
robjtede Sep 22, 2025
02be93d
Update `Swatinem/rust-cache` to v2.8.1
jonasbb Sep 23, 2025
d6688fb
Print an error and exit if 'rust-src-dir' does not point to an existi…
jonasbb Oct 3, 2025
5189717
Gate the rust-src-dir check by first checking if the value is set
jonasbb Oct 4, 2025
f89a806
Use the built-in working-directory selector and default to "." if rus…
jonasbb Oct 4, 2025
063a3b9
Use correct quoting style for working-directory
jonasbb Oct 4, 2025
1780873
Fix: Run the version detection steps in the selected `rust-src-dir` d…
jonasbb Oct 4, 2025
c103666
Bump actions/checkout from 5 to 6
dependabot[bot] Nov 24, 2025
ca4a643
Merge pull request #82 from actions-rust-lang/dependabot/github_actio…
robjtede Nov 24, 2025
e541adf
Bump Swatinem/rust-cache from 2.8.1 to 2.8.2
dependabot[bot] Dec 1, 2025
b598bed
Merge pull request #83 from actions-rust-lang/dependabot/github_actio…
robjtede Dec 1, 2025
806aa7d
Add dependabot cooldown
jonasbb Dec 24, 2025
a000416
Add .gitignore to exclude `test-workspace/target/`
xtqqczze Jan 29, 2026
e0e53f1
Merge pull request #85 from xtqqczze/gitignore
jonasbb Feb 28, 2026
a0b538f
Update changelog
jonasbb Feb 28, 2026
229ed07
deps: Bump Swatinem/rust-cache from 2.8.2 to 2.9.1
hyperfinitism Mar 14, 2026
aa63f57
Merge pull request #87 from hyperfinitism/deps/bump-rust-cache
jonasbb Mar 14, 2026
150fca8
Update CHANGELOG for version 1.15.4
jonasbb Mar 14, 2026
fa057b4
Update actions/checkout to v6 on README
ryuapp Mar 22, 2026
d197c15
Merge pull request #88 from ryuapp/chore/update-chekcout-v6-on-readme
jonasbb Mar 22, 2026
186b99e
feat: add cache-save-if input to propagate save-if to Swatinem/rust-c…
ChanTsune Apr 11, 2026
9030f3d
Merge pull request #90 from ChanTsune/feat/cache-save-if
jonasbb Apr 13, 2026
2b1f5e9
Update CHANGELOG for version 1.16.0
jonasbb Apr 13, 2026
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
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ updates:
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 7
2 changes: 1 addition & 1 deletion .github/workflows/autotag-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Get version from tag
id: tag_name
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- "beta"
- "stable"
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

# Test toolchain file support
- name: Write rust-toolchain.toml
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
name: Cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Install Rust
uses: ./
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-workspace/target/
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.16.0] - 2026-04-13

* Add new parameter `cache-save-if` that is propagated to `Swatinem/rust-cache` as `save-if` (#90 by @ChanTsune)

## [1.15.4] - 2026-03-15

* Bump Swatinem/rust-cache from 2.8.2 to 2.9.1 (#87 by @hyperfinitism)
This gets rid of the warnings about Node.js 20.

## [1.15.3] - 2026-03-01

* Bump Swatinem/rust-cache from 2.8.1 to 2.8.2

## [1.15.2] - 2025-10-04

* Fix: Run the version detection steps in the selected `rust-src-dir` directory.
This should enable the version selection even without a default toolchain installed.
Fixes #74.

## [1.15.1] - 2025-09-23

* Update `Swatinem/rust-cache` to v2.8.1

## [1.15.0] - 2025-09-14

* Add support for non-root source directory.
Accept source code and `rust-toolchain.toml` file in subdirectories of the repository.
Adds a new parameter `rust-src-dir` that controls the lookup for toolchain files and sets a default value for the `cache-workspace` input. (#69 by @Kubaryt)

## [1.14.1] - 2025-08-28

* Pin `Swatinem/rust-cache` action to a full commit SHA (#68 by @JohnTitor)
Expand Down
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: cargo test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo test --all-features

Expand All @@ -30,7 +30,7 @@ jobs:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
# Ensure rustfmt is installed and setup problem matcher
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
Expand All @@ -48,24 +48,26 @@ If no `toolchain` value or toolchain file is present, it will default to `stable
First, all items specified in the toolchain file are installed.
Afterward, the `components` and `target` specified via inputs are installed in addition to the items from the toolchain file.

| Name | Description | Default |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------- |
| `toolchain` | Comma-separated list of Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. The last version is the default. | stable |
| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | |
| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | |
| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true |
| `cache-directories` | Propagates the value to [`Swatinem/rust-cache`] | |
| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | |
| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true |
| `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | |
| `cache-shared-key` | Propagates the value to [`Swatinem/rust-cache`] as `shared-key` | |
| `cache-bin` | Propagates the value to [`Swatinem/rust-cache`] as `cache-bin` | true |
| `cache-provider` | Propagates the value to [`Swatinem/rust-cache`] as `cache-provider` | 'github' |
| `cache-all-crates` | Propagates the value to [`Swatinem/rust-cache`] as `cache-all-crates` | false |
| `cache-workspace-crates` | Propagates the value to [`Swatinem/rust-cache`] as `cache-workspace-crates` | false |
| `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" |
| `override` | Setup the last installed toolchain as the default via `rustup override` | true |
| Name | Description | Default |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| `toolchain` | Comma-separated list of Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. The last version is the default. | stable |
| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | |
| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | |
| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true |
| `cache-directories` | Propagates the value to [`Swatinem/rust-cache`] | |
| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`]. Influenced by the value of `rust-src-dir`. | |
| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true |
| `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | |
| `cache-shared-key` | Propagates the value to [`Swatinem/rust-cache`] as `shared-key` | |
| `cache-bin` | Propagates the value to [`Swatinem/rust-cache`] as `cache-bin` | true |
| `cache-provider` | Propagates the value to [`Swatinem/rust-cache`] as `cache-provider` | 'github' |
| `cache-all-crates` | Propagates the value to [`Swatinem/rust-cache`] as `cache-all-crates` | false |
| `cache-workspace-crates` | Propagates the value to [`Swatinem/rust-cache`] as `cache-workspace-crates` | false |
| `cache-save-if` | Propagates the value to [`Swatinem/rust-cache`] as `save-if` | true |
| `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" |
| `override` | Setup the last installed toolchain as the default via `rustup override` | true |
| `rust-src-dir` | Path from root directory to directory with the Rust source directory (if its not in the root of the repository). Sets a default value for `cache-workspaces` that enables caching. | |

[`Swatinem/rust-cache`]: https://github.com/Swatinem/rust-cache

Expand Down
30 changes: 27 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ 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-save-if:
description: "Determines whether the cache should be saved. If `false`, the cache is only restored."
required: false
default: "true"
matcher:
description: "Enable the Rust problem matcher"
required: false
Expand All @@ -69,6 +73,9 @@ inputs:
description: "Setup the last installed toolchain as the default via `rustup override`"
required: false
default: "true"
rust-src-dir:
description: "Specify path from root directory to the Rust source directory. By default root directory will be used."
required: false

outputs:
rustc-version:
Expand Down Expand Up @@ -163,9 +170,23 @@ runs:
targets: ${{inputs.target}}
components: ${{inputs.components}}
override: ${{inputs.override}}
rust_src_dir: ${{inputs.rust-src-dir}}
shell: bash
run: |
if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]]
# Check if value is set
if [[ -n "$rust_src_dir" ]]
then
# If value is set the directory must exist
if [[ -d "$rust_src_dir" ]]
then
cd "$rust_src_dir"
else
echo "'rust-src-dir' does not point to an existing directory" >&2
echo "The value of 'rust-src-dir' is: ${rust_src_dir}" >&2
exit 1
fi
fi
if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml") ]]
then
# Install the toolchain as specified in the file
# rustup show is the old way that implicitly installed a toolchain
Expand Down Expand Up @@ -194,6 +215,8 @@ runs:
- id: versions
name: Print installed versions
shell: bash
# Switch to the Rust sub-directory
working-directory: ${{inputs.rust-src-dir || '.'}}
run: |
echo "rustc-version=$(rustc --version)" >> $GITHUB_OUTPUT
rustc --version --verbose
Expand All @@ -220,14 +243,15 @@ runs:

- name: Setup Rust Caching
if: inputs.cache == 'true'
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: ${{inputs.cache-workspaces}}
workspaces: ${{ inputs.cache-workspaces || inputs.rust-src-dir }}
cache-directories: ${{inputs.cache-directories}}
cache-on-failure: ${{inputs.cache-on-failure}}
cache-bin: ${{inputs.cache-bin}}
cache-provider: ${{inputs.cache-provider}}
cache-all-crates: ${{inputs.cache-all-crates}}
cache-workspace-crates: ${{inputs.cache-workspace-crates}}
save-if: ${{inputs.cache-save-if}}
key: ${{inputs.cache-key}}
shared-key: ${{inputs.cache-shared-key}}