Skip to content

Commit e28509f

Browse files
committed
fix: use GitPython in _make_test_repo and run CI pytest once with coverage
- Convert _make_test_repo from subprocess.run to GitPython to prevent git failures on Linux CI (matching test_git_reader.py pattern) - Merge two CI pytest steps into one to avoid redundant runs and eliminate potential state pollution between runs
1 parent f34c6ee commit e28509f

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

.github/workflows/tests.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,8 @@ jobs:
9393
run: |
9494
python -m pip install --upgrade pip
9595
pip install -e ".[dev]"
96-
- name: Run tests (no coverage)
97-
run: pytest tests/ -v --tb=long --junitxml=junit.xml -o junit_family=legacy
98-
- name: Coverage check
99-
run: pytest tests/ -q --tb=short --cov=standup --cov-report=xml --cov-report=term-missing --cov-fail-under=85
96+
- name: Run tests with coverage
97+
run: pytest tests/ -v --tb=short --cov=standup --cov-report=xml --cov-report=term-missing --cov-fail-under=85 --junitxml=junit.xml -o junit_family=legacy
10098
- name: Upload coverage
10199
if: matrix.python-version == '3.12'
102100
uses: codecov/codecov-action@v5

tests/test_main_startup.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,18 @@ def generate_standup(self, prompt: str, tone: str) -> str:
6767

6868

6969
def _make_test_repo(tmp_path):
70-
import subprocess
71-
72-
repo = tmp_path / "repo"
73-
repo.mkdir()
74-
subprocess.run(["git", "init", "-q"], cwd=repo, check=True)
75-
subprocess.run(["git", "config", "user.email", "a@b.com"], cwd=repo, check=True)
76-
subprocess.run(["git", "config", "user.name", "Test"], cwd=repo, check=True)
77-
(repo / "f.txt").write_text("hi")
78-
subprocess.run(["git", "add", "."], cwd=repo, check=True)
79-
subprocess.run(["git", "commit", "-q", "-m", "feat: add file"], cwd=repo, check=True)
80-
return str(repo)
70+
import git as git_module
71+
72+
repo_dir = tmp_path / "repo"
73+
repo_dir.mkdir()
74+
repo = git_module.Repo.init(str(repo_dir))
75+
with repo.config_writer() as cw:
76+
cw.set_value("user", "email", "a@b.com")
77+
cw.set_value("user", "name", "Test")
78+
(repo_dir / "f.txt").write_text("hi")
79+
repo.index.add(["f.txt"])
80+
repo.index.commit("feat: add file")
81+
return str(repo_dir)
8182

8283

8384
def _base_config(repo_path: str) -> dict:

0 commit comments

Comments
 (0)