From 0c2bb2c881a5e79536ce4460d2f13d4078cfdc16 Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Mon, 19 May 2025 16:17:51 -0700 Subject: [PATCH 1/5] ci: Add GitHub Action to automatically run unit tests --- .github/workflows/unit-tests.yml | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 00000000..ac900704 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,53 @@ +name: Run Unit Tests + +on: + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + test: + name: Test with Python ${{ matrix.python-version }} + + runs-on: ubuntu-latest + + if: github.repository == 'google/a2a-python' + + strategy: + matrix: + python-version: ['3.13'] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: uv + cache-dependency-path: uv.lock + + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Add uv to PATH + run: | + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + + - name: Install dependencies + run: uv sync --dev + + - name: Run tests + run: pytest + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report-${{ matrix.python-version }} + path: coverage.xml + if-no-files-found: ignore From f3ab3ab01318286b259cad258c7a4e1108ef1ad2 Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Mon, 19 May 2025 16:20:20 -0700 Subject: [PATCH 2/5] Remove cache for uv --- .github/workflows/unit-tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index ac900704..9fd72642 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -28,8 +28,6 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: uv - cache-dependency-path: uv.lock - name: Install uv run: | From 1fba1b41ba7e793d488507a2962d40e7f15afb6f Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Mon, 19 May 2025 16:21:50 -0700 Subject: [PATCH 3/5] Update pytest command --- .github/workflows/unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 9fd72642..b742e723 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -41,7 +41,7 @@ jobs: run: uv sync --dev - name: Run tests - run: pytest + run: uv run pytest - name: Upload coverage report uses: actions/upload-artifact@v4 From aedf78c38e0d6e6dbb3019516d8d3cc815a4d6b7 Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Mon, 19 May 2025 16:27:59 -0700 Subject: [PATCH 4/5] Fix Unit Tests from recent updates --- .../request_handlers/test_jsonrpc_handler.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/server/request_handlers/test_jsonrpc_handler.py b/tests/server/request_handlers/test_jsonrpc_handler.py index cf3e66c8..7e36aeb9 100644 --- a/tests/server/request_handlers/test_jsonrpc_handler.py +++ b/tests/server/request_handlers/test_jsonrpc_handler.py @@ -527,8 +527,8 @@ async def streaming_coro(): json={ 'contextId': 'session-xyz', 'id': 'task_123', + 'kind': 'task', 'status': {'state': 'submitted'}, - 'type': 'task', }, ), call( @@ -537,13 +537,18 @@ async def streaming_coro(): 'artifacts': [ { 'artifactId': '11', - 'parts': [{'text': 'text', 'type': 'text'}], + 'parts': [ + { + 'kind': 'text', + 'text': 'text', + } + ], } ], 'contextId': 'session-xyz', 'id': 'task_123', + 'kind': 'task', 'status': {'state': 'submitted'}, - 'type': 'task', }, ), call( @@ -552,13 +557,18 @@ async def streaming_coro(): 'artifacts': [ { 'artifactId': '11', - 'parts': [{'text': 'text', 'type': 'text'}], + 'parts': [ + { + 'kind': 'text', + 'text': 'text', + } + ], } ], 'contextId': 'session-xyz', 'id': 'task_123', + 'kind': 'task', 'status': {'state': 'completed'}, - 'type': 'task', }, ), ] From 7ef27ef1c3c9248c1f9f874b2e0d96b9900c3514 Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Mon, 19 May 2025 16:30:49 -0700 Subject: [PATCH 5/5] Formatting --- .github/workflows/unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index b742e723..5f86cc81 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: - python-version: ['3.13'] + python-version: ["3.13"] steps: - name: Checkout code