Skip to content

Commit 9137ccf

Browse files
committed
Fix versions of rust and cache action
1 parent bfc9bd3 commit 9137ccf

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

content/actions/use-cases-and-examples/building-and-testing/building-and-testing-rust.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,30 @@ We recommend that you have a basic understanding of the Rust language. For more
4646

4747
## Specifying a Rust version
4848

49-
To use a preinstalled version of Rust on a {% data variables.product.prodname_dotcom %}-hosted runner, pass the relevant version to the `rust-version` property of the `setup-rust` action. This action finds a specific version of Rust from the tools cache on each runner, and adds the necessary binaries to `PATH`. These changes will persist for the remainder of the job.
49+
At the time of writing, the default rust compiler version is 1.83.0 rustup is available and can be used to install additional toolchains. For example, the following workflow temporarily sets the toolchain to nightly:
5050

51-
The `setup-rust` action is the recommended way of using rust with {% data variables.product.prodname_actions %}, because it helps ensure consistent behavior across different runners and different versions of Rust. If you are using a self-hosted runner, you must install rust and add it to your self-hosted runner's `PATH`.
51+
```yaml copy
52+
- name: Temporarily modify the rust toolchain version
53+
run: rustup override set nightly
54+
- name: Ouput rust version for educational purposes
55+
run: rustup --version
56+
```
5257
5358
### Caching dependencies
5459
55-
You can cache and restore dependencies using the following example below.
60+
You can cache and restore dependencies using the following example below. Note that you will need to have Cargo.lock in your repository to cache dependencies.
5661
5762
```yaml copy
5863
- name: ⚡ Cache
59-
uses: actions/cache@v2
64+
uses: actions/cache@v4
6065
with:
6166
path: |
6267
~/.cargo/registry
6368
~/.cargo/git
6469
target
6570
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
6671
```
67-
If you have a custom requirement or need finer controls for caching, you can use the [`cache` action](https://github.com/marketplace/actions/cache). For more information, see [AUTOTITLE](/actions/using-workflows/caching-dependencies-to-speed-up-workflows).
72+
If you have a custom requirement or need finer controls for caching, you can take a look at the [`cache` action](https://github.com/marketplace/actions/cache). For more information, see [AUTOTITLE](/actions/using-workflows/caching-dependencies-to-speed-up-workflows).
6873

6974
## Building and testing your code
7075

0 commit comments

Comments
 (0)