40 lines
1.0 KiB
Markdown
40 lines
1.0 KiB
Markdown
# actions-rust
|
||
|
||
Reusable Gitea Actions for Rust projects.
|
||
|
||
## actions/rust-cache
|
||
|
||
Composite action that installs a Rust toolchain and caches cargo/crate dependencies.
|
||
|
||
### Usage
|
||
|
||
```yaml
|
||
jobs:
|
||
build:
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- uses: https://gitea.com/actions/checkout@v4
|
||
|
||
- name: Setup Rust + Cache
|
||
uses: https://git.ericxliu.me/eric/actions-rust/.gitea/actions/rust-cache@main
|
||
with:
|
||
toolchain: stable # optional, defaults to stable
|
||
|
||
- run: cargo build --release
|
||
- run: cargo test
|
||
```
|
||
|
||
### What it does
|
||
|
||
1. **Cache restore** — Restores `~/.cargo/registry`, `~/.cargo/git`, `~/.rustup/toolchains`, and `target/` using Gitea's native `actions/cache`.
|
||
2. **Rust install** — Runs `rustup` to install or verify the requested toolchain.
|
||
3. **PATH setup** — Appends `$HOME/.cargo/bin` to `$GITHUB_PATH` so cargo/rustc are available in subsequent steps.
|
||
|
||
### Cache key format
|
||
|
||
```
|
||
rust-linux-{hash(Cargo.lock)}{hash(Cargo.toml)}
|
||
```
|
||
|
||
Warm builds run in ~40–60s vs ~3min for a cold build.
|