Files
actions-rust/README.md

47 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# actions-rust
Reusable Gitea Actions for Rust projects.
## actions/rust-cache
Composite action that restores Rust build caches, installs a Rust toolchain, and saves updated cargo/rustup/target caches after the job.
### 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
cache-prefix: rust # optional, defaults to rust
cache-version: v3 # optional, defaults to v3
- run: cargo build --release
- run: cargo test
```
### What it does
1. **Cache key** — Hashes root/workspace `Cargo.toml`, `Cargo.lock`, and `rust-toolchain*` files without relying on `hashFiles()`.
2. **Cache restore/save** — Restores `~/.cargo/registry`, `~/.cargo/git`, `~/.rustup/toolchains`, and `target/` using Gitea's native `actions/cache`. The cache action saves updated paths in its post step after later build/test steps have populated them.
3. **Rust install** — Runs `rustup` with the minimal profile to install or verify the requested toolchain.
4. **PATH setup** — Appends `$HOME/.cargo/bin` to `$GITHUB_PATH` so cargo/rustc are available in subsequent steps.
The cache upload is serialized with `CACHE_UPLOAD_CONCURRENCY=1` because Gitea
act_runner's cache server stores chunk metadata in BoltDB and can return 500s
under large parallel uploads.
### Cache key format
```
{cache-prefix}-{cache-version}-{runner.os}-{runner.arch}-{toolchain}-{hash(manifests/toolchain files)}
```
Warm builds run in ~4060s vs ~3min for a cold build.