Use caching to run tests and report coverage (#5086)

* use caching to run tests and report coverage

* fix test step dep name

* try to fix cov fname

* add working dir to mv step

* update artifact download

* fmt

* reduce concurrency on ext test

---------

Co-authored-by: Leonardo Pinheiro <lpinheiro@microsoft.com>
This commit is contained in:
Leonardo Pinheiro 2025-01-18 00:32:18 +10:00 committed by GitHub
parent ce20de9afb
commit a1fdbd9692
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 31 additions and 46 deletions

View File

@ -132,6 +132,7 @@ jobs:
- name: Run uv sync
run: |
uv sync --locked --all-extras
echo "PKG_NAME=$(basename '${{ matrix.package }}')" >> $GITHUB_ENV
working-directory: ./python
- name: Run task
@ -140,8 +141,20 @@ jobs:
poe --directory ${{ matrix.package }} test
working-directory: ./python
- name: Move coverage file
run: |
mv ${{ matrix.package }}/coverage.xml coverage_${{ env.PKG_NAME }}.xml
working-directory: ./python
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-${{ env.PKG_NAME }}
path: ./python/coverage_${{ env.PKG_NAME }}.xml
codecov:
runs-on: ubuntu-latest
needs: [test]
strategy:
matrix:
package:
@ -153,31 +166,20 @@ jobs:
]
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
version: "0.5.18"
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Run uv sync
- name: Set up environment
run: |
uv sync --locked --all-extras
working-directory: ./python
- name: Run task
run: |
source ${{ github.workspace }}/python/.venv/bin/activate
poe --directory ${{ matrix.package }} coverage
working-directory: ./python
- name: Upload coverage
uses: codecov/codecov-action@v5
echo "PKG_NAME=$(basename '${{ matrix.package }}')" >> $GITHUB_ENV
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
fail_ci_if_error: true # optional (default = false)
files: ${{ matrix.package }}/coverage.xml # optional
flags: unittests # optional
name: codecov-umbrella # optional
verbose: true # optional (default = false)
name: coverage-${{ env.PKG_NAME }}
path: ./
- uses: codecov/codecov-action@v5
with:
files: coverage_${{ env.PKG_NAME }}.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
docs:

View File

@ -35,5 +35,4 @@ testpaths = ["tests"]
include = "../../shared_tasks.toml"
[tool.poe.tasks]
test = "pytest -n auto"
coverage = "pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml"
test = "pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml"

View File

@ -106,8 +106,7 @@ mypy = [
include = "../../shared_tasks.toml"
[tool.poe.tasks]
test = "pytest -n auto"
coverage = "pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml"
test = "pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml"
mypy.default_item_type = "cmd"
mypy.sequence = [
"mypy --config-file ../../pyproject.toml --exclude src/autogen_core/application/protos --exclude tests/protos src tests",

View File

@ -87,14 +87,9 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
test.sequence = [
"playwright install",
"pytest -n auto",
"pytest -n 1 --cov=src --cov-report=term-missing --cov-report=xml",
]
test.default_item_type = "cmd"
coverage.sequence = [
"playwright install",
"pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml",
]
coverage.default_item_type = "cmd"
mypy = "mypy --config-file ../../pyproject.toml --exclude src/autogen_ext/runtimes/grpc/protos --exclude tests/protos src tests"
[tool.mypy]

View File

@ -54,15 +54,10 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
test.sequence = [
"playwright install",
"pytest -n auto",
]
test.default_item_type = "cmd"
coverage.sequence = [
"playwright install",
"pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml",
]
coverage.default_item_type = "cmd"
test.default_item_type = "cmd"
[tool.ruff]
extend = "../../pyproject.toml"

View File

@ -88,5 +88,4 @@ ignore = ["B008"]
fmt = "ruff format"
format.ref = "fmt"
lint = "ruff check"
test = "pytest -n 0"
coverage = "pytest -n 0 --cov=autogenstudio --cov-report=term-missing"
test = "pytest -n 0 --cov=autogenstudio --cov-report=term-missing"

View File

@ -27,4 +27,3 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src"
test = "true"
coverage = "true"

View File

@ -39,4 +39,3 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src"
test = "true"
coverage = "true"

View File

@ -44,4 +44,3 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src"
test = "true"
coverage = "true"

View File

@ -90,11 +90,10 @@ lint = "python run_task_in_pkgs_if_exist.py lint"
pyright = "python run_task_in_pkgs_if_exist.py pyright"
mypy = "python run_task_in_pkgs_if_exist.py mypy"
test = "python run_task_in_pkgs_if_exist.py test"
coverage = "python run_task_in_pkgs_if_exist.py coverage"
markdown-code-lint = """python check_md_code_blocks.py ../README.md ./packages/autogen-core/docs/src/**/*.md"""
samples-code-check = """pyright ./samples"""
check = ["fmt", "lint", "pyright", "mypy", "coverage", "markdown-code-lint", "samples-code-check"]
check = ["fmt", "lint", "pyright", "mypy", "test", "markdown-code-lint", "samples-code-check"]
gen-proto = "python -m grpc_tools.protoc --python_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --grpc_python_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --mypy_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --mypy_grpc_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --proto_path ../protos/ agent_worker.proto --proto_path ../protos/ cloudevent.proto"