Skip to content

Conversation

@ivanmkc
Copy link
Collaborator

@ivanmkc ivanmkc commented Nov 15, 2025

This PR introduces new tooling for managing and validating Go snippets within the repository.

Key additions include:

  • Go Snippets Runner (tools/go-snippets/runner.sh): A new script to build and run Go snippets, supporting both targeted execution for changed files and full regression testing. This script replaces the need for separate build_all.sh and run_all.sh scripts.
  • Go Files to Test List (tools/go-snippets/files_to_test.txt): A new configuration file that lists all Go snippet files to be included in the build and run processes. It supports single files and multiple files for packages with shared dependencies, and allows for comments.
  • Go Snippets PR Check (tools/go-snippets/check_go_snippets.sh): A new script to ensure that all .go files in the examples/go directory are properly referenced in files_to_test.txt, preventing new snippets from being overlooked in the test suite.
  • CI Workflow Integration: The .github/workflows/go-snippets-pr-check.yaml workflow utilizes these new scripts for comprehensive Go snippet testing on pull requests and a weekly schedule.
    These new files establish a robust and centralized system for Go snippet management, ensuring consistency and test coverage.

@ivanmkc ivanmkc force-pushed the imkc--go-regression-testing branch from 693c41d to d1260fa Compare November 15, 2025 06:19
@ivanmkc ivanmkc marked this pull request as ready for review November 15, 2025 06:22
@ivanmkc ivanmkc force-pushed the imkc--go-regression-testing branch from 48dc600 to 3f07437 Compare November 16, 2025 03:35
@joefernandez
Copy link
Collaborator

joefernandez commented Nov 20, 2025

@ivanmkc : Does this update have any dependencies on ADK Go releases beyond v0.1.0? If so, you should mark this as BLOCKED until an official release is available with these changes.

@ivanmkc ivanmkc force-pushed the imkc--go-regression-testing branch from cd0c700 to f76b10d Compare December 2, 2025 19:38
inMemoryService := session.InMemoryService()
fmt.Println("Initialized InMemoryService.")

// --8<-- [start:vertexai_service]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed as it is unreferenced and uses an old API

# Update to the latest version of the ADK.
# This ensures that we are always testing against the most recent release.
echo "Updating google.golang.org/adk to latest..."
(cd examples/go && go get google.golang.org/adk@latest)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kdroste-google ensures we run with the latest version of adk-go released.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looks good. Maybe it would make sense to check the exit code here as well (network issues etc).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

@kdroste-google kdroste-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls check the comments

# Update to the latest version of the ADK.
# This ensures that we are always testing against the most recent release.
echo "Updating google.golang.org/adk to latest..."
(cd examples/go && go get google.golang.org/adk@latest)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looks good. Maybe it would make sense to check the exit code here as well (network issues etc).

The scripts are primarily designed to be run automatically by GitHub Actions.

- **On Pull Requests:** When a pull request is opened, two workflows are triggered:
1. **Go Snippets Build on PR and Schedule:** This workflow runs `check_go_snippets.sh` to ensure new files are registered. It then intelligently builds **only the `.go` files that were changed** in the PR.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about that. There are dependencies like: examples/go/snippets/tools-custom/doc_analysis/doc_analysis.go and examples/go/snippets/tools-custom/doc_analysis/main.go - that imho may break - a change in doc_analysis.go itself can be fine, but main.go (no changes) may stop compiling.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. In our setup, multi-file snippets (like doc_analysis) are listed on the same line in files_to_test.txt. The runner works by matching the changed file to that line and executing the full build command for that entry (e.g., go build main.go doc_analysis.go). This ensures that main.go is indeed recompiled and verified. I've updated tools/go snippets/README.md to explicitly document this requirement.

ivanmkc added 11 commits December 3, 2025 14:22
…te ADK dependency

Consolidate all Go snippet module dependencies to a single  file located at . This simplifies dependency management and ensures consistent versions across all Go examples.

Update Usage: tools/go-snippets/runner.sh <build|run> [file1 file2 ...] to dynamically fetch the latest  module () before running any builds or tests. This ensures that PR and regression checks always validate against the most recent ADK release, preventing outdated dependency issues.

Address breaking changes in  by removing the  initialization from , which is no longer available.

Cleaned up extraneous  and  files from subdirectories within , as well as the unused  file.
Reverts previous attempts to infer Go snippet dependencies and clarifies the strict testing model.

- **`runner.sh`**: Restores `find_snippet_line` to rely on exact substring matching of changed files within `files_to_test.txt` lines. Adds `go get` exit code check.
- **`tools/go-snippets/README.md`**: Adds "Understanding the Test Runner" section detailing `files_to_test.txt` adherence, multi-file `package main` requirements, and `_test.go` file handling.
- **`runner_test.sh`**: Adds `test_find_snippet_line_multi_file_match` to verify correct behavior for multi-file snippets listed on a single line.
@ivanmkc ivanmkc force-pushed the imkc--go-regression-testing branch from d1ece7c to 12597ff Compare December 3, 2025 19:24
@ivanmkc ivanmkc merged commit 4f74c1c into google:main Dec 3, 2025
6 checks passed
@ivanmkc
Copy link
Collaborator Author

ivanmkc commented Dec 3, 2025

@ivanmkc : Does this update have any dependencies on ADK Go releases beyond v0.1.0? If so, you should mark this as BLOCKED until an official release is available with these changes.

This dynamically uses the latest release of ADK-Go from the package manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants