-
Notifications
You must be signed in to change notification settings - Fork 303
ci: Script for checking-out experimental types #507
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b0d6575
feat: script for checking-out experimental types
55d61c5
fix typo
2a412f1
Apply gemini suggestions
f206b66
Merge branch 'main' into experimental-types-script
lkawka b5a1e8b
Use generate_types script
0cda933
Merge branch 'main' into experimental-types-script
lkawka 7ec10a4
Add grpc generation
73b2cc6
Apply gemini suggestions
137e0f2
Merge branch 'main' into experimental-types-script
lkawka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Exit immediately if a command exits with a non-zero status. | ||
| # Treat unset variables as an error. | ||
| set -euo pipefail | ||
|
|
||
| TMP_WORK_DIR="/tmp/experimental_types" # Folder for temporary files. | ||
| A2A_SPEC_REPO="https://github.com/a2aproject/A2A.git" # URL for the A2A spec repo. | ||
| A2A_SPEC_BRANCH="main" # Name of the branch with experimental changes. | ||
| FEATURE_BRANCH="experimental-types" # Name of the feature branch to create. | ||
| ROOT_DIR=`pwd`"/.." | ||
lkawka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| usage() { | ||
| cat <<EOF | ||
| Usage: $0 [OPTIONS] | ||
|
|
||
| Creates a new feature branch with types generated from unmerged A2A spec changes. | ||
|
|
||
| This script clones the A2A spec repository, checks out a specific branch, | ||
| and creates a new local feature branch from it. | ||
|
|
||
| OPTIONS: | ||
| -r, --spec-repo URL for the A2A spec repository. | ||
| (Default: "$A2A_SPEC_REPO") | ||
|
|
||
| -b, --spec-branch Name of the branch with the experimental changes. | ||
| (Default: "$A2A_SPEC_BRANCH") | ||
|
|
||
| -f, --feature-branch Name of the new feature branch to create. | ||
| (Default: "$FEATURE_BRANCH") | ||
|
|
||
| -t, --tmp-dir Directory for temporary checkout files. | ||
| (Default: "$TMP_WORK_DIR") | ||
|
|
||
| -h, --help Display this help message and exit. | ||
|
|
||
| EXAMPLE: | ||
| # Run with all default settings: | ||
| $0 | ||
|
|
||
| # Run with custom settings: | ||
| $0 -r "https://github.com/edenreich/A2A.git" -b "feature/implement-list-tasks" -f "task-list" | ||
| EOF | ||
| } | ||
|
|
||
| # Handle command-line arguments. | ||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| -h|--help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| -r|--spec-repo) | ||
| A2A_SPEC_REPO="$2" | ||
| shift 2 | ||
| ;; | ||
| -b|--spec-branch) | ||
| A2A_SPEC_BRANCH="$2" | ||
| shift 2 | ||
| ;; | ||
| -f|--feature-branch) | ||
| FEATURE_BRANCH="$2" | ||
| shift 2 | ||
| ;; | ||
| -t|--tmp-dir) | ||
| TMP_WORK_DIR="$2" | ||
| shift 2 | ||
| ;; | ||
lkawka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| *) | ||
| echo "Error: Unknown option '$1'" >&2 | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| echo "Creating a temporary \"$TMP_WORK_DIR\" folder for A2A spec repo..." | ||
| rm -fR $TMP_WORK_DIR # Remove preexisting files if any exist. | ||
lkawka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| mkdir -p $TMP_WORK_DIR | ||
| cd $TMP_WORK_DIR | ||
|
|
||
| echo "Cloning the \"$A2A_SPEC_REPO\" repository..." | ||
| git clone $A2A_SPEC_REPO | ||
| cd A2A | ||
lkawka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| echo " Checking out the \"$A2A_SPEC_BRANCH\" branch..." | ||
lkawka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| git checkout $A2A_SPEC_BRANCH | ||
lkawka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| echo "Running datamodel-codegen..." | ||
| GENERATED_FILE="$ROOT_DIR/src/a2a/types.py" | ||
| uv run datamodel-codegen \ | ||
| --input "$TMP_WORK_DIR/A2A/specification/json/a2a.json" \ | ||
lkawka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| --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 \ | ||
| --use-subclass-enum \ | ||
| --base-class a2a._base.A2ABaseModel \ | ||
| --field-constraints \ | ||
| --snake-case-field \ | ||
| --no-alias | ||
|
|
||
| echo "Formatting generated types file with ruff..." | ||
| uv run ruff format "$GENERATED_FILE" | ||
lkawka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| echo "Committing generated types file to the \"$FEATURE_BRANCH\" branch..." | ||
| cd $ROOT_DIR | ||
| git checkout -b "$FEATURE_BRANCH" | ||
| git add "$GENERATED_FILE" | ||
| git commit -m "Experimental types" | ||
|
|
||
| echo "Cleaning up..." | ||
| yes | rm -R $TMP_WORK_DIR | ||
lkawka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.