Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
## Checklist
<!--- We appreciate your help and want to give you credit. Please take a moment to put an `x` in the boxes below as you complete them. -->
- [ ] I've added this contribution to the `changelog.rst`.
- [ ] I installed pre-commit hooks (`pip install pre-commit && pre-commit install`), and ran `black` on my code.
- [ ] I installed pre-commit hooks (`pip install pre-commit && pre-commit install`).
- [x] Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)
42 changes: 13 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,8 @@ jobs:

strategy:
matrix:
include:
- python-version: '3.7'
postgres-version: '10'
- python-version: '3.8'
postgres-version: '11'
- python-version: '3.9'
postgres-version: '12'
- python-version: '3.10'
postgres-version: '13'
- python-version: '3.11'
postgres-version: '14'
- python-version: '3.11'
postgres-version: '15'
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
postgres-version: ["10", "11", "12", "13", "14", "15"]

services:
postgres:
Expand All @@ -40,29 +29,24 @@ jobs:
--health-retries 5

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@c7f87aa956e4c323abf06d5dec078e358f6b4d04 # v6.0.0
with:
version: "latest"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}

- name: Install requirements
run: |
pip install -U pip setuptools
pip install --no-cache-dir .
pip install -r requirements-dev.txt
- name: Install dependencies
run: uv sync --all-extras -p ${{ matrix.python-version }}

- name: Run unit tests
env:
LANG: en_US.UTF-8
run: coverage run --source pgspecial -m pytest

- name: Run Black
run: black --check .
if: matrix.python-version == '3.7'
run: uv run tox -e py${{ matrix.python-version }}

- name: Coverage
run: |
coverage report
codecov
- name: Run Style Checks
run: uv run tox -e style
98 changes: 98 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Publish Python Package

on:
release:
types: [created]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
postgres-version: ["10", "11", "12", "13", "14", "15"]

services:
postgres:
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@c7f87aa956e4c323abf06d5dec078e358f6b4d04 # v6.0.0
with:
version: "latest"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --all-extras -p ${{ matrix.python-version }}

- name: Run unit tests
env:
LANG: en_US.UTF-8
run: uv run tox -e py${{ matrix.python-version }}

- name: Run Style Checks
run: uv run tox -e style

build:
runs-on: ubuntu-latest
needs: [test]

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@c7f87aa956e4c323abf06d5dec078e358f6b4d04 # v6.0.0
with:
version: "latest"

- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.13'

- name: Install dependencies
run: uv sync --all-extras -p 3.13

- name: Build
run: uv build

- name: Store the distribution packages
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: python-packages
path: dist/

publish:
name: Publish to PyPI
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
environment: release
permissions:
id-token: write
steps:
- name: Download distribution packages
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: python-packages
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
15 changes: 9 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
repos:
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
language_version: python3.11

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.11.7
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
41 changes: 14 additions & 27 deletions DEVELOP.rst → CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ Make the changes and create the commits in your local machine. Then push those
changes to your fork. Then click on the pull request icon on github and create
a new pull request. Add a description about the change and send it along. I
promise to review the pull request in a reasonable window of time and get back
to you.
to you.

In order to keep your fork up to date with any changes from mainline, add a new
git remote to your local copy called 'upstream' and point it to the main
``pgspecial`` repo.

::
::

$ git remote add upstream git@github.com:dbcli/pgspecial.git

Once the 'upstream' end point is added you can then periodically do a ``git
pull upstream master`` to update your local copy and then do a ``git push
origin master`` to keep your own fork up to date.
origin master`` to keep your own fork up to date.

Local Setup
-----------
Expand All @@ -34,28 +34,24 @@ The installation instructions in the README file are intended for users of
a slightly different way so you can see the effects of your changes right away
without having to go through the install cycle every time you change the code.

It is highly recommended to use virtualenv for development. If you don't know
what a virtualenv is, this `guide
<http://docs.python-guide.org/en/latest/dev/virtualenvs/#virtual-environments>`_
will help you get started.

Create a virtualenv (let's call it ``pgspecial-dev``). Activate it:
Set up [uv](https://docs.astral.sh/uv/getting-started/installation/) for development:

::

virtualenv ./pgspecial-dev
cd pgspecial
uv venv
source ./pgspecial-dev/bin/activate

Once the virtualenv is activated, `cd` into the local clone of pgspecial folder
and install pgspecial using pip as follows:

::

$ pip install --editable .
$ uv pip install --editable .[dev]

or

$ pip install -e .
$ pip install -e .[dev]

This will install the necessary dependencies as well as install pgspecial from
the working folder into the virtualenv. By installing it using `pip install -e`
Expand Down Expand Up @@ -111,41 +107,32 @@ First, install the requirements for testing:

::

$ pip install -r requirements-dev.txt
uv pip install -e .[dev]

After that, tests can be run with:

::

$ py.test
pytest

Pytest configuration can be found in the ``tool.pytest.ini_options`` table of the ``pyproject.toml`` file.

Enforcing the code style (linting)
------------------------------
----------------------------------

When you submit a PR, the changeset is checked for pep8 compliance using
`black <https://github.com/psf/black>`_. If you see a build failing because
of these checks, install ``black`` and apply style fixes:
`ruff <https://docs.astral.sh/ruff/>`_. You can run the linter and formatter locally:

::

$ pip install black
$ black .
$ tox -e style

Then commit and push the fixes.

To enforce ``black`` applied on every commit, we also suggest installing ``pre-commit`` and
To enforce ``ruff`` applied on every commit, we also suggest installing ``pre-commit`` and
using the ``pre-commit`` hooks available in this repo:

::

$ pip install pre-commit
$ pre-commit install

Git blame
---------

Use ``git blame my_file.py --ignore-revs-file .git-blame-ignore-revs`` to exclude irrelevant commits
(specifically Black) from ``git blame``. For more information,
see `here <https://github.com/psf/black#migrating-your-code-style-without-ruining-git-blame>`_.
8 changes: 8 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@

Unreleased (TBD)
==================

* Moderize the repository
* Use uv instead of pip
* Use github trusted publisher for pypi release

2.1.3 (2024-11-25)
==================

Expand Down
6 changes: 4 additions & 2 deletions pgspecial/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import importlib.metadata

__version__ = importlib.metadata.version("pgspecial")
__all__ = []
__version__ = "2.1.3"


def export(defn):
Expand All @@ -9,4 +11,4 @@ def export(defn):
return defn


from . import dbcommands, iocommands
from . import dbcommands, iocommands # noqa
Loading