Debian Codegraph @

.github/workflows/sqlx.yml

raw symbols SCIP
1 name: SQLx
2
3 on:
4 pull_request:
5 push:
6 branches:
7 - main
8 - "*-dev"
9
10 jobs:
11 format:
12 name: Format
13 runs-on: ubuntu-22.04
14 steps:
15 - uses: actions/checkout@v4
16 - run: rustup component add rustfmt
17 - run: cargo fmt --all -- --check
18
19 check:
20 name: Check
21 runs-on: ubuntu-22.04
22 strategy:
23 matrix:
24 runtime: [async-std, tokio]
25 tls: [native-tls, rustls, none]
26 steps:
27 - uses: actions/checkout@v4
28
29 - uses: Swatinem/rust-cache@v2
30 with:
31 key: "${{ runner.os }}-check-${{ matrix.runtime }}-${{ matrix.tls }}"
32
33 - run: |
34 rustup update
35 rustup component add clippy
36 rustup toolchain install beta
37 rustup component add --toolchain beta clippy
38
39 - run: >
40 cargo clippy
41 --no-default-features
42 --features all-databases,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }},macros
43 -- -D warnings
44
45 # Run beta for new warnings but don't break the build.
46 # Use a subdirectory of `target` to avoid clobbering the cache.
47 - run: >
48 cargo +beta clippy
49 --no-default-features
50 --features all-databases,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }},macros
51 --target-dir target/beta/
52
53 check-minimal-versions:
54 name: Check build using minimal versions
55 runs-on: ubuntu-22.04
56 steps:
57 - uses: actions/checkout@v4
58 - run: rustup update
59 - run: rustup toolchain install nightly
60 - run: cargo +nightly generate-lockfile -Z minimal-versions
61 - run: cargo build --all-features
62
63 test:
64 name: Unit Tests
65 runs-on: ubuntu-22.04
66 steps:
67 - uses: actions/checkout@v4
68
69 - uses: Swatinem/rust-cache@v2
70 with:
71 key: ${{ runner.os }}-test
72
73 - name: Install Rust
74 run: rustup update
75
76 - name: Test sqlx-core
77 run: >
78 cargo test
79 -p sqlx-core
80 --all-features
81
82 - name: Test sqlx-mysql
83 run: >
84 cargo test
85 -p sqlx-mysql
86 --all-features
87
88 - name: Test sqlx-postgres
89 run: >
90 cargo test
91 -p sqlx-postgres
92 --all-features
93
94 - name: Test sqlx-sqlite
95 run: >
96 cargo test
97 -p sqlx-sqlite
98 --all-features
99
100 - name: Test sqlx-macros-core
101 run: >
102 cargo test
103 -p sqlx-macros-core
104 --all-features
105
106 # Note: use `--lib` to not run integration tests that require a DB
107 - name: Test sqlx
108 run: >
109 cargo test
110 -p sqlx
111 --lib
112 --all-features
113
114 sqlite:
115 name: SQLite
116 runs-on: ubuntu-22.04
117 strategy:
118 matrix:
119 runtime: [async-std, tokio]
120 linking: [sqlite, sqlite-unbundled]
121 needs: check
122 steps:
123 - uses: actions/checkout@v4
124
125 - run: mkdir /tmp/sqlite3-lib && wget -O /tmp/sqlite3-lib/ipaddr.so https://github.com/nalgeon/sqlean/releases/download/0.15.2/ipaddr.so
126
127 - uses: Swatinem/rust-cache@v2
128 with:
129 key: "${{ runner.os }}-${{ matrix.linking }}-${{ matrix.runtime }}-${{ matrix.tls }}"
130
131 - name: Install system sqlite library
132 if: ${{ matrix.linking == 'sqlite-unbundled' }}
133 run: sudo apt-get install -y libsqlite3-dev
134
135 - run: echo "using ${DATABASE_URL}"
136
137 # Create data dir for offline mode
138 - run: mkdir .sqlx
139
140 - run: >
141 cargo test
142 --no-default-features
143 --features any,macros,${{ matrix.linking }},_unstable-all-types,runtime-${{ matrix.runtime }}
144 --
145 --test-threads=1
146 env:
147 DATABASE_URL: sqlite:tests/sqlite/sqlite.db
148 SQLX_OFFLINE_DIR: .sqlx
149 RUSTFLAGS: --cfg sqlite_ipaddr --cfg sqlite_test_sqlcipher
150 LD_LIBRARY_PATH: /tmp/sqlite3-lib
151
152 # Remove test artifacts
153 - run: cargo clean -p sqlx
154
155 # Build the macros-test in offline mode (omit DATABASE_URL)
156 - run: >
157 cargo build
158 --no-default-features
159 --test ${{ matrix.linking }}-macros
160 --features any,macros,${{ matrix.linking }},_unstable-all-types,runtime-${{ matrix.runtime }}
161 env:
162 SQLX_OFFLINE: true
163 SQLX_OFFLINE_DIR: .sqlx
164 RUSTFLAGS: -D warnings --cfg sqlite_ipaddr
165 LD_LIBRARY_PATH: /tmp/sqlite3-lib
166
167 # Test macros in offline mode (still needs DATABASE_URL to run)
168 - run: >
169 cargo test
170 --no-default-features
171 --test ${{ matrix.linking }}-macros
172 --features any,macros,${{ matrix.linking }},_unstable-all-types,runtime-${{ matrix.runtime }}
173 env:
174 DATABASE_URL: sqlite://tests/sqlite/sqlite.db
175 SQLX_OFFLINE: true
176 SQLX_OFFLINE_DIR: .sqlx
177 RUSTFLAGS: --cfg sqlite_ipaddr
178 LD_LIBRARY_PATH: /tmp/sqlite3-lib
179
180 postgres:
181 name: Postgres
182 runs-on: ubuntu-22.04
183 strategy:
184 matrix:
185 postgres: [17, 13]
186 runtime: [async-std, tokio]
187 tls: [native-tls, rustls-aws-lc-rs, rustls-ring, none]
188 needs: check
189 steps:
190 - uses: actions/checkout@v4
191
192 - uses: Swatinem/rust-cache@v2
193 with:
194 key: "${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ matrix.tls }}"
195
196 - env:
197 # FIXME: needed to disable `ltree` tests in Postgres 9.6
198 # but `PgLTree` should just fall back to text format
199 RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
200 run: cargo build --features postgres,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
201
202 - run: |
203 docker compose -f tests/docker-compose.yml run -d -p 5432:5432 --name postgres_${{ matrix.postgres }} postgres_${{ matrix.postgres }}
204 docker exec postgres_${{ matrix.postgres }} bash -c "until pg_isready; do sleep 1; done"
205
206 # Create data dir for offline mode
207 - run: mkdir .sqlx
208
209 - run: >
210 cargo test
211 --no-default-features
212 --features any,postgres,macros,migrate,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
213 env:
214 DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
215 SQLX_OFFLINE_DIR: .sqlx
216 # FIXME: needed to disable `ltree` tests in Postgres 9.6
217 # but `PgLTree` should just fall back to text format
218 RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
219
220 - if: matrix.tls != 'none'
221 run: >
222 cargo test
223 --no-default-features
224 --features any,postgres,macros,migrate,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
225 env:
226 DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=.%2Ftests%2Fcerts%2Fca.crt
227 SQLX_OFFLINE_DIR: .sqlx
228 # FIXME: needed to disable `ltree` tests in Postgres 9.6
229 # but `PgLTree` should just fall back to text format
230 RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
231
232 # Remove test artifacts
233 - run: cargo clean -p sqlx
234
235 # Build the macros-test in offline mode (omit DATABASE_URL)
236 - run: >
237 cargo build
238 --no-default-features
239 --test postgres-macros
240 --features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
241 env:
242 SQLX_OFFLINE: true
243 SQLX_OFFLINE_DIR: .sqlx
244 # FIXME: needed to disable `ltree` tests in Postgres 9.6
245 # but `PgLTree` should just fall back to text format
246 RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
247
248 # Test macros in offline mode (still needs DATABASE_URL to run)
249 - run: >
250 cargo test
251 --no-default-features
252 --test postgres-macros
253 --features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
254 env:
255 DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
256 SQLX_OFFLINE: true
257 SQLX_OFFLINE_DIR: .sqlx
258 # FIXME: needed to disable `ltree` tests in Postgres 9.6
259 # but `PgLTree` should just fall back to text format
260 RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
261
262 # client SSL authentication
263
264 - run: |
265 docker stop postgres_${{ matrix.postgres }}
266 docker compose -f tests/docker-compose.yml run -d -p 5432:5432 --name postgres_${{ matrix.postgres }}_client_ssl postgres_${{ matrix.postgres }}_client_ssl
267 docker exec postgres_${{ matrix.postgres }}_client_ssl bash -c "until pg_isready; do sleep 1; done"
268
269 - if: matrix.tls != 'none'
270 run: >
271 cargo test
272 --no-default-features
273 --features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
274 env:
275 DATABASE_URL: postgres://postgres@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=.%2Ftests%2Fcerts%2Fca.crt&sslkey=.%2Ftests%2Fkeys%2Fclient.key&sslcert=.%2Ftests%2Fcerts%2Fclient.crt
276 # FIXME: needed to disable `ltree` tests in Postgres 9.6
277 # but `PgLTree` should just fall back to text format
278 RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}_client_ssl
279
280 mysql:
281 name: MySQL
282 runs-on: ubuntu-22.04
283 strategy:
284 matrix:
285 mysql: [8]
286 runtime: [async-std, tokio]
287 tls: [native-tls, rustls-aws-lc-rs, rustls-ring, none]
288 needs: check
289 steps:
290 - uses: actions/checkout@v4
291
292 - uses: Swatinem/rust-cache@v2
293 with:
294 key: "${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}"
295
296 - run: cargo build --features mysql,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
297
298 - run: docker compose -f tests/docker-compose.yml run -d -p 3306:3306 --name mysql_${{ matrix.mysql }} mysql_${{ matrix.mysql }}
299 - run: sleep 60
300
301 # Create data dir for offline mode
302 - run: mkdir .sqlx
303
304 - run: >
305 cargo test
306 --no-default-features
307 --features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
308 env:
309 DATABASE_URL: mysql://root:password@localhost:3306/sqlx?ssl-mode=disabled
310 SQLX_OFFLINE_DIR: .sqlx
311 RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
312
313 # MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
314 - if: ${{ !(matrix.mysql == '5_7' && matrix.tls == 'rustls') }}
315 run: >
316 cargo test
317 --no-default-features
318 --features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
319 env:
320 DATABASE_URL: mysql://root:password@localhost:3306/sqlx
321 SQLX_OFFLINE_DIR: .sqlx
322 RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
323
324 # Remove test artifacts
325 - run: cargo clean -p sqlx
326
327 # Build the macros-test in offline mode (omit DATABASE_URL)
328 - run: >
329 cargo build
330 --no-default-features
331 --test mysql-macros
332 --features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
333 env:
334 SQLX_OFFLINE: true
335 SQLX_OFFLINE_DIR: .sqlx
336 RUSTFLAGS: -D warnings --cfg mysql_${{ matrix.mysql }}
337
338 # Test macros in offline mode (still needs DATABASE_URL to run)
339 # MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
340 - run: >
341 cargo test
342 --no-default-features
343 --test mysql-macros
344 --features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
345 env:
346 DATABASE_URL: mysql://root:password@localhost:3306/sqlx
347 SQLX_OFFLINE: true
348 SQLX_OFFLINE_DIR: .sqlx
349 RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
350
351 # client SSL authentication
352
353 - if: ${{ matrix.tls != 'none' }}
354 run: |
355 docker stop mysql_${{ matrix.mysql }}
356 docker compose -f tests/docker-compose.yml run -d -p 3306:3306 --name mysql_${{ matrix.mysql }}_client_ssl mysql_${{ matrix.mysql }}_client_ssl
357 sleep 60
358
359 - if: ${{ matrix.tls != 'none' }}
360 run: >
361 cargo test
362 --no-default-features
363 --features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
364 env:
365 DATABASE_URL: mysql://root@localhost:3306/sqlx?sslmode=verify_ca&ssl-ca=.%2Ftests%2Fcerts%2Fca.crt&ssl-key=.%2Ftests%2Fkeys%2Fclient.key&ssl-cert=.%2Ftests%2Fcerts%2Fclient.crt
366 RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
367
368 mariadb:
369 name: MariaDB
370 runs-on: ubuntu-22.04
371 strategy:
372 matrix:
373 mariadb: [verylatest, 11_4, 10_11, 10_4]
374 runtime: [async-std, tokio]
375 tls: [native-tls, rustls-aws-lc-rs, rustls-ring, none]
376 needs: check
377 steps:
378 - uses: actions/checkout@v4
379
380 - uses: Swatinem/rust-cache@v2
381 with:
382 key: "${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}"
383
384 - run: cargo build --features mysql,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
385
386 - run: docker compose -f tests/docker-compose.yml run -d -p 3306:3306 --name mariadb_${{ matrix.mariadb }} mariadb_${{ matrix.mariadb }}
387 - run: sleep 30
388
389 # Create data dir for offline mode
390 - run: mkdir .sqlx
391
392 - run: >
393 cargo test
394 --no-default-features
395 --features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
396 env:
397 DATABASE_URL: mysql://root:password@localhost:3306/sqlx
398 SQLX_OFFLINE_DIR: .sqlx
399 RUSTFLAGS: --cfg mariadb_${{ matrix.mariadb }}
400
401 # Remove test artifacts
402 - run: cargo clean -p sqlx
403
404 # Build the macros-test in offline mode (omit DATABASE_URL)
405 - run: >
406 cargo build
407 --no-default-features
408 --test mysql-macros
409 --features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
410 env:
411 SQLX_OFFLINE: true
412 SQLX_OFFLINE_DIR: .sqlx
413 RUSTFLAGS: -D warnings --cfg mariadb_${{ matrix.mariadb }}
414
415 # Test macros in offline mode (still needs DATABASE_URL to run)
416 - run: >
417 cargo test
418 --no-default-features
419 --test mysql-macros
420 --features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
421 env:
422 DATABASE_URL: mysql://root:password@localhost:3306/sqlx
423 SQLX_OFFLINE: true
424 SQLX_OFFLINE_DIR: .sqlx
425 RUSTFLAGS: --cfg mariadb_${{ matrix.mariadb }}
426
427 # client SSL authentication
428
429 - if: ${{ matrix.tls != 'none' }}
430 run: |
431 docker stop mariadb_${{ matrix.mariadb }}
432 docker compose -f tests/docker-compose.yml run -d -p 3306:3306 --name mariadb_${{ matrix.mariadb }}_client_ssl mariadb_${{ matrix.mariadb }}_client_ssl
433 sleep 60
434
435 - if: ${{ matrix.tls != 'none' }}
436 run: >
437 cargo test
438 --no-default-features
439 --features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
440 env:
441 DATABASE_URL: mysql://root@localhost:3306/sqlx?sslmode=verify_ca&ssl-ca=.%2Ftests%2Fcerts%2Fca.crt&ssl-key=.%2Ftests%2Fkeys%2Fclient.key&ssl-cert=.%2Ftests%2Fcerts%2Fclient.crt
442 RUSTFLAGS: --cfg mariadb_${{ matrix.mariadb }}