Skip to content

Commit cbdb6d6

Browse files
committed
ci: combine coverage
1 parent edf976b commit cbdb6d6

File tree

2 files changed

+103
-15
lines changed

2 files changed

+103
-15
lines changed

.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: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
- "*/pyproject.toml"
88
- .github/workflows/test-python.yml
99
- "!docs/**"
10-
push:
11-
branches: [main]
1210

1311
# cancel jobs if new commit pushed
1412
concurrency:
@@ -23,8 +21,8 @@ jobs:
2321
timeout-minutes: 40
2422
runs-on: ubuntu-latest
2523
steps:
26-
- uses: actions/checkout@v4
27-
- uses: actions/setup-python@v5
24+
- uses: actions/checkout@v6
25+
- uses: actions/setup-python@v6
2826
with:
2927
python-version: "3.14"
3028
- name: Install dependencies
@@ -42,8 +40,33 @@ jobs:
4240
tar -xf qemu-xtensa-softmmu-esp_develop_9.2.2_20250817-x86_64-linux-gnu.tar.xz
4341
tar -xf qemu-riscv32-softmmu-esp_develop_9.2.2_20250817-x86_64-linux-gnu.tar.xz
4442
echo "$PWD/qemu/bin" >> $GITHUB_PATH
43+
44+
- name: Save PR number
45+
run: echo ${{ github.event.number }} > pr_number.txt
46+
4547
- name: Run QEMU tests
46-
run: pytest pytest-embedded-qemu/tests/test_qemu.py
48+
run: |
49+
pytest pytest-embedded-qemu/tests/test_qemu.py \
50+
--junitxml pytest-qemu.xml \
51+
--cov-report=xml:coverage-qemu.xml \
52+
--cov=pytest_embedded \
53+
--cov=pytest_embedded_arduino \
54+
--cov=pytest_embedded_idf \
55+
--cov=pytest_embedded_jtag \
56+
--cov=pytest_embedded_qemu \
57+
--cov=pytest_embedded_serial \
58+
--cov=pytest_embedded_serial_esp \
59+
--cov=pytest_embedded_wokwi \
60+
--cov=pytest_embedded_nuttx
61+
- name: Upload test results
62+
uses: actions/upload-artifact@v6
63+
if: always()
64+
with:
65+
name: test-results-qemu
66+
path: |
67+
pr_number.txt
68+
pytest-qemu.xml
69+
coverage-qemu.xml
4770
4871
test-python:
4972
timeout-minutes: 40
@@ -74,11 +97,12 @@ jobs:
7497
bash foreach.sh install
7598
- name: Check ports
7699
run: ls -la /dev/ttyUSB*
100+
77101
- name: Run Tests with coverage
78102
run: |
79103
pytest \
80-
--junitxml=pytest.xml \
81-
--cov-report=term-missing \
104+
--junitxml=pytest-${{ matrix.python-version }}-${{ matrix.arch }}.xml \
105+
--cov-report=xml:coverage-${{ matrix.python-version }}-${{ matrix.arch }}.xml \
82106
--cov=pytest_embedded \
83107
--cov=pytest_embedded_arduino \
84108
--cov=pytest_embedded_idf \
@@ -88,12 +112,11 @@ jobs:
88112
--cov=pytest_embedded_serial_esp \
89113
--cov=pytest_embedded_wokwi \
90114
--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()
115+
- name: Upload test results
116+
uses: actions/upload-artifact@v6
117+
if: always()
97118
with:
98-
name: logs-${{ matrix.python-version }}
99-
path: logs.zip
119+
name: test-results-${{ matrix.python-version }}-${{ matrix.arch }}
120+
path: |
121+
pytest-${{ matrix.python-version }}-${{ matrix.arch }}.xml
122+
coverage-${{ matrix.python-version }}-${{ matrix.arch }}.xml

0 commit comments

Comments
 (0)