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: 1 addition & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-P ubuntu-24.04=catthehacker/ubuntu:act-latest
53 changes: 53 additions & 0 deletions .github/workflows/tests.yml
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also add a linting step?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but let's add it as a next step. wdyt ?

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run Tests

on:
pull_request:
push:
branches:
- master

jobs:
tests:
runs-on: ubuntu-24.04

services:
postgres:
image: postgres:18
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
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
--health-timeout 5s
--health-retries 5
Comment on lines +24 to +28
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Are the health checks of the postgres image not enough?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Official postgres images (e.g., 17/18) do not define a Docker HEALTHCHECK by default. Define one explicitly so the GitHub Actions service waits for readiness.


env:
E2E_PG_HOST: 127.0.0.1
E2E_PG_PORT: 5432
E2E_PG_USER: postgres
E2E_PG_PASSWORD: postgres
E2E_PG_DB: postgres

steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
make install-test

- name: Run tests
run: |
make test
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TEST_REQS ?= requirements-test.txt
LINT_REQS ?= requirements-lint.txt

PG_TEST_CONTAINER ?= pg-proxy-local-tests
PG_TEST_IMAGE ?= postgres:16
PG_TEST_IMAGE ?= postgres:18
PG_TEST_PORT ?= 55432
PG_TEST_USER ?= postgres
PG_TEST_PASSWORD ?= postgres
Expand All @@ -17,7 +17,7 @@ usage: ## Show this help
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

install: ## Install dependencies in local virtualenv folder
(test `which virtualenv` || $(PIP_CMD) install --user virtualenv) && \
(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))
Expand Down Expand Up @@ -78,4 +78,13 @@ start-pg-and-test: ## Start local PostgreSQL container, run all tests, and clean
$(MAKE) stop-postgres; \
exit $$status

.PHONY: usage install install-test install-lint clean publish lint start-postgres stop-postgres test start-pg-and-test
ACT_CMD ?= act
ACT_WORKFLOW ?= .github/workflows/tests.yml
ACT_JOB ?= tests
ACT_PULL ?= false
ACT_CONTAINER_ARCH ?= linux/arm64

test-act: ## Run the CI test workflow locally with act
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

$(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
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,27 @@ python -m pytest tests/test_plugins.py -vv
```

If PostgreSQL is not reachable, tests fail fast at startup.

#### 3) Run CI locally with `act`

Run the GitHub Actions test workflow locally with [`act`](https://github.com/nektos/act):

On macOS, install `act` with Homebrew:

```bash
brew install act
```

```bash
make test-act
```

Useful overrides for local runs:

```bash
# Refresh images explicitly when needed
make test-act ACT_PULL=true

# Match GitHub runner architecture on Apple Silicon (slower)
make test-act ACT_CONTAINER_ARCH=linux/amd64
```