test-label-analyzer: add filter expressions command for Ginkgo flags#4829
test-label-analyzer: add filter expressions command for Ginkgo flags#4829Maximus-08 wants to merge 3 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Maximus-08. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
buildExpressions, you escape double quotes but wrap values in single quotes; consider also handling embedded single quotes (or switching to double-quoted literals) so generated expressions remain syntactically valid when names/reasons contain'. - The new
expressionscommand currently uses an explicitlen(args) < 1check; you may want to leverage cobra'sArgs: cobra.ExactArgs(1)to make argument validation and usage messages more consistent with other commands. - The header in
expressions_test.gouses a 2026 copyright year, which is inconsistent withexpressions.goand the rest of the project; aligning the year will avoid future confusion.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `buildExpressions`, you escape double quotes but wrap values in single quotes; consider also handling embedded single quotes (or switching to double-quoted literals) so generated expressions remain syntactically valid when names/reasons contain `'`.
- The new `expressions` command currently uses an explicit `len(args) < 1` check; you may want to leverage cobra's `Args: cobra.ExactArgs(1)` to make argument validation and usage messages more consistent with other commands.
- The header in `expressions_test.go` uses a 2026 copyright year, which is inconsistent with `expressions.go` and the rest of the project; aligning the year will avoid future confusion.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
Adds a new test-label-analyzer filter expressions subcommand intended to turn matching-tests.json (from filter stats matching-tests) into ready-to-use Ginkgo flag expressions for text filtering and label filtering.
Changes:
- Introduces
filter expressionscobra command with--output-mode=text|json. - Implements
buildExpressions()to deduplicate test names and reasons and join them into OR expressions. - Adds unit tests for
buildExpressions().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| robots/test-label-analyzer/cmd/filter/expressions.go | Adds the new filter expressions command and expression-generation logic. |
| robots/test-label-analyzer/cmd/filter/expressions_test.go | Adds unit tests for the expression generation helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Add 'filter expressions' subcommand that reads matching-tests JSON and outputs --filter/--skip (v1) and --label-filter (v2) strings. Supports text and json output modes. Implement copilot suggestions Signed-off-by: Avnish Jaltare <avnishjaltare8@gmail.com>
2d79164 to
e06a617
Compare
Signed-off-by: Avnish Jaltare <avnishjaltare8@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds a new filter expressions subcommand to test-label-analyzer that converts matching-tests JSON into ready-to-paste Ginkgo v1 --filter/--skip and Ginkgo v2 --label-filter expressions, with optional JSON output.
Changes:
- Introduces
filter expressions <matching-tests.json>Cobra command and--output-mode=text|json. - Implements expression construction with deduplication + stable ordering.
- Adds unit tests for
buildExpressions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| robots/test-label-analyzer/cmd/filter/expressions.go | Adds the expressions command, reads matching-tests JSON, and renders Ginkgo v1/v2 expressions (text or JSON). |
| robots/test-label-analyzer/cmd/filter/expressions_test.go | Adds unit coverage for buildExpressions with empty + basic input. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…Tighten label-filter generation. Expand tests to cover deduplication, regex escaping, invalid label reasons. Signed-off-by: Avnish Jaltare <avnishjaltare8@gmail.com>
|
There has been no activity on this PR for 45 days. What you can do:
/lifecycle stale |
What this PR does / why we need it:
Implements the “generate strings for Ginkgo flags” use case from the test-label-analyzer design:
test-label-analyzer filter expressions <matching-tests.json>test-label-analyzer filter stats matching-tests(same format as existingmatching-testsoutput).--filter,--skip, and--label-filter(Ginkgo v1 text filters and v2 label filter).--output-mode=text|json(defaulttext).Typical flow: run
stats→filter stats matching-tests→filter expressionsto get strings to pass toginkgo --filter/ginkgo --label-filterfor the same set of tests.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #2679 (partial — filter string generation)
Special notes for your reviewer:
robots/test-label-analyzer/cmd/filter/expressions.goandexpressions_test.go. No changes to existing commands.Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note: