-
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
Conversation
- Add local pre-commit hook to run PowerShell Pester tests and save results before commit - Update .pre-commit-config.yaml to include the new hook - Enhance .github/workflows/ci.yml to skip expensive PowerShell tests in CI if recent local results are present - Ensure all changes are compatible with the repository's QA and security framework
|
@copilot There were some issues with the PowerShell tests. Open a PR to deal with those and with the feedback from your review of this PR. |
|
@AprilDeFeu I've opened a new pull request, #16, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a pre-commit hook to run PowerShell Pester tests locally and optimizes CI by conditionally skipping tests when recent local results are available. The changes also modify tests to run without admin rights and introduce a destructive mode selection feature in the PowerShell script.
Key changes:
- New pre-commit hook (
.githooks/pre-commit.ps1) to run and save Pester test results - CI workflow modified to skip expensive tests when local results exist and are recent (<2 days old)
- Test file refactored to use Pester 4 syntax and removed admin-requiring test contexts
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
.githooks/pre-commit.ps1 |
New pre-commit hook that runs Pester tests and saves results to tests/results/ |
.pre-commit-config.yaml |
Adds configuration for the new PowerShell Pester test hook |
.github/workflows/ci.yml |
Adds logic to check for and use local test results, conditionally skipping CI tests |
tests/unit/PowerShell/system-maintenance.Tests.ps1 |
Converts tests to Pester 4 syntax, removes admin-requiring contexts, adds hardcoded fallback path |
PowerShell/system-administration/maintenance/system-maintenance.ps1 |
Adds Begin block, removes Confirm-Action helper, adds destructive mode prompt with Read-Host, wraps disk cleanup in destructive mode check |
PowerShell/system-administration/maintenance/system-maintenance.ps1
Outdated
Show resolved
Hide resolved
PowerShell/system-administration/maintenance/system-maintenance.ps1
Outdated
Show resolved
Hide resolved
PowerShell/system-administration/maintenance/system-maintenance.ps1
Outdated
Show resolved
Hide resolved
PowerShell/system-administration/maintenance/system-maintenance.ps1
Outdated
Show resolved
Hide resolved
… paths Co-authored-by: AprilDeFeu <[email protected]>
Co-authored-by: AprilDeFeu <[email protected]>
Fix PowerShell Pester tests for v5 compatibility and update pre-commit hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 9 comments.
PowerShell/system-administration/maintenance/system-maintenance.ps1
Outdated
Show resolved
Hide resolved
PowerShell/system-administration/maintenance/system-maintenance.ps1
Outdated
Show resolved
Hide resolved
PowerShell/system-administration/maintenance/system-maintenance.ps1
Outdated
Show resolved
Hide resolved
PowerShell/system-administration/maintenance/system-maintenance.ps1
Outdated
Show resolved
Hide resolved
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@AprilDeFeu I've opened a new pull request, #17, to work on those changes. Once the pull request is ready, I'll request review from you. |
…se tests, improve automation support Co-authored-by: AprilDeFeu <[email protected]>
Co-authored-by: AprilDeFeu <[email protected]>
Fix runtime errors and automation blockers from PR #15 review feedback
Co-authored-by: Copilot <[email protected]>
|
@copilot Deal with the Codacy Code Analysis feedback and also apply changes based on this feedback |
|
@AprilDeFeu I've opened a new pull request, #18, to work on those changes. Once the pull request is ready, I'll request review from you. |
…eter Co-authored-by: AprilDeFeu <[email protected]>
…e.ps1 Co-authored-by: Copilot <[email protected]>
Fix PSScriptAnalyzer warnings and remove unused parameter
…e.ps1 Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
…e.ps1 Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
…e.ps1 Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
…e.ps1 Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
…e.ps1 Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
…e.ps1 Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
.pre-commit-config.yamlto include the new hook..github/workflows/ci.ymlto skip expensive PowerShell tests in CI if recent local results are present.This PR improves developer workflow, reduces CI costs, and enforces robust PowerShell script testing.