Skip to content

Commit 0bc29aa

Browse files
refactor: disable buf generate on build (#839)
# Description This PR disables the automatic generation of A2A types for v1.0 and for compatibility with v0.3 at build phase. `gen_proto.sh` and `gen_proto_compat.sh` can be used as scripts to generate those types
1 parent c162c13 commit 0bc29aa

14 files changed

Lines changed: 4300 additions & 81 deletions

File tree

.github/actions/spelling/excludes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
CHANGELOG.md
9090
^src/a2a/grpc/
9191
^src/a2a/types/
92+
^src/a2a/compat/v0_3/a2a_v0_3*
9293
^tests/
9394
.pre-commit-config.yaml
9495
(?:^|/)a2a\.json$

.github/workflows/linter.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222
- name: Add uv to PATH
2323
run: |
2424
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
25-
- name: Install Buf
26-
uses: bufbuild/buf-setup-action@v1
2725
- name: Install dependencies
2826
run: uv sync --locked
2927

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ jobs:
5454
- name: Add uv to PATH
5555
run: |
5656
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
57-
- name: Install Buf
58-
uses: bufbuild/buf-setup-action@v1
57+
5958
6059
# Coverage comparison for PRs (only on Python 3.13 to avoid duplicate work)
6160
- name: Checkout Base Branch
@@ -80,10 +79,6 @@ jobs:
8079
with:
8180
clean: true
8281

83-
- name: Install dependencies (PR)
84-
if: github.event_name == 'pull_request' && matrix.python-version == '3.13'
85-
run: uv sync --locked && uv build
86-
8782
- name: Run coverage (PR)
8883
if: github.event_name == 'pull_request' && matrix.python-version == '3.13'
8984
run: |

.github/workflows/update-a2a-types.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ test_venv/
1010
coverage.xml
1111
.nox
1212
spec.json
13-
src/a2a/types/a2a.json
1413
docker-compose.yaml
1514
.geminiignore

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,9 @@ changelog = "https://github.com/a2aproject/a2a-python/blob/main/CHANGELOG.md"
6262
documentation = "https://a2a-protocol.org/latest/sdk/python/"
6363

6464
[build-system]
65-
requires = ["hatchling", "uv-dynamic-versioning", "hatch-build-scripts"]
65+
requires = ["hatchling", "uv-dynamic-versioning"]
6666
build-backend = "hatchling.build"
6767

68-
[tool.hatch.build.hooks.build-scripts]
69-
artifacts = ["src/a2a/types/a2a.json"]
70-
71-
[[tool.hatch.build.hooks.build-scripts.scripts]]
72-
commands = ["bash scripts/gen_proto.sh"]
73-
work_dir = "."
7468

7569
[tool.hatch.version]
7670
source = "uv-dynamic-versioning"
@@ -291,6 +285,9 @@ exclude = [
291285
"src/a2a/types/a2a_pb2.py",
292286
"src/a2a/types/a2a_pb2.pyi",
293287
"src/a2a/types/a2a_pb2_grpc.py",
288+
"src/a2a/compat/v0_3/*_pb2.py",
289+
"src/a2a/compat/v0_3/*_pb2.pyi",
290+
"src/a2a/compat/v0_3/*_pb2_grpc.py",
294291
"tests/**",
295292
]
296293

@@ -347,6 +344,9 @@ exclude = [
347344
"src/a2a/types/a2a_pb2.py",
348345
"src/a2a/types/a2a_pb2.pyi",
349346
"src/a2a/types/a2a_pb2_grpc.py",
347+
"src/a2a/compat/v0_3/*_pb2.py",
348+
"src/a2a/compat/v0_3/*_pb2.pyi",
349+
"src/a2a/compat/v0_3/*_pb2_grpc.py",
350350
]
351351
docstring-code-format = true
352352
docstring-code-line-length = "dynamic"

scripts/gen_proto.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,4 @@ echo "Downloading legacy v0.3 proto file..."
2525
# Commit hash was selected as a2a.proto version from 0.3 branch with latests fixes.
2626
curl -o src/a2a/compat/v0_3/a2a_v0_3.proto https://raw.githubusercontent.com/a2aproject/A2A/b3b266d127dde3d1000ec103b252d1de81289e83/specification/grpc/a2a.proto
2727

28-
# Generate legacy v0.3 compatibility protobuf code
29-
echo "Generating legacy v0.3 compatibility protobuf code"
30-
npx --yes @bufbuild/buf generate src/a2a/compat/v0_3 --template buf.compat.gen.yaml
3128

32-
# Fix imports in legacy generated grpc file
33-
echo "Fixing imports in src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py"
34-
sed 's/import a2a_v0_3_pb2 as a2a__v0__3__pb2/from . import a2a_v0_3_pb2 as a2a__v0__3__pb2/g' src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py > src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py.tmp && mv src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py.tmp src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py

scripts/gen_proto_compat.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Generate legacy v0.3 compatibility protobuf code
5+
echo "Generating legacy v0.3 compatibility protobuf code"
6+
npx --yes @bufbuild/buf generate src/a2a/compat/v0_3 --template buf.compat.gen.yaml
7+
8+
# Fix imports in legacy generated grpc file
9+
echo "Fixing imports in src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py"
10+
sed 's/import a2a_v0_3_pb2 as a2a__v0__3__pb2/from . import a2a_v0_3_pb2 as a2a__v0__3__pb2/g' src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py > src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py.tmp && mv src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py.tmp src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py

src/a2a/compat/v0_3/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)