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
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[run]
parallel=True
source=pgcli
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
- [ ] I've added this contribution to the `changelog.rst`.
- [ ] I've added my name to the `AUTHORS` file (or it's already there).
<!-- We would appreciate if you comply with our code style guidelines. -->
- [ ] 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)
33 changes: 13 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

services:
postgres:
image: postgres:9.6
image: postgres:10
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -31,10 +31,14 @@ jobs:
--health-retries 5

steps:
- uses: actions/checkout@v4
- 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@v4
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -68,32 +72,21 @@ jobs:
psql -h localhost -U postgres -p 6432 pgbouncer -c 'show help'

- name: Install requirements
run: |
pip install -U pip setuptools
pip install --no-cache-dir ".[sshtunnel]"
pip install -r requirements-dev.txt
pip install keyrings.alt>=3.1
run: uv sync --all-extras -p ${{ matrix.python-version }}

- name: Run unit tests
run: coverage run --source pgcli -m pytest
run: uv run tox -e py${{ matrix.python-version }}

- name: Run integration tests
env:
PGUSER: postgres
PGPASSWORD: postgres
TERM: xterm

run: behave tests/features --no-capture
run: uv run tox -e integration

- name: Check changelog for ReST compliance
run: docutils --halt=warning changelog.rst >/dev/null
run: uv run tox -e rest

- name: Run Black
run: black --check .
if: matrix.python-version == '3.8'

- name: Coverage
run: |
coverage combine
coverage report
codecov
- name: Run style checks
run: uv run tox -e style
97 changes: 97 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
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"]

services:
postgres:
image: postgres:10
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ target/
venv/

.ropeproject/
uv.lock

13 changes: 9 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- 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. TODO: uncomment when the rest of the code is ruff-formatted
# - id: ruff-format
52 changes: 24 additions & 28 deletions DEVELOP.rst → CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ repo.
$ git remote add upstream git@github.com:dbcli/pgcli.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.
pull upstream main`` to update your local copy and then do a ``git push
origin main`` to keep your own fork up to date.

Check Github's `Understanding the GitHub flow guide
<https://guides.github.com/introduction/flow/>`_ for a more detailed
Expand All @@ -38,30 +38,23 @@ pgcli. If you're developing pgcli, you'll need to install it in 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 pgcli-dev). Activate it:
Set up [uv](https://docs.astral.sh/uv/getting-started/installation/) for development:

::

cd pgcli
uv venv
source ./pgcli-dev/bin/activate

or

.\pgcli-dev\scripts\activate (for Windows)

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

::

$ pip install --editable .
$ uv pip install --editable .

or

$ pip install -e .
$ uv pip install -e .

This will install the necessary dependencies as well as install pgcli from the
working folder into the virtualenv. By installing it using `pip install -e`
Expand Down Expand Up @@ -165,9 +158,7 @@ in the ``tests`` directory. An example::
First, install the requirements for testing:

::
$ pip install -U pip setuptools
$ pip install --no-cache-dir ".[sshtunnel]"
$ pip install -r requirements-dev.txt
$ uv pip install ".[dev]"

Ensure that the database user has permissions to create and drop test databases
by checking your ``pg_hba.conf`` file. The default user should be ``postgres``
Expand All @@ -180,20 +171,14 @@ service for the changes to take effect.
# ONLY IF YOU MADE CHANGES TO YOUR pg_hba.conf FILE
$ sudo service postgresql restart

After that, tests in the ``/pgcli/tests`` directory can be run with:
(Note that these ``behave`` tests do not currently work when developing on Windows due to pexpect incompatibility.)
After that:

::

# on directory /pgcli/tests
$ cd pgcli/tests
$ behave

And on the ``/pgcli`` directory:

::

# on directory /pgcli
$ py.test
Note that these ``behave`` tests do not currently work when developing on Windows due to pexpect incompatibility.

To see stdout/stderr, use the following command:

Expand All @@ -209,10 +194,21 @@ Troubleshooting the integration tests
- Check `this issue <https://github.com/dbcli/pgcli/issues/945>`_ for relevant information.
- `File an issue <https://github.com/dbcli/pgcli/issues/new>`_.

Running the unit tests
----------------------

The unit tests can be run with pytest:

::

$ cd pgcli
$ pytest


Coding Style
------------

``pgcli`` uses `black <https://github.com/ambv/black>`_ to format the source code. Make sure to install black.
``pgcli`` uses `ruff <https://github.com/astral-sh/ruff>`_ to format the source code.

Releases
--------
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ If you're interested in contributing to this project, first of all I would like
to extend my heartfelt gratitude. I've written a small doc to describe how to
get this running in a development setup.

https://github.com/dbcli/pgcli/blob/master/DEVELOP.rst
https://github.com/dbcli/pgcli/blob/main/CONTRIBUTING.rst

Please feel free to reach out to us if you need help.
* Amjith, pgcli author: amjith.r@gmail.com, Twitter: `@amjithr <http://twitter.com/amjithr>`_
Expand Down Expand Up @@ -362,12 +362,12 @@ Thanks to all the beta testers and contributors for your time and patience. :)
.. |Build Status| image:: https://github.com/dbcli/pgcli/actions/workflows/ci.yml/badge.svg?branch=main
:target: https://github.com/dbcli/pgcli/actions/workflows/ci.yml

.. |CodeCov| image:: https://codecov.io/gh/dbcli/pgcli/branch/master/graph/badge.svg
.. |CodeCov| image:: https://codecov.io/gh/dbcli/pgcli/branch/main/graph/badge.svg
:target: https://codecov.io/gh/dbcli/pgcli
:alt: Code coverage report

.. |Landscape| image:: https://landscape.io/github/dbcli/pgcli/master/landscape.svg?style=flat
:target: https://landscape.io/github/dbcli/pgcli/master
.. |Landscape| image:: https://landscape.io/github/dbcli/pgcli/main/landscape.svg?style=flat
:target: https://landscape.io/github/dbcli/pgcli/main
:alt: Code Health

.. |PyPI| image:: https://img.shields.io/pypi/v/pgcli.svg
Expand Down
22 changes: 2 additions & 20 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
Releasing pgcli
---------------

You have been made the maintainer of `pgcli`? Congratulations! We have a release script to help you:
You have been made the maintainer of `pgcli`? Congratulations!

```sh
> python release.py --help
Usage: release.py [options]

Options:
-h, --help show this help message and exit
-c, --confirm-steps Confirm every step. If the step is not confirmed, it
will be skipped.
-d, --dry-run Print out, but not actually run any steps.
```

The script can be run with `-c` to confirm or skip steps. There's also a `--dry-run` option that only prints out the steps.

To release a new version of the package:

* Create and merge a PR to bump the version in the changelog ([example PR](https://github.com/dbcli/pgcli/pull/1325)).
* Pull `main` and bump the version number inside `pgcli/__init__.py`. Do not check in - the release script will do that.
* Make sure you have the dev requirements installed: `pip install -r requirements-dev.txt -U --upgrade-strategy only-if-needed`.
* Finally, run the release script: `python release.py`.
To release a new version of the package, [create a new release](https://github.com/dbcli/pgcli/releases) in Github. This will trigger a Github action which will run all the tests, build the wheel and upload it to PyPI.
9 changes: 9 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ Features:
* Provide `init-command` in the config file
* Support dsn specific init-command in the config file

Internal:
---------

* Moderize the repository
* Use uv instead of pip
* Use github trusted publisher for pypi release
* Update dev requirements and replace requirements-dev.txt with pyproject.toml
* Use ruff instead of black

4.3.0 (2025-03-22)
==================

Expand Down
1 change: 0 additions & 1 deletion pgcli/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import errno
import shutil
import os
import platform
Expand Down
Loading
Loading