Skip to content

Commit 4463abf

Browse files
🪲 [Fix]: Fix setting the $ErrorView setting via inputs (#53)
This pull request introduces changes related to the handling of the `ErrorView` configuration in a GitHub Actions workflow. The changes streamline the `ErrorView` initialization logic by removing redundant code and adding validation to ensure `ErrorView` is set correctly during runtime. ### Changes to `ErrorView` handling: * [`.github/workflows/TestWorkflow.yml`](diffhunk://#diff-242a265d6d6bfff6094c9285345022d0e6d7ddde58504dfc80249fafbd89ba2cR228-R233): Added a validation step to confirm that `ErrorView` is set to `'NormalView'` during the workflow execution. If not, an exception is thrown. * [`action.yml`](diffhunk://#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6R94): Introduced the assignment of the `ErrorView` environment variable from the input parameter for use in subsequent scripts. * [`scripts/init.ps1`](diffhunk://#diff-f47ceebe9ade2bb55cede031de8267e9c87b09336a93fcd557c02c1f488554b6L7-L23): Removed the redundant initialization and validation logic for `ErrorView`, as this is now handled directly in the workflow and action configuration.
1 parent 1e8d9ba commit 4463abf

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

.github/workflows/TestWorkflow.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ jobs:
225225
Get-Content $env:GITHUB_OUTPUT -Raw | Set-GitHubStepSummary
226226
}
227227
228+
LogGroup "ErrorView should be 'NormalView' - [$ErrorView]" {
229+
if ($ErrorView -ne 'NormalView') {
230+
throw 'ErrorView is not NormalView'
231+
}
232+
}
233+
228234
- name: Run-test
229235
shell: pwsh
230236
env:

action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ runs:
9191
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
9292
run: |
9393
# ${{ inputs.Name }}
94+
$ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
9495
try {
9596
${{ github.action_path }}/scripts/init.ps1
9697
${{ github.action_path }}/scripts/info.ps1

scripts/init.ps1

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,6 @@ param()
44
begin {
55
$scriptName = $MyInvocation.MyCommand.Name
66
Write-Debug "[$scriptName] - Start"
7-
$PSStyle.OutputRendering = 'Ansi'
8-
9-
# Configure ErrorView based on input parameter
10-
if (-not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView)) {
11-
$validViews = @('NormalView', 'CategoryView', 'ConciseView', 'DetailedView')
12-
$errorViewSetting = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
13-
14-
# Simply find the first validView that matches the input using wildcards
15-
$matchedView = $validViews | Where-Object { $_ -like "*$errorViewSetting*" } | Select-Object -First 1
16-
17-
if ($matchedView) {
18-
Write-Debug "[$scriptName] - Input [$errorViewSetting] matched with [$matchedView]"
19-
$ErrorView = $matchedView
20-
} else {
21-
Write-Warning "[$scriptName] - Invalid ErrorView value: [$errorViewSetting]. Using default."
22-
}
23-
}
247
}
258

269
process {

0 commit comments

Comments
 (0)