Skip to content

Commit afb67b2

Browse files
cycraigabonander
andcommitted
chore: test macros' offline mode in CI
Co-authored-by: Austin Bonander <[email protected]>
1 parent 973e254 commit afb67b2

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

.github/workflows/sqlx.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ jobs:
158158

159159
- run: echo "using ${DATABASE_URL}"
160160

161+
# Create data dir for offline mode
162+
- run: mkdir .sqlx
163+
161164
- uses: actions-rs/cargo@v1
162165
with:
163166
command: test
@@ -168,6 +171,39 @@ jobs:
168171
--test-threads=1
169172
env:
170173
DATABASE_URL: sqlite:tests/sqlite/sqlite.db
174+
SQLX_OFFLINE_DIR: .sqlx
175+
RUSTFLAGS: --cfg sqlite_ipaddr
176+
LD_LIBRARY_PATH: /tmp/sqlite3-lib
177+
178+
# Remove test artifacts
179+
- run: cargo clean -p sqlx
180+
181+
# Build the macros-test in offline mode (omit DATABASE_URL)
182+
- uses: actions-rs/cargo@v1
183+
with:
184+
command: build
185+
args: >
186+
--no-default-features
187+
--test sqlite-macros
188+
--features any,macros,sqlite,_unstable-all-types,runtime-${{ matrix.runtime }}
189+
env:
190+
SQLX_OFFLINE: true
191+
SQLX_OFFLINE_DIR: .sqlx
192+
RUSTFLAGS: --cfg sqlite_ipaddr
193+
LD_LIBRARY_PATH: /tmp/sqlite3-lib
194+
195+
# Test macros in offline mode (still needs DATABASE_URL to run)
196+
- uses: actions-rs/cargo@v1
197+
with:
198+
command: test
199+
args: >
200+
--no-default-features
201+
--test sqlite-macros
202+
--features any,macros,sqlite,_unstable-all-types,runtime-${{ matrix.runtime }}
203+
env:
204+
DATABASE_URL: sqlite://tests/sqlite/sqlite.db
205+
SQLX_OFFLINE: true
206+
SQLX_OFFLINE_DIR: .sqlx
171207
RUSTFLAGS: --cfg sqlite_ipaddr
172208
LD_LIBRARY_PATH: /tmp/sqlite3-lib
173209

@@ -207,6 +243,9 @@ jobs:
207243
docker-compose -f tests/docker-compose.yml run -d -p 5432:5432 --name postgres_${{ matrix.postgres }} postgres_${{ matrix.postgres }}
208244
docker exec postgres_${{ matrix.postgres }} bash -c "until pg_isready; do sleep 1; done"
209245
246+
# Create data dir for offline mode
247+
- run: mkdir .sqlx
248+
210249
- uses: actions-rs/cargo@v1
211250
with:
212251
command: test
@@ -215,6 +254,7 @@ jobs:
215254
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
216255
env:
217256
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
257+
SQLX_OFFLINE_DIR: .sqlx
218258
# FIXME: needed to disable `ltree` tests in Postgres 9.6
219259
# but `PgLTree` should just fall back to text format
220260
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
@@ -228,6 +268,41 @@ jobs:
228268
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
229269
env:
230270
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=.%2Ftests%2Fcerts%2Fca.crt
271+
SQLX_OFFLINE_DIR: .sqlx
272+
# FIXME: needed to disable `ltree` tests in Postgres 9.6
273+
# but `PgLTree` should just fall back to text format
274+
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
275+
276+
# Remove test artifacts
277+
- run: cargo clean -p sqlx
278+
279+
# Build the macros-test in offline mode (omit DATABASE_URL)
280+
- uses: actions-rs/cargo@v1
281+
with:
282+
command: build
283+
args: >
284+
--no-default-features
285+
--test postgres-macros
286+
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
287+
env:
288+
SQLX_OFFLINE: true
289+
SQLX_OFFLINE_DIR: .sqlx
290+
# FIXME: needed to disable `ltree` tests in Postgres 9.6
291+
# but `PgLTree` should just fall back to text format
292+
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
293+
294+
# Test macros in offline mode (still needs DATABASE_URL to run)
295+
- uses: actions-rs/cargo@v1
296+
with:
297+
command: test
298+
args: >
299+
--no-default-features
300+
--test postgres-macros
301+
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
302+
env:
303+
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
304+
SQLX_OFFLINE: true
305+
SQLX_OFFLINE_DIR: .sqlx
231306
# FIXME: needed to disable `ltree` tests in Postgres 9.6
232307
# but `PgLTree` should just fall back to text format
233308
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
@@ -283,6 +358,9 @@ jobs:
283358
- run: docker-compose -f tests/docker-compose.yml run -d -p 3306:3306 --name mysql_${{ matrix.mysql }} mysql_${{ matrix.mysql }}
284359
- run: sleep 60
285360

361+
# Create data dir for offline mode
362+
- run: mkdir .sqlx
363+
286364
- uses: actions-rs/cargo@v1
287365
with:
288366
command: test
@@ -291,6 +369,7 @@ jobs:
291369
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
292370
env:
293371
DATABASE_URL: mysql://root:password@localhost:3306/sqlx?ssl-mode=disabled
372+
SQLX_OFFLINE_DIR: .sqlx
294373
RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
295374

296375
# MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
@@ -303,6 +382,39 @@ jobs:
303382
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
304383
env:
305384
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
385+
SQLX_OFFLINE_DIR: .sqlx
386+
RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
387+
388+
# Remove test artifacts
389+
- run: cargo clean -p sqlx
390+
391+
# Build the macros-test in offline mode (omit DATABASE_URL)
392+
- uses: actions-rs/cargo@v1
393+
with:
394+
command: build
395+
args: >
396+
--no-default-features
397+
--test mysql-macros
398+
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
399+
env:
400+
SQLX_OFFLINE: true
401+
SQLX_OFFLINE_DIR: .sqlx
402+
RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
403+
404+
# Test macros in offline mode (still needs DATABASE_URL to run)
405+
# MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
406+
- uses: actions-rs/cargo@v1
407+
if: ${{ !(matrix.mysql == '5_7' && matrix.tls == 'rustls') }}
408+
with:
409+
command: test
410+
args: >
411+
--no-default-features
412+
--test mysql-macros
413+
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
414+
env:
415+
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
416+
SQLX_OFFLINE: true
417+
SQLX_OFFLINE_DIR: .sqlx
306418
RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
307419

308420
# client SSL authentication
@@ -355,14 +467,48 @@ jobs:
355467
- run: docker-compose -f tests/docker-compose.yml run -d -p 3306:3306 --name mariadb_${{ matrix.mariadb }} mariadb_${{ matrix.mariadb }}
356468
- run: sleep 30
357469

470+
# Create data dir for offline mode
471+
- run: mkdir .sqlx
472+
473+
- uses: actions-rs/cargo@v1
474+
with:
475+
command: test
476+
args: >
477+
--no-default-features
478+
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
479+
env:
480+
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
481+
SQLX_OFFLINE_DIR: .sqlx
482+
RUSTFLAGS: --cfg mariadb_${{ matrix.mariadb }}
483+
484+
# Remove test artifacts
485+
- run: cargo clean -p sqlx
486+
487+
# Build the macros-test in offline mode (omit DATABASE_URL)
488+
- uses: actions-rs/cargo@v1
489+
with:
490+
command: build
491+
args: >
492+
--no-default-features
493+
--test mysql-macros
494+
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
495+
env:
496+
SQLX_OFFLINE: true
497+
SQLX_OFFLINE_DIR: .sqlx
498+
RUSTFLAGS: --cfg mariadb_${{ matrix.mariadb }}
499+
500+
# Test macros in offline mode (still needs DATABASE_URL to run)
358501
- uses: actions-rs/cargo@v1
359502
with:
360503
command: test
361504
args: >
362505
--no-default-features
506+
--test mysql-macros
363507
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
364508
env:
365509
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
510+
SQLX_OFFLINE: true
511+
SQLX_OFFLINE_DIR: .sqlx
366512
RUSTFLAGS: --cfg mariadb_${{ matrix.mariadb }}
367513

368514
# client SSL authentication

0 commit comments

Comments
 (0)