Skip to content

Commit b532eb3

Browse files
committed
chore: test macros' offline mode in CI
1 parent 1fa2381 commit b532eb3

File tree

1 file changed

+159
-6
lines changed

1 file changed

+159
-6
lines changed

.github/workflows/sqlx.yml

Lines changed: 159 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,47 @@ jobs:
170170
target
171171
key: ${{ runner.os }}-sqlite-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}
172172

173+
# Create data dir for offline mode
174+
- run: mkdir .sqlx
175+
176+
- uses: actions-rs/cargo@v1
177+
with:
178+
command: test
179+
args: >
180+
--no-default-features
181+
--features any,macros,migrate,sqlite,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
182+
--
183+
--test-threads=1
184+
env:
185+
DATABASE_URL: sqlite://tests/sqlite/sqlite.db
186+
187+
# Remove test artifacts
188+
- run: cargo clean -p sqlx
189+
190+
# Build the macros-test in offline mode (omit DATABASE_URL)
191+
- uses: actions-rs/cargo@v1
192+
with:
193+
command: build
194+
args: >
195+
--no-default-features
196+
--test sqlite-macros
197+
--features any,macros,migrate,sqlite,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
198+
env:
199+
SQLX_OFFLINE: true
200+
201+
# Test macros in offline mode (still needs DATABASE_URL to run)
173202
- uses: actions-rs/cargo@v1
174203
with:
175204
command: test
176205
args: >
177206
--no-default-features
178-
--features any,macros,migrate,sqlite,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
207+
--test sqlite-macros
208+
--features any,macros,migrate,sqlite,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
179209
--
180210
--test-threads=1
181211
env:
182212
DATABASE_URL: sqlite://tests/sqlite/sqlite.db
213+
SQLX_OFFLINE: true
183214

184215
postgres:
185216
name: Postgres
@@ -207,6 +238,9 @@ jobs:
207238
target
208239
key: ${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}
209240

241+
# Create data dir for offline mode
242+
- run: mkdir .sqlx
243+
210244
- uses: actions-rs/cargo@v1
211245
env:
212246
# FIXME: needed to disable `ltree` tests in Postgres 9.6
@@ -226,7 +260,7 @@ jobs:
226260
command: test
227261
args: >
228262
--no-default-features
229-
--features any,postgres,macros,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
263+
--features any,postgres,macros,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
230264
env:
231265
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
232266
# FIXME: needed to disable `ltree` tests in Postgres 9.6
@@ -238,13 +272,45 @@ jobs:
238272
command: test
239273
args: >
240274
--no-default-features
241-
--features any,postgres,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
275+
--features any,postgres,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
242276
env:
243277
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=.%2Ftests%2Fcerts%2Fca.crt
244278
# FIXME: needed to disable `ltree` tests in Postgres 9.6
245279
# but `PgLTree` should just fall back to text format
246280
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
247281

282+
# Remove test artifacts
283+
- run: cargo clean -p sqlx
284+
285+
# Build the macros-test in offline mode (omit DATABASE_URL)
286+
- uses: actions-rs/cargo@v1
287+
with:
288+
command: build
289+
args: >
290+
--no-default-features
291+
--test postgres-macros
292+
--features any,postgres,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
293+
env:
294+
SQLX_OFFLINE: true
295+
# FIXME: needed to disable `ltree` tests in Postgres 9.6
296+
# but `PgLTree` should just fall back to text format
297+
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
298+
299+
# Test macros in offline mode (still needs DATABASE_URL to run)
300+
- uses: actions-rs/cargo@v1
301+
with:
302+
command: test
303+
args: >
304+
--no-default-features
305+
--test postgres-macros
306+
--features any,postgres,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
307+
env:
308+
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
309+
SQLX_OFFLINE: true
310+
# FIXME: needed to disable `ltree` tests in Postgres 9.6
311+
# but `PgLTree` should just fall back to text format
312+
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
313+
248314
mysql:
249315
name: MySQL
250316
runs-on: ubuntu-20.04
@@ -271,6 +337,9 @@ jobs:
271337
target
272338
key: ${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}
273339

340+
# Create data dir for offline mode
341+
- run: mkdir .sqlx
342+
274343
- uses: actions-rs/cargo@v1
275344
with:
276345
command: build
@@ -285,10 +354,36 @@ jobs:
285354
command: test
286355
args: >
287356
--no-default-features
288-
--features any,mysql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
357+
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
289358
env:
290359
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
291360

361+
# Remove test artifacts
362+
- run: cargo clean -p sqlx
363+
364+
# Build the macros-test in offline mode (omit DATABASE_URL)
365+
- uses: actions-rs/cargo@v1
366+
with:
367+
command: build
368+
args: >
369+
--no-default-features
370+
--test mysql-macros
371+
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
372+
env:
373+
SQLX_OFFLINE: true
374+
375+
# Test macros in offline mode (still needs DATABASE_URL to run)
376+
- uses: actions-rs/cargo@v1
377+
with:
378+
command: test
379+
args: >
380+
--no-default-features
381+
--test mysql-macros
382+
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
383+
env:
384+
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
385+
SQLX_OFFLINE: true
386+
292387
mariadb:
293388
name: MariaDB
294389
runs-on: ubuntu-20.04
@@ -316,6 +411,9 @@ jobs:
316411
target
317412
key: ${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}
318413

414+
# Create data dir for offline mode
415+
- run: mkdir .sqlx
416+
319417
- uses: actions-rs/cargo@v1
320418
with:
321419
command: build
@@ -330,9 +428,35 @@ jobs:
330428
command: test
331429
args: >
332430
--no-default-features
333-
--features any,mysql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
431+
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
432+
env:
433+
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
434+
435+
# Remove test artifacts
436+
- run: cargo clean -p sqlx
437+
438+
# Build the macros-test in offline mode (omit DATABASE_URL)
439+
- uses: actions-rs/cargo@v1
440+
with:
441+
command: build
442+
args: >
443+
--no-default-features
444+
--test mysql-macros
445+
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
446+
env:
447+
SQLX_OFFLINE: true
448+
449+
# Test macros in offline mode (still needs DATABASE_URL to run)
450+
- uses: actions-rs/cargo@v1
451+
with:
452+
command: test
453+
args: >
454+
--no-default-features
455+
--test mysql-macros
456+
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
334457
env:
335458
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
459+
SQLX_OFFLINE: true
336460

337461
mssql:
338462
name: MSSQL
@@ -360,6 +484,9 @@ jobs:
360484
target
361485
key: ${{ runner.os }}-mssql-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}
362486

487+
# Create data dir for offline mode
488+
- run: mkdir .sqlx
489+
363490
- uses: actions-rs/cargo@v1
364491
with:
365492
command: build
@@ -374,6 +501,32 @@ jobs:
374501
command: test
375502
args: >
376503
--no-default-features
377-
--features any,mssql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
504+
--features any,mssql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
505+
env:
506+
DATABASE_URL: mssql://sa:Password123!@localhost/sqlx
507+
508+
# Remove test artifacts
509+
- run: cargo clean -p sqlx
510+
511+
# Build the macros-test in offline mode (omit DATABASE_URL)
512+
- uses: actions-rs/cargo@v1
513+
with:
514+
command: build
515+
args: >
516+
--no-default-features
517+
--test mssql-macros
518+
--features any,mssql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
519+
env:
520+
SQLX_OFFLINE: true
521+
522+
# Test macros in offline mode (still needs DATABASE_URL to run)
523+
- uses: actions-rs/cargo@v1
524+
with:
525+
command: test
526+
args: >
527+
--no-default-features
528+
--test mssql-macros
529+
--features any,mssql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
378530
env:
379531
DATABASE_URL: mssql://sa:Password123!@localhost/sqlx
532+
SQLX_OFFLINE: true

0 commit comments

Comments
 (0)