Skip to content
Merged
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
21 changes: 21 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Python Tests

permissions:
contents: read
pull-requests: write

on:
push:
Expand Down Expand Up @@ -72,10 +73,30 @@ jobs:
-m "full_pipeline" \
--runner=docker \
--junitxml=pytest-full.xml \
--cov-report=xml:coverage.xml \
--cov=src tests \
--cov-append \
--verbose

- name: Generate combined coverage report
if: matrix.os == 'ubuntu-latest'
shell: bash
run: >
uv run coverage xml -o coverage.xml

- name: Merge JUnitXml files
if: matrix.os == 'ubuntu-latest'
shell: bash
run: >
uv run scripts/merge_cov_junitxml.py

- name: Pytest coverage comment
if: matrix.os == 'ubuntu-latest'
uses: MishaKav/pytest-coverage-comment@v1
with:
pytest-xml-coverage-path: ./coverage.xml
junitxml-path: ./pytest.xml

ruff:
runs-on: ubuntu-latest
steps:
Expand Down
29 changes: 29 additions & 0 deletions scripts/merge_cov_junitxml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# /// script
# dependencies = ["junitparser"]
# requires-python = ">=3.12"
# ///
"""Merge pytest-cov's junitxml file for codecov commenting.

Reads all generated junitxml files and generates:
- pytest.xml (merged xml file)

Run with:
uv run scripts/merge_cov_junitxml.py
"""

from pathlib import Path

from junitparser import JUnitXml


def main() -> None:
"""Merge generated junitxml files."""
merged = JUnitXml()
for f in ["pytest-quick.xml", "pytest-slow.xml", "pytest-full.xml"]:
if Path(f).exists():
merged += JUnitXml.fromfile(f)
merged.write("pytest.xml")


if __name__ == "__main__":
main()