Fix and PR Workflow
Runs ScriptAnalyzer, fixes all issues, runs Pester tests, commits to a feature branch, creates a PR, merges it, and cleans up the branch.
Steps
- •Lint: Run
Invoke-ScriptAnalyzer -Path . -Recurse -Severity Warning,Errorto identify all lint issues - •Fix: For each warning or error found, fix it, then re-run the analyzer on that file to confirm the fix before moving to the next
- •Test: Run
Invoke-Pesterto ensure all tests pass- •If any tests fail, diagnose and fix the root cause, then re-run tests
- •Repeat until all tests pass with zero failures
- •Re-lint: Run
Invoke-ScriptAnalyzeragain to confirm zero warnings remain after test fixes - •Branch: Create a feature branch:
git checkout -b fix/<brief-description> - •Commit: Stage all changed files and commit with a descriptive message summarizing every fix
- •Push & PR: Push the branch and create a PR with a markdown body listing each file changed and what was fixed
- •Merge & Cleanup:
- •Merge the PR
- •Switch to main first:
git checkout main - •Then delete the feature branch:
git branch -d fix/<brief-description>
Rules
- •Always switch to main before deleting feature branches
- •Perform file writes sequentially, not in parallel, to avoid cascade failures
- •Never commit if ScriptAnalyzer warnings or test failures remain
- •Use
Write-ToLog(notWrite-Log) as the standard logging function - •All fixes must be cross-platform compatible (macOS and Windows)