From 87c4687a2e9409df2e408d131d59f1fe1590a1bc Mon Sep 17 00:00:00 2001 From: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com> Date: Fri, 30 Oct 2026 19:11:10 +0000 Subject: [PATCH] ci: save Rust caches only from pushes to main A cache saved by a pull request run is scoped to that pull request's merge ref, so only later runs of the same pull request can restore it. The three pull requests in the cache at 18:35 UTC on 30 Oct had saved 2.8 to 4.3 GB of Rust caches each, against the repository's 10 GB limit. The cache held 15.6 GB, none of it saved by main, and an entry restored at 18:09 had been evicted by 18:26. Main's 06:40 push saved all 17 of its Rust caches, and at least 15 of them were gone by the 13:27 runs. Each Swatinem/rust-cache step outside launcher.yml now sets save-if to github.ref == 'refs/heads/main'. Pull request and merge group runs restore main's caches and save nothing, so the cache holds main's entries and pull request and merge group runs can start from them. launcher.yml is unchanged. It runs only on pull requests, so with this setting it would never save a cache. --- .github/workflows/clippy.yml | 3 +++ .github/workflows/integration-cassandra.yml | 8 ++++++++ .github/workflows/integration-mongodb.yml | 8 ++++++++ .github/workflows/integration.yml | 12 ++++++++++++ .github/workflows/test.yml | 3 +++ 5 files changed, 34 insertions(+) diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index ca3ad0281..ce03b6e8e 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -28,4 +28,7 @@ jobs: with: components: clippy - uses: Swatinem/rust-cache@v2 + with: + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - run: cargo clippy --all-targets -- -D warnings diff --git a/.github/workflows/integration-cassandra.yml b/.github/workflows/integration-cassandra.yml index 703372dd0..1f578bfee 100644 --- a/.github/workflows/integration-cassandra.yml +++ b/.github/workflows/integration-cassandra.yml @@ -65,6 +65,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Configure Cassandra authentication run: | docker exec ${{ job.services.cassandra.id }} sed -i \ @@ -121,6 +123,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Configure Cassandra authentication run: | docker exec ${{ job.services.cassandra.id }} sed -i \ @@ -172,6 +176,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Configure Cassandra authentication run: | docker exec ${{ job.services.cassandra.id }} sed -i \ @@ -208,6 +214,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Check production Cassandra feature graph run: cargo check --release --no-default-features --features cassandra diff --git a/.github/workflows/integration-mongodb.yml b/.github/workflows/integration-mongodb.yml index 03223f967..01e28552f 100644 --- a/.github/workflows/integration-mongodb.yml +++ b/.github/workflows/integration-mongodb.yml @@ -41,6 +41,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - uses: actions/setup-python@v5 with: python-version: "3.11" @@ -64,6 +66,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Start replica set # Same bootstrap developers run locally; --mongo-only skips the # server and prints the URI. No pipe: a bootstrap failure must fail @@ -109,6 +113,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - uses: actions/setup-python@v5 with: python-version: "3.11" @@ -128,6 +134,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Check production MongoDB feature graph run: cargo check --release --no-default-features --features mongodb diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index da6c251d3..b1de36c0b 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -54,6 +54,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build release run: cargo build --release @@ -116,6 +118,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build release (SQLite backend) run: cargo build --release -p extenddb --no-default-features --features sqlite @@ -178,6 +182,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build release (dev mode, in-memory SQLite) run: cargo build --release -p extenddb --no-default-features --features sqlite-memory,dev-mode @@ -240,6 +246,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build release run: cargo build --release @@ -354,6 +362,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build release run: cargo build --release @@ -415,6 +425,8 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build release (SQLite backend) run: cargo build --release -p extenddb --no-default-features --features sqlite diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db09750f3..17f2a1d28 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,6 +34,9 @@ jobs: with: toolchain: ${{ matrix.toolchain }} - uses: Swatinem/rust-cache@v2 + with: + # Only pushes to main save, so other runs restore main's cache. + save-if: ${{ github.ref == 'refs/heads/main' }} # Local S3 endpoint for the backup-store conformance suite. moto is a # pip package, so it needs no container image; MinIO no longer