# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. name: Python CI on: push: branches: [main] paths: - "python/**" - "specification/**/json/**" - "specification/inference_formats/**" - "catalogs/**" - "conformance/**" - "samples/agent/adk/**" - "tools/build_catalog/**" - ".agents/skills/**" - "dart/a2ui_cli/**" - "scripts/run_skills_tests.py" - ".github/scripts/**" - ".github/workflows/python_ci.yml" - ".github/actions/setup-python/**" pull_request: paths: - "python/**" - "specification/**/json/**" - "specification/inference_formats/**" - "catalogs/**" - "conformance/**" - "samples/agent/adk/**" - "tools/build_catalog/**" - ".agents/skills/**" - "dart/a2ui_cli/**" - "scripts/run_skills_tests.py" - ".github/scripts/**" - ".github/workflows/python_ci.yml" - ".github/actions/setup-python/**" concurrency: group: ${{ github.workflow }}-${{ github.ref_name || github.ref }} cancel-in-progress: true permissions: contents: read jobs: python-ci: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false # a2ui_core and a2ui_agent derive their versions from git tags, so # the tags have to be present. Without this the build silently falls # back to the version pinned in pyproject.toml and CI would never # exercise the real versioning path. fetch-depth: 0 - uses: ./.github/actions/setup-python - name: Verify SDK version tags are reachable env: TARGET_BRANCH: ${{ github.base_ref || github.ref_name }} run: | set -euo pipefail for glob in 'python/a2ui-core/v*' 'python/a2ui-agent-sdk/v*'; do if ! git describe --tags --match "$glob" >/dev/null 2>&1; then if [ "$TARGET_BRANCH" != "main" ]; then echo "::warning::No tag matching $glob is reachable on branch $TARGET_BRANCH; fallback version will be used." continue fi echo "::error::No tag matching $glob is reachable, so package" \ "versions would fall back instead of coming from tags." exit 1 fi echo "$glob -> $(git describe --tags --match "$glob")" done - name: Install Dependencies run: uv sync --all-packages - name: Check Agent SDK Installs Without Agent Frameworks # The workspace venv has every package installed, so this check uses an # isolated environment with only a2ui-core and a2ui-agent-sdk. run: | uv run --isolated --no-project \ --with ./python/a2ui_core --with ./python/a2ui_agent \ python -c " import importlib.util import a2ui.inference_formats, a2ui.parser, a2ui.processor leaked = [m for m in ('a2a', 'google.adk', 'google.genai') if importlib.util.find_spec(m.split('.')[0]) and importlib.util.find_spec(m)] assert not leaked, f'a2ui-agent-sdk pulls in agent frameworks: {leaked}' " - name: Set Up Java uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287 # v5.3.0 with: java-version: "21" distribution: "temurin" - name: Check Generated Express Parser run: uv run python python/a2ui_agent/scripts/generate_express_parser.py --check - name: Check Formatting run: | uv run pyink --check . - name: Type Check run: | uv run --all-packages mypy . - name: Run Unit Tests env: A2UI_CONFORMANCE_MANIFEST_DIR: ${{ runner.temp }}/a2ui-manifest run: uv run pytest - name: Verify Core Conformance Manifest run: | uv run --project conformance python conformance/scripts/check_executed_cases.py \ --manifest-dir "${{ runner.temp }}/a2ui-manifest" \ --harness python-core \ --corpus core uv run --project conformance python conformance/scripts/check_executed_cases.py \ --manifest-dir "${{ runner.temp }}/a2ui-manifest" \ --corpus extensions \ --only 'extensions/a2a/**' \ --harness python-a2a uv run --project conformance python conformance/scripts/check_executed_cases.py \ --manifest-dir "${{ runner.temp }}/a2ui-manifest" \ --corpus extensions \ --only 'extensions/adk/**' \ --harness python-adk uv run --project conformance python conformance/scripts/check_executed_cases.py \ --manifest-dir "${{ runner.temp }}/a2ui-manifest" \ --corpus agent \ --harness python-agent uv run --project conformance python conformance/scripts/check_executed_cases.py \ --manifest-dir "${{ runner.temp }}/a2ui-manifest" \ --corpus e2e \ --harness python-agent - name: Verify Conformance Feature Coverage run: | uv run --project conformance python conformance/scripts/check_feature_coverage.py --static for h in python-core python-agent python-a2a python-adk; do uv run --project conformance python conformance/scripts/check_feature_coverage.py \ --manifest-dir "${{ runner.temp }}/a2ui-manifest" \ --harness "$h" done - name: Set Up Dart uses: ./.github/actions/setup-dart - name: Run CLI Python Runtime Tests env: REQUIRE_PYTHON_TESTS: "true" run: | cd dart/a2ui_cli flutter pub get VIRTUAL_ENV="$GITHUB_WORKSPACE/.venv" flutter test test/python_runtime_test.dart - name: Build All Packages run: uv build --all - name: Run Skills Unit Tests run: uv run python3 scripts/run_skills_tests.py - name: Run Workflow Script Unit Tests run: python3 -m unittest discover -s .github/scripts/tests # The tests marked `performance` time processing payloads of two sizes, as # conformance/core/message_processor_scaling.yaml describes. A slow or loaded # runner can fail them, so the root pyproject.toml deselects them in the job # above and they run here, in a job of their own. A regression can make them # run for minutes, so the job has a time limit of its own. python-performance: runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: ./.github/actions/setup-python - name: Install Dependencies run: uv sync --all-packages - name: Run Performance Tests run: uv run pytest -m performance python/a2ui_core/tests python/a2ui_agent/tests