Skip to content

Commit

Permalink
Merge f8d9fb0 into 9a53f11
Browse files Browse the repository at this point in the history
  • Loading branch information
fizyk committed Mar 24, 2021
2 parents 9a53f11 + f8d9fb0 commit 37a1d58
Show file tree
Hide file tree
Showing 14 changed files with 295 additions and 68 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/automerge.yml
@@ -0,0 +1,41 @@
name: Automerge Pull Requests
on:
pull_request:
types:
- labeled
- unlabeled
- synchronize
- opened
- edited
- ready_for_review
- reopened
- unlocked
pull_request_review:
types:
- submitted
check_suite:
types:
- completed
status: {}

jobs:
automerge:
name: Automerge Dependabot
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
steps:
- name: 'Wait for status checks'
id: waitforstatuschecks
uses: "WyriHaximus/github-action-wait-for-status@v1.3"
with:
ignoreActions: Automerge Dependabot
checkInterval: 13
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Merge pull requests
uses: pascalgn/automerge-action@v0.13.1
if: steps.waitforstatuschecks.outputs.status == 'success'
env:
MERGE_METHOD: "squash"
MERGE_LABELS: ""
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,26 @@
name: Test build package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
name: Build Python 🐍 distributions 📦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install build tools
run: pip install pep517
- name: Build a wheel package
run: python -m pep517.build .
- name: Install twine to check the package
run: pip install twine
- name: Check the package
run: twine check dist/*
52 changes: 52 additions & 0 deletions .github/workflows/linters.yml
@@ -0,0 +1,52 @@
name: Run linters

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
pydocstyle:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-lint.txt
- name: Run pydocstyle
run: |
pydocstyle src/ tests/
pycodestyle:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-lint.txt
- name: Run pydocstyle
run: |
pycodestyle src/ tests/
# black:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-python@v2
# - uses: psf/black@stable
29 changes: 29 additions & 0 deletions .github/workflows/pypi.yml
@@ -0,0 +1,29 @@
name: Package and publish
on:
push:
tags:
- v*
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install build tools
run: pip install pep517
- name: Build a wheel package
run: python -m pep517.build .
# - name: Publish distribution 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.test_pypi_password }}
# repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
verbose: true
63 changes: 63 additions & 0 deletions .github/workflows/tests.yml
@@ -0,0 +1,63 @@
name: Run tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, pypy-3.7-v7.3.3]
postgres-version: [9.5, 9.6, 10, 11, 12, 13]
env:
OS: ubuntu-latest
PYTHON: ${{ matrix.python-version }}
POSTGRES: ${{ matrix.postgres-version }}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install postgresql
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg ${{ matrix.postgres-version }}" > /etc/apt/sources.list.d/pgdg.list'
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "Package: *" > /etc/apt/preferences.d/psql'
sudo sh -c 'echo "Pin: release c=${{ matrix.poxtgresql-version }}" >> /etc/apt/preferences.d/psql'
sudo sh -c 'echo "Pin-Priority: 1000" >> /etc/apt/preferences.d/psql'
sudo apt-get update -o Dir::Etc::sourcelist="/etc/apt/sources.list.d/pgdg.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
sudo apt install -y postgresql-${{ matrix.postgres-version }} postgresql-client-${{ matrix.postgres-version }}
- name: Check installed locales
run: |
locale -a
sudo locale-gen de_DE.UTF-8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-test.txt
- name: Run test
run: |
py.test -n 0 --postgresql-exec="/usr/lib/postgresql/${{ matrix.postgres-version }}/bin/pg_ctl" --cov-report=xml
- name: Run xdist test
run: |
py.test -n 1 --postgresql-exec="/usr/lib/postgresql/${{ matrix.postgres-version }}/bin/pg_ctl" --cov-report=xml:coverage-xdist.xml
- uses: actions/upload-artifact@v2
if: failure()
with:
name: postgresql-${{ matrix.python-version }}-${{ matrix.postgres-version }}
path: /tmp/pytest-of-runner/**
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
files: ./coverage.xml, ./coverage-xdist.xml
flags: unittests
env_vars: OS, PYTHON, POSTGRES
fail_ci_if_error: true
25 changes: 12 additions & 13 deletions .travis.yml
@@ -1,11 +1,10 @@
dist: bionic
language: python
python:
- 3.9
- 3.8
- 3.7
- 3.6
- 3.9
- nightly
- pypy3
# blocklist branches
branches:
Expand All @@ -32,24 +31,19 @@ install:
- pip install -r requirements-test.txt
- pip install coveralls wheel
script:
- py.test -n 0
- POSTGRES=10 py.test -n 0
- POSTGRES=11 py.test -n 0
- POSTGRES=12 py.test -n 0
- POSTGRES=13 py.test -n 0
after_success:
- coveralls
jobs:
allow_failures:
- python: nightly
include:
- stage: xdist
script: py.test -n 1
- stage: linters
install:
- pip install -r requirements-lint.txt
script:
- pycodestyle
- pydocstyle
- pylint pytest_postgresql tests
- pyroma .
after_success: skip
- POSTGRES=13 py.test -n 1
- stage: osx
language: generic
os: osx
Expand All @@ -59,7 +53,12 @@ jobs:
- virtualenv venv -p python3
- source venv/bin/activate
script:
- py.test -n 0
- POSTGRES=9.5 py.test -n 0
- POSTGRES=9.6 py.test -n 0
- POSTGRES=10 py.test -n 0
- POSTGRES=11 py.test -n 0
- POSTGRES=12 py.test -n 0
- POSTGRES=13 py.test -n 0
- stage: deploy
if: tag IS present
script: skip
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -171,7 +171,7 @@ You can pick which you prefer, but remember that these settings are handled in t
- --postgresql-exec
- postgresql_exec
- -
- /usr/lib/postgresql/9.1/bin/pg_ctl
- /usr/lib/postgresql/9.5/bin/pg_ctl
* - host
- host
- --postgresql-host
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
@@ -0,0 +1,8 @@
[build-system]
requires = ["setuptools >= 40.6.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 100
target-version = ['py38']
include = '.*\.pyi?$'
4 changes: 1 addition & 3 deletions requirements-lint.txt
@@ -1,7 +1,5 @@
# linters
pycodestyle==2.7.0
pydocstyle==6.0.0
pylint==2.7.2
pygments
pyroma==3.1
black==20.8b1
-r requirements-test.txt
1 change: 0 additions & 1 deletion setup.cfg
Expand Up @@ -8,7 +8,6 @@ match = '(?!docs|build|venv).*\.py'

[tool:pytest]
addopts = --max-worker-restart=0 --showlocals --verbose --cov src/pytest_postgresql --cov tests
postgresql_exec = /usr/lib/postgresql/10/bin/pg_ctl
testpaths = tests
xfail_strict = true
pytester_example_dir = tests/examples
Expand Down
16 changes: 6 additions & 10 deletions tests/conftest.py
Expand Up @@ -5,6 +5,7 @@
from pytest_postgresql import factories

pytest_plugins = ['pytester']
POSTGRESQL_VERSION = os.environ.get("POSTGRES", "13")


def find_pg_ctl(path: str) -> Path:
Expand Down Expand Up @@ -33,15 +34,13 @@ def create_version(ver: str) -> Path:
TEST_SQL_DIR = os.path.dirname(os.path.abspath(__file__)) + '/test_sql/'

# pylint:disable=invalid-name
postgresql95 = factories.postgresql_proc(create_version(ver='9.5'), port=None)
postgresql96 = factories.postgresql_proc(create_version(ver='9.6'), port=None)
postgresql10 = factories.postgresql_proc(create_version(ver='10'), port=None)
postgresql11 = factories.postgresql_proc(create_version(ver='11'), port=None)
postgresql12 = factories.postgresql_proc(create_version(ver='12'), port=None)
postgresql13 = factories.postgresql_proc(create_version(ver='13'), port=None)
postgresql_proc_version = factories.postgresql_proc(
create_version(ver=POSTGRESQL_VERSION),
port=None
)
postgresql_version = factories.postgresql('postgresql_proc_version')

postgresql_proc2 = factories.postgresql_proc(port=9876)
postgres10 = factories.postgresql('postgresql10')
postgresql2 = factories.postgresql('postgresql_proc2', db_name='test-db')
postgresql_load_1 = factories.postgresql('postgresql_proc2', db_name='test-db',
load=[TEST_SQL_DIR + 'test.sql', ])
Expand All @@ -51,7 +50,4 @@ def create_version(ver: str) -> Path:

postgresql_rand_proc = factories.postgresql_proc(port=None)
postgresql_rand = factories.postgresql('postgresql_rand_proc')

postgresql_max_conns_proc = factories.postgresql_proc(postgres_options='-N 11')
postgres_max_conns = factories.postgresql('postgresql_max_conns_proc')
# pylint:enable=invalid-name
10 changes: 7 additions & 3 deletions tests/test_executor.py
Expand Up @@ -7,7 +7,7 @@
import pytest

from pytest_postgresql.executor import PostgreSQLExecutor, PostgreSQLUnsupported
from pytest_postgresql.factories import postgresql_proc
from pytest_postgresql.factories import postgresql_proc, postgresql
from pytest_postgresql.factories import get_config
from pytest_postgresql.port import get_port

Expand Down Expand Up @@ -105,8 +105,12 @@ def test_proc_with_password(
port=postgres_with_password.port)


postgresql_max_conns_proc = postgresql_proc(postgres_options='-N 42')
postgres_max_conns = postgresql('postgresql_max_conns_proc')


def test_postgres_options(postgres_max_conns):
"""Check that max connections (-N 11) is honored."""
"""Check that max connections (-N 42) is honored."""
cur = postgres_max_conns.cursor()
cur.execute('SHOW max_connections')
assert cur.fetchone() == ('11',)
assert cur.fetchone() == ('42',)

0 comments on commit 37a1d58

Please sign in to comment.