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/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/scripts/main.ps1 b/scripts/main.ps1 index 5df78d4..596e01b 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,13 +1,14 @@ # 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 $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]"