Repository navigation
feat(scripts): containerised cargo-sweep recipe to prune stale target/ artifacts - #276
Open
elasticdotventures wants to merge 3 commits into
Open
elasticdotventures wants to merge 3 commits into
elasticdotventures wants to merge 3 commits into
Conversation
…/ artifacts
Adds scripts/cargo-sweep/{Containerfile,sweep.sh,README.md} and a thin
`just sweep [days] [--apply]` recipe. cargo-sweep 0.8.0 runs in a container
(podman or docker) so nothing is installed on the host. Dry run by default with
the repo mounted read-only; --apply deletes; --maxsize trims oldest-first.
Verified: shellcheck clean; dry run leaves every file untouched; --apply on a
real, backdated crate build removed the stale artifacts (20 -> 13 files).
A --time 14 dry run against a real 258 GB checkout target/ (built on Windows,
swept from a Linux container) reported 216.63 GiB reclaimable.
Closes #275
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
cargo-sweep silently skips a workspace that `cargo metadata` cannot resolve (for example an uninitialised git submodule or missing path dependency), which left an empty, unexplained result. sweep.sh now keeps the tool's output and prints a note pointing at the likely cause when no "Would clean"/"Cleaned" line appears; the exit code of the container run is preserved. README documents it. Verified: shellcheck clean; a normal repo still reports sizes with exit code 0; an unresolvable workspace prints the note; a bad --root still exits non-zero. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The intro quoted size figures measured in a different repository, which reads as a claim about this one. Replace with a neutral statement; the measured figures for this repo are in the linked issue and PR. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #275
What
Adds a containerised cargo-sweep wrapper so stale
target/artifacts can be pruned without installing anything on the host.scripts/cargo-sweep/Containerfile- pins cargo-sweep 0.8.0 onrust:1-slim-bookworm. The image build context is that directory only, so building never sends the repo (or itstarget/) to the container engine.scripts/cargo-sweep/sweep.sh-podmanordocker; dry run by default with the repo mounted read-only;--applymounts read-write and deletes;--days N(default 14) or--maxsize SIZE;--root DIR.just sweep [days] [--apply]- thin recipe over the script (appended to the end of theJustfile).scripts/cargo-sweep/README.md.Age is taken from file access/modification times, so it also works on
target/directories built by another OS or toolchain.--installedis deliberately not exposed: inside the container it would compare against the container's toolchain, not the host's.Verification (all tooling run in containers)
shellcheck -x scripts/cargo-sweep/sweep.sh: clean.bash -n: OK. Bad arguments are rejected with a message.just --listshows the recipe;just --dry-run sweep,sweep 30,sweep 14 --applyexpand to the expectedbash scripts/cargo-sweep/sweep.shcalls.--time 14dry run against a real 258 GBtarget/(built on Windows, swept from a Linux container via Podman) reportedWould clean: 216.63 GiB; it took about 5 minutes over the Windows filesystem and deleted nothing.--applyon a real crate built in the container, with its wholetarget/backdated 90 days: the dry run left all 20 files untouched;--apply --days 30printedCleaned 8.63 KiBand the file count went 20 -> 13.cargo metadatacannot resolve, e.g. an uninitialised git submodule) now prints an explanatory note instead of an empty result; a normal repo still reports sizes and exit code 0.sweep.shis executable.Not covered
CONTAINER_ENGINEand uses onlyimage inspect,buildandrun.--applywas exercised on a throwaway crate, not on a real checkout'starget/.CLAUDE.mdasks for changes to go through a GSD workflow; that tooling was not available in the session that prepared this PR, so the change was made directly in a fresh clone at the owner's explicit request.🤖 Generated with Claude Code