Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹[Patch] Add workflow notice for succeeded tests #11

Merged
merged 11 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 3 additions & 15 deletions scripts/helpers/Test-PSModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function Test-PSModule {
Run = @{
Path = $Path
Container = $containers
PassThru = $false
PassThru = $true
}
TestResult = @{
Enabled = $true
Expand Down Expand Up @@ -128,23 +128,11 @@ function Test-PSModule {
Start-LogGroup 'Run tests'
$verbosepref = $VerbosePreference
$VerbosePreference = 'SilentlyContinue'
Invoke-Pester @pesterParams
$results = Invoke-Pester @pesterParams
$VerbosePreference = $verbosepref
$failedTests = $LASTEXITCODE
if ($failedTests -gt 0) {
Write-Error "[$failedTests] tests failed"
} else {
Write-Verbose 'All tests passed'
}
Write-Verbose 'Done'
Stop-LogGroup
#endregion

if ($failedTests -eq 0) {
Write-Verbose '✅ All tests passed.'
} else {
Write-Warning "❌ Failed tests: [$failedTests]"
}

$failedTests
$results
}
11 changes: 10 additions & 1 deletion scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,14 @@ Stop-LogGroup
$params = @{
Path = $codeToTest
}
$failedTests = Test-PSModule @params
$results = Test-PSModule @params

Start-LogGroup 'Test results'
Write-Verbose ($results | Out-String)
Stop-LogGroup

$failedTests = $results.FailedCount
if ($failedTests -eq 0) {
Write-Output '::notice::✅ All tests passed.'
}
exit $failedTests
Loading