Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bd103/cargo-sweep
Run `cargo-sweep` in Github Actions!
https://github.com/bd103/cargo-sweep
actions cache cargo rust
Last synced: about 1 month ago
JSON representation
Run `cargo-sweep` in Github Actions!
- Host: GitHub
- URL: https://github.com/bd103/cargo-sweep
- Owner: BD103
- License: mit
- Created: 2024-08-07T14:42:11.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-10T13:32:42.000Z (2 months ago)
- Last Synced: 2024-10-13T23:03:32.554Z (about 1 month ago)
- Topics: actions, cache, cargo, rust
- Language: JavaScript
- Homepage:
- Size: 2.19 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `cargo-sweep` action
This action leverages the power of [`cargo-sweep`](https://github.com/holmgr/cargo-sweep) to clean up stale build files from the `target` directory of a Rust project. Specifically, it uses the timestamp feature to delete unused build artifacts.
## When would you use this?
This is most useful if you cache the `target` directory and use `restore-keys` to fallback on old caches. In these specific examples, old artifacts tend to pile up over time, causing caches to grow to gigabytes in size. You can use `cargo-sweep` to prune these old artifacts while keeping the used ones.
## Quickstart
```yml
- name: Install Rust
uses: dtolnay/rust-toolchain@stable# Make sure to restore your cache before calling `cargo-sweep`.
- name: Cache build files
uses: actions/cache@v4
with:
# You probably want to cache more files and use a more-detailed key. This is kept short for
# brevity's sake.
path: target
key: my-job-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
# `cargo-sweep` is only useful if you use restore keys.
restore-keys: my-job-${{ runner.os }}-- name: Sweep cache for stale files
uses: BD103/cargo-sweep@v1# Any artifacts used between `cargo-sweep` and the end of the job will be kept, the rest will be
# discarded.
- run: cargo build
```For an all-in-one caching and sweeping solution, I highly recommend [Leafwing-Studios/cargo-cache](https://github.com/Leafwing-Studios/cargo-cache), which integrates with this action directly! Set `sweep-cache: true`.
## Caching
This action, by default, caches the `cargo-sweep` binary so it does not need to build / download it again. You can disable this by setting `use-cache: false` in the inputs. Caching greatly speeds up the time of subsequent runs that do not use prebuilt binaries, but has little affect otherwise.
## Prebuilt binaries
This repository automatically builds and hosts binaries of `cargo-sweep`, which you can inspect in [`build-cargo-sweep.yml`](.github/workflows/build-cargo-sweep.yml). You can opt-in to downloading these binaries by setting `use-prebuilt: true`, which may drastically speed up runtimes compared to a clean `cargo install`. These binaries are built weekly for `ubuntu-latest`, `windows-latest`, and `macos-latest`, so you may not be able to use them on other platforms.
This was originally introduced when caching was not implemented, but as of [v1.3] it has much less benefit. If your project is constantly running past Github's cache quota then you may want to enable prebuilt binaries, but in all other cases it is safer and nearly as fast to use caching instead.
[v1.3]: https://github.com/BD103/cargo-sweep/releases/tag/v1.3.0