From 391e2636cf09c82fec89135aafd4e510be2e525f Mon Sep 17 00:00:00 2001 From: Ivan Larin Date: Thu, 15 Jan 2026 19:43:40 +0300 Subject: [PATCH] ci: matrix for version of postgresql --- .github/workflows/ci.yml | 6 +++++- Makefile | 3 ++- tests/conftest.py | 2 ++ tests/v2/conftest.py | 5 +++-- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 tests/conftest.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3246d9..7a76910 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,12 +21,16 @@ jobs: - '3.12' - '3.13' - '3.14' + postgres-version: + - 16 + - 17 + - 18 steps: - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 - run: uv python install ${{ matrix.python-version }} - run: make lint - - run: make test + - run: make test postgres_version=${{ matrix.postgres-version }} automerge: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 93e3878..4dea0e1 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,9 @@ sync: uv sync --frozen --all-groups .PHONY: test +postgres_version:=latest test: - $(pytest) + $(pytest) --postgres-version $(postgres_version) .PHONY: lint lint: diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..e724d77 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,2 @@ +def pytest_addoption(parser) -> None: # type: ignore[no-untyped-def] + parser.addoption('--postgres-version', action='store', default='latest') diff --git a/tests/v2/conftest.py b/tests/v2/conftest.py index 9c28de9..b638fde 100644 --- a/tests/v2/conftest.py +++ b/tests/v2/conftest.py @@ -26,8 +26,9 @@ @pytest.fixture(scope='session') -def postgres_db() -> Iterator[PostgresContainer]: - with PostgresContainer() as db: +def postgres_db(request) -> Iterator[PostgresContainer]: # type: ignore[no-untyped-def] + postgres_version = request.config.getoption('--postgres-version') + with PostgresContainer(f'postgres:{postgres_version}') as db: yield db