From a3a198d4bafaefb6e652f3bea70bba48b154d693 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 10 Sep 2026 18:35:29 +0200 Subject: [PATCH 1/9] Add regression test for analyzer report paths --- .github/workflows/Action-Test.yml | 32 ++++++++++++++++ tests/Assert-ReportPaths.ps1 | 64 +++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tests/Assert-ReportPaths.ps1 diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index c27b734..d3d2e2c 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -121,6 +121,37 @@ jobs: Write-Host "Outcome: ${{ steps.action-test.outcome }}" Write-Host "Conclusion: ${{ steps.action-test.conclusion }}" + ActionTestReportPaths: + name: Action-Test - [Report Paths] + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + + - name: Action-Test + uses: ./ + id: action-test + with: + Path: src + WorkingDirectory: tests/srcTestRepo + TestResult_Enabled: true + TestResult_OutputFormat: NUnitXml + TestResult_OutputPath: .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml + CodeCoverage_Enabled: true + CodeCoverage_OutputFormat: JaCoCo + CodeCoverage_OutputPath: .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml + CodeCoverage_Path: ../../src/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1 + + - name: Assert report paths + shell: pwsh + run: | + tests/Assert-ReportPaths.ps1 ` + -WorkingDirectory tests/srcTestRepo ` + -TestResultPath .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml ` + -CodeCoveragePath .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml + ActionTestOutputs: name: Action-Test - [outputs] runs-on: ubuntu-latest @@ -153,6 +184,7 @@ jobs: - ActionTestSrcCustom - ActionTestSrcWithManifest - ActionTestSrcWithManifestDefault + - ActionTestReportPaths - ActionTestOutputs if: always() runs-on: ubuntu-latest diff --git a/tests/Assert-ReportPaths.ps1 b/tests/Assert-ReportPaths.ps1 new file mode 100644 index 0000000..91fbd08 --- /dev/null +++ b/tests/Assert-ReportPaths.ps1 @@ -0,0 +1,64 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory)] + [string] $WorkingDirectory, + + [Parameter(Mandatory)] + [string] $TestResultPath, + + [Parameter(Mandatory)] + [string] $CodeCoveragePath +) + +function Assert-ReportPath { + [CmdletBinding()] + param( + [Parameter(Mandatory)] + [string] $Path, + + [Parameter(Mandatory)] + [string] $ReportName, + + [Parameter(Mandatory)] + [string] $ArtifactDirectory + ) + + $resolvedPath = [System.IO.Path]::GetFullPath($Path) + $resolvedArtifactDirectory = [System.IO.Path]::GetFullPath($ArtifactDirectory).TrimEnd( + [System.IO.Path]::DirectorySeparatorChar, + [System.IO.Path]::AltDirectorySeparatorChar + ) + [System.IO.Path]::DirectorySeparatorChar + + if (-not $resolvedPath.StartsWith($resolvedArtifactDirectory, [System.StringComparison]::OrdinalIgnoreCase)) { + throw "Expected $ReportName report beneath [$resolvedArtifactDirectory], but found [$resolvedPath]." + } + + foreach ($reportPath in @($resolvedPath, [System.IO.Path]::ChangeExtension($resolvedPath, '.json'))) { + if (-not (Test-Path -Path $reportPath -PathType Leaf)) { + throw "Expected $ReportName report at [$reportPath]." + } + } + + try { + $null = [xml](Get-Content -Path $resolvedPath -Raw) + } catch { + throw "Expected an XML $ReportName report at [$resolvedPath]." + } +} + +$resolvedWorkingDirectory = [System.IO.Path]::GetFullPath($WorkingDirectory) +$artifactDirectory = Join-Path -Path $resolvedWorkingDirectory -ChildPath '.PSModule' + +Assert-ReportPath -Path (Join-Path -Path $resolvedWorkingDirectory -ChildPath $TestResultPath) ` + -ReportName 'test result' ` + -ArtifactDirectory $artifactDirectory +Assert-ReportPath -Path (Join-Path -Path $resolvedWorkingDirectory -ChildPath $CodeCoveragePath) ` + -ReportName 'code coverage' ` + -ArtifactDirectory $artifactDirectory + +foreach ($unexpectedDirectory in @('TestResult', 'CodeCoverage', '.temp')) { + $unexpectedPath = Join-Path -Path $resolvedWorkingDirectory -ChildPath $unexpectedDirectory + if (Test-Path -Path $unexpectedPath) { + throw "Did not expect generated action state at [$unexpectedPath]." + } +} From d6da4f9914073d2f38edd6baec43f956d89f9334 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 10 Sep 2026 18:38:19 +0200 Subject: [PATCH 2/9] Honor analyzer report path inputs --- .github/workflows/Action-Test.yml | 30 ++++++++++++++++++++++++++++++ README.md | 4 ++-- action.yml | 4 +++- tests/Assert-ReportPaths.ps1 | 4 ++++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index d3d2e2c..0276c53 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -152,6 +152,35 @@ jobs: -TestResultPath .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml ` -CodeCoveragePath .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml + ActionTestDefaultReportPaths: + name: Action-Test - [Default Report Paths] + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + + - name: Action-Test + uses: ./ + id: action-test + with: + Path: src + WorkingDirectory: tests/srcTestRepo + TestResult_Enabled: true + TestResult_OutputFormat: NUnitXml + CodeCoverage_Enabled: true + CodeCoverage_OutputFormat: JaCoCo + CodeCoverage_Path: ../../src/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1 + + - name: Assert report paths + shell: pwsh + run: | + tests/Assert-ReportPaths.ps1 ` + -WorkingDirectory tests/srcTestRepo ` + -TestResultPath .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml ` + -CodeCoveragePath .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml + ActionTestOutputs: name: Action-Test - [outputs] runs-on: ubuntu-latest @@ -185,6 +214,7 @@ jobs: - ActionTestSrcWithManifest - ActionTestSrcWithManifestDefault - ActionTestReportPaths + - ActionTestDefaultReportPaths - ActionTestOutputs if: always() runs-on: ubuntu-latest diff --git a/README.md b/README.md index 27f0017..ccc8adc 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ customize rule selection, severity filtering, and custom rule inclusion. | `Run_SkipRemainingOnFailure` | Skips remaining tests after failure (None/Run/Container/Block). | false | | | `CodeCoverage_Enabled` | Enable CodeCoverage. | false | | | `CodeCoverage_OutputFormat` | Format to use for code coverage report (JaCoCo/CoverageGutters/Cobertura). | false | | -| `CodeCoverage_OutputPath` | Path relative to the current directory where code coverage report is saved. | false | | +| `CodeCoverage_OutputPath` | Path relative to the current directory where code coverage report is saved. | false | `.PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml` | | `CodeCoverage_OutputEncoding` | Encoding of the output file. | false | | | `CodeCoverage_Path` | Directories or files to be used for code coverage. | false | | | `CodeCoverage_ExcludeTests` | Exclude tests from code coverage. | false | | @@ -51,7 +51,7 @@ customize rule selection, severity filtering, and custom rule inclusion. | `CodeCoverage_SingleHitBreakpoints` | Remove breakpoint when it is hit. | false | | | `TestResult_Enabled` | Enable TestResult. | false | | | `TestResult_OutputFormat` | Format to use for test result report (NUnitXml/NUnit2.5/NUnit3/JUnitXml). | false | | -| `TestResult_OutputPath` | Path relative to the current directory where test result report is saved. | false | | +| `TestResult_OutputPath` | Path relative to the current directory where test result report is saved. | false | `.PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml` | | `TestResult_OutputEncoding` | Encoding of the output file. | false | | | `TestResult_TestSuiteName` | Set the name assigned to the root 'test-suite' element. | false | `PSScriptAnalyzer` | | `Should_ErrorAction` | Controls if Should throws on error. Use 'Stop' or 'Continue'. | false | | diff --git a/action.yml b/action.yml index 4efa4b1..03bd4fe 100644 --- a/action.yml +++ b/action.yml @@ -110,6 +110,7 @@ inputs: description: | Path relative to the current directory where code coverage report is saved. required: false + default: .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml CodeCoverage_OutputEncoding: description: | Encoding of the output file. @@ -150,6 +151,7 @@ inputs: description: | Path relative to the current directory where test result report is saved. required: false + default: .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml TestResult_OutputEncoding: description: | Encoding of the output file. @@ -282,7 +284,7 @@ runs: Script: ${{ github.action_path }}/src/main.ps1 - name: Invoke-Pester - uses: PSModule/Invoke-Pester@4ff33199141fdf22568990b6107fe3148ae93a1c # v5.1.0 + uses: PSModule/Invoke-Pester@c5494aba3c07d7bfd81bdbbc9f301e8fa4a729fb # v5.1.1 id: test env: SettingsFilePath: ${{ fromJson(steps.paths.outputs.result).SettingsFilePath }} diff --git a/tests/Assert-ReportPaths.ps1 b/tests/Assert-ReportPaths.ps1 index 91fbd08..2655575 100644 --- a/tests/Assert-ReportPaths.ps1 +++ b/tests/Assert-ReportPaths.ps1 @@ -11,6 +11,10 @@ param( ) function Assert-ReportPath { + <# + .SYNOPSIS + Confirms that an action report is generated in the fixture artifact directory. + #> [CmdletBinding()] param( [Parameter(Mandatory)] From 4574c66c8ebdb2520e13261ce132545e523328f4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 10 Sep 2026 18:43:30 +0200 Subject: [PATCH 3/9] Align analyzer report defaults --- .github/workflows/Action-Test.yml | 12 ++++++------ README.md | 4 ++-- action.yml | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 0276c53..ee3040a 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -138,10 +138,10 @@ jobs: WorkingDirectory: tests/srcTestRepo TestResult_Enabled: true TestResult_OutputFormat: NUnitXml - TestResult_OutputPath: .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml + TestResult_OutputPath: .PSModule/Explicit/TestResult.xml CodeCoverage_Enabled: true CodeCoverage_OutputFormat: JaCoCo - CodeCoverage_OutputPath: .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml + CodeCoverage_OutputPath: .PSModule/Explicit/CodeCoverage.xml CodeCoverage_Path: ../../src/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1 - name: Assert report paths @@ -149,8 +149,8 @@ jobs: run: | tests/Assert-ReportPaths.ps1 ` -WorkingDirectory tests/srcTestRepo ` - -TestResultPath .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml ` - -CodeCoveragePath .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml + -TestResultPath .PSModule/Explicit/TestResult.xml ` + -CodeCoveragePath .PSModule/Explicit/CodeCoverage.xml ActionTestDefaultReportPaths: name: Action-Test - [Default Report Paths] @@ -178,8 +178,8 @@ jobs: run: | tests/Assert-ReportPaths.ps1 ` -WorkingDirectory tests/srcTestRepo ` - -TestResultPath .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml ` - -CodeCoveragePath .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml + -TestResultPath .PSModule/TestResult/Results.xml ` + -CodeCoveragePath .PSModule/CodeCoverage/Coverage.xml ActionTestOutputs: name: Action-Test - [outputs] diff --git a/README.md b/README.md index ccc8adc..700c4be 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ customize rule selection, severity filtering, and custom rule inclusion. | `Run_SkipRemainingOnFailure` | Skips remaining tests after failure (None/Run/Container/Block). | false | | | `CodeCoverage_Enabled` | Enable CodeCoverage. | false | | | `CodeCoverage_OutputFormat` | Format to use for code coverage report (JaCoCo/CoverageGutters/Cobertura). | false | | -| `CodeCoverage_OutputPath` | Path relative to the current directory where code coverage report is saved. | false | `.PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml` | +| `CodeCoverage_OutputPath` | Path relative to the current directory where code coverage report is saved. | false | `.PSModule/CodeCoverage/Coverage.xml` | | `CodeCoverage_OutputEncoding` | Encoding of the output file. | false | | | `CodeCoverage_Path` | Directories or files to be used for code coverage. | false | | | `CodeCoverage_ExcludeTests` | Exclude tests from code coverage. | false | | @@ -51,7 +51,7 @@ customize rule selection, severity filtering, and custom rule inclusion. | `CodeCoverage_SingleHitBreakpoints` | Remove breakpoint when it is hit. | false | | | `TestResult_Enabled` | Enable TestResult. | false | | | `TestResult_OutputFormat` | Format to use for test result report (NUnitXml/NUnit2.5/NUnit3/JUnitXml). | false | | -| `TestResult_OutputPath` | Path relative to the current directory where test result report is saved. | false | `.PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml` | +| `TestResult_OutputPath` | Path relative to the current directory where test result report is saved. | false | `.PSModule/TestResult/Results.xml` | | `TestResult_OutputEncoding` | Encoding of the output file. | false | | | `TestResult_TestSuiteName` | Set the name assigned to the root 'test-suite' element. | false | `PSScriptAnalyzer` | | `Should_ErrorAction` | Controls if Should throws on error. Use 'Stop' or 'Continue'. | false | | diff --git a/action.yml b/action.yml index 03bd4fe..6f4ad54 100644 --- a/action.yml +++ b/action.yml @@ -110,7 +110,7 @@ inputs: description: | Path relative to the current directory where code coverage report is saved. required: false - default: .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml + default: .PSModule/CodeCoverage/Coverage.xml CodeCoverage_OutputEncoding: description: | Encoding of the output file. @@ -151,7 +151,7 @@ inputs: description: | Path relative to the current directory where test result report is saved. required: false - default: .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml + default: .PSModule/TestResult/Results.xml TestResult_OutputEncoding: description: | Encoding of the output file. From 4b7d949b8135d91812f188762dce98d4a88c45e2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 10 Sep 2026 19:59:49 +0200 Subject: [PATCH 4/9] Match Pester report default names --- .github/workflows/Action-Test.yml | 4 ++-- README.md | 12 ++++++++++-- action.yml | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index ee3040a..1a31391 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -178,8 +178,8 @@ jobs: run: | tests/Assert-ReportPaths.ps1 ` -WorkingDirectory tests/srcTestRepo ` - -TestResultPath .PSModule/TestResult/Results.xml ` - -CodeCoveragePath .PSModule/CodeCoverage/Coverage.xml + -TestResultPath .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml ` + -CodeCoveragePath .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml ActionTestOutputs: name: Action-Test - [outputs] diff --git a/README.md b/README.md index 700c4be..ad7295e 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ customize rule selection, severity filtering, and custom rule inclusion. | `Run_SkipRemainingOnFailure` | Skips remaining tests after failure (None/Run/Container/Block). | false | | | `CodeCoverage_Enabled` | Enable CodeCoverage. | false | | | `CodeCoverage_OutputFormat` | Format to use for code coverage report (JaCoCo/CoverageGutters/Cobertura). | false | | -| `CodeCoverage_OutputPath` | Path relative to the current directory where code coverage report is saved. | false | `.PSModule/CodeCoverage/Coverage.xml` | +| `CodeCoverage_OutputPath` | Path relative to the current directory where code coverage report is saved. | false | See below | | `CodeCoverage_OutputEncoding` | Encoding of the output file. | false | | | `CodeCoverage_Path` | Directories or files to be used for code coverage. | false | | | `CodeCoverage_ExcludeTests` | Exclude tests from code coverage. | false | | @@ -51,7 +51,7 @@ customize rule selection, severity filtering, and custom rule inclusion. | `CodeCoverage_SingleHitBreakpoints` | Remove breakpoint when it is hit. | false | | | `TestResult_Enabled` | Enable TestResult. | false | | | `TestResult_OutputFormat` | Format to use for test result report (NUnitXml/NUnit2.5/NUnit3/JUnitXml). | false | | -| `TestResult_OutputPath` | Path relative to the current directory where test result report is saved. | false | `.PSModule/TestResult/Results.xml` | +| `TestResult_OutputPath` | Path relative to the current directory where test result report is saved. | false | See below | | `TestResult_OutputEncoding` | Encoding of the output file. | false | | | `TestResult_TestSuiteName` | Set the name assigned to the root 'test-suite' element. | false | `PSScriptAnalyzer` | | `Should_ErrorAction` | Controls if Should throws on error. Use 'Stop' or 'Continue'. | false | | @@ -68,6 +68,14 @@ customize rule selection, severity filtering, and custom rule inclusion. | `TestDrive_Enabled` | Enable TestDrive. | false | | | `TestRegistry_Enabled` | Enable TestRegistry. | false | | +The default report paths match the `Invoke-Pester` filename convention while +using `.PSModule` to keep generated files out of the repository root: + +```text +TestResult_OutputPath: .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml +CodeCoverage_OutputPath: .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml +``` + ## Outputs The action provides the following outputs: diff --git a/action.yml b/action.yml index 6f4ad54..03bd4fe 100644 --- a/action.yml +++ b/action.yml @@ -110,7 +110,7 @@ inputs: description: | Path relative to the current directory where code coverage report is saved. required: false - default: .PSModule/CodeCoverage/Coverage.xml + default: .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml CodeCoverage_OutputEncoding: description: | Encoding of the output file. @@ -151,7 +151,7 @@ inputs: description: | Path relative to the current directory where test result report is saved. required: false - default: .PSModule/TestResult/Results.xml + default: .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml TestResult_OutputEncoding: description: | Encoding of the output file. From 0488622dbb71729faf5973269a268f58ed373c4d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 10 Sep 2026 20:02:37 +0200 Subject: [PATCH 5/9] Use generic analyzer report directories --- .github/workflows/Action-Test.yml | 8 +++++--- README.md | 7 ++++--- action.yml | 4 ++-- tests/Assert-ReportPaths.ps1 | 7 +++++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 1a31391..6405b83 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -150,7 +150,8 @@ jobs: tests/Assert-ReportPaths.ps1 ` -WorkingDirectory tests/srcTestRepo ` -TestResultPath .PSModule/Explicit/TestResult.xml ` - -CodeCoveragePath .PSModule/Explicit/CodeCoverage.xml + -CodeCoveragePath .PSModule/Explicit/CodeCoverage.xml ` + -ArtifactDirectory .PSModule ActionTestDefaultReportPaths: name: Action-Test - [Default Report Paths] @@ -178,8 +179,9 @@ jobs: run: | tests/Assert-ReportPaths.ps1 ` -WorkingDirectory tests/srcTestRepo ` - -TestResultPath .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml ` - -CodeCoveragePath .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml + -TestResultPath reports/TestResult/PSScriptAnalyzer-TestResult-Report.xml ` + -CodeCoveragePath reports/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml ` + -ArtifactDirectory reports ActionTestOutputs: name: Action-Test - [outputs] diff --git a/README.md b/README.md index ad7295e..7d23209 100644 --- a/README.md +++ b/README.md @@ -69,11 +69,12 @@ customize rule selection, severity filtering, and custom rule inclusion. | `TestRegistry_Enabled` | Enable TestRegistry. | false | | The default report paths match the `Invoke-Pester` filename convention while -using `.PSModule` to keep generated files out of the repository root: +using generic `reports` directories to keep generated files out of the +repository root: ```text -TestResult_OutputPath: .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml -CodeCoverage_OutputPath: .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml +TestResult_OutputPath: reports/TestResult/PSScriptAnalyzer-TestResult-Report.xml +CodeCoverage_OutputPath: reports/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml ``` ## Outputs diff --git a/action.yml b/action.yml index 03bd4fe..5bc5433 100644 --- a/action.yml +++ b/action.yml @@ -110,7 +110,7 @@ inputs: description: | Path relative to the current directory where code coverage report is saved. required: false - default: .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml + default: reports/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml CodeCoverage_OutputEncoding: description: | Encoding of the output file. @@ -151,7 +151,7 @@ inputs: description: | Path relative to the current directory where test result report is saved. required: false - default: .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml + default: reports/TestResult/PSScriptAnalyzer-TestResult-Report.xml TestResult_OutputEncoding: description: | Encoding of the output file. diff --git a/tests/Assert-ReportPaths.ps1 b/tests/Assert-ReportPaths.ps1 index 2655575..4849641 100644 --- a/tests/Assert-ReportPaths.ps1 +++ b/tests/Assert-ReportPaths.ps1 @@ -7,7 +7,10 @@ param( [string] $TestResultPath, [Parameter(Mandatory)] - [string] $CodeCoveragePath + [string] $CodeCoveragePath, + + [Parameter(Mandatory)] + [string] $ArtifactDirectory ) function Assert-ReportPath { @@ -51,7 +54,7 @@ function Assert-ReportPath { } $resolvedWorkingDirectory = [System.IO.Path]::GetFullPath($WorkingDirectory) -$artifactDirectory = Join-Path -Path $resolvedWorkingDirectory -ChildPath '.PSModule' +$artifactDirectory = Join-Path -Path $resolvedWorkingDirectory -ChildPath $ArtifactDirectory Assert-ReportPath -Path (Join-Path -Path $resolvedWorkingDirectory -ChildPath $TestResultPath) ` -ReportName 'test result' ` From f4c5691b0f8f947979123d89b808c0345e74b2ef Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 10 Sep 2026 20:12:31 +0200 Subject: [PATCH 6/9] Preserve Pester report defaults --- .github/workflows/Action-Test.yml | 16 +++++++++------- README.md | 20 +++++++++++++------- action.yml | 2 -- tests/Assert-ReportPaths.ps1 | 6 ++++-- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 6405b83..ed4fb18 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -151,10 +151,11 @@ jobs: -WorkingDirectory tests/srcTestRepo ` -TestResultPath .PSModule/Explicit/TestResult.xml ` -CodeCoveragePath .PSModule/Explicit/CodeCoverage.xml ` - -ArtifactDirectory .PSModule + -ArtifactDirectory .PSModule ` + -UnexpectedDirectory TestResult,CodeCoverage,.temp - ActionTestDefaultReportPaths: - name: Action-Test - [Default Report Paths] + ActionTestInvokePesterDefaultReportPaths: + name: Action-Test - [Invoke-Pester Default Report Paths] runs-on: ubuntu-latest steps: - name: Checkout repo @@ -179,9 +180,10 @@ jobs: run: | tests/Assert-ReportPaths.ps1 ` -WorkingDirectory tests/srcTestRepo ` - -TestResultPath reports/TestResult/PSScriptAnalyzer-TestResult-Report.xml ` - -CodeCoveragePath reports/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml ` - -ArtifactDirectory reports + -TestResultPath TestResult/PSScriptAnalyzer-TestResult-Report.xml ` + -CodeCoveragePath CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml ` + -ArtifactDirectory . ` + -UnexpectedDirectory .temp ActionTestOutputs: name: Action-Test - [outputs] @@ -216,7 +218,7 @@ jobs: - ActionTestSrcWithManifest - ActionTestSrcWithManifestDefault - ActionTestReportPaths - - ActionTestDefaultReportPaths + - ActionTestInvokePesterDefaultReportPaths - ActionTestOutputs if: always() runs-on: ubuntu-latest diff --git a/README.md b/README.md index 7d23209..31489a2 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ customize rule selection, severity filtering, and custom rule inclusion. | `Run_SkipRemainingOnFailure` | Skips remaining tests after failure (None/Run/Container/Block). | false | | | `CodeCoverage_Enabled` | Enable CodeCoverage. | false | | | `CodeCoverage_OutputFormat` | Format to use for code coverage report (JaCoCo/CoverageGutters/Cobertura). | false | | -| `CodeCoverage_OutputPath` | Path relative to the current directory where code coverage report is saved. | false | See below | +| `CodeCoverage_OutputPath` | Path relative to the current directory where code coverage report is saved. | false | | | `CodeCoverage_OutputEncoding` | Encoding of the output file. | false | | | `CodeCoverage_Path` | Directories or files to be used for code coverage. | false | | | `CodeCoverage_ExcludeTests` | Exclude tests from code coverage. | false | | @@ -51,7 +51,7 @@ customize rule selection, severity filtering, and custom rule inclusion. | `CodeCoverage_SingleHitBreakpoints` | Remove breakpoint when it is hit. | false | | | `TestResult_Enabled` | Enable TestResult. | false | | | `TestResult_OutputFormat` | Format to use for test result report (NUnitXml/NUnit2.5/NUnit3/JUnitXml). | false | | -| `TestResult_OutputPath` | Path relative to the current directory where test result report is saved. | false | See below | +| `TestResult_OutputPath` | Path relative to the current directory where test result report is saved. | false | | | `TestResult_OutputEncoding` | Encoding of the output file. | false | | | `TestResult_TestSuiteName` | Set the name assigned to the root 'test-suite' element. | false | `PSScriptAnalyzer` | | `Should_ErrorAction` | Controls if Should throws on error. Use 'Stop' or 'Continue'. | false | | @@ -68,13 +68,19 @@ customize rule selection, severity filtering, and custom rule inclusion. | `TestDrive_Enabled` | Enable TestDrive. | false | | | `TestRegistry_Enabled` | Enable TestRegistry. | false | | -The default report paths match the `Invoke-Pester` filename convention while -using generic `reports` directories to keep generated files out of the -repository root: +When a report output path is empty, `Invoke-Pester` uses its default location +relative to `WorkingDirectory`: ```text -TestResult_OutputPath: reports/TestResult/PSScriptAnalyzer-TestResult-Report.xml -CodeCoverage_OutputPath: reports/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml +TestResult/PSScriptAnalyzer-TestResult-Report.xml +CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml +``` + +Set either input to override only that report's location: + +```text +TestResult_OutputPath: .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml +CodeCoverage_OutputPath: .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml ``` ## Outputs diff --git a/action.yml b/action.yml index 5bc5433..81ff981 100644 --- a/action.yml +++ b/action.yml @@ -110,7 +110,6 @@ inputs: description: | Path relative to the current directory where code coverage report is saved. required: false - default: reports/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml CodeCoverage_OutputEncoding: description: | Encoding of the output file. @@ -151,7 +150,6 @@ inputs: description: | Path relative to the current directory where test result report is saved. required: false - default: reports/TestResult/PSScriptAnalyzer-TestResult-Report.xml TestResult_OutputEncoding: description: | Encoding of the output file. diff --git a/tests/Assert-ReportPaths.ps1 b/tests/Assert-ReportPaths.ps1 index 4849641..ab96d75 100644 --- a/tests/Assert-ReportPaths.ps1 +++ b/tests/Assert-ReportPaths.ps1 @@ -10,7 +10,9 @@ param( [string] $CodeCoveragePath, [Parameter(Mandatory)] - [string] $ArtifactDirectory + [string] $ArtifactDirectory, + + [string[]] $UnexpectedDirectory = @() ) function Assert-ReportPath { @@ -63,7 +65,7 @@ Assert-ReportPath -Path (Join-Path -Path $resolvedWorkingDirectory -ChildPath $C -ReportName 'code coverage' ` -ArtifactDirectory $artifactDirectory -foreach ($unexpectedDirectory in @('TestResult', 'CodeCoverage', '.temp')) { +foreach ($unexpectedDirectory in $UnexpectedDirectory) { $unexpectedPath = Join-Path -Path $resolvedWorkingDirectory -ChildPath $unexpectedDirectory if (Test-Path -Path $unexpectedPath) { throw "Did not expect generated action state at [$unexpectedPath]." From 48408b07e728c1fd2146322997eaf61c5aae26bc Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 10 Sep 2026 20:18:18 +0200 Subject: [PATCH 7/9] Use generic report path examples --- .github/workflows/Action-Test.yml | 10 +++++----- README.md | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index ed4fb18..d0a8566 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -138,10 +138,10 @@ jobs: WorkingDirectory: tests/srcTestRepo TestResult_Enabled: true TestResult_OutputFormat: NUnitXml - TestResult_OutputPath: .PSModule/Explicit/TestResult.xml + TestResult_OutputPath: artifacts/TestResult/results.xml CodeCoverage_Enabled: true CodeCoverage_OutputFormat: JaCoCo - CodeCoverage_OutputPath: .PSModule/Explicit/CodeCoverage.xml + CodeCoverage_OutputPath: artifacts/CodeCoverage/coverage.xml CodeCoverage_Path: ../../src/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1 - name: Assert report paths @@ -149,9 +149,9 @@ jobs: run: | tests/Assert-ReportPaths.ps1 ` -WorkingDirectory tests/srcTestRepo ` - -TestResultPath .PSModule/Explicit/TestResult.xml ` - -CodeCoveragePath .PSModule/Explicit/CodeCoverage.xml ` - -ArtifactDirectory .PSModule ` + -TestResultPath artifacts/TestResult/results.xml ` + -CodeCoveragePath artifacts/CodeCoverage/coverage.xml ` + -ArtifactDirectory artifacts ` -UnexpectedDirectory TestResult,CodeCoverage,.temp ActionTestInvokePesterDefaultReportPaths: diff --git a/README.md b/README.md index 31489a2..8a7945d 100644 --- a/README.md +++ b/README.md @@ -79,8 +79,8 @@ CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml Set either input to override only that report's location: ```text -TestResult_OutputPath: .PSModule/TestResult/PSScriptAnalyzer-TestResult-Report.xml -CodeCoverage_OutputPath: .PSModule/CodeCoverage/PSScriptAnalyzer-CodeCoverage-Report.xml +TestResult_OutputPath: artifacts/TestResult/results.xml +CodeCoverage_OutputPath: artifacts/CodeCoverage/coverage.xml ``` ## Outputs From db34c16d69bf2a52f0917d40df0330d2c9439bcf Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 10 Sep 2026 20:39:21 +0200 Subject: [PATCH 8/9] Aggregate report path test outcomes --- .github/workflows/Action-Test.yml | 10 ++++++++++ tests/Get-AggregatedStatus.ps1 | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index d0a8566..2e4f399 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -124,6 +124,9 @@ jobs: ActionTestReportPaths: name: Action-Test - [Report Paths] runs-on: ubuntu-latest + outputs: + Outcome: ${{ steps.action-test.outcome }} + Conclusion: ${{ steps.action-test.conclusion }} steps: - name: Checkout repo uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 @@ -157,6 +160,9 @@ jobs: ActionTestInvokePesterDefaultReportPaths: name: Action-Test - [Invoke-Pester Default Report Paths] runs-on: ubuntu-latest + outputs: + Outcome: ${{ steps.action-test.outcome }} + Conclusion: ${{ steps.action-test.conclusion }} steps: - name: Checkout repo uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 @@ -231,6 +237,10 @@ jobs: WithManifestConclusion: ${{ needs.ActionTestSrcWithManifest.outputs.Conclusion }} WithManifestDefaultOutcome: ${{ needs.ActionTestSrcWithManifestDefault.outputs.Outcome }} WithManifestDefaultConclusion: ${{ needs.ActionTestSrcWithManifestDefault.outputs.Conclusion }} + ReportPathsOutcome: ${{ needs.ActionTestReportPaths.outputs.Outcome }} + ReportPathsConclusion: ${{ needs.ActionTestReportPaths.outputs.Conclusion }} + InvokePesterDefaultReportPathsOutcome: ${{ needs.ActionTestInvokePesterDefaultReportPaths.outputs.Outcome }} + InvokePesterDefaultReportPathsConclusion: ${{ needs.ActionTestInvokePesterDefaultReportPaths.outputs.Conclusion }} OutputsOutcome: ${{ needs.ActionTestOutputs.outputs.Outcome }} OutputsConclusion: ${{ needs.ActionTestOutputs.outputs.Conclusion }} steps: diff --git a/tests/Get-AggregatedStatus.ps1 b/tests/Get-AggregatedStatus.ps1 index 2ca554c..46802e3 100644 --- a/tests/Get-AggregatedStatus.ps1 +++ b/tests/Get-AggregatedStatus.ps1 @@ -51,6 +51,16 @@ $jobs = @( Outcome = @{ Actual = $env:WithManifestDefaultOutcome; Expected = 'failure' } Conclusion = @{ Actual = $env:WithManifestDefaultConclusion; Expected = 'success' } } + @{ + Name = 'Action-Test - [Report Paths]' + Outcome = @{ Actual = $env:ReportPathsOutcome; Expected = 'success' } + Conclusion = @{ Actual = $env:ReportPathsConclusion; Expected = 'success' } + } + @{ + Name = 'Action-Test - [Invoke-Pester Default Report Paths]' + Outcome = @{ Actual = $env:InvokePesterDefaultReportPathsOutcome; Expected = 'success' } + Conclusion = @{ Actual = $env:InvokePesterDefaultReportPathsConclusion; Expected = 'success' } + } @{ Name = 'Action-Test - [outputs]' Outcome = @{ Actual = $env:OutputsOutcome; Expected = 'success' } From 5de3efdacac49e7bf88b4ebc04fa8d95c923d63c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 10 Sep 2026 20:44:02 +0200 Subject: [PATCH 9/9] Aggregate report path job results --- .github/workflows/Action-Test.yml | 12 ++---------- tests/Get-AggregatedStatus.ps1 | 8 ++++---- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 2e4f399..2829d54 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -124,9 +124,6 @@ jobs: ActionTestReportPaths: name: Action-Test - [Report Paths] runs-on: ubuntu-latest - outputs: - Outcome: ${{ steps.action-test.outcome }} - Conclusion: ${{ steps.action-test.conclusion }} steps: - name: Checkout repo uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 @@ -160,9 +157,6 @@ jobs: ActionTestInvokePesterDefaultReportPaths: name: Action-Test - [Invoke-Pester Default Report Paths] runs-on: ubuntu-latest - outputs: - Outcome: ${{ steps.action-test.outcome }} - Conclusion: ${{ steps.action-test.conclusion }} steps: - name: Checkout repo uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 @@ -237,10 +231,8 @@ jobs: WithManifestConclusion: ${{ needs.ActionTestSrcWithManifest.outputs.Conclusion }} WithManifestDefaultOutcome: ${{ needs.ActionTestSrcWithManifestDefault.outputs.Outcome }} WithManifestDefaultConclusion: ${{ needs.ActionTestSrcWithManifestDefault.outputs.Conclusion }} - ReportPathsOutcome: ${{ needs.ActionTestReportPaths.outputs.Outcome }} - ReportPathsConclusion: ${{ needs.ActionTestReportPaths.outputs.Conclusion }} - InvokePesterDefaultReportPathsOutcome: ${{ needs.ActionTestInvokePesterDefaultReportPaths.outputs.Outcome }} - InvokePesterDefaultReportPathsConclusion: ${{ needs.ActionTestInvokePesterDefaultReportPaths.outputs.Conclusion }} + ReportPathsResult: ${{ needs.ActionTestReportPaths.result }} + InvokePesterDefaultReportPathsResult: ${{ needs.ActionTestInvokePesterDefaultReportPaths.result }} OutputsOutcome: ${{ needs.ActionTestOutputs.outputs.Outcome }} OutputsConclusion: ${{ needs.ActionTestOutputs.outputs.Conclusion }} steps: diff --git a/tests/Get-AggregatedStatus.ps1 b/tests/Get-AggregatedStatus.ps1 index 46802e3..a8be615 100644 --- a/tests/Get-AggregatedStatus.ps1 +++ b/tests/Get-AggregatedStatus.ps1 @@ -53,13 +53,13 @@ $jobs = @( } @{ Name = 'Action-Test - [Report Paths]' - Outcome = @{ Actual = $env:ReportPathsOutcome; Expected = 'success' } - Conclusion = @{ Actual = $env:ReportPathsConclusion; Expected = 'success' } + Outcome = @{ Actual = $env:ReportPathsResult; Expected = 'success' } + Conclusion = @{ Actual = $env:ReportPathsResult; Expected = 'success' } } @{ Name = 'Action-Test - [Invoke-Pester Default Report Paths]' - Outcome = @{ Actual = $env:InvokePesterDefaultReportPathsOutcome; Expected = 'success' } - Conclusion = @{ Actual = $env:InvokePesterDefaultReportPathsConclusion; Expected = 'success' } + Outcome = @{ Actual = $env:InvokePesterDefaultReportPathsResult; Expected = 'success' } + Conclusion = @{ Actual = $env:InvokePesterDefaultReportPathsResult; Expected = 'success' } } @{ Name = 'Action-Test - [outputs]'