Skip to content

Commit 059020f

Browse files
committed
ci: combine coverage
1 parent edf976b commit 059020f

2 files changed

Lines changed: 97 additions & 13 deletions

File tree

.github/workflows/report.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Report
2+
on:
3+
workflow_run:
4+
workflows:
5+
- Target Tests
6+
types:
7+
- completed
8+
9+
permissions:
10+
actions: read
11+
checks: write
12+
pull-requests: write
13+
14+
jobs:
15+
report:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Download test results
19+
uses: dawidd6/action-download-artifact@v16
20+
with:
21+
workflow: ${{ github.event.workflow_run.workflow_id }}
22+
run_id: ${{ github.event.workflow_run.id }}
23+
name_is_regexp: true
24+
name: "test-results-.*"
25+
path: test-results
26+
if_no_artifact_found: ignore
27+
28+
- name: Read PR number
29+
id: pr-number
30+
run: |
31+
PR_FILE=$(find test-results -name pr_number.txt | head -n 1)
32+
if [ -n "$PR_FILE" ] && [ -f "$PR_FILE" ]; then
33+
echo "PR_NUMBER=$(cat $PR_FILE)" >> $GITHUB_ENV
34+
else
35+
echo "No pr_number.txt found, skipping comment."
36+
exit 0
37+
fi
38+
39+
- name: Prepare multiple files string
40+
if: env.PR_NUMBER != ''
41+
id: generate-files
42+
run: |
43+
MULTIPLE_FILES=""
44+
for xml_file in $(find test-results -name "pytest-*.xml"); do
45+
dir_name=$(dirname "$xml_file")
46+
# title from directory name test-results-qemu -> qemu
47+
title=$(basename "$dir_name" | sed 's/^test-results-//')
48+
# Capitalize first letter and replace hyphens with spaces
49+
title=$(echo "$title" | awk '{print toupper(substr($0,1,1)) substr($0,2)}' | tr '-' ' ')
50+
51+
cov_file=$(find "$dir_name" -name "coverage-*.xml" | head -n 1)
52+
# Add to multiple files string
53+
MULTIPLE_FILES="${MULTIPLE_FILES}${title}, ${cov_file}, ${xml_file}"$'\n'
54+
done
55+
56+
echo "FILES<<EOF" >> $GITHUB_OUTPUT
57+
echo -e "$MULTIPLE_FILES" >> $GITHUB_OUTPUT
58+
echo "EOF" >> $GITHUB_OUTPUT
59+
60+
- name: Comment on PR
61+
uses: MishaKav/pytest-coverage-comment@v1
62+
if: env.PR_NUMBER != '' && steps.generate-files.outputs.FILES != ''
63+
with:
64+
issue-number: ${{ env.PR_NUMBER }}
65+
multiple-files: ${{ steps.generate-files.outputs.FILES }}

.github/workflows/test-python.yml

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
timeout-minutes: 40
2424
runs-on: ubuntu-latest
2525
steps:
26-
- uses: actions/checkout@v4
27-
- uses: actions/setup-python@v5
26+
- uses: actions/checkout@v6
27+
- uses: actions/setup-python@v6
2828
with:
2929
python-version: "3.14"
3030
- name: Install dependencies
@@ -43,7 +43,27 @@ jobs:
4343
tar -xf qemu-riscv32-softmmu-esp_develop_9.2.2_20250817-x86_64-linux-gnu.tar.xz
4444
echo "$PWD/qemu/bin" >> $GITHUB_PATH
4545
- name: Run QEMU tests
46-
run: pytest pytest-embedded-qemu/tests/test_qemu.py
46+
run: |
47+
pytest pytest-embedded-qemu/tests/test_qemu.py \
48+
--junitxml pytest-qemu.xml \
49+
--cov-report=xml:coverage-qemu.xml \
50+
--cov=pytest_embedded \
51+
--cov=pytest_embedded_arduino \
52+
--cov=pytest_embedded_idf \
53+
--cov=pytest_embedded_jtag \
54+
--cov=pytest_embedded_qemu \
55+
--cov=pytest_embedded_serial \
56+
--cov=pytest_embedded_serial_esp \
57+
--cov=pytest_embedded_wokwi \
58+
--cov=pytest_embedded_nuttx
59+
- name: Upload test results
60+
uses: actions/upload-artifact@v6
61+
if: always()
62+
with:
63+
name: test-results-qemu
64+
path: |
65+
pytest-qemu.xml
66+
coverage-qemu.xml
4767
4868
test-python:
4969
timeout-minutes: 40
@@ -77,8 +97,8 @@ jobs:
7797
- name: Run Tests with coverage
7898
run: |
7999
pytest \
80-
--junitxml=pytest.xml \
81-
--cov-report=term-missing \
100+
--junitxml=pytest-${{ matrix.python-version }}-${{ matrix.arch }}.xml \
101+
--cov-report=xml:coverage-${{ matrix.python-version }}-${{ matrix.arch }}.xml \
82102
--cov=pytest_embedded \
83103
--cov=pytest_embedded_arduino \
84104
--cov=pytest_embedded_idf \
@@ -88,12 +108,11 @@ jobs:
88108
--cov=pytest_embedded_serial_esp \
89109
--cov=pytest_embedded_wokwi \
90110
--cov=pytest_embedded_nuttx
91-
- name: Zip log files
92-
if: failure()
93-
run: |
94-
zip -r logs.zip /tmp/pytest-embedded
95-
- uses: actions/upload-artifact@v6
96-
if: failure()
111+
- name: Upload test results
112+
uses: actions/upload-artifact@v6
113+
if: always()
97114
with:
98-
name: logs-${{ matrix.python-version }}
99-
path: logs.zip
115+
name: test-results-${{ matrix.python-version }}-${{ matrix.arch }}
116+
path: |
117+
pytest-${{ matrix.python-version }}-${{ matrix.arch }}.xml
118+
coverage-${{ matrix.python-version }}-${{ matrix.arch }}.xml

0 commit comments

Comments
 (0)