From 27c7b1a16778e41df5f21cba9c049ae6c7419704 Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Tue, 20 May 2025 13:20:01 -0700 Subject: [PATCH 1/3] ci: Create GitHub Action to generate `types.py` from specification JSON --- .github/actions/spelling/allow.txt | 1 + .github/workflows/update-a2a-types.yml | 86 ++++++++++++++++++++++++++ development.md | 18 +++++- 3 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/update-a2a-types.yml diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt index dd4dd5ec..19f28982 100644 --- a/.github/actions/spelling/allow.txt +++ b/.github/actions/spelling/allow.txt @@ -26,6 +26,7 @@ dunders genai gle inmemory +kwarg langgraph lifecycles linting diff --git a/.github/workflows/update-a2a-types.yml b/.github/workflows/update-a2a-types.yml new file mode 100644 index 00000000..56bf302a --- /dev/null +++ b/.github/workflows/update-a2a-types.yml @@ -0,0 +1,86 @@ +name: Update A2A Schema from Specification + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + check_and_update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Configure uv shell + run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH + + - name: Install dependencies (datamodel-code-generator) + run: uv sync + + - name: Define output file variable + id: vars + run: | + GENERATED_FILE="./src/a2a/types.py" + echo "GENERATED_FILE=$GENERATED_FILE" >> "$GITHUB_OUTPUT" + + - name: Run datamodel-codegen + run: | + set -euo pipefail # Exit immediately if a command exits with a non-zero status + + REMOTE_URL="https://raw.githubusercontent.com/google/A2A/refs/heads/main/specification/json/a2a.json" + GENERATED_FILE="${{ steps.vars.outputs.GENERATED_FILE }}" + + echo "Running datamodel-codegen..." + uv run datamodel-codegen \ + --url "$REMOTE_URL" \ + --input-file-type jsonschema \ + --output "$GENERATED_FILE" \ + --target-python-version 3.10 \ + --output-model-type pydantic_v2.BaseModel \ + --disable-timestamp \ + --use-schema-description \ + --use-union-operator \ + --use-field-description \ + --use-default \ + --use-default-kwarg \ + --use-one-literal-as-default \ + --class-name A2A \ + --use-standard-collections + echo "Codegen finished." + + - name: Commit and push if generated file changed + if: github.ref == 'refs/heads/main' # Or your default branch name + run: | + set -euo pipefail + + GENERATED_FILE="${{ steps.vars.outputs.GENERATED_FILE }}" + + # Check if the generated file has any changes compared to HEAD + if git diff --quiet "$GENERATED_FILE"; then + echo "$GENERATED_FILE has no changes after codegen. Nothing to commit." + else + echo "Changes detected in $GENERATED_FILE. Committing..." + # Configure git user for the commit + git config user.name "github-actions" + git config user.email "github-actions@github.com" + + # Add the generated file + git add "$GENERATED_FILE" + + # Commit changes + git commit -m "🤖 chore: Auto-update A2A schema from specification" + + # Push changes + git push + echo "Changes committed and pushed." + fi diff --git a/development.md b/development.md index 0d9ef29c..7f42a75c 100644 --- a/development.md +++ b/development.md @@ -2,8 +2,20 @@ ## Type generation from spec - - ```bash -uv run datamodel-codegen --input ./spec.json --input-file-type jsonschema --output ./src/a2a/types.py --target-python-version 3.10 --output-model-type pydantic_v2.BaseModel --disable-timestamp --use-schema-description --use-union-operator --use-field-description --use-default --use-default-kwarg --use-one-literal-as-default --class-name A2A --use-standard-collections +uv run datamodel-codegen \ + --url https://raw.githubusercontent.com/google/A2A/refs/heads/main/specification/json/a2a.json \ + --input-file-type jsonschema \ + --output ./src/a2a/types.py \ + --target-python-version 3.10 \ + --output-model-type pydantic_v2.BaseModel \ + --disable-timestamp \ + --use-schema-description \ + --use-union-operator \ + --use-field-description \ + --use-default \ + --use-default-kwarg \ + --use-one-literal-as-default \ + --class-name A2A \ + --use-standard-collections ``` From 8915571b088610447b5e6d9782fcec2066673312 Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Tue, 20 May 2025 13:20:01 -0700 Subject: [PATCH 2/3] ci: Create GitHub Action to generate `types.py` from specification JSON --- .github/actions/spelling/allow.txt | 1 + .github/workflows/update-a2a-types.yml | 86 ++++++++++++++++++++++++++ development.md | 18 +++++- 3 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/update-a2a-types.yml diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt index dd4dd5ec..19f28982 100644 --- a/.github/actions/spelling/allow.txt +++ b/.github/actions/spelling/allow.txt @@ -26,6 +26,7 @@ dunders genai gle inmemory +kwarg langgraph lifecycles linting diff --git a/.github/workflows/update-a2a-types.yml b/.github/workflows/update-a2a-types.yml new file mode 100644 index 00000000..56bf302a --- /dev/null +++ b/.github/workflows/update-a2a-types.yml @@ -0,0 +1,86 @@ +name: Update A2A Schema from Specification + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + check_and_update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Configure uv shell + run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH + + - name: Install dependencies (datamodel-code-generator) + run: uv sync + + - name: Define output file variable + id: vars + run: | + GENERATED_FILE="./src/a2a/types.py" + echo "GENERATED_FILE=$GENERATED_FILE" >> "$GITHUB_OUTPUT" + + - name: Run datamodel-codegen + run: | + set -euo pipefail # Exit immediately if a command exits with a non-zero status + + REMOTE_URL="https://raw.githubusercontent.com/google/A2A/refs/heads/main/specification/json/a2a.json" + GENERATED_FILE="${{ steps.vars.outputs.GENERATED_FILE }}" + + echo "Running datamodel-codegen..." + uv run datamodel-codegen \ + --url "$REMOTE_URL" \ + --input-file-type jsonschema \ + --output "$GENERATED_FILE" \ + --target-python-version 3.10 \ + --output-model-type pydantic_v2.BaseModel \ + --disable-timestamp \ + --use-schema-description \ + --use-union-operator \ + --use-field-description \ + --use-default \ + --use-default-kwarg \ + --use-one-literal-as-default \ + --class-name A2A \ + --use-standard-collections + echo "Codegen finished." + + - name: Commit and push if generated file changed + if: github.ref == 'refs/heads/main' # Or your default branch name + run: | + set -euo pipefail + + GENERATED_FILE="${{ steps.vars.outputs.GENERATED_FILE }}" + + # Check if the generated file has any changes compared to HEAD + if git diff --quiet "$GENERATED_FILE"; then + echo "$GENERATED_FILE has no changes after codegen. Nothing to commit." + else + echo "Changes detected in $GENERATED_FILE. Committing..." + # Configure git user for the commit + git config user.name "github-actions" + git config user.email "github-actions@github.com" + + # Add the generated file + git add "$GENERATED_FILE" + + # Commit changes + git commit -m "🤖 chore: Auto-update A2A schema from specification" + + # Push changes + git push + echo "Changes committed and pushed." + fi diff --git a/development.md b/development.md index 0d9ef29c..7f42a75c 100644 --- a/development.md +++ b/development.md @@ -2,8 +2,20 @@ ## Type generation from spec - - ```bash -uv run datamodel-codegen --input ./spec.json --input-file-type jsonschema --output ./src/a2a/types.py --target-python-version 3.10 --output-model-type pydantic_v2.BaseModel --disable-timestamp --use-schema-description --use-union-operator --use-field-description --use-default --use-default-kwarg --use-one-literal-as-default --class-name A2A --use-standard-collections +uv run datamodel-codegen \ + --url https://raw.githubusercontent.com/google/A2A/refs/heads/main/specification/json/a2a.json \ + --input-file-type jsonschema \ + --output ./src/a2a/types.py \ + --target-python-version 3.10 \ + --output-model-type pydantic_v2.BaseModel \ + --disable-timestamp \ + --use-schema-description \ + --use-union-operator \ + --use-field-description \ + --use-default \ + --use-default-kwarg \ + --use-one-literal-as-default \ + --class-name A2A \ + --use-standard-collections ``` From 3e894f8bf8ebdbf6f8cfafaf57406cab9bcd65ea Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Tue, 20 May 2025 13:23:19 -0700 Subject: [PATCH 3/3] Update release please --- .github/release-please.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/release-please.yml b/.github/release-please.yml index b0a050d4..8d4679d2 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,3 +1,4 @@ releaseType: python handleGHRelease: true bumpMinorPreMajor: false +bumpPatchForMinorPreMajor: true