Skip to content

Commit

Permalink
test: Start testing with all supported Postgres versions (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Oct 29, 2024
1 parent 528bc3b commit 684e635
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 27 deletions.
40 changes: 31 additions & 9 deletions .github/workflows/ci_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ on:
workflow_dispatch:
inputs: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 1

jobs:
tests:
name: Python ${{ matrix.python-version }} / Postgres ${{ matrix.postgres-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -32,6 +40,19 @@ jobs:
- "3.11"
- "3.10"
- "3.9"
postgres-version:
- "17"
include:
- python-version: "3.13"
postgres-version: "12"
- python-version: "3.13"
postgres-version: "13"
- python-version: "3.13"
postgres-version: "14"
- python-version: "3.13"
postgres-version: "15"
- python-version: "3.13"
postgres-version: "16"
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -43,8 +64,11 @@ jobs:
chmod 600 ssl/pkey.key
chmod 644 ssl/public_pkey.key
- name: Set up Postgres container
env:
POSTGRES_VERSION: ${{ matrix.postgres-version }}
run: |
docker compose -f docker-compose.yml up -d
- run: docker ps
- name: Set up Python '${{ matrix.python-version }}'
uses: actions/setup-python@v5
with:
Expand All @@ -54,20 +78,16 @@ jobs:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
python -m pip install --upgrade pip
pipx install poetry
pipx inject poetry poetry-dynamic-versioning
- name: Install dependencies
run: |
poetry env use python${{ matrix.python-version }}
poetry install
pipx install tox
- name: Run pytest
run: |
poetry run pytest --capture=no
tox -e $(echo py${{ matrix.python-version }} | tr -d .)
- name: Run lint
run: |
poetry run tox -e lint
tox -e lint
integration:
name: Meltano integration test
runs-on: ubuntu-latest
services:
postgres:
Expand All @@ -88,9 +108,11 @@ jobs:
with:
python-version: 3.x
- name: Install dependencies
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
python -m pip install --upgrade pip
pipx install meltano
meltano install
meltano --version
- name: smoke-test-tap
run: meltano run tap-smoke-test target-postgres
3 changes: 2 additions & 1 deletion .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
poetry==1.8.4
meltano==3.6.0b2
tox==4.23.2
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Built with the [Meltano SDK](https://sdk.meltano.com) for Singer Taps and Target
* `target-schema`
* `hard-delete`

## Supported Python and PostgreSQL Versions

This target is tested with all actively supported Python and PostgreSQL versions. At the time of writing, this includes Python 3.9 through 3.13 and PostgreSQL 12 through 17.

## Settings

| Setting | Required | Default | Description |
Expand Down
7 changes: 3 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
# docker compose -f docker-compose.yml up -d
version: "2.1"
services:
postgres:
image: docker.io/postgres:latest
image: postgres:${POSTGRES_VERSION:-latest}
command: postgres -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key -c ssl_ca_file=/var/lib/postgresql/ca.crt -c hba_file=/var/lib/postgresql/pg_hba.conf
environment:
POSTGRES_USER: postgres
Expand All @@ -20,7 +19,7 @@ services:
ports:
- "5432:5432"
postgres_no_ssl: # Borrowed from https://github.com/MeltanoLabs/tap-postgres/blob/main/.github/workflows/test.yml#L13-L23
image: docker.io/postgres:latest
image: postgres:${POSTGRES_VERSION:-latest}
environment:
POSTGRES_PASSWORD: postgres
ports:
Expand All @@ -43,7 +42,7 @@ services:
networks:
- inner
postgresdb:
image: postgres:13.0
image: postgres:${POSTGRES_VERSION:-latest}
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand Down
32 changes: 19 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,37 @@
[tox]
envlist = py312
isolated_build = true
min_version = 4

[testenv]
allowlist_externals = poetry

[testenv:pytest]
# Run the python tests.
# To execute, run `tox -e pytest`
# To execute, run `tox -e py313`
envlist = py3{9,10,11,12,13}
deps =
pytest
commands =
poetry install -v
poetry run pytest
pytest

[testenv:format]
# Attempt to auto-resolve lint errors before they are raised.
# To execute, run `tox -e format`
deps =
ruff
commands =
poetry install -v
poetry run ruff check target_postgres/
poetry run ruff format target_postgres/
ruff check target_postgres/
ruff format target_postgres/

[testenv:lint]
# Raise an error if lint and style standards are not met.
# To execute, run `tox -e lint`
deps =
mypy
ruff
types-paramiko
types-simplejson
types-sqlalchemy
types-jsonschema
commands =
poetry install -v
poetry run ruff check --diff target_postgres/
poetry run ruff format --check target_postgres/
poetry run mypy .
ruff check --diff target_postgres/
ruff format --check target_postgres/
mypy .

0 comments on commit 684e635

Please sign in to comment.