Skip to content

support running and debugging pytest for local tree #1316

support running and debugging pytest for local tree

support running and debugging pytest for local tree #1316

Workflow file for this run

name: Python Test
on: [push, pull_request]
permissions:
contents: read
# Cancel ongoing builds on new changes
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Run tasks
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
task: [test]
# The include map here is actually used to extend the matrix.
# By passing all keys used in the matrix we append new unique combinations.
# For more information see:
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#example-adding-configurations
include:
# Run linter/type checks only on 1 combination
- os: ubuntu-latest
python-version: '3.13'
task: gh-lint
- os: ubuntu-latest
python-version: '3.13'
task: gh-format
- os: ubuntu-latest
python-version: '3.13'
task: types
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
# This is enough to find many quoting issues
with:
path: "./check out"
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
with:
python-version: ${{ matrix.python-version }}
working-directory: './check out/'
enable-cache: true
- name: Setup project
run: uv sync --frozen --directory "./check out/"
- name: Display Python version
run: echo "import sys; print(sys.version); print(sys.platform)" | uv run -
- name: Run ${{ matrix.task }} on ${{ matrix.os }} - ${{ matrix.python-version }}
run: uv run --frozen --directory "./check out/" --env-file=.github/http_env_block.conf poe ${{ matrix.task }}
- name: Upload coverage reports
if: ${{ matrix.task == 'test' }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: "./check out/.coverage"
include-hidden-files: true
- name: Upload test reports
if: ${{ matrix.task == 'test' }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: tests-${{ matrix.os }}-${{ matrix.python-version }}
path: "./check out/junit.xml"
test-report:
name: Report test results
runs-on: ubuntu-latest
needs: ["build"]
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: '3.13'
- name: Download all artifacts
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
- name: Install coverage
run: pip3 install coverage
- name: Create coverage report
run: |
coverage combine coverage-*/.coverage
coverage xml
- name: Upload combined coverage report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage-combined
path: coverage.xml
- name: Upload coverage to Codecov
if: github.repository_owner == 'zephyrproject-rtos'
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: github.repository_owner == 'zephyrproject-rtos' && ${{ !cancelled() }}
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1
with:
token: ${{ secrets.CODECOV_TOKEN }}