mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
0a0de4ac21
* Python: Add coverage threshold gate for PR checks (#3392) - Add python-check-coverage.py script to enforce coverage threshold on specific modules - Modify python-test-coverage.yml to run coverage check after tests - Initial enforced module: agent_framework_azure_ai at 85% threshold - Other modules are reported for visibility but don't block merges * Fail if module not found * Force unit test job to run * Comment 1 * Fix coverage check to use full package paths for submodule support * Update report format
54 lines
1.7 KiB
YAML
54 lines
1.7 KiB
YAML
name: Python - Test Coverage
|
|
|
|
on:
|
|
pull_request:
|
|
branches: ["main", "feature*"]
|
|
paths:
|
|
- "python/packages/**"
|
|
- "python/tests/unit/**"
|
|
env:
|
|
# Configure a constant location for the uv cache
|
|
UV_CACHE_DIR: /tmp/.uv-cache
|
|
# Coverage threshold percentage for enforced modules
|
|
COVERAGE_THRESHOLD: 85
|
|
|
|
jobs:
|
|
python-tests-coverage:
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: false
|
|
defaults:
|
|
run:
|
|
working-directory: python
|
|
env:
|
|
UV_PYTHON: "3.10"
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
# Save the PR number to a file since the workflow_run event
|
|
# in the coverage report workflow does not have access to it
|
|
- name: Save PR number
|
|
run: |
|
|
echo ${{ github.event.number }} > ./pr_number
|
|
- name: Set up python and install the project
|
|
id: python-setup
|
|
uses: ./.github/actions/python-setup
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
os: ${{ runner.os }}
|
|
env:
|
|
# Configure a constant location for the uv cache
|
|
UV_CACHE_DIR: /tmp/.uv-cache
|
|
- name: Run all tests with coverage report
|
|
run: uv run poe all-tests-cov --cov-report=xml:python-coverage.xml -q --junitxml=pytest.xml
|
|
- name: Check coverage threshold
|
|
run: python ${{ github.workspace }}/.github/workflows/python-check-coverage.py python-coverage.xml ${{ env.COVERAGE_THRESHOLD }}
|
|
- name: Upload coverage report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
path: |
|
|
python/python-coverage.xml
|
|
python/pytest.xml
|
|
python/pr_number
|
|
overwrite: true
|
|
retention-days: 1
|
|
if-no-files-found: error
|