test(scripts): add Pester tests for Invoke-YamlLint.ps1#326
Merged
WilliamBerryiii merged 5 commits intomainfrom Jan 27, 2026
Merged
test(scripts): add Pester tests for Invoke-YamlLint.ps1#326WilliamBerryiii merged 5 commits intomainfrom
WilliamBerryiii merged 5 commits intomainfrom
Conversation
…% coverage 🧪 - Generated by Copilot
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive Pester 5.x unit tests for the Invoke-YamlLint.ps1 script, which validates GitHub Actions workflow files using actionlint. The test suite provides extensive coverage of all script functionality including parameter handling, file discovery, JSON output parsing, GitHub Actions integration, and error scenarios.
Changes:
- Added 37 unit tests organized across 9 Describe blocks covering parameter validation, tool availability checks, file discovery modes, JSON parsing edge cases, issue processing, output generation, GitHub Actions integration, and exit code handling
- Implemented comprehensive mocking for actionlint binary and LintingHelpers module functions
- Created tests for both all-files and changed-files-only modes with proper filtering
- add Write-Verbose statements to 3 empty catch blocks 🔧 - Generated by Copilot
🔧 - Generated by Copilot
- create global stub function for actionlint to enable mocking when binary not installed - cleanup stub in AfterAll block 🔧 - Generated by Copilot
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #326 +/- ##
==========================================
+ Coverage 38.30% 40.60% +2.30%
==========================================
Files 15 15
Lines 2864 2864
==========================================
+ Hits 1097 1163 +66
+ Misses 1767 1701 -66
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
katriendg
approved these changes
Jan 27, 2026
This was referenced Jan 27, 2026
WilliamBerryiii
added a commit
that referenced
this pull request
Jan 27, 2026
) ## Description This PR fixes incorrect type assertions in the Invoke-YamlLint Pester tests. The `Set-GitHubOutput` function accepts string parameters, but the test assertions were comparing against integer values instead of strings. This caused test failures when validating the correct behavior of the YAML linting script. - fix(scripts): Changed 8 `Set-GitHubOutput` value assertions from integers to quoted strings - `$Value -eq 0` → `$Value -eq '0'` - `$Value -eq 1` → `$Value -eq '1'` - `$Value -eq 2` → `$Value -eq '2'` ## Related Issue(s) Fixes #330 ## Type of Change Select all that apply: **Code & Documentation:** - [x] Bug fix (non-breaking change fixing an issue) - [ ] New feature (non-breaking change adding functionality) - [ ] Breaking change (fix or feature causing existing functionality to change) - [ ] Documentation update **Infrastructure & Configuration:** - [ ] GitHub Actions workflow - [ ] Linting configuration (markdown, PowerShell, etc.) - [ ] Security configuration - [ ] DevContainer configuration - [ ] Dependency update **AI Artifacts:** - [ ] Reviewed contribution with `prompt-builder` agent and addressed all feedback - [ ] Copilot instructions (`.github/instructions/*.instructions.md`) - [ ] Copilot prompt (`.github/prompts/*.prompt.md`) - [ ] Copilot agent (`.github/agents/*.agent.md`) > **Note for AI Artifact Contributors**: > > - **Agents**: Research, indexing/referencing other project (using standard VS Code GitHub Copilot/MCP tools), planning, and general implementation agents likely already exist. Review `.github/agents/` before creating new ones. > - **Model Versions**: Only contributions targeting the **latest Anthropic and OpenAI models** will be accepted. Older model versions (e.g., GPT-3.5, Claude 3) will be rejected. > - See [Agents Not Accepted](../docs/contributing/custom-agents.md#agents-not-accepted) and [Model Version Requirements](../docs/contributing/ai-artifacts-common.md#model-version-requirements). **Other:** - [x] Script/automation (`.ps1`, `.sh`, `.py`) - [ ] Other (please describe): ## Testing - Verified all 8 assertions updated from integer to string comparisons - PowerShell linting passed via `npm run lint:ps` ## Checklist ### Required Checks - [ ] Documentation is updated (if applicable) - [x] Files follow existing naming conventions - [x] Changes are backwards compatible (if applicable) - [ ] Tests added for new functionality (if applicable) ### AI Artifact Contributions N/A - This PR does not include AI artifact contributions. ### Required Automated Checks The following validation commands must pass before merging: - [ ] Markdown linting: `npm run lint:md` - [ ] Spell checking: `npm run spell-check` - [ ] Frontmatter validation: `npm run lint:frontmatter` - [ ] Link validation: `npm run lint:md-links` - [x] PowerShell analysis: `npm run lint:ps` ## Security Considerations - [x] This PR does not contain any sensitive or NDA information - [x] Any new dependencies have been reviewed for security issues - [x] Security-related scripts follow the principle of least privilege ## Additional Notes This fix addresses code review feedback from PR #326 where the copilot-pull-request-reviewer identified that `Set-GitHubOutput` accepts string parameters, making the integer comparisons technically incorrect. 🐛 - Generated by Copilot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added comprehensive Pester 5.x unit tests for
Invoke-YamlLint.ps1, achieving 100% code coverage. The test suite validates all script functionality including parameter handling, tool availability checks, file discovery modes, JSON parsing edge cases, GitHub Actions integration, and exit code behavior.actionlintbinary andLintingHelpersmodule functionsRelated Issue(s)
N/A
Type of Change
Select all that apply:
Code & Documentation:
Infrastructure & Configuration:
AI Artifacts:
prompt-builderagent and addressed all feedback.github/instructions/*.instructions.md).github/prompts/*.prompt.md).github/agents/*.agent.md)Other:
.ps1,.sh,.py)Sample Prompts (for AI Artifact Contributions)
N/A - This is a test file contribution.
Testing
Invoke-Pesterwith code coverage analysislogs/coverage-yamllint.xmlChecklist
Required Checks
AI Artifact Contributions
N/A
Required Automated Checks
The following validation commands must pass before merging:
npm run lint:mdnpm run spell-checknpm run lint:frontmatternpm run lint:md-linksnpm run lint:psSecurity Considerations
Additional Notes
Test file location:
scripts/tests/linting/Invoke-YamlLint.Tests.ps1Test coverage areas:
🧪 - Generated by Copilot