No description
  • Shell 88.6%
  • Makefile 11.4%
Find a file
Stephen Way a00dba6a22
All checks were successful
test / unit (push) Successful in 22s
test / e2e (push) Successful in 35s
Replace mapfile with a bash 3.2-safe loop in cache-key.sh (#1)
2026-06-02 03:32:43 +00:00
.forgejo Replace mapfile with a bash 3.2-safe loop in cache-key.sh (#1) 2026-06-02 03:32:43 +00:00
.githooks Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
examples/workflows Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
scripts Replace mapfile with a bash 3.2-safe loop in cache-key.sh (#1) 2026-06-02 03:32:43 +00:00
tests Replace mapfile with a bash 3.2-safe loop in cache-key.sh (#1) 2026-06-02 03:32:43 +00:00
.editorconfig Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
.gitignore Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
action.yml Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
CHANGELOG.md Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
CONTRIBUTING.md Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
LICENSE Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
Makefile Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
MIGRATION.md Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
README.md Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00
SECURITY.md Add Forgejo-compatible rust-cache action 2026-05-28 09:35:42 -07:00

rust-cache-action

test

Cache Cargo's registry, git dependencies, and build output on Forgejo Actions runners. A Swatinem/rust-cache-style wrapper that delegates storage to rasterstate/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/rasterstate/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 workspace target/ (plus cache-directories).
  • Key: <prefix>-<shared-key|key|job>-<os>-<rustc version+host+commit>-<Cargo.lock hash>, with a prefix restore-keys fallback. The rustc identity is read from rustc --version --verbose, so a toolchain bump invalidates the cache, exactly like rust-cache.

rust-cache vs sccache: which to use

rasterstate/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 set RUSTC_WRAPPER=sccache and consider cache-targets: false here 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 registry src/ before saving, so caches can be larger. Set cache-targets: false or scope workspaces if size matters. See MIGRATION.md.

Examples

See examples/workflows: CLI, workspace, Tauri, and cross-compilation.

License

MIT. See LICENSE.