test(scripts): add Pester test infrastructure and GitMocks module#202
Merged
WilliamBerryiii merged 3 commits intomainfrom Jan 17, 2026
Merged
test(scripts): add Pester test infrastructure and GitMocks module#202WilliamBerryiii merged 3 commits intomainfrom
WilliamBerryiii merged 3 commits intomainfrom
Conversation
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 establishes the foundational Pester 5.x test infrastructure for PowerShell scripts in the HVE-Core repository. It introduces a configurable test execution framework with CI/local modes and a comprehensive mock helper module for isolating Git CLI and GitHub Actions dependencies in tests.
Changes:
- Added Pester configuration script with dual-mode execution (CI with exit codes and NUnit XML output vs. local with detailed verbosity)
- Created GitMocks module with 10 helper functions for mocking Git commands, managing GitHub Actions environment state, and generating test data
- Added fixtures directory placeholder for test data files
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| scripts/tests/pester.config.ps1 | Pester 5.x configuration script with CI/local modes, test result output, and code coverage settings |
| scripts/tests/Mocks/GitMocks.psm1 | Reusable mock helper module providing Git CLI mocks, GitHub Actions environment management, and test data generators |
| scripts/tests/Fixtures/.gitkeep | Placeholder for test fixtures directory |
agreaves-ms
approved these changes
Jan 17, 2026
WilliamBerryiii
added a commit
that referenced
this pull request
Jan 17, 2026
- add standard script header to pester.config.ps1 - add standard module header to GitMocks.psm1 - add .DESCRIPTION to Initialize-GitMocks and Initialize-MockGitHubEnvironment - fix Test-Path mock filter to catch implicit Leaf checks 🔧 - Generated by Copilot
- add pester.config.ps1 with CI and local execution support - add GitMocks.psm1 with 10 exported mock helper functions - create scripts/tests/ directory structure with Mocks and Fixtures 🧪 - Generated by Copilot
- add standard script header to pester.config.ps1 - add standard module header to GitMocks.psm1 - add .DESCRIPTION to Initialize-GitMocks and Initialize-MockGitHubEnvironment - fix Test-Path mock filter to catch implicit Leaf checks 🔧 - Generated by Copilot
cee34c5 to
03269a7
Compare
- remove Created date from pester.config.ps1 header - remove Created date from GitMocks.psm1 header - remove Usage example comment from pester.config.ps1 - remove plan-phase marker from code coverage comment 🧹 - Generated by Copilot
26 tasks
WilliamBerryiii
added a commit
that referenced
this pull request
Jan 17, 2026
…ntegration (#204) # Pull Request ## Description Adds a reusable GitHub Actions workflow for running Pester tests across the repository and integrates it into the PR validation pipeline. This provides standardized PowerShell testing infrastructure that blocks PRs with failing tests. Key features: - **Reusable pester-tests.yml workflow**: - `workflow_call` trigger enables reuse from other workflows via `uses: ./.github/workflows/pester-tests.yml` - Configurable inputs: `soft-fail` (default: false), `changed-files-only` (default: true) - Pester 5.x with `-CI` configuration for CI-optimized output - Artifact upload persists NUnit XML results for 30 days - **PR validation integration**: - Adds `pester-tests` job to pr-validation.yml - Configured with `soft-fail: false` to block PRs with failing tests - Uses `changed-files-only: true` for efficiency - **Security**: - All GitHub Actions are SHA-pinned to prevent supply chain attacks - Uses `persist-credentials: false` on checkout - Minimal `contents: read` permission scope ## Related Issue(s) Closes #194 Closes #195 ## 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:** - [x] GitHub Actions workflow - [ ] Linting configuration (markdown, PowerShell, etc.) - [ ] Security configuration - [ ] DevContainer configuration - [ ] Dependency update **AI Artifacts:** - [ ] Reviewed contribution with `prompt-builder` chatmode and addressed all feedback - [ ] Copilot instructions (`.github/instructions/*.instructions.md`) - [ ] Copilot prompt (`.github/prompts/*.prompt.md`) - [ ] Copilot chatmode (`.github/chatmodes/*.chatmode.md`) **Other:** - [ ] Script/automation (`.ps1`, `.sh`, `.py`) - [ ] Other (please describe): ## Testing - Validated YAML syntax - Confirmed workflow structure matches existing patterns (ps-script-analyzer.yml) - Verified SHA pins match approved versions in tool-checksums.json ## Checklist ### Required Checks - [x] Documentation is updated (if applicable) - [x] Files follow existing naming conventions - [x] Changes are backwards compatible (if applicable) ### AI Artifact Contributions N/A - This PR does not include AI artifacts. ### Required Automated Checks The following validation commands must pass before merging: - [x] Markdown linting: `npm run lint:md` - [x] Spell checking: `npm run spell-check` - [x] Frontmatter validation: `npm run lint:frontmatter` - [x] 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 **Security notes:** - Uses `persist-credentials: false` on checkout to prevent credential leakage - Minimal `contents: read` permission scope at both workflow and job levels - All GitHub Actions are SHA-pinned to prevent supply chain attacks: - `actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8` (v4.2.2) - `actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f` (v4.4.3) ## Additional Notes This workflow builds on the Pester infrastructure established in #202 (pester.config.ps1, GitMocks.psm1). Future PRs will add actual test files that leverage this workflow.
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.
test(scripts): add Pester test infrastructure and GitMocks module
Description
Establishes the foundational Pester 5.x test infrastructure for PowerShell script validation in the HVE-Core repository. This adds a reusable configuration system with CI/local execution modes and a comprehensive mock helper module for Git CLI and GitHub Actions testing scenarios.
pester.config.ps1with dual-mode execution support—CI mode enables exit codes, GithubActions output format, and NUnit XML test results; local mode provides detailed verbosity for interactive debuggingGitMocks.psm1module with 10 exported functions for test isolation:Save-GitHubEnvironment,Restore-GitHubEnvironment,Initialize-MockGitHubEnvironment,Clear-MockGitHubEnvironment,Remove-MockGitHubFilesInitialize-GitMocks,Set-GitMockChangedFiles,Set-GitMockMergeBaseFailureNew-MockFileList,Get-MockGitDiffScenario.gitkeepplaceholder for test fixtures directoryRelated Issue(s)
Closes #193
Type of Change
Select all that apply:
Code & Documentation:
Infrastructure & Configuration:
AI Artifacts:
prompt-builderchatmode and addressed all feedback.github/instructions/*.instructions.md).github/prompts/*.prompt.md).github/chatmodes/*.chatmode.md)Other:
.ps1,.sh,.py)Sample Prompts (for AI Artifact Contributions)
Testing
pester.config.ps1returns validPesterConfigurationobjectpester.config.ps1 -CIenables exit codes and GithubActions formatGitMocks.psm1imports successfully and exports all 10 functionsChecklist
Required Checks
AI Artifact Contributions
prompt-builderchatmode to review contributionprompt-builderreviewRequired 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
This PR is part of the broader Pester testing framework initiative tracked in GitHub issue #190. It establishes the infrastructure foundation (sub-issue #193) that subsequent PRs will build upon for actual test implementations.
🧪 - Generated by Copilot