Skip to content

Run only affected test apps in pull request builds - #14630

Open
Don Syme (dsyme) wants to merge 6 commits into
microsoft:mainfrom
dsyme:ci/pr-test-selection
Open

Don Syme (dsyme) wants to merge 6 commits into
microsoft:mainfrom
dsyme:ci/pr-test-selection

Conversation

@dsyme

@dsyme Don Syme (dsyme) commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #14628. Part of #14597.

What changed

  • Build on the churn-based proposal analysis merged in Log churn-based test proposals without skipping tests #13565 rather than maintaining a second dependency selector and Git-diff implementation.
  • Add an optional ApplySelection switch to Get-SelectedTestApps. Invoke-PerProjectTestRun enables it only for pull_request events; other events retain upstream logging-only behavior and run the original full bucket.
  • Reuse upstream Get-ChangedFilesForCI -CompareWithPullRequestMerge, including verified tested-merge comparison, shallow-checkout support and both paths for renamed files.
  • Preserve candidate dispatch order, full-run fallbacks and the mandatory Tests-NewObjects-Internal selection. A known empty proposal skips dispatch, writes a successful per-container completion marker, and lets subsequent app hooks reuse that result instead of repeating discovery and impact analysis.
  • Setting enableChurnBasedTesting to false or leaving it absent bypasses selection and runs the full bucket, including on PRs.

Safety and scope

Unknown impact and AL-Go full-build patterns retain all tests. Merge queue, push, schedule and workflow-dispatch test selection remain unchanged. The selector only changes test workloads on the GitHub-BCAppsPL self-hosted pool; it does not directly reduce GitHub-hosted job-minutes. This PR changes build/ scripts, so its own run matches the full-build fallback and does not demonstrate the savings. No coverage change from #14583 is included.

Savings estimate (self-hosted; sensitivity only)

In the frozen baseline week, 279 PR runs whose current PR file lists touched src/Apps without matching a full-build pattern used about 850,258 self-hosted Unit Tests job-min/day. A 10%-25% reduction in aggregate test-job duration for this eligible cohort would correspond to about 85,000-213,000 self-hosted job-min/day. This is a sensitivity scenario, not a forecast or measured saving: test selection counts do not map directly to job duration, the historical classification uses current PR file lists rather than each run’s exact diff, and the existing probes also changed the country matrix under #14631, so they cannot isolate this PR’s effect. No direct hosted saving is claimed.

Validation

  • Pester 5.7.1, BuildOptimization and ParallelTestExecution suites: 181 passed, 5 failed. The same five failures were reproduced on unchanged main: two Linux shallow-clone URI cases, a Windows-drive path case, a project-script path case and a connector-inventory assertion. All changed-selection tests passed.
  • After caching the known-empty selection, the focused ParallelTestExecution suite passed 112/112; it verifies repeated hooks reuse the marker and avoid re-running discovery.
  • All edited PowerShell files parse successfully. PSScriptAnalyzer reports no errors; existing module BOM warnings remain.
  • Container calls are mocked; no local Business Central build or container test execution was performed. Windows CI remains the platform validation.

Re-wires the BuildOptimization test selection (microsoft#7392) that was dropped when
test projects moved to Invoke-PerProjectTestRun, and computes PR changes from
the PR merge commit so base-branch changes missing from a stale PR branch are
no longer treated as PR changes. Non-PR events still run every test app.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme
Don Syme (dsyme) requested a review from a team November 26, 2026 18:30
@github-actions github-actions Bot added Build: scripts & configs Build scripts and configuration files From Fork Pull request is coming from a fork labels Nov 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Issue #14628 is not valid. Please make sure you link an issue that exists, is open and is approved.

@github-actions github-actions Bot added Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction Team: Other GitHub request for other area than SCM, Finance or Integration labels Nov 26, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread build/scripts/BuildOptimization.psm1 Resolved
Don Syme (dsyme) and others added 2 commits November 27, 2026 12:24
Reuse upstream churn analysis and tested-merge diff logic. Apply test selection only in PR builds while retaining logging-only behavior elsewhere, full-run fallbacks and mandatory NewObjects tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Include the newly landed Verifactu changes without further changes to the tested PowerShell resolution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Persist a successful completion marker for known-empty PR test selection so subsequent per-app hooks reuse the result rather than repeating discovery and impact analysis.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Restore comment help on Get-CachedTestRunResult and document the per-container state path and empty-selection marker helpers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch was successfully deployed

1 active (outdated) deployment
triage — 043ee7d3 Deployed Nov 26, 2026 by dsyme via Classify team ownership #12241
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build: scripts & configs Build scripts and configuration files From Fork Pull request is coming from a fork Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction Team: Other GitHub request for other area than SCM, Finance or Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run only affected test apps on PR builds

2 participants