Skip to content

internal: [TE-5828] Add bktec plan step to collect commit metadata on agent builds#3924

Merged
gchan merged 4 commits into
mainfrom
te-5828-bktec-plan-collect-commit-metadata
May 14, 2026
Merged

internal: [TE-5828] Add bktec plan step to collect commit metadata on agent builds#3924
gchan merged 4 commits into
mainfrom
te-5828-bktec-plan-collect-commit-metadata

Conversation

@gchan
Copy link
Copy Markdown
Contributor

@gchan gchan commented May 14, 2026

Description

Adds a discardable bktec plan --collect-git-metadata step to the
agent build pipeline so git commit metadata is sent to Buildkite Test
Engine on every build. The plan output is discarded -- existing test
steps continue to use their declared parallelism: values, so this is
a metadata-only side-channel with no run-time contract change.

bktec v2.5.0 is downloaded from the test-engine-client GitHub
release at step time. The agent repo pins test-engine-client v1.6.0
in go.mod for use as go tool test-engine-client in
.buildkite/steps/tests.sh, which predates the plan subcommand
(v2.0.0) and the --collect-git-metadata flag (v2.4.0). A coordinated
bump of both call sites is tracked as follow-up.

The step is soft_fail: true, has no depends_on and no dependents,
so a Test Engine API hiccup never blocks the build. It runs inside the
existing agent docker-compose service to pick up go on PATH (bktec
shells out to go list ./... for package discovery) and the
BUILDKITE_TEST_ENGINE_API_ACCESS_TOKEN env var.

Context

Internal ticket: TE-5828.

Changes

Best reviewed commit-by-commit:

  • Add bktec plan script to collect git commit metadata
  • Wire bktec metadata step into agent build pipeline
  • Run bktec metadata step inside agent compose service
  • Simplify metadata script for linux-only compose service

Verification

The new :test_tube: Collect commit metadata step should:

  • Print bktec 2.5.0 after the download.
  • Exit 0 with the log line Plan request issued -- git commit metadata sent to Test Engine.
  • Not affect the Tests and Coverage group's timing or behaviour.

AI assisted.

Deployment

Low risk. New step is soft_fail: true and has no dependents.

Rollback

Yes -- single revert.

gchan added 2 commits May 15, 2026 10:53
Adds a discardable plan-step script for the Test Engine plan metadata
side-channel. Script downloads bktec v2.5.0 from the test-engine-client
GitHub release at step time, then runs:

    BKTEC_PREVIEW_SELECTION=1 bktec plan --json --collect-git-metadata > /dev/null

Plan output is discarded -- the goal is the metadata write, not the plan.
Sets MAX_PARALLELISM=2 / TARGET_TIME=1m so the Test Engine API accepts
the plan request (it rejects parallelism = 0 even on metadata-only
requests; surfaced by TE-5766 verification on bk/bk-rspec).

bktec is installed via curl rather than bumping go.mod because the agent
repo pins test-engine-client v1.6.0 for use as 'go tool test-engine-client'
on the runtime test path. v1.6.0 predates the 'plan' subcommand (v2.0.0)
and the --collect-git-metadata flag (v2.4.0). A coordinated bump is left
as follow-up.
Adds a top-level 🧪 Collect commit metadata step in
.buildkite/pipeline.yml between the lint group and the Tests group.

Step characteristics:

- soft_fail: true -- a Test Engine API hiccup never blocks the build.
- No depends_on, no dependents -- runs in parallel with everything from
  t=0; nothing waits on it.
- Top-level placement (not inside the Tests group) so metadata is
  collected on every build, including doc-only PRs that don't trigger
  the tests group's if_changed.
- Bare-agent step (no docker-compose) -- .git is present from the
  agent's normal checkout, so no app-with-git-style compose service is
  needed (unlike bk/bk-rspec in TE-5640).

Sets BUILDKITE_TEST_ENGINE_SUITE_SLUG=buildkite-agent and
BUILDKITE_TEST_ENGINE_TEST_RUNNER=gotest at the step level for
consistency with .buildkite/steps/tests.sh.
@gchan gchan changed the title [TE-5828] Add bktec plan step to collect commit metadata on agent builds [internal] [TE-5828] Add bktec plan step to collect commit metadata on agent builds May 14, 2026
@gchan gchan changed the title [internal] [TE-5828] Add bktec plan step to collect commit metadata on agent builds internal: [TE-5828] Add bktec plan step to collect commit metadata on agent builds May 14, 2026
First verification build (12477) failed with:

    failed to run go list: exec: "go": executable file not found in $PATH

bktec's gotest runner shells out to `go list ./...` for package
discovery (see test-engine-client/internal/runner/gotest.go GetFiles).
The bare agent runner has no Go on PATH; only the `agent` docker-compose
service does (it builds from Dockerfile-compile, which is based on
golang:1.25.10).

Wraps the step in the existing `agent` docker-compose service via the
docker-compose plugin, matching how .buildkite/steps/tests.sh is wired.
Side benefit: BUILDKITE_TEST_ENGINE_API_ACCESS_TOKEN is already declared
on this service in .buildkite/docker-compose.yml, removing the
bare-agent token-availability unknown flagged in the PR description.

propagate-environment: true forwards the step-level
BUILDKITE_TEST_ENGINE_* env vars into the container.
@gchan gchan added the internal Non-user facing, internal change. label May 14, 2026
Step now runs inside the `agent` docker-compose service which is
linux-only (golang:1.25.10 base image). Drop OS detection.

Drop the ${VAR:-default} fallbacks for BUILDKITE_TEST_ENGINE_* env vars
-- they're all set at the pipeline step level in pipeline.yml, so the
script-level defaults were belt-and-braces.

Fold the multi-line curl and bktec invocations onto single lines.

83 -> 58 lines, no behaviour change. Arch detection stays -- the
compose service still runs on both amd64 and arm64 runners.
@gchan gchan marked this pull request as ready for review May 14, 2026 23:07
@gchan gchan requested review from a team as code owners May 14, 2026 23:07
@gchan
Copy link
Copy Markdown
Contributor Author

gchan commented May 14, 2026

Verified metadata is being collected.

@gchan gchan requested a review from a team May 14, 2026 23:11
Copy link
Copy Markdown
Contributor

@buildkate buildkate left a comment

Choose a reason for hiding this comment

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

LGMT. Will the be reverted once the model has been trained or is this a permanent fixture?

@gchan
Copy link
Copy Markdown
Contributor Author

gchan commented May 14, 2026

LGMT. Will the be reverted once the model has been trained or is this a permanent fixture?

Likely permanent-ish as we would like to collect new data for periodic re-training.

@gchan gchan merged commit e793ea8 into main May 14, 2026
4 checks passed
@gchan gchan deleted the te-5828-bktec-plan-collect-commit-metadata branch May 14, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Non-user facing, internal change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants