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
65 changes: 65 additions & 0 deletions .github/workflows/report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Report
on:
workflow_run:
workflows:
- Target Tests
types:
- completed

permissions:
actions: read
checks: write
pull-requests: write

jobs:
report:
runs-on: ubuntu-latest
steps:
- name: Download test results
uses: dawidd6/action-download-artifact@v16
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
run_id: ${{ github.event.workflow_run.id }}
name_is_regexp: true
name: "test-results-.*"
path: test-results
if_no_artifact_found: ignore

- name: Read PR number
id: pr-number
run: |
PR_FILE=$(find test-results -name pr_number.txt | head -n 1)
if [ -n "$PR_FILE" ] && [ -f "$PR_FILE" ]; then
echo "PR_NUMBER=$(cat $PR_FILE)" >> $GITHUB_ENV
else
echo "No pr_number.txt found, skipping comment."
exit 0
fi

- name: Prepare multiple files string
if: env.PR_NUMBER != ''
id: generate-files
run: |
MULTIPLE_FILES=""
for xml_file in $(find test-results -name "pytest-*.xml"); do
dir_name=$(dirname "$xml_file")
# title from directory name test-results-qemu -> qemu
title=$(basename "$dir_name" | sed 's/^test-results-//')
# Capitalize first letter and replace hyphens with spaces
title=$(echo "$title" | awk '{print toupper(substr($0,1,1)) substr($0,2)}' | tr '-' ' ')

cov_file=$(find "$dir_name" -name "coverage-*.xml" | head -n 1)
# Add to multiple files string
MULTIPLE_FILES="${MULTIPLE_FILES}${title}, ${cov_file}, ${xml_file}"$'\n'
done

echo "FILES<<EOF" >> $GITHUB_OUTPUT
echo -e "$MULTIPLE_FILES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Comment on PR
uses: MishaKav/pytest-coverage-comment@v1
if: env.PR_NUMBER != '' && steps.generate-files.outputs.FILES != ''
with:
issue-number: ${{ env.PR_NUMBER }}
multiple-files: ${{ steps.generate-files.outputs.FILES }}
75 changes: 62 additions & 13 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Python Packages
name: Target Tests

on:
pull_request:
Expand All @@ -7,8 +7,6 @@ on:
- "*/pyproject.toml"
- .github/workflows/test-python.yml
- "!docs/**"
push:
branches: [main]

# cancel jobs if new commit pushed
concurrency:
Expand All @@ -19,6 +17,57 @@ env:
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}

jobs:
test-qemu:
timeout-minutes: 40
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Install dependencies
run: |
sudo apt update && sudo apt install -y libgcrypt20 libglib2.0-0 libpixman-1-0 libsdl2-2.0-0 libslirp0
pip install -U pip
export PIP_EXTRA_INDEX_URL="https://dl.espressif.com/pypi"
pip install cryptography --prefer-binary
pip install -r requirements.txt
bash foreach.sh install
- name: Download and install QEMU
run: |
wget https://github.com/espressif/qemu/releases/download/esp-develop-9.2.2-20250817/qemu-xtensa-softmmu-esp_develop_9.2.2_20250817-x86_64-linux-gnu.tar.xz
wget https://github.com/espressif/qemu/releases/download/esp-develop-9.2.2-20250817/qemu-riscv32-softmmu-esp_develop_9.2.2_20250817-x86_64-linux-gnu.tar.xz
tar -xf qemu-xtensa-softmmu-esp_develop_9.2.2_20250817-x86_64-linux-gnu.tar.xz
tar -xf qemu-riscv32-softmmu-esp_develop_9.2.2_20250817-x86_64-linux-gnu.tar.xz
echo "$PWD/qemu/bin" >> $GITHUB_PATH

- name: Save PR number
run: echo ${{ github.event.number }} > pr_number.txt

- name: Run QEMU tests
run: |
pytest pytest-embedded-qemu/tests/test_qemu.py \
--junitxml pytest-qemu.xml \
--cov-report=xml:coverage-qemu.xml \
--cov=pytest_embedded \
--cov=pytest_embedded_arduino \
--cov=pytest_embedded_idf \
--cov=pytest_embedded_jtag \
--cov=pytest_embedded_qemu \
--cov=pytest_embedded_serial \
--cov=pytest_embedded_serial_esp \
--cov=pytest_embedded_wokwi \
--cov=pytest_embedded_nuttx
- name: Upload test results
uses: actions/upload-artifact@v6
if: always()
with:
name: test-results-qemu
path: |
pr_number.txt
pytest-qemu.xml
coverage-qemu.xml

test-python:
timeout-minutes: 40
strategy:
Expand Down Expand Up @@ -48,11 +97,12 @@ jobs:
bash foreach.sh install
- name: Check ports
run: ls -la /dev/ttyUSB*

- name: Run Tests with coverage
run: |
pytest \
--junitxml=pytest.xml \
--cov-report=term-missing \
--junitxml=pytest-${{ matrix.python-version }}-${{ matrix.arch }}.xml \
--cov-report=xml:coverage-${{ matrix.python-version }}-${{ matrix.arch }}.xml \
--cov=pytest_embedded \
--cov=pytest_embedded_arduino \
--cov=pytest_embedded_idf \
Expand All @@ -62,12 +112,11 @@ jobs:
--cov=pytest_embedded_serial_esp \
--cov=pytest_embedded_wokwi \
--cov=pytest_embedded_nuttx
- name: Zip log files
if: failure()
run: |
zip -r logs.zip /tmp/pytest-embedded
- uses: actions/upload-artifact@v6
if: failure()
- name: Upload test results
uses: actions/upload-artifact@v6
if: always()
with:
name: logs-${{ matrix.python-version }}
path: logs.zip
name: test-results-${{ matrix.python-version }}-${{ matrix.arch }}
path: |
pytest-${{ matrix.python-version }}-${{ matrix.arch }}.xml
coverage-${{ matrix.python-version }}-${{ matrix.arch }}.xml
Loading