Skip to content

Add --tag option to set tag for a run #530

Open
nprizal wants to merge 4 commits into
mainfrom
te-6027-add-upload-tags-option-to-bktec
Open

Add --tag option to set tag for a run #530
nprizal wants to merge 4 commits into
mainfrom
te-6027-add-upload-tags-option-to-bktec

Conversation

@nprizal
Copy link
Copy Markdown
Contributor

@nprizal nprizal commented Jun 3, 2026

Summary

  • Adds --tag flag and BUILDKITE_TEST_ENGINE_TAGS env var to bktec run to tag the run when uploading to Test Engine
  • Tags are key=value pairs sent as tags[key]=value multipart fields in the upload body
  • Brings feature parity with test-collector-buildkite-plugin for upload-level tagging

Usage

# CLI flags (repeatable)
bktec run --tag env=production --tag region=us-east-1

# Environment variable (comma-separated)
export BUILDKITE_TEST_ENGINE_TAGS="env=production,region=us-east-1"

Notes for reviewer

  • The comma-split in the flag Action is needed because DisableSliceFlagSeparator: true on the run command prevents the CLI library from splitting env var values automatically. There's no per-flag override for this in urfave/cli/v3.
  • Parsing and validation happen in the flag's Action callback in cli.go, not in main.go.
  • The README includes an "Upload test results to Test Engine" section. This overlaps with changes in te-6006-update-bktec-docs — a merge conflict is expected there, just keep whichever version includes the --upload-tags docs.

Closes TE-6027

Adds support for upload-level tagging when uploading test results to
Test Engine, bringing feature parity with test-collector-buildkite-plugin.

Tags are passed as key=value pairs via --upload-tags (repeatable) or
BUILDKITE_TEST_ENGINE_UPLOAD_TAGS (comma-separated). They are sent as
tags[key]=value fields in the multipart upload body.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nprizal nprizal requested a review from a team as a code owner June 3, 2026 02:15
@pda
Copy link
Copy Markdown
Member

pda commented Jun 3, 2026

bktec run --upload-tags env=production --upload-tags region=us-east-1

The plural on repeated --upload-tags bugs me a bit. If each option takes one tag, then --upload-tag perhaps is better?

bktec run --upload-tag env=production --upload-tag region=us-east-1

And further, I'm not sure we need to specify that it's an upload tag here. They're just tags that end up on all the executions. So maybe just --tag?

bktec run --tag env=production --tag region=us-east-1

That'd be my preference ☝🏼

Keep BUILDKITE_TEST_ENGINE_UPLOAD_TAGS env var plural to match convention
of other multi-value env vars.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nprizal nprizal requested a review from malclocke June 3, 2026 05:25
@nprizal
Copy link
Copy Markdown
Contributor Author

nprizal commented Jun 3, 2026

And further, I'm not sure we need to specify that it's an upload tag here. They're just tags that end up on all the executions. So maybe just --tag?

bktec run --tag env=production --tag region=us-east-1

Will people confuse this as "run tests that has these tags"? We have tag-filters for pytest that does that, so I use upload-tags to avoid confusion. Also, in Rspec --tag is used to filter tests with specific tags.

nprizal and others added 2 commits June 4, 2026 10:05
@nprizal nprizal changed the title Add --upload-tags option to bktec Add --tag option to bktec Jun 3, 2026
@nprizal nprizal changed the title Add --tag option to bktec Add --tag to set tag for a run Jun 3, 2026
@nprizal nprizal changed the title Add --tag to set tag for a run Add --tag option to set tag for a run Jun 3, 2026
@nprizal nprizal requested a review from buildsworth-bk June 4, 2026 00:52
Copy link
Copy Markdown

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Choose a reason for hiding this comment

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

Small, focused addition and the upload path looks correct — tags[key]=value mirrors the existing run_env[...] multipart fields, and the env-var binding test plus the multipart-body test cover the main paths.

One non-blocking note inline about comma handling in tag values.

The one open item is really the flag name (--tag vs something more specific) — you and @pda are already on that thread, so I'll leave that call to you two rather than pile on.

Note: this PR has no risk: label.

Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:

Download the buildsworth logs from build 480, then answer my questions about the findings.

Comment thread cli.go
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.

2 participants