Skip to content

[Issue]: Integrate Pester tests into PR validation workflow #195

@WilliamBerryiii

Description

@WilliamBerryiii

Summary

Integrate the Pester testing workflow into the PR validation process so tests run automatically on pull requests that modify PowerShell files.

Parent Issue: #190

Requirements

  • Update .github/workflows/ci.yml (or create dedicated PR workflow)
  • Call the reusable pester-tests.yml workflow
  • Use changed-files-only: true for efficient PR validation
  • Use soft-fail: false to block PRs with failing tests
  • Configure path filtering for **/*.ps1 and **/*.psm1

Implementation Details

Integration Pattern

jobs:
  pester-tests:
    name: PowerShell Tests
    uses: ./.github/workflows/pester-tests.yml
    with:
      soft-fail: false
      changed-files-only: true
    if: |
      github.event_name == 'pull_request' && 
      (contains(github.event.pull_request.changed_files, '.ps1') ||
       contains(github.event.pull_request.changed_files, '.psm1'))

Alternative: Path Filter Job

jobs:
  changes:
    runs-on: ubuntu-latest
    outputs:
      powershell: ${{ steps.filter.outputs.powershell }}
    steps:
      - uses: dorny/paths-filter@... # SHA-pinned
        id: filter
        with:
          filters: |
            powershell:
              - '**/*.ps1'
              - '**/*.psm1'
              - 'scripts/tests/**'

  pester-tests:
    needs: changes
    if: needs.changes.outputs.powershell == 'true'
    uses: ./.github/workflows/pester-tests.yml

Acceptance Criteria

  • PR workflow calls pester-tests.yml for PowerShell changes
  • Tests block PR merge on failure (soft-fail: false)
  • Only runs when .ps1 or .psm1 files change
  • Check appears in PR status checks
  • Works with existing CI workflow structure

Dependencies

Estimated Effort

30 minutes - 1 hour


Additional Context

Reference Files

  • .github/workflows/ci.yml - Existing CI workflow to integrate with
  • .github/workflows/ps-script-analyzer.yml - Example of reusable workflow integration

Related Issues

Metadata

Metadata

Labels

enhancementNew feature or requestgithub-actionsGitHub Actions workflowsworkflowsGitHub Actions workflows

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions