Skip to content

test(monorepo): adds adhoc package selection for CI system tests - #17931

Open
chalmerlowe wants to merge 21 commits into
mainfrom
feat/adhoc-package-selection
Open

test(monorepo): adds adhoc package selection for CI system tests#17931
chalmerlowe wants to merge 21 commits into
mainfrom
feat/adhoc-package-selection

Conversation

@chalmerlowe

@chalmerlowe chalmerlowe commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem

Currently, there is no easy way to run tests for specific packages in our continuous integration (CI) pipeline without making temporary changes to those packages (like adding a space to a comment or inserting a blank line) to trigger detection of a diff. This causes noise in commit history and extra toil to revert the changes used solely for triggering tests prior to merge.

Solution

We have implemented an "Ad-Hoc Package Selection" feature for system tests. This allows developers to specify which packages or groups of packages they want to test by editing simple configuration files within their Pull Request (PR). The feature is triggered by applying a specific GitHub label (test:adhoc) to the PR.

A new script parses these configuration files and merges the ad hoc packages with those that have actual code diffs, ensuring that no modified packages are missed.

Changes

  • Ad-Hoc Configuration: Added
    • ci/adhoc/.standalone_package_list.txt for listing individual packages
    • AND ci/adhoc/.package_groups.txt for defining groups of packages (e.g., handwritten, core`).
  • Parsing Logic: Added ci/adhoc/adhoc_test_runner.sh script to parse and deduplicate requested packages.
  • CI Integration: Updated .kokoro/system.sh to integrate this ad-hoc logic when the test:adhoc label is present.

Note

Notes to Reviewers

  • This feature runs in Kokoro AND relies on the GitHub API to check for a UI labels.
  • The configuration files in ci/adhoc/ are intended to be modified in your PR to select target packages and DO NOT require cleanup before merging.
  • Temporary Code: This PR includes temporary changes (a dummy failing test in google-resumable-media and a trigger comment in google-cloud-speech) strictly for verifying the ad-hoc mechanism works with diff'ed packages and to confirm output formatting in successful and failed situations. These will be reverted before final merge.
  • This will need to be accompanied by an update to the google3 internal kokoro config.

@chalmerlowe chalmerlowe self-assigned this Jul 29, 2026
@chalmerlowe chalmerlowe changed the title test(monorepo): adds adhoc package selection for CI system tests test(monorepo): [WIP] adds adhoc package selection for CI system tests Jul 29, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an ad-hoc testing integration into the Kokoro CI pipeline, allowing dynamic package selection based on PR labels and configuration files. The review feedback highlights several crucial robustness improvements, including handling potential grep failures under set -o pipefail in the ad-hoc test runner, authenticating GitHub API requests to prevent rate-limiting, safely parsing the API response in the inline Python snippet, and quoting variables to avoid pathname expansion.

Comment thread ci/adhoc/adhoc_test_runner.sh Outdated
Comment thread ci/adhoc/adhoc_test_runner.sh Outdated
Comment thread ci/adhoc/adhoc_test_runner.sh Outdated
Comment thread .kokoro/system.sh Outdated
Comment thread .kokoro/system.sh
Comment thread ci/adhoc/adhoc_test_runner.sh Outdated
@chalmerlowe chalmerlowe added test:adhoc Enables ad hoc tests of packages (even with no diff), esp. when testing new CI pipeline features kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed kokoro:run Add this label to force Kokoro to re-run the tests. labels Jul 29, 2026
Comment thread ci/adhoc/adhoc_test_runner.sh Outdated
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 29, 2026
Comment thread packages/google-cloud-speech/google/cloud/speech_v1/services/speech/client.py Outdated
@chalmerlowe
chalmerlowe force-pushed the feat/adhoc-package-selection branch from 60505a8 to 9e72163 Compare August 3, 2026 10:28
@chalmerlowe
chalmerlowe force-pushed the feat/adhoc-package-selection branch from bcb4c15 to d376408 Compare August 3, 2026 11:10
@chalmerlowe chalmerlowe changed the title test(monorepo): [WIP] adds adhoc package selection for CI system tests test(monorepo): adds adhoc package selection for CI system tests Aug 3, 2026
@chalmerlowe
chalmerlowe marked this pull request as ready for review August 3, 2026 12:04
@chalmerlowe
chalmerlowe requested review from a team as code owners August 3, 2026 12:04
@chalmerlowe
chalmerlowe requested review from sycai and removed request for a team August 3, 2026 12:04
Comment thread .kokoro/system.sh Outdated
@chalmerlowe chalmerlowe added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Aug 3, 2026
@chalmerlowe

Copy link
Copy Markdown
Contributor Author

do-not-merge label added as a note to self to remind us to remove two sets of changes before merge:

Changes were made to two packages to ensure that the combination and deduplication of diff'ed packages and ad hoc packages functioned as expected.

Comment thread .kokoro/system.sh
headers=(-H "User-Agent: Kokoro")
if [[ -n "${GITHUB_TOKEN:-${GH_TOKEN}}" ]]; then
headers+=(-H "Authorization: token ${GITHUB_TOKEN:-${GH_TOKEN}}")
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the GitHub token already being populated in kokoro? Or is this a new secret we need to add for this feature?

Comment thread .kokoro/system.sh
# For this prototype:
# we use a small inline Python snippet here because parsing JSON in pure Bash is difficult/error-prone,
# and we cannot guarantee that tools like 'jq' or 'gh' are installed in the test environment.
# Python and its built-in 'json' module are guaranteed to be available in this repository.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we cannot guarantee that tools like 'jq' or 'gh' are installed in the test environment.

Are you sure? It looks like kokoro is using the gcr.io/cloud-devrel-kokoro-resources/python-multi image. I just tested it locally, and it seems to have jq available

@@ -0,0 +1,40 @@
#!/bin/bash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks like the copyright header is missing

# Ensure we are in the project root if called directly,
# but usually this is sourced and CWD is already project root.
# For safety, we can use script location but if sourced $0 might be the parent script.
# Let's assume CWD is project root as per system.sh behavior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this comment still relevant?

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

Labels

do not merge Indicates a pull request not ready for merge, due to either quality or timing. test:adhoc Enables ad hoc tests of packages (even with no diff), esp. when testing new CI pipeline features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants