Skip to content

Commit 36e67e6

Browse files
committed
ci: split and speed up PR test matrix
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 8c05a9e commit 36e67e6

1 file changed

Lines changed: 157 additions & 27 deletions

File tree

.github/workflows/test.yml

Lines changed: 157 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,70 @@
11
name: Tests
22

3+
concurrency:
4+
group: bm-ci-${{ github.workflow }}-${{ github.repository }}-${{ github.head_ref || github.ref }}
5+
cancel-in-progress: true
6+
37
on:
48
push:
59
branches: [ "main" ]
610
pull_request:
711
branches: [ "main" ]
8-
# pull_request_target runs on the BASE of the PR, not the merge result.
9-
# It has write permissions and access to secrets.
10-
# It's useful for PRs from forks or automated PRs but requires careful use for security reasons.
11-
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
12-
pull_request_target:
13-
branches: [ "main" ]
1412

1513
jobs:
16-
test-sqlite:
17-
name: Test SQLite (${{ matrix.os }}, Python ${{ matrix.python-version }})
14+
static-checks:
15+
name: Static Checks (Python 3.12)
16+
timeout-minutes: 20
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
submodules: true
23+
24+
- name: Set up Python 3.12
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: "3.12"
28+
cache: "pip"
29+
30+
- name: Install uv
31+
run: |
32+
pip install uv
33+
34+
- uses: extractions/setup-just@v3
35+
36+
- name: Create virtual env
37+
run: |
38+
uv venv
39+
40+
- name: Install dependencies
41+
run: |
42+
uv pip install -e ".[dev]"
43+
44+
- name: Run type checks
45+
run: |
46+
just typecheck
47+
48+
- name: Run linting
49+
run: |
50+
just lint
51+
52+
test-sqlite-unit:
53+
name: Test SQLite Unit (${{ matrix.os }}, Python ${{ matrix.python-version }})
1854
timeout-minutes: 30
55+
needs: [static-checks]
1956
strategy:
2057
fail-fast: false
2158
matrix:
22-
os: [ubuntu-latest, windows-latest]
23-
python-version: [ "3.12", "3.13", "3.14" ]
59+
include:
60+
- os: ubuntu-latest
61+
python-version: "3.12"
62+
- os: ubuntu-latest
63+
python-version: "3.13"
64+
- os: ubuntu-latest
65+
python-version: "3.14"
66+
- os: windows-latest
67+
python-version: "3.12"
2468
runs-on: ${{ matrix.os }}
2569

2670
steps:
@@ -46,24 +90,63 @@ jobs:
4690
4791
- name: Install dependencies
4892
run: |
49-
uv pip install -e ".[dev,semantic]"
93+
uv pip install -e ".[dev]"
5094
51-
- name: Run type checks
95+
- name: Run tests (SQLite Unit)
5296
run: |
53-
just typecheck
97+
just test-unit-sqlite
5498
55-
- name: Run linting
99+
test-sqlite-integration:
100+
name: Test SQLite Integration (${{ matrix.os }}, Python ${{ matrix.python-version }})
101+
timeout-minutes: 45
102+
needs: [static-checks]
103+
strategy:
104+
fail-fast: false
105+
matrix:
106+
include:
107+
- os: ubuntu-latest
108+
python-version: "3.12"
109+
- os: ubuntu-latest
110+
python-version: "3.13"
111+
- os: ubuntu-latest
112+
python-version: "3.14"
113+
- os: windows-latest
114+
python-version: "3.12"
115+
runs-on: ${{ matrix.os }}
116+
117+
steps:
118+
- uses: actions/checkout@v4
119+
with:
120+
submodules: true
121+
122+
- name: Set up Python ${{ matrix.python-version }}
123+
uses: actions/setup-python@v4
124+
with:
125+
python-version: ${{ matrix.python-version }}
126+
cache: 'pip'
127+
128+
- name: Install uv
56129
run: |
57-
just lint
130+
pip install uv
58131
59-
- name: Run tests (SQLite)
132+
- uses: extractions/setup-just@v3
133+
134+
- name: Create virtual env
135+
run: |
136+
uv venv
137+
138+
- name: Install dependencies
60139
run: |
61-
uv pip install pytest pytest-cov
62-
just test-sqlite
140+
uv pip install -e ".[dev]"
63141
64-
test-postgres:
65-
name: Test Postgres (Python ${{ matrix.python-version }})
142+
- name: Run tests (SQLite Integration)
143+
run: |
144+
just test-int-sqlite
145+
146+
test-postgres-unit:
147+
name: Test Postgres Unit (Python ${{ matrix.python-version }})
66148
timeout-minutes: 30
149+
needs: [static-checks]
67150
strategy:
68151
fail-fast: false
69152
matrix:
@@ -95,16 +178,57 @@ jobs:
95178
96179
- name: Install dependencies
97180
run: |
98-
uv pip install -e ".[dev,semantic]"
181+
uv pip install -e ".[dev]"
99182
100-
- name: Run tests (Postgres via testcontainers)
183+
- name: Run tests (Postgres Unit)
101184
run: |
102-
uv pip install pytest pytest-cov
103-
just test-postgres
185+
just test-unit-postgres
186+
187+
test-postgres-integration:
188+
name: Test Postgres Integration (Python ${{ matrix.python-version }})
189+
timeout-minutes: 45
190+
needs: [static-checks]
191+
strategy:
192+
fail-fast: false
193+
matrix:
194+
python-version: [ "3.12", "3.13", "3.14" ]
195+
runs-on: ubuntu-latest
196+
197+
# Note: No services section needed - testcontainers handles Postgres in Docker
198+
199+
steps:
200+
- uses: actions/checkout@v4
201+
with:
202+
submodules: true
203+
204+
- name: Set up Python ${{ matrix.python-version }}
205+
uses: actions/setup-python@v4
206+
with:
207+
python-version: ${{ matrix.python-version }}
208+
cache: 'pip'
209+
210+
- name: Install uv
211+
run: |
212+
pip install uv
213+
214+
- uses: extractions/setup-just@v3
215+
216+
- name: Create virtual env
217+
run: |
218+
uv venv
219+
220+
- name: Install dependencies
221+
run: |
222+
uv pip install -e ".[dev]"
223+
224+
- name: Run tests (Postgres Integration)
225+
run: |
226+
just test-int-postgres
104227
105228
test-semantic:
106229
name: Test Semantic (Python 3.12)
107230
timeout-minutes: 45
231+
needs: [static-checks]
108232
runs-on: ubuntu-latest
109233

110234
steps:
@@ -134,12 +258,19 @@ jobs:
134258
135259
- name: Run tests (Semantic)
136260
run: |
137-
uv pip install pytest pytest-cov
138261
just test-semantic
139262
140263
coverage:
141264
name: Coverage Summary (combined, Python 3.12)
142-
timeout-minutes: 30
265+
timeout-minutes: 60
266+
needs:
267+
- static-checks
268+
- test-sqlite-unit
269+
- test-sqlite-integration
270+
- test-postgres-unit
271+
- test-postgres-integration
272+
- test-semantic
273+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
143274
runs-on: ubuntu-latest
144275

145276
steps:
@@ -169,7 +300,6 @@ jobs:
169300
170301
- name: Run combined coverage (SQLite + Postgres)
171302
run: |
172-
uv pip install pytest pytest-cov
173303
just coverage
174304
175305
- name: Add coverage report to job summary

0 commit comments

Comments
 (0)