Skip to content

Commit b02ea2a

Browse files
authored
split Rust quality CI and prune caches (#1512)
Rust quality checks run sequentially, extending the CI critical path. Whole build-directory snapshots also consume the cache quota and evict shared dependencies when several pull requests run at once. Run packaging, public API compatibility, and nightly docs in separate jobs while keeping lint and stable documentation together. Preserve all existing check commands and fetch release history only for API checks. Use Rust-aware dependency pruning across Rust and conformance jobs. Save caches only on master, let one Postgres matrix job save the shared artifacts, and key nightly artifacts with their own compiler. Cache only registry downloads for package verification's fresh temporary builds.
1 parent d61ef9c commit b02ea2a

2 files changed

Lines changed: 77 additions & 54 deletions

File tree

‎.github/workflows/conformance.yaml‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ permissions:
3737
contents: read
3838

3939
env:
40-
# Keep the cross-run cache small; Cargo still reuses compiled dependencies.
40+
# Cache reusable dependencies instead of incremental workspace builds.
4141
CARGO_INCREMENTAL: "0"
4242

4343
jobs:
@@ -56,18 +56,14 @@ jobs:
5656
go-version-file: go.work
5757

5858
- uses: dtolnay/rust-toolchain@stable
59-
id: rust
6059

61-
- name: Cache Rust dependencies and build artifacts
62-
uses: actions/cache@v6
60+
# Prune build artifacts and keep shared caches in master's branch scope.
61+
- name: Cache Rust dependencies
62+
uses: Swatinem/rust-cache@v2
6363
with:
64-
path: |
65-
~/.cargo/registry/index
66-
~/.cargo/registry/cache
67-
~/.cargo/git/db
68-
rust/target
69-
key: rust-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('rust/**/Cargo.toml', 'rust/Cargo.lock') }}
70-
restore-keys: rust-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ steps.rust.outputs.cachekey }}-
64+
cache-bin: false
65+
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
66+
workspaces: rust -> target
7167

7268
- uses: ./.github/actions/setup-js
7369

‎.github/workflows/rust.yaml‎

Lines changed: 70 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ permissions:
2828
contents: read
2929

3030
env:
31-
# Keep the cross-run cache small; Cargo still reuses compiled dependencies.
31+
# Cache reusable dependencies instead of incremental workspace builds.
3232
CARGO_INCREMENTAL: "0"
3333

3434
jobs:
@@ -38,28 +38,20 @@ jobs:
3838

3939
steps:
4040
- uses: actions/checkout@v7
41-
with:
42-
fetch-depth: 0
4341
- uses: dtolnay/rust-toolchain@stable
44-
id: rust
4542
with:
4643
components: clippy,rustfmt
47-
- name: Cache Rust dependencies and build artifacts
48-
uses: actions/cache@v6
44+
# Prune workspace binaries, docs, and unused dependencies before saving.
45+
# PRs restore master caches without saving duplicate branch snapshots.
46+
- name: Cache Rust dependencies
47+
uses: Swatinem/rust-cache@v2
4948
with:
50-
path: |
51-
~/.cargo/registry/index
52-
~/.cargo/registry/cache
53-
~/.cargo/git/db
54-
rust/target
55-
key: rust-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('rust/**/Cargo.toml', 'rust/Cargo.lock') }}
56-
restore-keys: rust-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ steps.rust.outputs.cachekey }}-
49+
cache-bin: false
50+
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
51+
workspaces: rust -> target
5752
- uses: taiki-e/install-action@v2
5853
with:
5954
tool: cargo-deny@0.20.2
60-
- uses: taiki-e/install-action@v2
61-
with:
62-
tool: cargo-semver-checks@0.51.0
6355

6456
- name: Lint, including Postgres-only and SQLite-only builds
6557
run: make lint/rust
@@ -70,22 +62,66 @@ jobs:
7062
- name: Dependency and license policy
7163
run: make check/rust/dependencies
7264

65+
docsrs:
66+
runs-on: ubuntu-latest
67+
timeout-minutes: 20
68+
69+
steps:
70+
- uses: actions/checkout@v7
71+
- uses: dtolnay/rust-toolchain@nightly
72+
# Key the nightly build cache with the compiler that actually builds it.
73+
- name: Cache Rust dependencies
74+
uses: Swatinem/rust-cache@v2
75+
with:
76+
cache-bin: false
77+
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
78+
workspaces: rust -> target/docsrs
79+
- name: Documentation as docs.rs builds it
80+
run: make doc/rust/docsrs
81+
82+
package:
83+
runs-on: ubuntu-latest
84+
timeout-minutes: 20
85+
86+
steps:
87+
- uses: actions/checkout@v7
88+
- uses: dtolnay/rust-toolchain@stable
89+
# Package verification intentionally compiles in a fresh temporary build
90+
# directory; only registry downloads can be reused between runs.
91+
- name: Cache Rust dependencies
92+
uses: Swatinem/rust-cache@v2
93+
with:
94+
cache-bin: false
95+
cache-targets: false
96+
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
97+
workspaces: rust -> target
7398
- name: Package archives
7499
run: make check/rust/package
75100

101+
semver:
102+
runs-on: ubuntu-latest
103+
timeout-minutes: 20
104+
105+
steps:
106+
- uses: actions/checkout@v7
107+
with:
108+
fetch-depth: 0
109+
- uses: dtolnay/rust-toolchain@stable
110+
- name: Cache Rust dependencies
111+
uses: Swatinem/rust-cache@v2
112+
with:
113+
cache-bin: false
114+
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
115+
workspaces: rust -> target
116+
- uses: taiki-e/install-action@v2
117+
with:
118+
tool: cargo-semver-checks@0.51.0
76119
# Compare with the latest published Rust release tag, which the full
77120
# checkout above includes. Before the first release there is no
78121
# baseline and the step reports that instead of failing.
79122
- name: Public API compatibility
80123
run: make check/rust/semver
81124

82-
# docs.rs builds with a nightly toolchain and `--cfg docsrs`, which
83-
# enables the crates' `doc_cfg` feature badges. Last, since installing
84-
# nightly makes it the default toolchain for later steps.
85-
- uses: dtolnay/rust-toolchain@nightly
86-
- name: Documentation as docs.rs builds it
87-
run: make doc/rust/docsrs
88-
89125
rust_versions:
90126
runs-on: ubuntu-latest
91127
timeout-minutes: 20
@@ -97,19 +133,14 @@ jobs:
97133
steps:
98134
- uses: actions/checkout@v7
99135
- uses: dtolnay/rust-toolchain@master
100-
id: rust
101136
with:
102137
toolchain: ${{ matrix.rust-version }}
103-
- name: Cache Rust dependencies and build artifacts
104-
uses: actions/cache@v6
138+
- name: Cache Rust dependencies
139+
uses: Swatinem/rust-cache@v2
105140
with:
106-
path: |
107-
~/.cargo/registry/index
108-
~/.cargo/registry/cache
109-
~/.cargo/git/db
110-
rust/target
111-
key: rust-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('rust/**/Cargo.toml', 'rust/Cargo.lock') }}
112-
restore-keys: rust-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ steps.rust.outputs.cachekey }}-
141+
cache-bin: false
142+
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
143+
workspaces: rust -> target
113144
# Tests read fixtures generated from River's Go implementation.
114145
- uses: actions/setup-go@v7
115146
with:
@@ -145,17 +176,13 @@ jobs:
145176
steps:
146177
- uses: actions/checkout@v7
147178
- uses: dtolnay/rust-toolchain@stable
148-
id: rust
149-
- name: Cache Rust dependencies and build artifacts
150-
uses: actions/cache@v6
179+
# The database versions share build artifacts; one matrix job saves them.
180+
- name: Cache Rust dependencies
181+
uses: Swatinem/rust-cache@v2
151182
with:
152-
path: |
153-
~/.cargo/registry/index
154-
~/.cargo/registry/cache
155-
~/.cargo/git/db
156-
rust/target
157-
key: rust-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('rust/**/Cargo.toml', 'rust/Cargo.lock') }}
158-
restore-keys: rust-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ steps.rust.outputs.cachekey }}-
183+
cache-bin: false
184+
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.postgres-version == 18 }}
185+
workspaces: rust -> target
159186
# Tests read fixtures generated from River's Go implementation.
160187
- uses: actions/setup-go@v7
161188
with:

0 commit comments

Comments
 (0)