-
Notifications
You must be signed in to change notification settings - Fork 0
Add robust pre-commit PowerShell test integration and CI optimization #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
675a191
Add robust pre-commit PowerShell test integration and CI optimization
AprilDeFeu 162a72e
Initial plan
Copilot 8c20533
Fix PowerShell tests: Update to Pester v5 syntax and remove hardcoded…
Copilot b86ba8c
Update pre-commit hook to Pester v5 and fix test result format
Copilot 48e7cff
Merge pull request #16 from AprilDeFeu/copilot/sub-pr-15
AprilDeFeu ad7f45d
Initial plan
Copilot fddf330
Address PR review feedback: fix Confirm-Action calls, restore edge ca…
Copilot 06938b1
Fix PSCmdlet references in scriptblocks and update documentation
Copilot 34de42d
Merge pull request #17 from AprilDeFeu/copilot/sub-pr-15
AprilDeFeu b6956b0
Update .githooks/pre-commit.ps1
AprilDeFeu 3965bbc
Initial plan
Copilot b6bac37
Fix PSScriptAnalyzer warnings and remove unused DestructiveMode param…
Copilot d35cf4f
Update PowerShell/system-administration/maintenance/system-maintenanc…
AprilDeFeu aad1413
Merge pull request #18 from AprilDeFeu/copilot/sub-pr-15-again
AprilDeFeu da50f48
Update PowerShell/system-administration/maintenance/system-maintenanc…
AprilDeFeu 69c5e4d
Update .githooks/pre-commit.ps1
AprilDeFeu d54bd48
Update PowerShell/system-administration/maintenance/system-maintenanc…
AprilDeFeu ab9e85d
Update .githooks/pre-commit.ps1
AprilDeFeu 2585550
Update PowerShell/system-administration/maintenance/system-maintenanc…
AprilDeFeu 2ee523a
Update PowerShell/system-administration/maintenance/system-maintenanc…
AprilDeFeu 66d08cf
Update .githooks/pre-commit.ps1
AprilDeFeu 4a3a3d8
Update .githooks/pre-commit.ps1
AprilDeFeu 5606b86
Update .githooks/pre-commit.ps1
AprilDeFeu 7954f09
Update PowerShell/system-administration/maintenance/system-maintenanc…
AprilDeFeu b611a3e
Update PowerShell/system-administration/maintenance/system-maintenanc…
AprilDeFeu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env pwsh | ||
| # Pre-commit hook: Run Pester tests for system-maintenance.ps1 and save results | ||
| $ErrorActionPreference = 'Stop' | ||
| $testScript = 'PowerShell/system-administration/maintenance/system-maintenance.ps1' | ||
| $testPath = 'tests/unit/PowerShell/system-maintenance.Tests.ps1' | ||
| $resultsPath = 'tests/results/system-maintenance.xml' | ||
|
|
||
| if (Test-Path $testPath) { | ||
| Write-Information "Running Pester tests for $testScript..." | ||
|
|
||
| # Set SCRIPTS_ROOT environment variable for tests | ||
| $env:SCRIPTS_ROOT = (Get-Location).Path | ||
|
|
||
| # Ensure the results directory exists before running Pester | ||
| New-Item -ItemType Directory -Path (Split-Path $resultsPath -Parent) -Force -ErrorAction SilentlyContinue | Out-Null | ||
|
|
||
| # Use Pester v5 configuration syntax | ||
| $config = New-PesterConfiguration | ||
| $config.Run.Path = $testPath | ||
| $config.Run.PassThru = $true | ||
| $config.TestResult.Enabled = $true | ||
| $config.TestResult.OutputPath = $resultsPath | ||
| $config.TestResult.OutputFormat = 'JUnitXml' | ||
|
|
||
AprilDeFeu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Ensure the results directory exists before running Pester | ||
| New-Item -ItemType Directory -Path (Split-Path $resultsPath -Parent) -Force -ErrorAction SilentlyContinue | ||
| $result = Invoke-Pester -Configuration $config | ||
|
|
||
| if ($result.FailedCount -gt 0) { | ||
| Write-Error "Tests failed. Aborting commit." | ||
| exit 1 | ||
| } | ||
|
|
||
| if (Test-Path $resultsPath) { | ||
| Write-Information "Test results saved to: $resultsPath" | ||
| } | ||
| else { | ||
| Write-Information "Test results not found, aborting commit." | ||
| exit 1 | ||
| } | ||
| } | ||
| else { | ||
| Write-Output "Test file not found: $testPath" | ||
| Write-Host "Cannot verify script quality. Aborting commit." | ||
| exit 1 | ||
| } | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,6 @@ | |
|
|
||
| #Ignore vscode AI rules | ||
| .github\instructions\codacy.instructions.md | ||
|
|
||
| # Test results | ||
| tests/results/ | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.