@@ -28,7 +28,7 @@ permissions:
2828 contents : read
2929
3030env :
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
3434jobs :
@@ -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