-
-
Notifications
You must be signed in to change notification settings - Fork 30
feat: Allow configuring PowerShell preference variables #67
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughRemoves hardcoded global PowerShell preference assignments from Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User
participant ActionPS as action.ps1
participant Vars as src/Variables.psm1
Note over ActionPS,Vars `#DDEEFF`: Startup flow after this PR
User->>ActionPS: trigger action
ActionPS->>Vars: import / dot-source Variables module
Vars->>Vars: Initialize-PreferenceVariable()
rect rgb(220,238,255)
Note right of Vars: Build ordered defaults\nSet ErrorActionPreference first (ignored from env)
end
alt Env override present (per-variable, except ignored)
Vars->>Vars: read Env:<Name> -> apply override
else No env override
Vars->>Vars: apply defaults
end
Vars->>ActionPS: preferences set in Global: scope
ActionPS->>User: continue execution (no hardcoded global prefs)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
README.md (1)
28-35: Consider clarifying ErrorActionPreference handling.The documentation describes four preference variables that can be overridden via environment variables. However, the implementation in
src/Variables.psm1also managesErrorActionPreferencebut explicitly prevents environment variable overrides (line 8:IgnoreEnv = $true).Consider adding a note explaining that
ErrorActionPreferenceis managed internally and cannot be overridden, or briefly mention why it's excluded from user configuration.Example addition after line 29:
- If an environment variable with the same name as the following PowerShell preference variable exists, its value will be assigned to the corresponding PowerShell preference variable: - Note: `ErrorActionPreference` is managed internally and cannot be overridden via environment variables.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
README.md(1 hunks)action.ps1(0 hunks)src/Variables.psm1(1 hunks)
💤 Files with no reviewable changes (1)
- action.ps1
🔇 Additional comments (2)
src/Variables.psm1 (2)
8-8: Verify that locking ErrorActionPreference is intentional.Line 8 prevents
ErrorActionPreferencefrom being overridden via environment variables. This is a significant decision sinceErrorActionPreferencecontrols how the script handles errors globally. Confirm this restriction aligns with your design goals.If users need to override error handling behavior (e.g., for debugging), they won't be able to do so via environment variables with this implementation.
32-33: LGTM!Invoking the initialization function at module load time ensures preference variables are configured before any other module code executes. The approach is appropriate for this use case.
1f8e54e to
717dfd3
Compare
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
README.md(1 hunks)action.ps1(0 hunks)src/Variables.psm1(1 hunks)
💤 Files with no reviewable changes (1)
- action.ps1
🔇 Additional comments (3)
src/Variables.psm1 (3)
7-13: Past critical issue resolved.The typo "Vaule" → "Value" from the previous review has been correctly fixed. The hashtable structure now properly stores default preference values that will be retrieved on line 17.
26-26: Past refactor suggestion implemented.The code now uses
Write-Hostinstead ofWrite-Warningas suggested in the previous review, with a clear justifying comment on line 25 explaining the rationale.
1-33: Implementation looks solid.The
Initialize-PreferenceVariablefunction correctly:
- Defines sensible defaults for PowerShell preference variables
- Respects environment variable overrides (except for ErrorActionPreference, which is intentionally protected)
- Sets variables in the Global scope as required for preference variables
- Is appropriately scoped as internal-only (not exported)
The implementation addresses the PR objective to reduce verbose output by defaulting VerbosePreference to SilentlyContinue.
717dfd3 to
ad54d5c
Compare
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/Variables.psm1 (2)
21-23: Consider making the IgnoreEnv check more explicit.The condition
-not $Preferences.IgnoreEnvworks correctly but relies on$nullbeing falsy whenIgnoreEnvis not specified. For better readability and maintainability, consider being more explicit:- if ((-not $Preferences.IgnoreEnv) -and ($EnvValue)) { + if (($Preferences.IgnoreEnv -ne $true) -and ($EnvValue)) { $Value = $EnvValue }This makes it clearer that the intent is to check whether
IgnoreEnvis explicitly set to$true.
1-33: Verify: Is the function intentionally internal-only?The function
Initialize-PreferenceVariableis not included in theExport-ModuleMembercall (lines 71-74), making it internal to the module. Since it's invoked immediately on line 33 during module import, this is likely intentional. However, this means users cannot manually re-initialize preferences later if needed.If the function should remain internal-only, this is fine. If there's a use case for allowing manual re-initialization, consider exporting it.
Optional: Consider adding ProgressPreference to the list.
The code sets five common preference variables but omits
ProgressPreference, which controls progress bar display. In CI/CD environments, setting it to'SilentlyContinue'can reduce unnecessary output.If desired, add it to the hashtable:
$DefaultPreferences = [ordered]@{ ErrorActionPreference = @{ Value = 'Continue'; IgnoreEnv = $true } # Prevent changing ErrorActionPreference from env DebugPreference = @{ Value = 'SilentlyContinue' } InformationPreference = @{ Value = 'SilentlyContinue' } + ProgressPreference = @{ Value = 'SilentlyContinue' } VerbosePreference = @{ Value = 'SilentlyContinue' } WarningPreference = @{ Value = 'Continue' } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
README.md(1 hunks)action.ps1(0 hunks)src/Variables.psm1(1 hunks)
💤 Files with no reviewable changes (1)
- action.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
- README.md
🔇 Additional comments (2)
src/Variables.psm1 (2)
1-5: LGTM!The function follows PowerShell naming conventions and includes appropriate documentation for its purpose.
25-28: LGTM!The logging approach with
Write-Hostis appropriate for GitHub Actions, and using-Scope Globalcorrectly ensures preference variables are set globally even when called from within the module.
chore: Change default VerbosePreference to SilentlyContinue
ad54d5c to
1318e00
Compare

Description
This PR makes the following changes:
'SilentlyContinue''SilentlyContinue''SilentlyContinue''Continue'VerbosePreferencefromContinuetoSilentlyContinue.Motivation and Context
Closes Add configuration items to reduce a large amount of meaningless verbose output #66
Relates to Improve GitHub Action log output for reduced debug information and better readability #33
Test Cases
Summary by CodeRabbit
Documentation
Behavioral Change
Refactor