Skip to content

Commit

Permalink
Merge pull request #63 from schireson/dc/version-compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCardin authored Nov 1, 2022
2 parents 3d2683f + 4ed809b commit 7db8f21
Show file tree
Hide file tree
Showing 20 changed files with 859 additions and 1,004 deletions.
160 changes: 0 additions & 160 deletions .circleci/config.yml

This file was deleted.

85 changes: 85 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: CI
on: push

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

jobs:
test:
services:
postgres:
image: postgres:11.12
env:
POSTGRES_DB: dev
POSTGRES_USER: user
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
pytest-version: ["6.2", "7.0"]
pytest-asyncio-version: ["0.16", "0.19"]
sqlalchemy-version: ["1.3", "1.4"]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: abatilo/[email protected]
with:
poetry-version: "1.2"

- name: Set up cache
uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytest-version }}-${{ matrix.pytest-asyncio-version }}-${{ matrix.sqlalchemy-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: poetry run make install

- name: Install specific versions
run: |
poetry run pip install 'sqlalchemy~=${{ matrix.sqlalchemy-version }}'
poetry run pip install 'pytest~=${{ matrix.pytest-version }}'
poetry run pip install 'pytest-asyncio~=${{ matrix.pytest-asyncio-version }}'
- name: Run linters
run: poetry run make lint

- name: Run tests
run: poetry run make test

- name: Store test result artifacts
uses: actions/upload-artifact@v3
with:
path: coverage.xml

- name: Coveralls
env:
COVERALLS_FLAG_NAME: run-${{ inputs.working-directory }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
run: |
pip install tomli coveralls
coveralls --service=github
finish:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install tomli coveralls
coveralls --service=github --finish
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build:

test:
COVERAGE_PROCESS_START="$(PWD)/pyproject.toml" \
coverage run -m py.test src tests -vv
coverage run -m pytest src tests -vv
coverage combine
coverage report -i
coverage xml
Expand Down
4 changes: 4 additions & 0 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ If you are not already familiar with Poetry_, this is a poetry project, so you'l

Getting Setup
-------------
Note, while the project itself provisionally runs on python 3.6, test dependencies
including pytest-mock-resources, coverage, and black, have minimum python versions of 3.7.
So local development of pytest-alembic itself requires. Additionally this means
we dont test 3.6 support, so supporting it is best effort until it becomes inconvenient.

See the :code:`Makefile` for common commands, but for some basic setup:

Expand Down
9 changes: 6 additions & 3 deletions docs/source/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ behavior.
directory like :code:`pytest folder/tests`, or the tests are otherwise located at a different
location, relative to the :code:`pytest` invocation.

.. note::

As of pytest-alembic version 0.8.5, this option is ignored. Tests will be registered
at the top level, and `--test-alembic` will automatically include the tests regardless
of the provided path.


Alembic Config
~~~~~~~~~~~~~~
Expand Down Expand Up @@ -61,9 +67,6 @@ Simply import the tests at whatever location you want tests to be included:
from pytest_alembic.tests import test_up_down_consistency
It should be noted, that this obviates the need specify the :code:`pytest_alembic_tests_folder`
config option, as they will be run from the location of your import by pytest automatically.

Furthermore, doing this as well as using :code:`--test-alembic` will cause the tests to be
run twice (since they'd be considered unique tests with different paths). So generally, these
methods should be considered mutually exclusive.
Expand Down
9 changes: 8 additions & 1 deletion examples/test_async_sqlalchemy/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import pytest
import pytest_asyncio
from pytest_mock_resources import create_postgres_fixture
from sqlalchemy.engine.url import URL
from sqlalchemy.ext.asyncio import create_async_engine

pg = create_postgres_fixture()


@pytest.fixture
try:
fixture = pytest_asyncio.fixture
except AttributeError:
fixture = pytest.fixture


@fixture
def alembic_engine(pg):
creds = pg.pmr_credentials
url = URL.create(
Expand Down
1 change: 1 addition & 0 deletions examples/test_async_sqlalchemy/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[tool:pytest]
pytest_alembic_tests_folder = tests
asyncio_mode = auto

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7db8f21

Please sign in to comment.