Skip to content

Extract embedded PowerShell from pester-tests.yml and extension-package.yml into testable scripts #736

@WilliamBerryiii

Description

@WilliamBerryiii

Summary

Two GitHub Actions workflows contain embedded PowerShell logic that cannot be unit-tested in isolation. This issue tracks extracting that logic into standalone scripts with full Pester test coverage.

Target Workflows

Workflow Step Embedded Logic
pester-tests.yml Get changed PowerShell files Git diff parsing, source-to-test mapping, skill directory discovery
extension-package.yml Discover collection manifests YAML parsing, maturity filtering, matrix JSON generation

Approach

  1. Extract each embedded block into a standalone .ps1 script following the reference pattern from Invoke-PSScriptAnalyzer.ps1 (shebang, copyright, Requires, CmdletBinding, regions, script guard).
  2. Use CIHelpers.psm1 (Set-CIEnv, Set-CIOutput) instead of raw $env:GITHUB_OUTPUT file I/O.
  3. Write Pester 5.7.1 tests for each extracted script using GitMocks.psm1 patterns.
  4. Replace workflow embedded blocks with thin wrapper calls to the new scripts.

Deliverables

  • scripts/tests/Get-ChangedTestFiles.ps1 — extracted changed-file detection logic
  • scripts/tests/Get-ChangedTestFiles.Tests.ps1 — Pester tests for changed-file detection
  • scripts/extension/Find-CollectionManifests.ps1 — extracted collection manifest discovery
  • scripts/tests/extension/Find-CollectionManifests.Tests.ps1 — Pester tests for manifest discovery
  • Updated pester-tests.yml with thin wrapper call
  • Updated extension-package.yml with thin wrapper call
  • All validation passes (npm run lint:all, npm run test:ps)

Metadata

Metadata

Labels

enhancementNew feature or requesttestingTest infrastructure and test files

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions