Fail the build on failed HQRM blocks and containers#179
Conversation
Fail_Build_If_HQRM_Tests_Failed gated only on FailedCount, but a Pester 5 discovery/container failure (for example an empty -ForEach) does not increase FailedCount. It sets FailedContainersCount/FailedBlocksCount and marks the run Result as 'Failed', so the build wrongly passed as green. Gate on the Result property, which already accounts for failed tests, blocks and containers. This matches the container-aware check already used in the Invoke_HQRM_Tests task. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
WalkthroughThe ChangesPester Result-based build gating
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
source/tasks/Fail_Build_If_HQRM_Tests_Failed.build.ps1 (1)
109-110: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueLine exceeds 120-character guideline.
Line 109 is roughly 131 characters. Consider breaking the message string across lines.
As per path instructions, PowerShell files should "Try to limit lines to 120 characters".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@source/tasks/Fail_Build_If_HQRM_Tests_Failed.build.ps1` around lines 109 - 110, The $assertMessage assignment in Fail_Build_If_HQRM_Tests_Failed.build.ps1 exceeds the 120-character guideline; split the long formatted string across multiple lines while keeping the same Pester failure message and formatting logic in the $assertMessage construction.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@source/tasks/Fail_Build_If_HQRM_Tests_Failed.build.ps1`:
- Around line 109-110: The $assertMessage assignment in
Fail_Build_If_HQRM_Tests_Failed.build.ps1 exceeds the 120-character guideline;
split the long formatted string across multiple lines while keeping the same
Pester failure message and formatting logic in the $assertMessage construction.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 746fabb7-59ab-40ce-a3a5-31d6c6b6aa56
📒 Files selected for processing (2)
CHANGELOG.mdsource/tasks/Fail_Build_If_HQRM_Tests_Failed.build.ps1
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #179 +/- ##
===================================
Coverage 79% 79%
===================================
Files 43 43
Lines 569 569
===================================
Hits 452 452
Misses 117 117 🚀 New features to boost your workflow:
|
johlju
left a comment
There was a problem hiding this comment.
@johlju reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on nohwnd).
|
@dan-hughes fyi I push this in a full release shortly, if there are any problems out there you know why 🙂 |
Pull Request (PR) description
Fail_Build_If_HQRM_Tests_Failedgated the build onFailedCountonly:FailedCountonly counts failed tests. A Pester 5 discovery/container failure — for example aDescribe/Contextwith an empty or$null-ForEach, or a parse error in a test file — fails during discovery and never runs a test. It setsFailedContainersCount/FailedBlocksCountand marks the runResultasFailed, but leavesFailedCountat0. The gate therefore passed and the build went green even though HQRM testing had actually failed. (This is the same class of failure that recently slipped through in dbachecks.)This PR gates on the run
Resultinstead, which already accounts for failed tests, blocks and containers:This mirrors the container-aware check already present in
Invoke_HQRM_Tests.build.ps1(if ($script:testResults.Result -eq 'Failed') { throw ... }); the separateFail_Build_If_HQRM_Tests_Failedgate task simply had not been updated to match. The repository already requires Pester-MinimumVersion 5.1, soResultis always present and no Pester 4 fallback is needed. The assertion message now also reports the failed block and container counts to make such failures easier to diagnose.This Pull Request (PR) fixes the following issues
None
Task list
This change is