Skip to content

Commit 58aaf0b

Browse files
committed
Try and minimize cache size by using cargo sweep
Signed-off-by: Adam Gutglick <[email protected]>
1 parent 1d54ca8 commit 58aaf0b

File tree

3 files changed

+60
-6
lines changed

3 files changed

+60
-6
lines changed

.cargo/config.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,15 @@ timeout = 3600
2121
# Environment variables for PyO3. Ensures reproducible builds and avoids spurious recompilations.
2222
[env]
2323
PYO3_ENVIRONMENT_SIGNATURE = { value = "cpython-3.11-64bit", force = true }
24+
25+
[cache.global-clean]
26+
# Anything older than this duration will be deleted in the source cache.
27+
max-src-age = "1 week"
28+
# Anything older than this duration will be deleted in the compressed crate cache.
29+
max-crate-age = "1 week"
30+
# Any git checkout older than this duration will be deleted from the checkout cache.
31+
max-git-co-age = "1 week"
32+
# Any index older than this duration will be deleted from the index cache.
33+
max-index-age = "1 month"
34+
# Any git clone older than this duration will be deleted from the git cache.
35+
max-git-db-age = "1 month"

.github/actions/setup-rust/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ inputs:
1919
description: "optional suffix for cache key to isolate builds with different RUSTFLAGS (e.g. 'sanitizer')"
2020
required: false
2121
default: ""
22+
timestamp:
23+
description: "Timestamp cache with cargo sweep"
24+
default: "false"
2225

2326
runs:
2427
using: "composite"
@@ -61,3 +64,13 @@ runs:
6164
with:
6265
version: "29.3"
6366
repo-token: ${{ inputs.repo-token }}
67+
68+
- name: Install Sweep
69+
shell: bash
70+
if: ${{ inputs.timestamp == 'true' && github.ref_name == 'develop' }}
71+
run: cargo install cargo-sweep
72+
73+
- name: Timestamp Cache
74+
shell: bash
75+
if: ${{ inputs.timestamp == 'true' && github.ref_name == 'develop' }}
76+
run: cargo sweep --stamp

.github/workflows/ci.yml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ jobs:
221221
with:
222222
sccache: s3
223223
- uses: actions/checkout@v6
224-
- uses: ./.github/actions/setup-rust
224+
- id: setup-rust
225+
uses: ./.github/actions/setup-rust
225226
with:
226227
repo-token: ${{ secrets.GITHUB_TOKEN }}
228+
timestamp: "true"
227229
- name: Install wasm32 target
228230
if: ${{ matrix.config.target == 'wasm32-unknown-unknown' }}
229231
run: rustup target add wasm32-unknown-unknown
@@ -235,6 +237,9 @@ jobs:
235237
run: |
236238
git status --porcelain
237239
test -z "$(git status --porcelain)"
240+
- name: Prune cache
241+
if: github.ref_name == 'develop' && steps.setup-rust.outputs.deps-cache-hit != 'true'
242+
run: cargo sweep --file
238243

239244
check-min-deps:
240245
name: "Check build with minimal dependencies"
@@ -273,10 +278,12 @@ jobs:
273278
with:
274279
sccache: s3
275280
- uses: actions/checkout@v6
276-
- uses: ./.github/actions/setup-rust
281+
- id: setup-rust
282+
uses: ./.github/actions/setup-rust
277283
with:
278284
toolchain: nightly
279285
repo-token: ${{ secrets.GITHUB_TOKEN }}
286+
timestamp: "true"
280287
- name: Rust Lint - Format
281288
run: cargo +nightly fmt --all --check
282289
- name: Rustc check
@@ -287,6 +294,9 @@ jobs:
287294
run: cargo clippy --locked --all-features --all-targets -- -D warnings
288295
- name: Rust Lint - Clippy Default Features
289296
run: cargo clippy --locked --all-targets -- -D warnings
297+
- name: Prune cache
298+
if: github.ref_name == 'develop' && steps.setup-rust.outputs.deps-cache-hit != 'true'
299+
run: cargo sweep --file
290300

291301
rust-lint-no-default:
292302
name: "Rust (lint, no default)"
@@ -303,16 +313,21 @@ jobs:
303313
with:
304314
sccache: s3
305315
- uses: actions/checkout@v6
306-
- uses: ./.github/actions/setup-rust
316+
- id: setup-rust
317+
uses: ./.github/actions/setup-rust
307318
with:
308319
repo-token: ${{ secrets.GITHUB_TOKEN }}
320+
timestamp: "true"
309321
- name: Install cargo-hack
310322
uses: taiki-e/install-action@cargo-hack
311323
- name: Rust Lint - Clippy No Default Features
312324
shell: bash
313325
run: |
314326
# https://spiraldb.slack.com/archives/C07BV3GKAJ2/p1732736281946729
315327
cargo hack clippy --no-default-features -- -D warnings
328+
- name: Prune cache
329+
if: github.ref_name == 'develop' && steps.setup-rust.outputs.deps-cache-hit != 'true'
330+
run: cargo sweep --file
316331

317332
rust-semver:
318333
name: "Rust (semver checks)"
@@ -380,7 +395,8 @@ jobs:
380395
with:
381396
sccache: s3
382397
- uses: actions/checkout@v6
383-
- uses: ./.github/actions/setup-rust
398+
- id: setup-rust
399+
uses: ./.github/actions/setup-rust
384400
with:
385401
repo-token: ${{ secrets.GITHUB_TOKEN }}
386402
- name: Install grcov
@@ -427,6 +443,9 @@ jobs:
427443
disable_search: true
428444
flags: ${{ matrix.suite }}
429445
use_oidc: true
446+
- name: Prune cache
447+
if: github.ref_name == 'develop' && steps.setup-rust.outputs.deps-cache-hit != 'true'
448+
run: cargo sweep --file
430449

431450
rust-test:
432451
name: "Rust tests (sanitizer)"
@@ -459,12 +478,14 @@ jobs:
459478
with:
460479
compiler: llvm
461480
cache-tools: true
462-
- uses: ./.github/actions/setup-rust
481+
- id: setup-rust
482+
uses: ./.github/actions/setup-rust
463483
with:
464484
repo-token: ${{ secrets.GITHUB_TOKEN }}
465485
toolchain: nightly
466486
components: "rust-src, rustfmt, clippy, llvm-tools-preview"
467487
cache-suffix: "sanitizer"
488+
timestamp: "true"
468489
- name: Install build dependencies
469490
run: |
470491
sudo apt-get update
@@ -485,6 +506,9 @@ jobs:
485506
--no-fail-fast \
486507
--target x86_64-unknown-linux-gnu \
487508
--verbose
509+
- name: Prune cache
510+
if: github.ref_name == 'develop' && steps.setup-rust.outputs.deps-cache-hit != 'true'
511+
run: cargo sweep --file
488512

489513
rust-test-other:
490514
name: "Rust tests (${{ matrix.os }})"
@@ -520,9 +544,11 @@ jobs:
520544
uses: actions/setup-python@v5
521545
with:
522546
python-version: "3.11"
523-
- uses: ./.github/actions/setup-rust
547+
- id: setup-rust
548+
uses: ./.github/actions/setup-rust
524549
with:
525550
repo-token: ${{ secrets.GITHUB_TOKEN }}
551+
timestamp: "true"
526552
- name: Install nextest
527553
uses: taiki-e/install-action@v2
528554
with:
@@ -534,6 +560,9 @@ jobs:
534560
- name: Rust Tests (Other)
535561
if: matrix.os != 'windows-x64'
536562
run: cargo nextest run --locked --workspace --all-features --no-fail-fast --exclude vortex-bench --exclude vortex-duckdb
563+
- name: Prune cache
564+
if: github.ref_name == 'develop' && steps.setup-rust.outputs.deps-cache-hit != 'true'
565+
run: cargo sweep --file
537566

538567
build-java:
539568
name: "Java"

0 commit comments

Comments
 (0)