Skip to content

test-label-analyzer: add filter expressions command for Ginkgo flags#4829

Open
Maximus-08 wants to merge 3 commits into
kubevirt:mainfrom
Maximus-08:test-label-analyzer-filter-expressions
Open

test-label-analyzer: add filter expressions command for Ginkgo flags#4829
Maximus-08 wants to merge 3 commits into
kubevirt:mainfrom
Maximus-08:test-label-analyzer-filter-expressions

Conversation

@Maximus-08
Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Implements the “generate strings for Ginkgo flags” use case from the test-label-analyzer design:

  • New subcommand: test-label-analyzer filter expressions <matching-tests.json>
  • Input: JSON produced by test-label-analyzer filter stats matching-tests (same format as existing matching-tests output).
  • Output (default text): Lines suitable for --filter, --skip, and --label-filter (Ginkgo v1 text filters and v2 label filter).
  • Flag: --output-mode=text|json (default text).

Typical flow: run statsfilter stats matching-testsfilter expressions to get strings to pass to ginkgo --filter / ginkgo --label-filter for 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:

  • New files: robots/test-label-analyzer/cmd/filter/expressions.go and expressions_test.go. No changes to existing commands.
  • Deduplicates test names (for v1 filter) and category reasons (for v2 label-filter). Output format is intentionally simple (OR of literals).

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:

test-label-analyzer: add `filter expressions` subcommand to generate Ginkgo --filter/--skip and --label-filter strings from matching-tests JSON.

Copilot AI review requested due to automatic review settings March 15, 2026 21:48
@kubevirt-bot kubevirt-bot added the dco-signoff: yes Indicates the PR's author has DCO signed all their commits. label Mar 15, 2026
@kubevirt-bot kubevirt-bot requested review from dollierp and enp0s3 March 15, 2026 21:48
@kubevirt-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tiraboschi for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot
Copy link
Copy Markdown
Contributor

Hi @Maximus-08. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

Instructions 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.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

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 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 expressions cobra 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.

Comment thread robots/test-label-analyzer/cmd/filter/expressions.go Outdated
Comment thread robots/test-label-analyzer/cmd/filter/expressions.go
Comment thread robots/test-label-analyzer/cmd/filter/expressions.go
Comment thread robots/test-label-analyzer/cmd/filter/expressions.go
Comment thread robots/test-label-analyzer/cmd/filter/expressions_test.go Outdated
Comment thread robots/test-label-analyzer/cmd/filter/expressions_test.go Outdated
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>
@Maximus-08 Maximus-08 force-pushed the test-label-analyzer-filter-expressions branch from 2d79164 to e06a617 Compare March 16, 2026 05:21
Signed-off-by: Avnish Jaltare <avnishjaltare8@gmail.com>
@Maximus-08 Maximus-08 requested a review from Copilot March 16, 2026 13:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread robots/test-label-analyzer/cmd/filter/expressions.go
Comment thread robots/test-label-analyzer/cmd/filter/expressions.go
Comment thread robots/test-label-analyzer/cmd/filter/expressions.go
Comment thread robots/test-label-analyzer/cmd/filter/expressions.go
…Tighten label-filter generation. Expand tests to cover deduplication, regex escaping, invalid label reasons.

Signed-off-by: Avnish Jaltare <avnishjaltare8@gmail.com>
@kubevirt-bot
Copy link
Copy Markdown
Contributor

There has been no activity on this PR for 45 days.
To protect limited CI resources, it has been automatically labelled 'stale'.
This PR will automatically rot after an additional 14 days of inactivity, and will be closed shortly after that.

What you can do:

  • If the PR is waiting on you to respond to a question or feedback and/or update the PR, please do so.
  • You can mark the PR as fresh and remove the label with the following command: /remove-lifecycle stale
  • If this PR is safe to close now, please help the project by closing it with: /close
  • If you need attention on this PR from a reviewer, you can raise it on the agenda of the relevant SIG meeting or KubeVirt Community meeting, or ping the kubevirt-dev slack channel.

/lifecycle stale

@kubevirt-bot kubevirt-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test tooling: support long term test migration of Gingko textual labels (v1) to first class labels (v2)

3 participants