Skip to content

Commit eb000fc

Browse files
feat(ci): add GitHub Actions workflow and act support (#14)
* feat(ci): add GitHub Actions workflow and act support for local CI runs --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d3bdfb9 commit eb000fc

4 files changed

Lines changed: 90 additions & 3 deletions

File tree

.actrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-P ubuntu-24.04=catthehacker/ubuntu:act-latest

.github/workflows/tests.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Run Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-24.04
12+
13+
services:
14+
postgres:
15+
image: postgres:18
16+
env:
17+
POSTGRES_USER: postgres
18+
POSTGRES_PASSWORD: postgres
19+
POSTGRES_DB: postgres
20+
ports:
21+
- 5432:5432
22+
# The official postgres image does not expose a default Docker HEALTHCHECK,
23+
# so we define one explicitly for the GitHub Actions service container.
24+
options: >-
25+
--health-cmd "pg_isready -U postgres"
26+
--health-interval 10s
27+
--health-timeout 5s
28+
--health-retries 5
29+
30+
env:
31+
E2E_PG_HOST: 127.0.0.1
32+
E2E_PG_PORT: 5432
33+
E2E_PG_USER: postgres
34+
E2E_PG_PASSWORD: postgres
35+
E2E_PG_DB: postgres
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Set up Python
41+
uses: actions/setup-python@v5
42+
with:
43+
python-version: "3.13"
44+
45+
- name: Install dependencies
46+
run: |
47+
sudo apt-get update
48+
sudo apt-get install -y postgresql-client
49+
make install-test
50+
51+
- name: Run tests
52+
run: |
53+
make test

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TEST_REQS ?= requirements-test.txt
77
LINT_REQS ?= requirements-lint.txt
88

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

1919
install: ## Install dependencies in local virtualenv folder
20-
(test `which virtualenv` || $(PIP_CMD) install --user virtualenv) && \
20+
(test `which virtualenv` || $(PIP_CMD) install virtualenv) && \
2121
(test -e $(VENV_DIR) || virtualenv $(VENV_OPTS) $(VENV_DIR)) && \
2222
($(VENV_RUN) && $(PIP_CMD) install --upgrade pip) && \
2323
(test ! -e requirements.txt || ($(VENV_RUN); $(PIP_CMD) install -r requirements.txt))
@@ -78,4 +78,13 @@ start-pg-and-test: ## Start local PostgreSQL container, run all tests, and clean
7878
$(MAKE) stop-postgres; \
7979
exit $$status
8080

81-
.PHONY: usage install install-test install-lint clean publish lint start-postgres stop-postgres test start-pg-and-test
81+
ACT_CMD ?= act
82+
ACT_WORKFLOW ?= .github/workflows/tests.yml
83+
ACT_JOB ?= tests
84+
ACT_PULL ?= false
85+
ACT_CONTAINER_ARCH ?= linux/arm64
86+
87+
test-act: ## Run the CI test workflow locally with act
88+
$(ACT_CMD) -W $(ACT_WORKFLOW) -j $(ACT_JOB) --pull=$(ACT_PULL) --container-architecture $(ACT_CONTAINER_ARCH)
89+
90+
.PHONY: usage install install-test install-lint clean publish lint start-postgres stop-postgres test test-act start-pg-and-test

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,27 @@ python -m pytest tests/test_plugins.py -vv
149149
```
150150

151151
If PostgreSQL is not reachable, tests fail fast at startup.
152+
153+
#### 3) Run CI locally with `act`
154+
155+
Run the GitHub Actions test workflow locally with [`act`](https://github.com/nektos/act):
156+
157+
On macOS, install `act` with Homebrew:
158+
159+
```bash
160+
brew install act
161+
```
162+
163+
```bash
164+
make test-act
165+
```
166+
167+
Useful overrides for local runs:
168+
169+
```bash
170+
# Refresh images explicitly when needed
171+
make test-act ACT_PULL=true
172+
173+
# Match GitHub runner architecture on Apple Silicon (slower)
174+
make test-act ACT_CONTAINER_ARCH=linux/amd64
175+
```

0 commit comments

Comments
 (0)