Skip to content

Commit ee68e69

Browse files
authored
Merge pull request #13 from toirl/broader-testing
Test against mysql and postgres in addition to sqlite
2 parents 440a5f8 + 7b9811a commit ee68e69

File tree

1 file changed

+70
-8
lines changed

1 file changed

+70
-8
lines changed

.github/workflows/ci.yml

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: "Continuous Integration"
22

3-
43
on:
54
push:
65
branches: [master]
@@ -10,7 +9,7 @@ on:
109

1110
jobs:
1211
tests:
13-
name: python ${{ matrix.python-version }} tests, ${{ matrix.uv-resolution }} dependencies
12+
name: python ${{ matrix.python-version }}, ${{ matrix.database }}, ${{ matrix.uv-resolution }} deps
1413
runs-on: ubuntu-latest
1514
strategy:
1615
fail-fast: false
@@ -21,9 +20,63 @@ jobs:
2120
- "3.11"
2221
- "3.12"
2322
- "3.13"
23+
database:
24+
- sqlite
2425
uv-resolution:
25-
- "lowest-direct"
26-
- "highest"
26+
- highest
27+
include:
28+
# Add lowest-direct resolution test for oldest and newest Python
29+
- python-version: "3.9"
30+
database: sqlite
31+
uv-resolution: lowest-direct
32+
- python-version: "3.13"
33+
database: sqlite
34+
uv-resolution: lowest-direct
35+
36+
# Also test against Postgres and MySQL for oldest and newest Python
37+
- python-version: "3.9"
38+
database: postgres
39+
uv-resolution: highest
40+
- python-version: "3.13"
41+
database: postgres
42+
uv-resolution: highest
43+
- python-version: "3.9"
44+
database: mysql
45+
uv-resolution: highest
46+
- python-version: "3.13"
47+
database: mysql
48+
uv-resolution: highest
49+
50+
services:
51+
postgres:
52+
# workaround for https://github.com/actions/runner/issues/822
53+
image: ${{ matrix.database == 'postgres' && 'postgres:latest' || '' }}
54+
env:
55+
POSTGRES_PASSWORD: postgres
56+
POSTGRES_USER: postgres
57+
POSTGRES_DB: test_db
58+
ports:
59+
- 5432:5432
60+
options: >-
61+
--health-cmd pg_isready
62+
--health-interval 10s
63+
--health-timeout 5s
64+
--health-retries 5
65+
66+
mysql:
67+
# workaround for https://github.com/actions/runner/issues/822
68+
image: ${{ matrix.database == 'mysql' && 'mysql:latest' || '' }}
69+
env:
70+
MYSQL_ROOT_PASSWORD: mysql
71+
MYSQL_DATABASE: test_db
72+
ports:
73+
- 3306:3306
74+
options: >-
75+
--health-cmd "mysqladmin ping -h localhost"
76+
--health-interval 10s
77+
--health-timeout 5s
78+
--health-retries 5
79+
2780
steps:
2881
- uses: actions/checkout@v4
2982

@@ -34,9 +87,18 @@ jobs:
3487
cache-dependency-glob: "**/pyproject.toml"
3588
cache-suffix: ${{ matrix.uv-resolution }}
3689

37-
- name: Install the project
38-
run: uv sync --all-extras --dev --resolution ${{ matrix.uv-resolution }}
90+
- name: Run tests with SQLite
91+
if: matrix.database == 'sqlite'
92+
run: |
93+
uv run --all-extras --dev --resolution ${{ matrix.uv-resolution }} -m pytest --sqlalchemy-connect-url="sqlite:///foo.sqlite"
94+
95+
- name: Run tests with PostgreSQL
96+
if: matrix.database == 'postgres'
97+
run: |
98+
uv run --all-extras --dev --with psycopg2 --resolution ${{ matrix.uv-resolution }} -m pytest --sqlalchemy-connect-url="postgresql://postgres:postgres@localhost:5432/test_db"
3999
40-
- name: Run tests
100+
- name: Run tests with MySQL
101+
if: matrix.database == 'mysql'
102+
# 127.0.0.1 is to persuade mysqlclient to use tcp rather than the domain socket :-/
41103
run: |
42-
uv run pytest --sqlalchemy-connect-url="sqlite:///foo.sqlite"
104+
uv run --all-extras --dev --with mysqlclient --resolution ${{ matrix.uv-resolution }} -m pytest --sqlalchemy-connect-url="mysql://root:mysql@127.0.0.1:3306/test_db"

0 commit comments

Comments
 (0)