|
1 | 1 | name: "Continuous Integration" |
2 | 2 |
|
3 | | - |
4 | 3 | on: |
5 | 4 | push: |
6 | 5 | branches: [master] |
|
10 | 9 |
|
11 | 10 | jobs: |
12 | 11 | tests: |
13 | | - name: python ${{ matrix.python-version }} tests, ${{ matrix.uv-resolution }} dependencies |
| 12 | + name: python ${{ matrix.python-version }}, ${{ matrix.database }}, ${{ matrix.uv-resolution }} deps |
14 | 13 | runs-on: ubuntu-latest |
15 | 14 | strategy: |
16 | 15 | fail-fast: false |
|
21 | 20 | - "3.11" |
22 | 21 | - "3.12" |
23 | 22 | - "3.13" |
| 23 | + database: |
| 24 | + - sqlite |
24 | 25 | 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 | +
|
27 | 80 | steps: |
28 | 81 | - uses: actions/checkout@v4 |
29 | 82 |
|
|
34 | 87 | cache-dependency-glob: "**/pyproject.toml" |
35 | 88 | cache-suffix: ${{ matrix.uv-resolution }} |
36 | 89 |
|
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" |
39 | 99 |
|
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 :-/ |
41 | 103 | 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