Skip to content
Draft
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
50 changes: 42 additions & 8 deletions .github/workflows/tests.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: Run Tests
name: CI

on:
pull_request:
push:
branches:
- master
branches: [ master ]
paths-ignore:
- "README.md"
tags:
- "v*.*"
pull_request:
branches: [ master ]

jobs:
lint:
Expand Down Expand Up @@ -33,8 +37,6 @@ jobs:
POSTGRES_DB: postgres
ports:
- 5432:5432
# The official postgres image does not expose a default Docker HEALTHCHECK,
# so we define one explicitly for the GitHub Actions service container.
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
Expand Down Expand Up @@ -63,5 +65,37 @@ jobs:
make install-test

- name: Run tests
run: |
make test
run: make test

release:
needs: tests
runs-on: ubuntu-24.04

environment:
name: pypi
url: https://pypi.org/p/postgresql-proxy

permissions:
id-token: write

if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Build release
run: make dist

- name: List artifacts
run: ls -lah dist/

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ venv.bak/

# private config information
config.yml

# Hatch VCS hook generates this file during build
postgresql_proxy/version.py
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@ install: ## Install dependencies in local virtualenv folder
(test `which virtualenv` || $(PIP_CMD) install virtualenv) && \
(test -e $(VENV_DIR) || virtualenv $(VENV_OPTS) $(VENV_DIR)) && \
($(VENV_RUN) && $(PIP_CMD) install --upgrade pip) && \
(test ! -e requirements.txt || ($(VENV_RUN); $(PIP_CMD) install -r requirements.txt))
(test ! -e requirements.txt || ($(VENV_RUN); $(PIP_CMD) install -r requirements.txt)) && \
($(VENV_RUN); $(PIP_CMD) install -e .)

publish: ## Publish the library to the central PyPi repository
($(VENV_RUN); pip install twine; python ./setup.py sdist && twine upload dist/*)
dist: clean ## Build distribution packages
python -m pip install -U build hatchling hatch-vcs
python -m build

clean: ## Remove build artifacts
rm -rf dist build *.egg-info postgresql_proxy/version.py

publish: dist ## Publish the library to the central PyPi repository
($(VENV_RUN); pip install twine; twine upload dist/*)

install-test: install ## Install test dependencies in local virtualenv
($(VENV_RUN); $(PIP_CMD) install -r $(TEST_REQS))
Expand Down Expand Up @@ -85,12 +93,12 @@ start-pg-and-test: ## Start local PostgreSQL container, run all tests, and clean
exit $$status

ACT_CMD ?= act
ACT_WORKFLOW ?= .github/workflows/tests.yml
ACT_WORKFLOW ?= .github/workflows/build.yml
ACT_JOB ?= tests
ACT_PULL ?= false
ACT_CONTAINER_ARCH ?= linux/arm64

test-act: ## Run the CI test workflow locally with act
$(ACT_CMD) -W $(ACT_WORKFLOW) -j $(ACT_JOB) --pull=$(ACT_PULL) --container-architecture $(ACT_CONTAINER_ARCH)

.PHONY: usage install install-test install-lint clean publish lint start-postgres stop-postgres test test-act start-pg-and-test
.PHONY: usage install install-test install-lint dist clean publish lint start-postgres stop-postgres test test-act start-pg-and-test
1 change: 1 addition & 0 deletions postgresql_proxy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from postgresql_proxy.version import __version__ # noqa
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "postgresql-proxy"
dynamic = ["version"]
description = "Postgresql Proxy"
readme = "README.md"
requires-python = ">=3.10"
license = { text = "Apache-2.0" }
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.13",
"License :: OSI Approved :: Apache Software License",
"Topic :: Software Development :: Testing",
]

[tool.ruff]
exclude = ["postgresql_proxy/version.py"]

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "postgresql_proxy/version.py"
20 changes: 0 additions & 20 deletions setup.py

This file was deleted.

Loading