Skip to content

Commit 2384840

Browse files
authored
Enhance GitHub Actions caching (#34)
- Added dtolnay/rust-toolchain action for stable Rust toolchain. - Updated rust-cache configurations with prefix and shared keys for better cache management. - Adjusted save conditions for caching based on branch and runtime settings.
1 parent 5167a14 commit 2384840

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

.github/workflows/sqlx.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ jobs:
2424
tls: [native-tls, rustls]
2525
steps:
2626
- uses: actions/checkout@v4
27+
- uses: dtolnay/rust-toolchain@stable
2728
- uses: Swatinem/rust-cache@v2
29+
with:
30+
prefix-key: v1-sqlx
31+
save-if: ${{ false }}
2832
- name: Run clippy for core with all features
2933
run: |
3034
cargo clippy --manifest-path sqlx-core/Cargo.toml \
@@ -62,7 +66,11 @@ jobs:
6266
]
6367
steps:
6468
- uses: actions/checkout@v4
69+
- uses: dtolnay/rust-toolchain@stable
6570
- uses: Swatinem/rust-cache@v2
71+
with:
72+
prefix-key: v1-sqlx
73+
save-if: ${{ false }}
6674
- run:
6775
cargo test
6876
--manifest-path sqlx-core/Cargo.toml
@@ -90,7 +98,11 @@ jobs:
9098

9199
steps:
92100
- uses: actions/checkout@v4
101+
- uses: dtolnay/rust-toolchain@stable
93102
- uses: Swatinem/rust-cache@v2
103+
with:
104+
prefix-key: v1-sqlx
105+
save-if: ${{ github.ref == 'refs/heads/main' }}
94106
- run:
95107
cargo build
96108
--manifest-path sqlx-cli/Cargo.toml
@@ -114,7 +126,12 @@ jobs:
114126
steps:
115127
- uses: actions/checkout@v4
116128
- run: mkdir /tmp/sqlite3-lib && wget -O /tmp/sqlite3-lib/ipaddr.so https://github.com/nalgeon/sqlean/releases/download/0.15.2/ipaddr.so
129+
- uses: dtolnay/rust-toolchain@stable
117130
- uses: Swatinem/rust-cache@v2
131+
with:
132+
prefix-key: v1-sqlx
133+
shared-key: sqlite-${{ matrix.runtime }}-${{ matrix.tls }}
134+
save-if: ${{ github.ref == 'refs/heads/main' && matrix.runtime == 'tokio' && matrix.tls == 'native-tls' }}
118135
- name: Run clippy for sqlite
119136
run: |
120137
cargo clippy \
@@ -148,7 +165,9 @@ jobs:
148165

149166
- uses: Swatinem/rust-cache@v2
150167
with:
151-
key: ${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ matrix.tls }}
168+
prefix-key: v1-sqlx
169+
shared-key: postgres-${{ matrix.runtime }}-${{ matrix.tls }}
170+
save-if: ${{ github.ref == 'refs/heads/main' && matrix.postgres == '14' }}
152171

153172
- run: |
154173
cargo build --features postgres,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
@@ -192,9 +211,12 @@ jobs:
192211
needs: check
193212
steps:
194213
- uses: actions/checkout@v4
214+
- uses: dtolnay/rust-toolchain@stable
195215
- uses: Swatinem/rust-cache@v2
196216
with:
197-
key: linux-postgres-ssl-client-cert
217+
prefix-key: v1-sqlx
218+
shared-key: postgres-actix-rustls
219+
save-if: ${{ false }}
198220
- run: docker compose up --wait postgres_16
199221
working-directory: tests
200222
- run: cargo test --no-default-features --features any,postgres,macros,all-types,runtime-actix-rustls
@@ -217,7 +239,9 @@ jobs:
217239

218240
- uses: Swatinem/rust-cache@v2
219241
with:
220-
key: ${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}
242+
prefix-key: v1-sqlx
243+
shared-key: mysql-${{ matrix.runtime }}-${{ matrix.tls }}
244+
save-if: ${{ github.ref == 'refs/heads/main' && matrix.mysql == '8' }}
221245

222246
- run: |
223247
cargo build --features mysql,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
@@ -260,7 +284,9 @@ jobs:
260284

261285
- uses: Swatinem/rust-cache@v2
262286
with:
263-
key: ${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}
287+
prefix-key: v1-sqlx
288+
shared-key: mariadb-${{ matrix.runtime }}-${{ matrix.tls }}
289+
save-if: ${{ github.ref == 'refs/heads/main' && matrix.mariadb == '10_6' }}
264290

265291
- run: |
266292
cargo build --features mysql,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
@@ -296,7 +322,9 @@ jobs:
296322

297323
- uses: Swatinem/rust-cache@v2
298324
with:
299-
key: ${{ runner.os }}-mssql-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}
325+
prefix-key: v1-sqlx
326+
shared-key: mssql-${{ matrix.runtime }}-${{ matrix.tls }}
327+
save-if: ${{ github.ref == 'refs/heads/main' && matrix.mssql == '2022' }}
300328

301329
- run: |
302330
cargo build --features mssql,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}

0 commit comments

Comments
 (0)