Skip to content

Make the test selector comment more readable with reasoning - #18376

Merged
radical merged 3 commits into
mainfrom
ankj/select-tests-comment-grouping
Jun 22, 2026
Merged

Make the test selector comment more readable with reasoning#18376
radical merged 3 commits into
mainfrom
ankj/select-tests-comment-grouping

Conversation

@radical

@radical radical commented Jun 20, 2026

Copy link
Copy Markdown
Member

What this changes

The Tests selector PR comment posted by tools/SelectTests (the
selective-CI advisory comment) was hard to read. It listed every selected
test project on its own line with the selection reason appended, so when one
change fans out across the project graph the same reason repeats on dozens
of lines
. A reviewer couldn't tell at a glance which projects and jobs run,
or which change drove the bulk of the selection.

Example — the old comment had 46 near-identical lines like:

- `Aspire.Hosting.Azure.Kusto.Tests` — via graph from `tests/Aspire.Hosting.Tests/Dashboard/DashboardServiceHostTests.cs`
- `Aspire.Hosting.Blazor.Tests` — via graph from `tests/Aspire.Hosting.Tests/Dashboard/DashboardServiceHostTests.cs`
- … 30 more identical reasons …

The fix

Restructure the comment into what runs, then how it was chosen:

  • Lead with what runs — a flat list of selected test projects, then a
    flat list of selected jobs. Full impact is visible up front, even with many
    changed files.
  • Then how it was chosen — collapsed by default inside a <details>
    block (the heading is its <summary>), so the comment opens on the lists
    above and a reviewer expands only when they want the rationale. Inside,
    the selected projects are grouped under each trigger (a changed file and
    its graph fan-out
    under one heading, an affected project, or a derived
    test). Each reason is stated once instead of per project; large fan-outs
    collapse into a nested <details>; a per-job table names what triggered
    each job. A headline ⚠️ call-out names the single change driving a large
    share of a big selection.

Call-outs

  • Full attribution is preserved — a project selected by several triggers
    appears under each group, so no "why" is dropped.
  • Updated the CLI / Layer 1 / comment-script tests (including the threshold
    and collapse paths) and docs/ci/test-trigger-selector-design.md.
  • No change to the selection logic, job booleans, or one-comment-per-commit
    posting behavior — only the comment body layout.

Supersedes #18368 (which was opened from a fork, so its selection comment
couldn't post).

Copilot AI review requested due to automatic review settings June 20, 2026 17:49
@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://github.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18376

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18376"

@github-actions

This comment has been minimized.

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

Pull request overview

This PR restructures the advisory "Tests selector" PR comment emitted by the selective-CI tool (tools/SelectTests). Previously the comment repeated the same selection reason on every project line, which became unreadable when one change fanned out across the project graph. The comment now leads with what runs (flat lists of selected jobs and test projects) and then explains how it was chosen by grouping projects under each trigger, collapsing large fan-outs into <details>, and surfacing a headline call-out when one change drives most of the selection. It also makes the comment_selection job gracefully handle the read-only GITHUB_TOKEN on fork PRs (403) by warning and writing the selection to the step summary instead of failing. Selection logic, job booleans, and one-comment-per-commit posting are unchanged.

Changes:

  • Rewrote WriteSelectionComment to render "what runs" first, then a per-trigger rationale (AppendSelectionRationale plus grouping/header/hops/RenderProjectList helpers), replacing the per-line cause suffix.
  • Added fork-PR 403 handling in tests.yml: warn and emit the selection into the job step summary rather than failing the informational job.
  • Updated CLI, Layer 1, and comment-script tests (including a large-fan-out headline/collapse test and a fork-summary test) and the design doc.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/SelectTests/Program.cs Restructured the PR comment body into "what runs" + per-trigger grouping; added grouping/header/hops/render helpers and WriteCommentFile; removed AllCausesSuffix.
.github/workflows/tests.yml comment_selection now catches the fork read-only-token 403, warns with the fork cause, and writes the selection to the step summary.
tests/Infrastructure.Tests/WorkflowScripts/SelectTestsCommentScriptTests.cs Added a fork-403 test asserting no comment/minimize, a warning, and a step-summary fallback containing the selection.
tests/Infrastructure.Tests/WorkflowScripts/select-tests-comment.harness.js Mock harness now captures warnings/summary and can simulate a createComment 403.
tests/Infrastructure.Tests/TestTriggerMap/SelectTestsLayer1IntegrationTests.cs Updated assertions for the new grouped graph rendering.
tests/Infrastructure.Tests/TestTriggerMap/SelectTestsCliTests.cs Updated assertions to the new headings; added a large-fan-out headline/<details> collapse test.
docs/ci/test-trigger-selector-design.md Documented the new comment structure and the fork step-summary fallback.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI review requested due to automatic review settings June 21, 2026 04:06
@github-actions

This comment has been minimized.

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@radical
radical force-pushed the ankj/select-tests-comment-grouping branch from fbfeb4d to 3b6addd Compare June 21, 2026 04:15
@github-actions

This comment has been minimized.

radical and others added 3 commits June 21, 2026 00:24
The selective-CI "Tests selector" comment from tools/SelectTests listed
every selected test project on its own line with the reason appended, so a
single change fanning out across the project graph repeated the same reason
on dozens of lines. A reviewer couldn't see at a glance what runs or which
change drove the bulk of the selection.

Restructure the rendered comment to lead with what runs -- a flat list of
selected jobs and a flat list of selected test projects -- then explain how
it was chosen by grouping the selected projects under each trigger (a changed
file and its graph fan-out under one heading, an affected project, or a
derived test). Each reason is stated once instead of per project, large
fan-outs collapse into a <details> block, a per-job table names what
triggered each job, and a headline call-out flags the single change driving a
large share of a big selection. Full attribution is preserved: a project
selected by several triggers appears under each group.

No change to the selection logic, job booleans, or one-comment-per-commit
posting behavior -- only the comment body layout.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update the comment-rendering tests for the new grouped layout: assert the
"what runs" job/project lists, the per-trigger grouping with every cause
preserved, and the per-job reasons table. Add LargeFanOutEmitsHeadlineAnd-
CollapsesProjectList to cover the headline call-out plus the <details>
collapse threshold for big fan-outs, and MultiHopGraphSelectionAnnotates-
HopCountInComment to verify the hop-count annotation on a multi-hop graph
path (via a GraphRepoFixture that can insert an intermediate project).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update the test-trigger selector design doc to describe the reworked PR
comment: it leads with the flat job/project lists, then groups the selection
under each trigger (with a changed file's graph fan-out collapsed under one
heading), keeps full per-trigger attribution, and adds a per-job reasons
table.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 21, 2026 04:26
@radical
radical force-pushed the ankj/select-tests-comment-grouping branch from 3b6addd to 360f70c Compare June 21, 2026 04:26

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@radical
radical marked this pull request as ready for review June 21, 2026 04:35
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector (audit mode)

The full test matrix and all jobs still run in audit mode. The tests and jobs below are what selective CI would run under enforcement.

1 / 97 test projects · 0 jobs, from 3 changed files.

Selected test projects (1 / 97)

Infrastructure.Tests

Selected jobs (0)

none


How these were chosen — grouped by what changed

🧪 tests/Infrastructure.Tests/TestTriggerMap/SelectTestsCliTests.cs (changed test)
1 directly: Infrastructure.Tests

🧪 tests/Infrastructure.Tests/TestTriggerMap/SelectTestsLayer1IntegrationTests.cs (changed test)
1 directly: Infrastructure.Tests

📄 tools/SelectTests/Program.cs (changed)
1 directly: Infrastructure.Tests

Job reasons

none


Selection computed for commit 360f70c.

@radical
radical requested a review from adamint June 21, 2026 04:51
@radical radical changed the title Group the selective-CI test-selector comment by trigger and lead with what runs Make the test selector comment more readable with reasoning Jun 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@JamesNK JamesNK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clean implementation. The trigger-group inversion, threshold gating, nested <details> rendering, and hop annotations all look correct. Tests directly target the failure modes (revert detection for ordering, collapse, headline, and job-reason table). No issues found.

@radical
radical merged commit 10be133 into main Jun 22, 2026
679 of 682 checks passed
@radical
radical deleted the ankj/select-tests-comment-grouping branch June 22, 2026 05:37
@github-actions github-actions Bot added this to the 13.5 milestone Jun 22, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

docs_optional → build_or_ci_only

No documentation PR is needed for this change.

Triggered signals: none (signal_count = 0; recommendation: "docs_optional").

Allowlist rationale — build_or_ci_only: All 4 changed files are CI infrastructure with no user-facing impact on Aspire end-users:

  • tools/SelectTests/Program.cs — CI test-selection tooling (generates advisory PR comments about test selection; not a user-facing Aspire feature)
  • tests/Infrastructure.Tests/TestTriggerMap/SelectTestsCliTests.cs — tests for CI tooling
  • tests/Infrastructure.Tests/TestTriggerMap/SelectTestsLayer1IntegrationTests.cs — tests for CI tooling
  • docs/ci/test-trigger-selector-design.md — internal CI documentation (not published to microsoft/aspire.dev)

The change restructures the format of the selective-CI PR comment posted by tools/SelectTests — this is an internal contributor-experience improvement with no effect on any feature, API, CLI option, integration, or template documented on the Aspire docs site.

@github-actions github-actions Bot locked and limited conversation to collaborators Jul 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants