Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Test Workflow with Coverage

# Two independent jobs — one per Python service in this monorepo.
# A failure in one job does NOT block the other (no `needs:` between them).
# We run both jobs on every push/PR touching either service or the workflow
# itself; the per-service `paths:` filter is intentionally NOT split, so a
# cross-service refactor (or a bug in this workflow) is never silently skipped.
on:
push:
branches:
Expand All @@ -9,6 +14,9 @@ on:
- 'src/backend-api/**/*.py'
- 'src/backend-api/pyproject.toml'
- 'src/backend-api/pytest.ini'
- 'src/processor/**/*.py'
- 'src/processor/pyproject.toml'
- 'src/processor/pytest.ini'
- '.github/workflows/test.yml'
pull_request:
types:
Expand All @@ -23,6 +31,9 @@ on:
- 'src/backend-api/**/*.py'
- 'src/backend-api/pyproject.toml'
- 'src/backend-api/pytest.ini'
- 'src/processor/**/*.py'
- 'src/processor/pyproject.toml'
- 'src/processor/pytest.ini'
- '.github/workflows/test.yml'

permissions:
Expand All @@ -32,6 +43,7 @@ permissions:

jobs:
backend_tests:
name: Backend API tests
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -61,6 +73,9 @@ jobs:
echo "skip_backend_tests=false" >> $GITHUB_ENV
fi

# Known quirk: src/backend-api/pytest.ini is written as TOML
# ([tool.pytest.ini_options] table) and is not a valid pytest .ini file.
# We bypass it with `-c /dev/null` and pass the test-runner flags here.
- name: Run Backend Tests with Coverage
if: env.skip_backend_tests == 'false'
run: |
Expand All @@ -74,6 +89,14 @@ jobs:
--junitxml=pytest.xml \
-v

- name: Upload Backend Coverage XML
if: always() && env.skip_backend_tests == 'false'
uses: actions/upload-artifact@v4
with:
name: backend-coverage-xml
path: src/backend-api/reports/coverage.xml
if-no-files-found: warn

- name: Pytest Coverage Comment
if: |
always() &&
Expand All @@ -85,8 +108,84 @@ jobs:
pytest-xml-coverage-path: src/backend-api/reports/coverage.xml
junitxml-path: src/backend-api/pytest.xml
report-only-changed-files: true
unique-id-for-comment: backend-api

- name: Skip Backend Tests
if: env.skip_backend_tests == 'true'
run: |
echo "Skipping backend tests because no test files were found."

processor_tests:
name: Processor tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"

- name: Install Processor Dependencies
run: |
python -m pip install --upgrade pip
cd src/processor
pip install -e .
pip install pytest pytest-cov pytest-asyncio

- name: Check if Processor Test Files Exist
id: check_processor_tests
run: |
if [ -z "$(find src/processor/src/tests -type f -name 'test_*.py' 2>/dev/null)" ]; then
echo "No processor test files found, skipping processor tests."
echo "skip_processor_tests=true" >> $GITHUB_ENV
else
echo "Processor test files found, running tests."
echo "skip_processor_tests=false" >> $GITHUB_ENV
fi

# Processor's pyproject.toml carries [tool.pytest.ini_options] (with
# `pythonpath = ["src"]`), so we let pytest pick it up normally.
# Coverage is scoped to the four real source dirs so that the test
# tree itself does not inflate the % (the suite lives under src/tests).
- name: Run Processor Tests with Coverage
if: env.skip_processor_tests == 'false'
run: |
cd src/processor
pytest src/tests \
--cov=src/libs \
--cov=src/services \
--cov=src/steps \
--cov=src/utils \
--cov-report=term-missing \
--cov-report=xml:reports/coverage.xml \
--junitxml=pytest.xml \
-v

- name: Upload Processor Coverage XML
if: always() && env.skip_processor_tests == 'false'
uses: actions/upload-artifact@v4
with:
name: processor-coverage-xml
path: src/processor/reports/coverage.xml
if-no-files-found: warn

- name: Pytest Coverage Comment
if: |
always() &&
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.fork == false &&
env.skip_processor_tests == 'false'
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
with:
pytest-xml-coverage-path: src/processor/reports/coverage.xml
junitxml-path: src/processor/pytest.xml
report-only-changed-files: true
unique-id-for-comment: processor

- name: Skip Processor Tests
if: env.skip_processor_tests == 'true'
run: |
echo "Skipping processor tests because no test files were found."
Loading
Loading