1386c59eaa4ec426d45c68f8e7fbf32d6383fd9a
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
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
- Cache key — Hashes root/workspace
Cargo.toml,Cargo.lock, andrust-toolchain*files without relying onhashFiles(). - Cache restore/save — Restores
~/.cargo/registry,~/.cargo/git,~/.rustup/toolchains, andtarget/using Gitea's nativeactions/cache. The cache action saves updated paths in its post step after later build/test steps have populated them. - Rust install — Runs
rustupwith the minimal profile to install or verify the requested toolchain. - PATH setup — Appends
$HOME/.cargo/binto$GITHUB_PATHso 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 ~40–60s vs ~3min for a cold build.
Description