No description
- Shell 88.6%
- Makefile 11.4%
Org migration: the action family now lives under fjord/. Repoints internal repo references (uses:, CI badges, docs, migration guides) at fjord/ and sets the action author to fjord. The old rasterstate copies are left in place. |
||
|---|---|---|
| .forgejo | ||
| .githooks | ||
| examples/workflows | ||
| scripts | ||
| tests | ||
| .editorconfig | ||
| .gitignore | ||
| action.yml | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| Makefile | ||
| MIGRATION.md | ||
| README.md | ||
| SECURITY.md | ||
rust-cache-action
Cache Cargo's registry, git dependencies, and build output on Forgejo Actions runners. A Swatinem/rust-cache-style wrapper that delegates storage to fjord/cache-action instead of the GitHub cache service. Composite action, pure shell, no build step.
Quick start
jobs:
test:
runs-on: [self-hosted, Linux]
env:
RASTER_CACHE_S3_BUCKET: ci-cache
RASTER_CACHE_S3_ENDPOINT: https://fsn1.your-objectstorage.com
RASTER_CACHE_S3_REGION: fsn1
RASTER_CACHE_S3_ACCESS_KEY_ID: ${{ secrets.CACHE_S3_KEY_ID }}
RASTER_CACHE_S3_SECRET_ACCESS_KEY: ${{ secrets.CACHE_S3_SECRET }}
steps:
- uses: actions/checkout@v6
- uses: https://github.com/dtolnay/rust-toolchain@stable
- uses: https://rasterhub.com/fjord/rust-cache-action@v1
- run: cargo test
Place it after the toolchain setup (it reads rustc --version for the key) and before the build.
Inputs
Close to Swatinem/rust-cache.
| Input | Default | Description |
|---|---|---|
prefix-key |
rust-cache |
Static key prefix. |
shared-key |
Key shared across jobs (overrides the per-job segment). | |
key |
Extra key segment. | |
workspaces |
. |
Workspaces, one per line as path or path -> target-dir. |
cache-directories |
Extra directories to cache, one per line. | |
cache-targets |
true |
Cache the workspace target directories. |
save-if |
true |
Only save when this is "true". Restore always runs. Pass an expression, e.g. ${{ github.ref == 'refs/heads/main' }}. |
Outputs
| Output | Description |
|---|---|
cache-hit |
Whether an exact cache match was restored. |
What gets cached and the key
- Paths:
$CARGO_HOME/registry/index,$CARGO_HOME/registry/cache,$CARGO_HOME/git/db, and each workspacetarget/(pluscache-directories). - Key:
<prefix>-<shared-key|key|job>-<os>-<rustc version+host+commit>-<Cargo.lock hash>, with a prefixrestore-keysfallback. The rustc identity is read fromrustc --version --verbose, so a toolchain bump invalidates the cache, exactly like rust-cache.
rust-cache vs sccache: which to use
fjord/sccache-action and this action solve overlapping but different problems:
- rust-cache (this action) caches the dependency build artifacts and registry for a workspace, keyed by
Cargo.lock. Best for the common case: one repo, dependencies that change rarely,target/reused between runs of the same job. - sccache is a compiler cache: it caches individual compilation units in S3, shared across branches/jobs/repos, and helps most when many builds share crates or when
Cargo.lock(and thus the rust-cache key) changes often.
Recommendation:
- Most repos: rust-cache alone. Simple, fast restores, no per-call overhead.
- Monorepos / many short-lived branches / frequently churning lockfiles: sccache alone (cross-branch reuse beats a frequently-missed target cache).
- Large workspaces where both incremental
target/reuse and cross-run compiler caching help: both, but setRUSTC_WRAPPER=sccacheand considercache-targets: falsehere to avoid double-storing what sccache already holds.
Do not enable Cargo incremental compilation together with sccache (sccache ignores incremental); rust-cache is fine with it.
Notes
- Storage goes through cache-action, so a configured backend (
RASTER_CACHE_*) is required. - Unlike Swatinem/rust-cache, this action does not yet prune
target/or clean the registrysrc/before saving, so caches can be larger. Setcache-targets: falseor scopeworkspacesif size matters. See MIGRATION.md.
Examples
See examples/workflows: CLI, workspace, Tauri, and cross-compilation.
License
MIT. See LICENSE.