Skip to content

Commit f69b299

Browse files
Add AHBG CI gate
1 parent 554eb06 commit f69b299

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

.github/workflows/ahbg-ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: ahbg-ci
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "ahbg/**"
7+
- ".github/workflows/ahbg-ci.yml"
8+
push:
9+
branches: [main]
10+
paths:
11+
- "ahbg/**"
12+
- ".github/workflows/ahbg-ci.yml"
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
verify:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
python-version: ["3.10", "3.12"]
24+
steps:
25+
- uses: actions/checkout@v7.0.1
26+
- uses: actions/setup-python@v7.0.0
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Install verification dependencies
30+
run: python -m pip install --upgrade pip pytest
31+
- name: Compile AHBG Python surfaces
32+
run: |
33+
python - <<'PY'
34+
from hashlib import sha256
35+
from pathlib import Path
36+
import py_compile
37+
import tempfile
38+
39+
out_dir = Path(tempfile.mkdtemp(prefix="ahbg-pyc-"))
40+
for path in sorted(Path("ahbg").rglob("*.py")):
41+
out = out_dir / (sha256(str(path).encode("utf-8")).hexdigest() + ".pyc")
42+
py_compile.compile(str(path), cfile=str(out), doraise=True)
43+
PY
44+
- name: Run AHBG presentation tests
45+
run: python -m unittest discover -s ahbg/presentation/tests -p "test*.py"
46+
- name: Reject generated Python caches
47+
run: |
48+
python - <<'PY'
49+
from pathlib import Path
50+
51+
caches = sorted(str(path) for path in Path("ahbg").rglob("__pycache__"))
52+
if caches:
53+
raise SystemExit("generated Python caches present: " + ", ".join(caches))
54+
PY

0 commit comments

Comments
 (0)