Skip to content

A programming framework for agentic AI

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

Leonardo Pinheiroa1fdbd96922b
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 0a1e8024c..1ea805d93 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -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:
+ name: coverage-${{ env.PKG_NAME }}
+ path: ./
+ - uses: codecov/codecov-action@v5
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)
+ files: coverage_${{ env.PKG_NAME }}.xml
+ flags: unittests
+ name: codecov-umbrella
+ fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
docs:
diff --git a/python/packages/autogen-agentchat/pyproject.toml b/python/packages/autogen-agentchat/pyproject.toml
index e84b70bce..b0b49d623 100644
--- a/python/packages/autogen-agentchat/pyproject.toml
+++ b/python/packages/autogen-agentchat/pyproject.toml
@@ -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"
diff --git a/python/packages/autogen-core/pyproject.toml b/python/packages/autogen-core/pyproject.toml
index 78eb2bef3..39bece3b0 100644
--- a/python/packages/autogen-core/pyproject.toml
+++ b/python/packages/autogen-core/pyproject.toml
@@ -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",
diff --git a/python/packages/autogen-ext/pyproject.toml b/python/packages/autogen-ext/pyproject.toml
index e0f05425b..8f87bfa00 100644
--- a/python/packages/autogen-ext/pyproject.toml
+++ b/python/packages/autogen-ext/pyproject.toml
@@ -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]
diff --git a/python/packages/autogen-magentic-one/pyproject.toml b/python/packages/autogen-magentic-one/pyproject.toml
index a778c390b..b6e333f79 100644
--- a/python/packages/autogen-magentic-one/pyproject.toml
+++ b/python/packages/autogen-magentic-one/pyproject.toml
@@ -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"
diff --git a/python/packages/autogen-studio/pyproject.toml b/python/packages/autogen-studio/pyproject.toml
index cfc7c9302..598a58d4e 100644
--- a/python/packages/autogen-studio/pyproject.toml
+++ b/python/packages/autogen-studio/pyproject.toml
@@ -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"
diff --git a/python/packages/autogen-test-utils/pyproject.toml b/python/packages/autogen-test-utils/pyproject.toml
index 0bbda6165..76877e5a9 100644
--- a/python/packages/autogen-test-utils/pyproject.toml
+++ b/python/packages/autogen-test-utils/pyproject.toml
@@ -27,4 +27,3 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src"
test = "true"
-coverage = "true"
diff --git a/python/packages/component-schema-gen/pyproject.toml b/python/packages/component-schema-gen/pyproject.toml
index eef5fc405..272142601 100644
--- a/python/packages/component-schema-gen/pyproject.toml
+++ b/python/packages/component-schema-gen/pyproject.toml
@@ -39,4 +39,3 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src"
test = "true"
-coverage = "true"
diff --git a/python/packages/magentic-one-cli/pyproject.toml b/python/packages/magentic-one-cli/pyproject.toml
index 20960d2ea..240d78e2f 100644
--- a/python/packages/magentic-one-cli/pyproject.toml
+++ b/python/packages/magentic-one-cli/pyproject.toml
@@ -44,4 +44,3 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src"
test = "true"
-coverage = "true"
diff --git a/python/pyproject.toml b/python/pyproject.toml
index 27a40d135..c2c5c84bb 100644
--- a/python/pyproject.toml
+++ b/python/pyproject.toml
@@ -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"