Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
daedd98
🩹 [Patch]: Update default working directory in action.yml to use a re…
MariusStorhaug Mar 6, 2025
0a6707a
🩹 [Patch]: Enhance test file discovery by separating root and subfold…
MariusStorhaug Mar 8, 2025
403457a
🩹 [Patch]: Refactor test file combination to use a generic List for i…
MariusStorhaug Mar 8, 2025
556da9c
🩹 [Patch]: Enhance error handling in action.yml and main.ps1 for test…
MariusStorhaug Mar 8, 2025
34d47cf
🩹 [Patch]: Refactor test execution workflow to improve output handlin…
MariusStorhaug Mar 8, 2025
04d1e60
🩹 [Patch]: Replace main.ps1 with exec.ps1 to consolidate test executi…
MariusStorhaug Mar 8, 2025
7b0d20d
🩹 [Patch]: Improve test result handling in action.yml by consolidatin…
MariusStorhaug Mar 8, 2025
86bfa45
🩹 [Patch]: Add outputs for test results, outcome, and conclusion in a…
MariusStorhaug Mar 8, 2025
b9a84ec
🩹 [Patch]: Add new test job for simple execution failure in Action-Te…
MariusStorhaug Mar 8, 2025
2d95d19
🩹 [Patch]: Remove obsolete ExecutionFailure.Tests.ps1 and replace wit…
MariusStorhaug Mar 8, 2025
9ca1e6a
🩹 [Patch]: Refactor test result handling in action.yml to use a custo…
MariusStorhaug Mar 8, 2025
84c71d5
🩹 [Patch]: Disable continue-on-error for test jobs in Action-Test.yml…
MariusStorhaug Mar 8, 2025
ec33c4c
🩹 [Patch]: Enable continue-on-error for test jobs in Action-Test.yml
MariusStorhaug Mar 8, 2025
0f985cf
🩹 [Patch]: Enhance error handling in action.yml to check for test out…
MariusStorhaug Mar 8, 2025
ed3e578
Refactor outcome and conclusion checks in action.yml for improved cla…
MariusStorhaug Mar 8, 2025
b8f4a9c
Refactor error handling in action.yml for better clarity and maintain…
MariusStorhaug Mar 8, 2025
e18fcac
Refactor string interpolation in Action-Test.yml for consistency and …
MariusStorhaug Mar 8, 2025
8f20398
Enhance README and action.yml to include additional test output metri…
MariusStorhaug Mar 8, 2025
d1e6084
Refactor output formatting in Action-Test.yml to use Format-List for …
MariusStorhaug Mar 8, 2025
5d0d8ea
Refactor output variables in Action-Test.yml for improved clarity and…
MariusStorhaug Mar 8, 2025
576e44e
Refactor output handling in action.yml to use status step for test ex…
MariusStorhaug Mar 8, 2025
51fdff6
Update expected outcomes in Action-Test.yml for failure test cases
MariusStorhaug Mar 8, 2025
d94107c
Enhance README to provide detailed test outcome metrics and update ac…
MariusStorhaug Mar 8, 2025
274dfe3
Fix variable names in Action-Test.yml for clarity in error reporting
MariusStorhaug Mar 8, 2025
00fec1c
Refactor Action-Test.yml to improve variable naming for clarity in te…
MariusStorhaug Mar 8, 2025
7b6da25
Fix variable naming in Action-Test.yml for consistency in result eval…
MariusStorhaug Mar 8, 2025
2349146
Update jscpd configuration to ignore Action-Test workflow files
MariusStorhaug Mar 8, 2025
9d5b2e2
Fix jscpd configuration to correctly ignore Action-Test workflow files
MariusStorhaug Mar 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"consoleFull"
],
"ignore": [
"**/tests/**"
"**/tests/**",
"**/.github/workflows/Action-Test**"
],
"absolute": true
}
235 changes: 182 additions & 53 deletions .github/workflows/Action-Test.yml

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions .github/workflows/Auto-Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ jobs:

- name: Auto-Release
uses: PSModule/Auto-Release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
231 changes: 162 additions & 69 deletions README.md

Large diffs are not rendered by default.

91 changes: 86 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,57 @@ inputs:
WorkingDirectory:
description: The working directory where the script will run from.
required: false
default: ${{ github.workspace }}
default: '.'

outputs:
Outcome:
description: |
The outcome of the test run.
value: ${{ steps.test.outcome }}
Conclusion:
description: |
The conclusion of the test run.
value: ${{ steps.test.conclusion }}
Executed:
description: |
Whether tests were executed.
value: ${{ steps.status.outputs.Executed }}
Result:
description: |
Overall result of the Pester test run (e.g., Passed, Failed).
value: ${{ steps.test.outputs.Result }}
FailedCount:
description: |
Number of failed tests.
value: ${{ steps.test.outputs.FailedCount }}
FailedBlocksCount:
description: |
Number of failed blocks.
value: ${{ steps.test.outputs.FailedBlocksCount }}
FailedContainersCount:
description: |
Number of failed containers.
value: ${{ steps.test.outputs.FailedContainersCount }}
PassedCount:
description: |
Number of passed tests.
value: ${{ steps.test.outputs.PassedCount }}
SkippedCount:
description: |
Number of skipped tests.
value: ${{ steps.test.outputs.SkippedCount }}
InconclusiveCount:
description: |
Number of inconclusive tests.
value: ${{ steps.test.outputs.InconclusiveCount }}
NotRunCount:
description: |
Number of tests not run.
value: ${{ steps.test.outputs.NotRunCount }}
TotalCount:
description: |
Total count of tests.
value: ${{ steps.test.outputs.TotalCount }}

runs:
using: composite
Expand Down Expand Up @@ -268,14 +318,16 @@ runs:
# Invoke-Pester (init)
${{ github.action_path }}/scripts/init.ps1

- name: Invoke-Pester
- name: Invoke-Pester (exec)
shell: pwsh
continue-on-error: true
working-directory: ${{ inputs.WorkingDirectory }}
env:
PSMODULE_INVOKE_PESTER_INPUT_ReportAsJson: ${{ inputs.ReportAsJson }}
id: test
run: ${{ github.action_path }}/scripts/main.ps1
run: |
# Invoke-Pester (exec)
${{ github.action_path }}/scripts/exec.ps1

- name: Upload test results - [${{ steps.test.outputs.TestSuiteName }}-TestResults]
uses: actions/upload-artifact@v4
Expand All @@ -297,10 +349,39 @@ runs:

- name: Status
shell: pwsh
id: status
working-directory: ${{ inputs.WorkingDirectory }}
env:
PSMODULE_INVOKE_PESTER_INTERNAL_Executed: ${{ steps.test.outputs.Executed }}
PSMODULE_INVOKE_PESTER_INTERNAL_Outcome: ${{ steps.test.outcome }}
PSMODULE_INVOKE_PESTER_INTERNAL_Conclusion: ${{ steps.test.conclusion }}
run: |
$outcome = '${{ steps.test.outcome }}'
Write-Host "outcome: [$outcome]"
# Status
$PSStyle.OutputRendering = 'Ansi'
$executed = $env:PSMODULE_INVOKE_PESTER_INTERNAL_Executed -eq 'true'
$outcome = $env:PSMODULE_INVOKE_PESTER_INTERNAL_Outcome
$conclusion = $env:PSMODULE_INVOKE_PESTER_INTERNAL_Conclusion

"Executed=$executed" >> $env:GITHUB_OUTPUT

[PSCustomObject]@{
Executed = $executed
Outcome = $outcome
Conclusion = $conclusion
} | Format-List | Out-String

# If the tests did not execute, exit with a failure code
if ($executed -ne 'true') {
Write-Error "Tests did not execute."
exit 1
}
# If the outcome is not success, exit with a failure code
if ($outcome -ne 'success') {
Write-Error "Tests did not pass."
exit 1
}
# If the conclusion is not success
if ($conclusion -ne 'success') {
Write-Error "Tests did not pass."
exit 1
}
13 changes: 13 additions & 0 deletions scripts/main.ps1 → scripts/exec.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ if (-not (Test-Path -Path $configPath)) {
exit 1
}
Get-Content -Path $configPath -Raw
'::endgroup::'

'::group::Exec - PesterConfiguration'
$configuration = . $configPath
$configuration.Run.Container = @()
$containerFiles = Get-ChildItem -Path $path -Filter *.Container.* -Recurse | Sort-Object FullName
Expand Down Expand Up @@ -99,6 +102,16 @@ LogGroup 'Eval - Set outputs' {
Set-GitHubOutput -Name 'TestResultOutputPath' -Value $testResultOutputFolderPath
Set-GitHubOutput -Name 'CodeCoverageEnabled' -Value $testResults.Configuration.CodeCoverage.Enabled.Value
Set-GitHubOutput -Name 'CodeCoverageOutputPath' -Value $codeCoverageOutputFolderPath
Set-GitHubOutput -Name 'Executed' -Value $testResults.Executed
Set-GitHubOutput -Name 'Result' -Value $testResults.Result
Set-GitHubOutput -Name 'FailedCount' -Value $testResults.FailedCount
Set-GitHubOutput -Name 'FailedBlocksCount' -Value $testResults.FailedBlocksCount
Set-GitHubOutput -Name 'FailedContainersCount' -Value $testResults.FailedContainersCount
Set-GitHubOutput -Name 'PassedCount' -Value $testResults.PassedCount
Set-GitHubOutput -Name 'SkippedCount' -Value $testResults.SkippedCount
Set-GitHubOutput -Name 'InconclusiveCount' -Value $testResults.InconclusiveCount
Set-GitHubOutput -Name 'NotRunCount' -Value $testResults.NotRunCount
Set-GitHubOutput -Name 'TotalCount' -Value $testResults.TotalCount

if ($env:PSMODULE_INVOKE_PESTER_INPUT_ReportAsJson -eq 'true' -and $testResults.Configuration.TestResult.Enabled.Value) {
$jsonOutputPath = $testResults.Configuration.TestResult.OutputPath.Value -Replace '\.xml$', '.json'
Expand Down
28 changes: 23 additions & 5 deletions scripts/init.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -194,20 +194,37 @@ LogGroup 'Init - Export containers' {
$containerFiles = Get-ChildItem -Path $testDir -Filter *.Container.* -Recurse
Write-Output "Containers found in [$testDir]: [$($containerFiles.Count)]"
if ($containerFiles.Count -eq 0) {
# Look for test files and make a container for each test file.
$testFiles = Get-ChildItem -Path $testDir -Filter *.Tests.ps1 -Recurse
Write-Output "Test files found in [$testDir]: [$($testFiles.Count)]"
# First, look for test files directly in the test directory (non-recursive)
$rootTestFiles = Get-ChildItem -Path $testDir -Filter *.Tests.ps1 -File
Write-Output "Root level test files found in [$testDir]: [$($rootTestFiles.Count)]"

# Then, look for test files in subdirectories
$subfolderTestFiles = Get-ChildItem -Path $testDir -Filter *.Tests.ps1 -Recurse -File |
Where-Object { $_.DirectoryName -ne $testDir }
Write-Output "Subfolder test files found in [$testDir]: [$($subfolderTestFiles.Count)]"

# Combine all test files using a generic List
$testFiles = [System.Collections.Generic.List[System.IO.FileInfo]]::new()
if ($rootTestFiles) {
$rootTestFiles | ForEach-Object { $testFiles.Add($_) }
}
if ($subfolderTestFiles) {
$subfolderTestFiles | ForEach-Object { $testFiles.Add($_) }
}
Write-Output "Total test files found in [$testDir]: [$($testFiles.Count)]"

foreach ($testFile in $testFiles) {
$container = @{
Path = $testFile.FullName
}
$containerFileName = ($testFile | Split-Path -Leaf).Replace('.Tests.ps1', '.Container.ps1')
LogGroup "Init - Export containers - Generated - $containerFileName" {
$containerFileName = ($testFile | Split-Path -Leaf).Replace('.Tests.ps1', '.Container.ps1')
Write-Output "Exporting container [$path/$containerFileName]"
Export-Hashtable -Hashtable $container -Path "$path/$containerFileName"
}
Write-Output "Containers created from test files: [$($containers.Count)]"
$containers += $container
}
Write-Output "Containers created from test files: [$($containers.Count)]"
}
foreach ($containerFile in $containerFiles) {
$container = Import-Hashtable $containerFile
Expand All @@ -217,6 +234,7 @@ LogGroup 'Init - Export containers' {
Write-Output "Exporting container [$path/$containerFileName]"
Export-Hashtable -Hashtable $container -Path "$path/$containerFileName"
}
$containers += $container
}
}
$configuration.Run.Container = @()
Expand Down
1 change: 1 addition & 0 deletions tests/1-Simple-ExecutionFailure/ExecutionFailure.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"Not a testfile"