From e78429e20eec0a2122bcd08c367b83320efcd726 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 23:17:53 +0100 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Align=20`WorkingD?= =?UTF-8?q?irectory`=20usage=20in=20workflows=20and=20update=20path=20reso?= =?UTF-8?q?lution=20in=20main=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 9 ++++----- scripts/main.ps1 | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 5b4aac8..e8aefae 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -31,9 +31,9 @@ jobs: uses: ./ id: action-test with: - WorkingDirectory: tests/srcTestRepo Path: src Settings: SourceCode + WorkingDirectory: tests/srcTestRepo - name: Status shell: pwsh @@ -55,10 +55,10 @@ jobs: uses: ./ id: action-test with: - WorkingDirectory: tests/srcTestRepo Path: src Settings: Custom SettingsFilePath: tests/Custom.Settings.psd1 + WorkingDirectory: tests/srcTestRepo - name: Status shell: pwsh @@ -81,9 +81,9 @@ jobs: continue-on-error: true id: action-test with: - WorkingDirectory: tests/srcWithManifestTestRepo Path: src Settings: SourceCode + WorkingDirectory: tests/srcWithManifestTestRepo - name: Status shell: pwsh @@ -105,9 +105,9 @@ jobs: uses: ./ id: action-test with: - WorkingDirectory: tests/outputTestRepo Path: outputs/modules/PSModuleTest Settings: Module + WorkingDirectory: tests/outputTestRepo - name: Status shell: pwsh @@ -229,4 +229,3 @@ jobs: Write-GitHubError 'One or more jobs failed' exit 1 } - diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 5df78d4..4fd92d5 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,7 +1,7 @@ # If test type is module, the code we ought to test is in the path/name folder, otherwise it's in the path folder. $settings = $env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Settings $testPath = Resolve-Path -Path "$PSScriptRoot/tests/PSScriptAnalyzer" | Select-Object -ExpandProperty Path -$codePath = Resolve-Path -Path $env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Path | Select-Object -ExpandProperty Path +$codePath = Resolve-Path -Path "./$env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Path" | Select-Object -ExpandProperty Path $settingsFilePath = switch -Regex ($settings) { 'Module|SourceCode' { "$testPath/$settings.Settings.psd1" From bb9468fd7078a992e0e4cc95b9f4823e86945531 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 23:22:01 +0100 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Simplify=20path?= =?UTF-8?q?=20resolution=20by=20removing=20unnecessary=20string=20interpol?= =?UTF-8?q?ation=20in=20main=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 4fd92d5..83bad86 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,13 +1,13 @@ # If test type is module, the code we ought to test is in the path/name folder, otherwise it's in the path folder. $settings = $env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Settings $testPath = Resolve-Path -Path "$PSScriptRoot/tests/PSScriptAnalyzer" | Select-Object -ExpandProperty Path -$codePath = Resolve-Path -Path "./$env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Path" | Select-Object -ExpandProperty Path +$codePath = Resolve-Path -Path $env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Path | Select-Object -ExpandProperty Path $settingsFilePath = switch -Regex ($settings) { 'Module|SourceCode' { "$testPath/$settings.Settings.psd1" } 'Custom' { - Resolve-Path -Path "$env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_SettingsFilePath" | Select-Object -ExpandProperty Path + Resolve-Path -Path $env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_SettingsFilePath | Select-Object -ExpandProperty Path } default { throw "Invalid test type: [$settings]" From c3e5eb90f1e5b18061ce82562b4413464a249a4f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 1 Mar 2025 09:29:23 +0100 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20README?= =?UTF-8?q?=20and=20action.yml=20to=20specify=20default=20path=20for=20cod?= =?UTF-8?q?e=20testing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- action.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c78e9f..f0d42b5 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ jobs: - name: Invoke PSScriptAnalyzer uses: PSModule/Invoke-ScriptAnalyzer@v2 with: - Path: ${{ github.workspace }} + Path: src Settings: SourceCode ``` diff --git a/action.yml b/action.yml index fa1761f..5cbf2e5 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,7 @@ inputs: Path: description: The path to the code to test. required: false + default: '.' Settings: description: The type of tests to run. Can be either 'Module', 'SourceCode' or 'Custom'. required: false From 13e05c914f0248d3e060edbc29e903f8d84cdb4a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 1 Mar 2025 09:40:49 +0100 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20default?= =?UTF-8?q?=20value=20for=20Path=20input=20in=20action.yml=20and=20update?= =?UTF-8?q?=20path=20resolution=20logic=20in=20main.ps1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 1 - scripts/main.ps1 | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 5cbf2e5..fa1761f 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,6 @@ inputs: Path: description: The path to the code to test. required: false - default: '.' Settings: description: The type of tests to run. Can be either 'Module', 'SourceCode' or 'Custom'. required: false diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 83bad86..ca8a7c9 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,7 +1,8 @@ # If test type is module, the code we ought to test is in the path/name folder, otherwise it's in the path folder. $settings = $env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Settings $testPath = Resolve-Path -Path "$PSScriptRoot/tests/PSScriptAnalyzer" | Select-Object -ExpandProperty Path -$codePath = Resolve-Path -Path $env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Path | Select-Object -ExpandProperty Path +$path = [string]::IsNullOrEmpty($env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Path) ? '.' : $env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Path +$codePath = Resolve-Path -Path $path | Select-Object -ExpandProperty Path | Select-Object -ExpandProperty Path $settingsFilePath = switch -Regex ($settings) { 'Module|SourceCode' { "$testPath/$settings.Settings.psd1" From 0e5ae5dfe54a844260d42fe85b444a30ec864dd0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 1 Mar 2025 09:55:16 +0100 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Simplify=20path?= =?UTF-8?q?=20resolution=20by=20removing=20redundant=20Select-Object=20in?= =?UTF-8?q?=20main.ps1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index ca8a7c9..596e01b 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -2,7 +2,7 @@ $settings = $env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Settings $testPath = Resolve-Path -Path "$PSScriptRoot/tests/PSScriptAnalyzer" | Select-Object -ExpandProperty Path $path = [string]::IsNullOrEmpty($env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Path) ? '.' : $env:PSMODULE_INVOKE_SCRIPTANALYZER_INPUT_Path -$codePath = Resolve-Path -Path $path | Select-Object -ExpandProperty Path | Select-Object -ExpandProperty Path +$codePath = Resolve-Path -Path $path | Select-Object -ExpandProperty Path $settingsFilePath = switch -Regex ($settings) { 'Module|SourceCode' { "$testPath/$settings.Settings.psd1"