Skip to content

Commit a077f1d

Browse files
ci: add python-tests workflow and fix CLI imports (install editable)
1 parent 3c37525 commit a077f1d

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

.github/workflows/python-tests.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: python-tests
1+
---
2+
name: Python tests
23

3-
on:
4+
"on":
45
push:
56
branches: ["**"]
67
pull_request:
@@ -12,18 +13,19 @@ jobs:
1213
- name: Checkout
1314
uses: actions/checkout@v4
1415

15-
- name: Setup Python
16+
- name: Set up Python
1617
uses: actions/setup-python@v5
1718
with:
1819
python-version: "3.12"
1920

20-
- name: Install deps
21+
- name: Install dependencies
2122
run: |
2223
python -m pip install --upgrade pip
2324
pip install -r requirements.txt
2425
pip install pytest
26+
pip install -e .
2527
2628
- name: Run tests
27-
run: |
28-
pytest -q
29-
echo "All tests passed!"
29+
env:
30+
PYTHONPATH: ${{ github.workspace }}/src
31+
run: pytest -q

tests/test_cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
import json
2+
import os
23
import subprocess
34
import sys
45
from pathlib import Path
56

7+
REPO_ROOT = Path(__file__).resolve().parents[1]
8+
SRC_PATH = str(REPO_ROOT / "src")
9+
610

711
def run_cmd(args: list[str], cwd: Path) -> subprocess.CompletedProcess:
12+
env = os.environ.copy()
13+
env["PYTHONPATH"] = SRC_PATH + (
14+
os.pathsep + env["PYTHONPATH"] if "PYTHONPATH" in env else ""
15+
)
816
return subprocess.run(
917
[sys.executable, "-m", "agent.runner", *args],
1018
cwd=str(cwd),
1119
stdout=subprocess.PIPE,
1220
stderr=subprocess.PIPE,
1321
text=True,
22+
env=env,
1423
)
1524

1625

0 commit comments

Comments
 (0)