Skip to content

Commit 3e23d93

Browse files
ambvclaude
andcommitted
Add backend tests to CI, triggered only on backend/ changes
Compares changed files to detect backend modifications. On pushes to main, always runs if backend files changed. On PRs, compares against the base branch. Skips test setup entirely when only frontend or other files are modified. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a3f65fd commit 3e23d93

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,34 @@ jobs:
4040
echo "::error::Please run pip-compile to regenerate lockfiles. See README for instructions."
4141
exit 1
4242
fi
43+
44+
backend-tests:
45+
name: Backend tests
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
- name: Check for backend changes
52+
id: changes
53+
run: |
54+
if [ "${{ github.event_name }}" = "push" ]; then
55+
CHANGED=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "backend/")
56+
else
57+
CHANGED=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
58+
fi
59+
if echo "$CHANGED" | grep -q '^backend/'; then
60+
echo "backend=true" >> "$GITHUB_OUTPUT"
61+
fi
62+
- uses: actions/setup-python@v5
63+
if: steps.changes.outputs.backend == 'true'
64+
with:
65+
python-version: "3.13"
66+
cache: pip
67+
cache-dependency-path: backend/requirements-dev.txt
68+
- name: Run tests
69+
if: steps.changes.outputs.backend == 'true'
70+
working-directory: backend
71+
run: |
72+
pip install -r requirements-dev.txt
73+
python -m pytest tests/ -v --cov=app --cov-report=term-missing

0 commit comments

Comments
 (0)