Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use caching to run tests and report coverage #5086

48 changes: 25 additions & 23 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions python/packages/autogen-agentchat/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 1 addition & 2 deletions python/packages/autogen-core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 1 addition & 6 deletions python/packages/autogen-ext/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 1 addition & 6 deletions python/packages/autogen-magentic-one/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions python/packages/autogen-studio/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 0 additions & 1 deletion python/packages/autogen-test-utils/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src"
test = "true"
coverage = "true"
1 change: 0 additions & 1 deletion python/packages/component-schema-gen/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src"
test = "true"
coverage = "true"
1 change: 0 additions & 1 deletion python/packages/magentic-one-cli/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ include = "../../shared_tasks.toml"
[tool.poe.tasks]
mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src"
test = "true"
coverage = "true"
3 changes: 1 addition & 2 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Loading