Skip to content

[Issue]: Add reusable Pester testing GitHub Actions workflow #194

@WilliamBerryiii

Description

@WilliamBerryiii

Summary

Create a reusable GitHub Actions workflow for running Pester tests, following the established pattern from ps-script-analyzer.yml.

Parent Issue: #190

Requirements

  • Create .github/workflows/pester-tests.yml as reusable workflow
  • Support workflow_call trigger with inputs:
    • soft-fail (boolean, default: false)
    • changed-files-only (boolean, default: true)
  • Install Pester 5.x from PSGallery
  • Run tests using configuration from scripts/tests/pester.config.ps1
  • Upload NUnit XML results as artifact
  • Enable GitHub Actions annotations via Pester's CIFormat

Implementation Details

Workflow Structure

name: Pester Tests

on:
  workflow_call:
    inputs:
      soft-fail:
        description: 'Whether to continue on test failures'
        required: false
        type: boolean
        default: false
      changed-files-only:
        description: 'Only test changed PowerShell files'
        required: false
        type: boolean
        default: true

permissions:
  contents: read

jobs:
  pester:
    name: PowerShell Tests
    runs-on: ubuntu-latest
    # ... steps follow

Key Steps

  1. Checkout with fetch-depth: 0 (needed for git diff in changed-files-only mode)
  2. Install Pester from PSGallery (Install-Module -Name Pester -MinimumVersion 5.0.0)
  3. Run Pester with configuration file
  4. Upload test results artifact (if: always())
  5. Check results and fail job if needed (respecting soft-fail)

Repository Conventions

  • SHA-pinned actions with version comments (e.g., @sha # v4.2.2)
  • persist-credentials: false on checkout
  • permissions: contents: read baseline

Acceptance Criteria

  • Workflow file exists at .github/workflows/pester-tests.yml
  • Workflow triggers on workflow_call only
  • soft-fail and changed-files-only inputs work correctly
  • Pester 5.x installs successfully on ubuntu-latest
  • Test results uploaded as pester-test-results artifact
  • Actions follow SHA-pinning convention with version comments

Dependencies

Estimated Effort

1-2 hours


Additional Context

Reference Implementation

See existing workflow pattern:

  • .github/workflows/ps-script-analyzer.yml - Reusable workflow structure to follow

Related Issues

Metadata

Metadata

Labels

automationCI/CD and automation improvementsenhancementNew 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