Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update project to use GitHub workflows (#9)
* Add pre-commit * Convert project to use pyproject.toml * Fix project to comply with pre-commit hooks * Add GitHub action workflow for PR's * Add yaml pre-commit hook * Fix workflow * Update circleci build * Fix Action trigger events * Fix workflow syntax * Add pre-commit to deps * Wrap pre-commit in venv * Fix pytest version * Fix workflow actions * Add postgres db to workflow * Add multiple Python versions and OSes to workflow * Try removing lock file * Remove support for 3.6 * Fix deps caching for matrix strategy * Fix re-factor typo in unit test * Add code coverage step * Remove other OSes * Rename workflow file * Split out major steps into separate jobs * Add license file to package * Fix order of step variables * Remove push pre-commit step * Add release workflow * Add release workflow * Generate release body * Uncomment publish steps * Add pre-commit hook to validate pyproject.toml * Rename pipeline workflow file * Remove CircleCI pipeline
- Loading branch information
Showing
21 changed files
with
563 additions
and
415 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
max-complexity = 10 | ||
exclude = | ||
psycopg2_pgevents/__init__.py, | ||
tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
name: Build, Lint, Test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
|
||
jobs: | ||
lint: | ||
name: ️⚒️ & 👕 | ||
|
||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8] | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install poetry | ||
uses: dschep/install-poetry-action@v1.3 | ||
with: | ||
create_virtualenvs: true | ||
|
||
- name: Cache Poetry virtualenv | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: ~/.virtualenvs | ||
key: poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | ||
restore-keys: | | ||
poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | ||
- name: Set Poetry config | ||
run: | | ||
poetry config virtualenvs.in-project false | ||
poetry config virtualenvs.path ~/.virtualenvs | ||
- name: Install Dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: poetry install | ||
|
||
- name: Run pre-commit | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
git fetch origin master:master | ||
poetry run pre-commit run --from-ref master --to-ref HEAD | ||
test: | ||
name: 🧪 | ||
needs: lint | ||
|
||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8] | ||
|
||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres:10-alpine | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: test | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install poetry | ||
uses: dschep/install-poetry-action@v1.3 | ||
with: | ||
create_virtualenvs: true | ||
|
||
- name: Cache Poetry virtualenv | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: ~/.virtualenvs | ||
key: poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | ||
restore-keys: | | ||
poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | ||
- name: Set Poetry config | ||
run: | | ||
poetry config virtualenvs.in-project false | ||
poetry config virtualenvs.path ~/.virtualenvs | ||
- name: Install Dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: poetry install | ||
|
||
- name: Unit Test | ||
env: | ||
TEST_DATABASE_BASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }} | ||
run: poetry run python -m pytest --cov=psycopg2_pgevents --cov-branch tests/ | ||
|
||
- name: Submit Code Coverage | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COVERALLS_FLAG_NAME: py-${{ matrix.python-version }} | ||
COVERALLS_PARALLEL: true | ||
run: poetry run coveralls | ||
|
||
test-finish: | ||
name: 🚪 | ||
needs: test | ||
|
||
runs-on: ubuntu-latest | ||
container: python:3-slim | ||
|
||
steps: | ||
- name: Finished | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
pip3 install coveralls | ||
coveralls --finish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Package, Ship | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
package: | ||
name: 📦 & 🚢 | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: '0' | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Get next package version | ||
id: bumpversion | ||
uses: anothrNick/github-tag-action@1.23.0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
WITH_V: false | ||
DRY_RUN: true | ||
|
||
- name: Install poetry | ||
uses: dschep/install-poetry-action@v1.3 | ||
with: | ||
create_virtualenvs: true | ||
|
||
- name: Bump release version | ||
run: poetry version ${{ steps.bumpversion.outputs.new_tag }} | ||
|
||
- name: Build package | ||
run: poetry build | ||
|
||
- name: Publish package (Test PyPI) | ||
run: | | ||
poetry config repositories.testpypi https://test.pypi.org/legacy/ | ||
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_PASSWORD }} | ||
poetry publish -r testpypi | ||
- name: Publish package (PyPI) | ||
run: | | ||
poetry config pypi-token.pypi ${{ secrets.PYPI_PASSWORD }} | ||
poetry publish | ||
- name: Generate release message | ||
id: release_message | ||
run: | | ||
# Get (squashed) commit summaries since last tag, convert to list, | ||
# escape multi-lines into a format GitHub Actions respect, and set as output | ||
export NOTES=`git log --pretty=format:'%s' $(git describe --tags --abbrev=0 HEAD^)..HEAD | tr '\n' '\0' | xargs -0 -I{} echo '- {}'` | ||
export NOTES_ENCODED_NEWLINES="${NOTES//$'\n'/'%0A'}" | ||
echo "::set-output name=message::$NOTES_ENCODED_NEWLINES" | ||
- name: Create release | ||
uses: actions/create-release@v1.1.2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.bumpversion.outputs.new_tag }} | ||
release_name: ${{ steps.bumpversion.outputs.new_tag }} | ||
body: ${{ steps.release_message.outputs.message}} | ||
draft: false | ||
prerelease: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[settings] | ||
known_third_party = psycopg2,pytest,testfixtures | ||
multi_line_output=3 | ||
include_trailing_comma=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
repos: | ||
- repo: https://gitlab.com/smop/pre-commit-hooks | ||
rev: v1.0.0 | ||
hooks: | ||
- id: check-poetry | ||
- repo: https://github.com/asottile/seed-isort-config | ||
rev: v2.2.0 | ||
hooks: | ||
- id: seed-isort-config | ||
- repo: https://github.com/psf/black | ||
rev: 19.10b0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/pre-commit/mirrors-isort | ||
rev: v5.0.9 | ||
hooks: | ||
- id: isort | ||
- repo: https://github.com/pre-commit/pre-commit | ||
rev: v2.6.0 | ||
hooks: | ||
- id: validate_manifest | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.1.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: check-toml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.8.3 | ||
hooks: | ||
- id: flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
"""This package provides the ability to listen for PostGreSQL table events at the database level.""" | ||
from psycopg2_pgevents.__about__ import __author__, __copyright__, __email__, __license__, __summary__, \ | ||
__title__, __uri__, __version__ | ||
|
||
|
||
from psycopg2_pgevents.debug import log, set_debug | ||
from psycopg2_pgevents.event import poll, register_event_channel, unregister_event_channel | ||
from psycopg2_pgevents.event import ( | ||
poll, | ||
register_event_channel, | ||
unregister_event_channel, | ||
) | ||
from psycopg2_pgevents.sql import execute | ||
from psycopg2_pgevents.trigger import install_trigger, install_trigger_function, trigger_function_installed, \ | ||
trigger_installed, uninstall_trigger, uninstall_trigger_function | ||
from psycopg2_pgevents.trigger import ( | ||
install_trigger, | ||
install_trigger_function, | ||
trigger_function_installed, | ||
trigger_installed, | ||
uninstall_trigger, | ||
uninstall_trigger_function, | ||
) |
Oops, something went wrong.