Skip to content

test(scripts): add Pester tests for Invoke-YamlLint.ps1#326

Merged
WilliamBerryiii merged 5 commits intomainfrom
test/invoke-yamllint-coverage
Jan 27, 2026
Merged

test(scripts): add Pester tests for Invoke-YamlLint.ps1#326
WilliamBerryiii merged 5 commits intomainfrom
test/invoke-yamllint-coverage

Conversation

@WilliamBerryiii
Copy link
Copy Markdown
Member

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.

  • Created 37 unit tests organized across 9 Describe blocks covering all code paths
  • Implemented extensive mocking of actionlint binary and LintingHelpers module functions
  • Tested both all-files and changed-files-only modes with proper filtering
  • Validated JSON parsing for null, empty, single, multiple, and malformed outputs
  • Verified GitHub Actions outputs, environment variables, annotations, and step summaries

Related Issue(s)

N/A

Type of Change

Select all that apply:

Code & Documentation:

  • 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)

Other:

  • Script/automation (.ps1, .sh, .py)
  • Other (please describe):

Sample Prompts (for AI Artifact Contributions)

N/A - This is a test file contribution.

Testing

  • Executed Invoke-Pester with code coverage analysis
  • All 37 tests passed
  • Achieved 100% code coverage (target: 80%)
  • Coverage report generated at logs/coverage-yamllint.xml

Checklist

Required Checks

  • Documentation is updated (if applicable)
  • Files follow existing naming conventions
  • Changes are backwards compatible (if applicable)
  • Tests added for new functionality (if applicable)

AI Artifact Contributions

N/A

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
  • PowerShell analysis: npm run lint:ps

Security Considerations

  • This PR does not contain any sensitive or NDA information
  • Any new dependencies have been reviewed for security issues
  • Security-related scripts follow the principle of least privilege

Additional Notes

Test file location: scripts/tests/linting/Invoke-YamlLint.Tests.ps1

Test coverage areas:

Area Tests
Parameter Validation 3
Tool Availability 3
File Discovery 8
JSON Parsing 5
Issue Processing 3
Output Generation 3
GitHub Actions Integration 7
Exit Code Handling 5

🧪 - Generated by Copilot

@WilliamBerryiii WilliamBerryiii requested a review from a team as a code owner January 27, 2026 04:15
Copilot AI review requested due to automatic review settings January 27, 2026 04:15
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 27, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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
Copilot AI review requested due to automatic review settings January 27, 2026 04:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 1 out of 1 changed files in this pull request and generated no new comments.

- create global stub function for actionlint to enable mocking when binary not installed
- cleanup stub in AfterAll block

🔧 - Generated by Copilot
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.60%. Comparing base (35c4417) to head (ee0ebd7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
pester 40.60% <ø> (+2.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings January 27, 2026 19:07
@WilliamBerryiii WilliamBerryiii merged commit fa17f2b into main Jan 27, 2026
20 checks passed
@WilliamBerryiii WilliamBerryiii deleted the test/invoke-yamllint-coverage branch January 27, 2026 19:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 1 out of 1 changed files in this pull request and generated 8 comments.

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

4 participants