Skip to content

Commit d7a9ae6

Browse files
committed
Refactor GitHub Actions workflow for Rust
replace actions-rs/cargo with direct cargo commands for build and test steps, and update toolchain action to dtolnay/rust-toolchain.
1 parent 98ad187 commit d7a9ae6

File tree

1 file changed

+24
-76
lines changed

1 file changed

+24
-76
lines changed

.github/workflows/sqlx.yml

Lines changed: 24 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,18 @@ jobs:
160160
steps:
161161
- uses: actions/checkout@v4
162162

163-
- uses: actions-rs/toolchain@v1
164-
with:
165-
profile: minimal
166-
toolchain: stable
167-
override: true
163+
- uses: dtolnay/rust-toolchain@stable
168164

169165
- uses: Swatinem/rust-cache@v2
170166
with:
171167
key: ${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ matrix.tls }}
172168

173-
- uses: actions-rs/cargo@v1
169+
- run: |
170+
cargo build --features postgres,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
174171
env:
175172
# FIXME: needed to disable `ltree` tests in Postgres 9.6
176173
# but `PgLTree` should just fall back to text format
177174
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
178-
with:
179-
command: build
180-
args: >
181-
--features postgres,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
182175
183176
- name: Run clippy for postgres
184177
run: |
@@ -193,24 +186,16 @@ jobs:
193186
docker compose -f tests/docker-compose.yml run -d -p 5432:5432 --name postgres_${{ matrix.postgres }} postgres_${{ matrix.postgres }}
194187
docker exec postgres_${{ matrix.postgres }} bash -c "until pg_isready; do sleep 1; done"
195188
196-
- uses: actions-rs/cargo@v1
197-
with:
198-
command: test
199-
args: >
200-
--no-default-features
201-
--features any,postgres,macros,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
189+
- run: |
190+
cargo test --no-default-features --features any,postgres,macros,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
202191
env:
203192
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
204193
# FIXME: needed to disable `ltree` tests in Postgres 9.6
205194
# but `PgLTree` should just fall back to text format
206195
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
207196
208-
- uses: actions-rs/cargo@v1
209-
with:
210-
command: test
211-
args: >
212-
--no-default-features
213-
--features any,postgres,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
197+
- run: |
198+
cargo test --no-default-features --features any,postgres,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
214199
env:
215200
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=./tests/certs/ca.crt
216201
# FIXME: needed to disable `ltree` tests in Postgres 9.6
@@ -244,21 +229,14 @@ jobs:
244229
steps:
245230
- uses: actions/checkout@v4
246231

247-
- uses: actions-rs/toolchain@v1
248-
with:
249-
profile: minimal
250-
toolchain: stable
251-
override: true
232+
- uses: dtolnay/rust-toolchain@stable
252233

253234
- uses: Swatinem/rust-cache@v2
254235
with:
255236
key: ${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}
256237

257-
- uses: actions-rs/cargo@v1
258-
with:
259-
command: build
260-
args: >
261-
--features mysql,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
238+
- run: |
239+
cargo build --features mysql,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
262240
263241
- name: Run clippy for mysql
264242
run: |
@@ -270,23 +248,15 @@ jobs:
270248
- run: docker compose -f tests/docker-compose.yml run -d -p 3306:3306 mysql_${{ matrix.mysql }}
271249
- run: sleep 60
272250

273-
- uses: actions-rs/cargo@v1
274-
with:
275-
command: test
276-
args: >
277-
--no-default-features
278-
--features any,mysql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
251+
- run: |
252+
cargo test --no-default-features --features any,mysql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
279253
env:
280254
DATABASE_URL: mysql://root:password@localhost:3306/sqlx?ssl-mode=disabled
281255
282256
# MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
283-
- uses: actions-rs/cargo@v1
257+
- run: |
258+
cargo test --no-default-features --features any,mysql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
284259
if: ${{ !(matrix.mysql == '5_7' && matrix.tls == 'rustls') }}
285-
with:
286-
command: test
287-
args: >
288-
--no-default-features
289-
--features any,mysql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
290260
env:
291261
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
292262
@@ -302,21 +272,14 @@ jobs:
302272
steps:
303273
- uses: actions/checkout@v4
304274

305-
- uses: actions-rs/toolchain@v1
306-
with:
307-
profile: minimal
308-
toolchain: stable
309-
override: true
275+
- uses: dtolnay/rust-toolchain@stable
310276

311277
- uses: Swatinem/rust-cache@v2
312278
with:
313279
key: ${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}
314280

315-
- uses: actions-rs/cargo@v1
316-
with:
317-
command: build
318-
args: >
319-
--features mysql,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
281+
- run: |
282+
cargo build --features mysql,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
320283
321284
- name: Run clippy for mariadb
322285
run: |
@@ -328,12 +291,8 @@ jobs:
328291
- run: docker compose -f tests/docker-compose.yml run -d -p 3306:3306 mariadb_${{ matrix.mariadb }}
329292
- run: sleep 30
330293

331-
- uses: actions-rs/cargo@v1
332-
with:
333-
command: test
334-
args: >
335-
--no-default-features
336-
--features any,mysql,macros,migrate,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
294+
- run: |
295+
cargo test --no-default-features --features any,mysql,macros,migrate,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
337296
env:
338297
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
339298
@@ -349,21 +308,14 @@ jobs:
349308
steps:
350309
- uses: actions/checkout@v4
351310

352-
- uses: actions-rs/toolchain@v1
353-
with:
354-
profile: minimal
355-
toolchain: stable
356-
override: true
311+
- uses: dtolnay/rust-toolchain@stable
357312

358313
- uses: Swatinem/rust-cache@v2
359314
with:
360315
key: ${{ runner.os }}-mssql-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}
361316

362-
- uses: actions-rs/cargo@v1
363-
with:
364-
command: build
365-
args: >
366-
--features mssql,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
317+
- run: |
318+
cargo build --features mssql,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
367319
368320
- name: Run clippy for mssql
369321
run: |
@@ -375,11 +327,7 @@ jobs:
375327
- run: docker compose -f tests/docker-compose.yml run -d -p 1433:1433 mssql_${{ matrix.mssql }}
376328
- run: sleep 80 # MSSQL takes a "bit" to startup
377329

378-
- uses: actions-rs/cargo@v1
379-
with:
380-
command: test
381-
args: >
382-
--no-default-features
383-
--features any,mssql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
330+
- run: |
331+
cargo test --no-default-features --features any,mssql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
384332
env:
385333
DATABASE_URL: mssql://sa:Password123!@localhost/sqlx

0 commit comments

Comments
 (0)