Skip to content

Add -ExcludeProduct to Invoke-Maester - #2608

Merged
merill merged 2 commits into
mainfrom
claude/fervent-edison-eh3o9h
Oct 30, 2026
Merged

merill merged 2 commits into
mainfrom
claude/fervent-edison-eh3o9h

Conversation

@merill

@merill merill commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

📑 Description

Adds a first-class way to leave a product out of a run: Invoke-Maester -ExcludeProduct <product> and Selection.ExcludeProduct in the run configuration. Until now, skipping a product meant listing every other product with -Product, or using a 2.x tag such as -ExcludeTag EXO. That tag prints a deprecation warning and misses tests added after 3.0.

Behaviour

  • Matching works like -Product. It matches a test's Product or any of its RelatedProduct values. * wildcards are allowed. Names go through Resolve-MtProductKey, so exo, EXO and exchange all mean the same product.
  • The parameter adds to the config list, the same way -ExcludeTag and -ExcludeTestId do.
  • Exclusion wins over -Product, -TestId and the other selectors. For example, -Product entra -ExcludeProduct entra runs nothing from entra. In the native plan the check sits right after -ExcludeTestId and before -TestId.
  • Excluded tests are reported, not dropped. They appear as NotRun with the new reason code ExcludedByProduct, and ReasonDetail reads Excluded by product (exchange).
  • Tests with no product always run (Pester-format rule). A test with no Product, such as a Pester-format custom test, is never excluded. This is the opposite of -Product, which leaves such tests out. -ExcludeProduct is not counted by Test-MtSelectorInUse, so using it alone adds no ExcludeLine entries for Pester tests. Maester ships no Pester-format tests of its own, so the Pester selection plan needs no exclusion logic.
  • -DryRun and the native path both apply it, through Resolve-MtNativePlan.
  • Excluded services aren't connected. A service that only excluded tests need is no longer read or connected. $neededServices in Invoke-Maester now skips excluded tests.
  • Better 2.x tag warning. When a product tag is used in -ExcludeTag, the warning now suggests the exclude form: -ExcludeTag EXO reports (now -ExcludeProduct exchange) instead of -Product exchange.

Changes

  • Resolve-MtSelection.ps1: new -ExcludeProduct parameter, merged with the config list and resolved to product keys. New Test-MtProductExcluded helper.
  • Resolve-MtNativePlan.ps1: the ExcludedByProduct gate, and the context-aware legacy tag warning.
  • Resolve-MtRunConfig.ps1: default and blank-value cleanup for Selection.ExcludeProduct.
  • Invoke-Maester.ps1: the new parameter with .PARAMETER help and an .EXAMPLE (Invoke-Maester -ExcludeProduct exchange), plus the $neededServices filter.
  • Docs:
    • run-configuration.md: added to the Selection example, the table, the rules, the merge rules and the 2.x tag table.
    • applicability.md: the new reason code and its place in the order of checks.
    • upgrading-from-2x.md: the parameter table and -ExcludeTag EXO → -ExcludeProduct exchange.
    • website/docs/commands/ is generated and left untouched.
  • ExcludedByProduct is added to the golden exporter's list of selection reasons (fixture text updated to match) and to the parity allowlist.
  • The run config has no JSON schema, so there was no schema to update.

Tests

  • TestAttributes.Tests.ps1:
    • exclude one product
    • an alias
    • a wildcard
    • a RelatedProduct match
    • a test with no product is kept
    • the reason code and detail
    • exclusion wins over -Product and -TestId
    • config and parameter lists merge
    • -ExcludeProduct alone does not count as selecting by attribute
    • an end-to-end -DryRun where the native test is ExcludedByProduct and the Pester-format test stays DryRun
    • the legacy tag warning
  • Get-MtPesterSelectionPlan.Tests.ps1: ExcludeProduct = '*' excludes no Pester-format test.

✅ Checks

  • My pull request adheres to the code style of this project.
  • My code requires changes to the documentation.
  • I have updated the documentation as required.
  • The build and unit tests pass after running /powershell/tests/pester.ps1 locally.

ℹ️ Additional Information

Test results

  • ./build/Build-MaesterModule.ps1 and ./build/Test-MaesterModuleOutput.ps1 pass.
  • ./powershell/tests/pester.ps1: 4172 of 4224 tests pass. The changed files' suites all pass: TestAttributes, Get-MtPesterSelectionPlan, Resolve-MtRunConfig, Invoke-Maester.Selection and Golden.
  • The 52 failures are in the AD/LDAP, Connect-Maester, Invoke-MtAzureRequest and Invoke-MtGraphRequestCache tests. They fail the same way on main in this sandbox. The PowerShell Gallery was not reachable from it, so Microsoft.Graph.Authentication was a local stub without the SDK's types. CI with the real modules should be the judge.

Possible follow-up: -ExcludeFeature, -ExcludeArea, -ExcludeSeverity and -ExcludeSuite would follow the same pattern: a list in Resolve-MtSelection, a matcher like Test-MtProductExcluded, one gate in Resolve-MtNativePlan, and one reason code each, or a shared ExcludedByAttribute. They are left out to keep this PR focused. Unlike Product, a Pester-format test does have a Suite, so -ExcludeSuite would need its own rule in the Pester plan.


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Added -ExcludeProduct to exclude tests matching a product name, alias, or wildcard, including tests associated with a related product. Product exclusions take precedence over other selectors; tests without a product, including Pester-format tests, remain eligible.
    • Excluded tests are marked as “Excluded by product,” and services needed only by excluded tests are skipped.
  • Documentation
    • Added guidance for product exclusions in configuration and upgrade documentation, including mappings from legacy tag exclusions. Updated the ASD Essential Eight suite link.

Leaves out the tests whose Product or RelatedProduct matches, with '*'
wildcards and product aliases resolved as for -Product. The parameter adds
to the config list and wins over -Product, -TestId and the other selectors.
Excluded tests are NotRun with the reason code ExcludedByProduct. A test
without a product, such as a Pester-format test, is never excluded, and
-ExcludeProduct alone does not count as selecting by attribute.

Services needed only by excluded tests are no longer read or connected,
and the 2.x tag warning names -ExcludeProduct for -ExcludeTag EXO.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPZKVDDUsNJQCdanp88YaD
@merill
merill requested review from a team as code owners October 30, 2026 00:38
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 2839621 and 00ee066.

Files selected for processing: 1
  • website/src/pages/index.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Walkthrough

The change adds -ExcludeProduct to selection configuration and Invoke-Maester. Matching native tests are marked NotRun with reason ExcludedByProduct; services used only by those tests are omitted. Legacy-tag warnings, tests, fixtures, and documentation are updated. The homepage ASD suite link points to the /docs/next/tests/asd route.

Changes: Product-based test exclusion

Layer / File(s) Summary
Configure and resolve product exclusions
powershell/internal/engine/Resolve-MtRunConfig.ps1, powershell/internal/engine/Resolve-MtSelection.ps1, powershell/public/run/Invoke-Maester.ps1, powershell/tests/functions/engine/TestAttributes.Tests.ps1, website/docs/configuration/run-configuration.md, website/docs/upgrading-from-2x.md
Configuration and the public command accept ExcludeProduct. Resolution combines configured and command-line values and handles aliases, keys, and wildcards. Tests and documentation describe the filter.
Apply exclusions to native tests
powershell/internal/engine/Resolve-MtNativePlan.ps1, powershell/public/run/Invoke-Maester.ps1, powershell/tests/functions/engine/*, powershell/tests/fixtures/golden/selection.json, build/golden/Export-MtGoldenFixture.ps1, build/parity/parity-allowlist.psd1, website/docs/configuration/applicability.md, website/docs/configuration/run-configuration.md
Native planning checks exclusions before ID inclusion and marks matches NotRun with ExcludedByProduct. Tests without product data remain eligible. Services used only by excluded native tests are omitted. Fixtures and documentation include the new reason.
Map legacy tag exclusions
powershell/internal/engine/Resolve-MtNativePlan.ps1, powershell/tests/functions/engine/TestAttributes.Tests.ps1, website/docs/configuration/run-configuration.md, website/docs/upgrading-from-2x.md
Legacy-tag warnings use -ExcludeProduct for excluded tags when a product mapping exists. Tests and migration documentation include the mappings.

ASD homepage link

Layer / File(s) Summary
Update ASD suite destination
website/src/pages/index.js
The ASD suite link now points to /docs/next/tests/asd.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Invoke-Maester
  participant Resolve-MtSelection
  participant Resolve-MtNativePlan
  Invoke-Maester->>Resolve-MtSelection: Pass ExcludeProduct values
  Resolve-MtSelection-->>Invoke-Maester: Return resolved exclusion patterns
  Invoke-Maester->>Resolve-MtNativePlan: Pass selection and native test rows
  Resolve-MtNativePlan-->>Invoke-Maester: Mark matching rows ExcludedByProduct
Loading

Possibly related PRs

Suggested reviewers: f-bader, samerde

Merge Risk: Minimal · up to 00ee0

No actionable merge-blocking issue remains in the reviewed change.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the primary change: adding -ExcludeProduct to Invoke-Maester.
Description check Passed The description follows the required template and explains the behavior, implementation, documentation updates, tests, and known sandbox failures. The issue reference is blank, but this is non-critica…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description follows the required template and explains the behavior, implementation, documentation updates, tests, and known sandbox failures. The issue reference is blank, but this is non-critical.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

codacy-production Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

merill commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Build Docusaurus website 🏗️ (and the Cloudflare Pages preview) is red, but the failure doesn't come from this PR.

Docusaurus reports one broken link on /: /docs/tests/asd. It comes from the ASD suite card that #2552 added to website/src/pages/index.js. /docs/ serves the released version, 2.3.0, and versioned_docs/version-2.3.0/tests has no asd folder. The ASD pages exist only under /docs/next/tests/asd. Every PR built on the current main fails the same way, for example the website builds on #2525 and on feat/github-cis-direct-checks. This PR changes no homepage or test-doc files.

There's no fix PR yet. I've kept it out of this PR to keep it focused. Proposed patch, to revert once 3.0 docs are versioned:

--- a/website/src/pages/index.js
+++ b/website/src/pages/index.js
@@
     count: "14 tests",
-    href: "/docs/tests/asd",
+    href: "/docs/next/tests/asd",
   },

Everything else is green, including build-validation on Ubuntu, macOS and Windows. Entire Gates is waiting on that check and on a reviewer's approval.


Generated by Claude Code

Ports #2611 so the website build passes on this branch.
/docs/ serves the released 2.3.0 docs, which have no ASD pages, so the
link added in #2552 broke the Docusaurus broken-link check. The change
no-ops once main carries #2611.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPZKVDDUsNJQCdanp88YaD
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Deploying maester with  Cloudflare Pages  Cloudflare Pages

Latest commit: 00ee066
Status:🚫  Build failed.

View logs

merill commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up to my earlier comment on the website build: #2611 now has the fix, so I ported it here as 00ee066 (same one-line change to website/src/pages/index.js). That should turn Build Docusaurus website 🏗️ green on this branch. The change becomes a no-op once #2611 merges.


Generated by Claude Code

merill commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

A correction to my earlier comment: the link fix covers Build Docusaurus website 🏗️ but not Cloudflare Pages. Cloudflare fails on this PR at 00ee066, and that failure isn't from this PR either.

The Cloudflare build fails in about a minute, far too fast for a real website build. #2611, which holds only the link fix and passes the GitHub Actions website build, fails Cloudflare Pages the same way (the check completes in 0 seconds). The cause is in the Cloudflare Pages project, not in the repository. The build log is on the Cloudflare dashboard, which needs maintainer access, and I can't re-run the check from here. The repository has no fix for it.


Generated by Claude Code

@merill
merill merged commit 6488831 into main Oct 30, 2026
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants