Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Sep 26, 2020
0 parents commit 99970e0
Show file tree
Hide file tree
Showing 12 changed files with 111,031 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [Swatinem]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Rust Cache Action

A GitHub Action that implements smart caching for rust/cargo projects

## Inputs

- `key` - An optional key for the `target` cache. This is useful in case you
have different jobs for test / check / clippy, etc

## Example usage

```yaml
- uses: Swatinem/rust-cache@v1
with:
key: test
```

## Specifics

This action tries to be better than just caching the following directories:

```
~/.cargo/registry
~/.cargo/git
target
```

It disables incremental compilation and only caches dependencies. The
assumption is that we will likely recompile the own crate(s) anyway.

It also separates the cache into 4 groups, each treated differently:

- Index: `~/.cargo/registry/index/<registry>`:

This is always restored from its latest snapshot, and persisted based on the
most recent revision.

- Registry / Cache: `~/.cargo/registry/cache/<registry>`:

Automatically keyed by the lockfile/toml hash, and is being pruned to only
persist the dependencies that are being used.

- Registry / Git: `~/.cargo/registry/git/<registry>`:

Automatically keyed by the lockfile/toml hash. Pruning is still TODO.

- target: `./target`

Automatically keyed by the lockfile/toml hash, and is being pruned to only
persist the dependencies that are being used. This is especially throwing
away any intermediate artifacts.
15 changes: 15 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Rust Cache"
description: "A GitHub Action that implements smart caching for rust/cargo projects"
author: "Arpad Borsos <arpad.borsos@googlemail.com>"
inputs:
key:
description: "An explicit key for restoring and saving the target cache"
required: false
runs:
using: "node12"
main: "dist/restore/index.js"
post: "dist/save/index.js"
post-if: "success()"
branding:
icon: "archive"
color: "gray-dark"

0 comments on commit 99970e0

Please sign in to comment.