-
Notifications
You must be signed in to change notification settings - Fork 247
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
Fix bug where Pester fails to run but workflow pipeline itself doesn't fail #1470
Open
james-garriss
wants to merge
161
commits into
main
Choose a base branch
from
1454-pipeline-does-not-fail-on-pester-fail
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
161 commits
Select commit
Hold shift + click to select a range
35f98e9
intentionally cause an error
james-garriss d4c5303
add try catch block
james-garriss ac0c901
add errorvariable and check count
james-garriss 4ff2b5c
try the CI flag
james-garriss cb4a46f
add erroraction stop
james-garriss b091c7e
set ErrorActionPreference
james-garriss b9a2a47
write the error message
james-garriss c7f7c40
rethrow the err
james-garriss d9dbbcc
remove ErrorActionPreference
james-garriss 52548d9
remove try catch
james-garriss 337094f
use exit 1
james-garriss 3e1942f
add write
james-garriss 5f194a6
print result
james-garriss 5fa2772
print just result
james-garriss e5be4cd
get type
james-garriss ae1e250
check result for null
james-garriss 28d9175
fix typo
james-garriss f81e7d4
fix lint
james-garriss 52764e9
should work
james-garriss d0da0c4
put result outside of try catch
james-garriss 2e86f1e
only try invoke pester
james-garriss 437c641
use configuration
james-garriss 26c28fc
send to stream
james-garriss a40caa8
write the result
james-garriss 73f0bd2
try passthru
james-garriss a384091
try passthru wo config
james-garriss 549cbc7
fix lint
james-garriss 8a13c24
try for failure with bad dir
james-garriss b3d723e
clean up code
james-garriss 708ff04
i hate yaml lint
james-garriss e930e42
set correct dir
james-garriss c56c8b3
use function
james-garriss 1aab9d0
fix path
james-garriss d6e0d25
test w bad dir
james-garriss b6817ad
update powershell unit tests to use function
james-garriss 8ffcf46
fix linter
james-garriss 2de374b
move test files
james-garriss fabde4f
debug path
james-garriss a00fb37
find name of files
james-garriss e05ea9f
ignore dummy file
james-garriss f6f63cd
more different remove
james-garriss 9145f40
remove file from collection
james-garriss 83d7c9a
find files
james-garriss 747aed6
source functions
james-garriss 69cb887
test pssa install
james-garriss 8c73c10
add params to invoke call
james-garriss e4a4e5e
add results test
james-garriss e344a30
add write test
james-garriss cac5992
fix pssa error (oh the irony)
james-garriss a55d089
Remove afterall
james-garriss 6087ae2
comment
james-garriss c27968e
all comms
james-garriss 5b56337
remove alt test
james-garriss c81cfdf
test output
james-garriss 414f30a
fix order
james-garriss cbf53e5
Fix typo
james-garriss ec5eca5
try write-host
james-garriss d39b7d2
sssh to PSSA
james-garriss e0d67f5
add before discovery
james-garriss 849e248
fixed scope
james-garriss 70472fc
Split describe
james-garriss 91b935a
fix lint
james-garriss 020c55a
fix typo
james-garriss 0ca0f43
fix another typo grrrrr
james-garriss 2d93e8f
try redirect
james-garriss 2c993b3
remove write host
james-garriss d530107
fix the test to be a complete sentence
james-garriss 0acafe5
Fix or
james-garriss b6cd533
FIx or
james-garriss 83f9f9e
fix or
james-garriss aab0a61
Find last output
james-garriss adf0db7
Condense to one it
james-garriss 7738f7b
set output to global
james-garriss 98ce945
Suppress PSSA global
james-garriss 968dbba
Split back into 2 describes
james-garriss 35b778a
test concurrency
james-garriss 60a7a6c
remove publish tests
james-garriss 1f51d44
remove pssa
james-garriss ef9a22f
put publish back
james-garriss 39f1de2
combine pssa check
james-garriss ea1cd53
fix lint
james-garriss 24c06bc
add missing variable
james-garriss 96d1efc
remove tests
james-garriss 122188d
fix lint
james-garriss 4c33edf
debug
james-garriss 78bea91
debug
james-garriss e2c8cc8
fix lint
james-garriss 10c4922
use write-warning
james-garriss 43fd3b0
debug paths
james-garriss 3e27fae
fix lint
james-garriss 6c31eb5
Debug
james-garriss 122deab
fix scriptpath
james-garriss f52b045
convert to string
james-garriss ac8181a
fix lint
james-garriss 8a892db
invoke again
james-garriss 7346658
fix path
james-garriss f0ae516
test invoke in bd
james-garriss 36ad99b
test output
james-garriss 06cf676
suppress PSSA
james-garriss 65cfa71
tweak global
james-garriss 56b32d4
just check install
james-garriss c14f885
fix typo in invoke
james-garriss 73e4e4b
Change to Before All
james-garriss 7172f8d
just run invoke pssa
james-garriss 108b0a9
just run pssa
james-garriss 455dc0f
tweak test
james-garriss 6179116
fix source
james-garriss 19922ae
remvoe suppress
james-garriss 9c41409
remove before discovery
james-garriss a622563
list path
james-garriss f486c94
just invoke
james-garriss bc1278a
don't invoke
james-garriss a75d570
fix source
james-garriss b3021be
add suppress
james-garriss aa5b6c0
debug
james-garriss 21118b4
add foreach
james-garriss 56f6ad0
summarize
james-garriss 7d31c0c
check exists
james-garriss a5794e4
drop param
james-garriss 9a8fd85
change to warning
james-garriss d89fb19
change more to warning
james-garriss 2cb026b
add debug mode
james-garriss eff9abb
finish warning
james-garriss 0452695
remove exit 0
james-garriss e5b2284
test install
james-garriss 38910bc
use output
james-garriss df9228d
use 3
james-garriss 816aad3
check write warning
james-garriss 4deb3f3
use warning variable
james-garriss 5c918b9
write out the warnings
james-garriss 6ea07d2
fix the test
james-garriss f807a92
split tests
james-garriss 9a9a9ce
change location
james-garriss 7ef907f
fix warning variable name
james-garriss 2bc9a5c
time serial
james-garriss ccd125c
make serial for real
james-garriss 9d6f8e6
Put in final form
james-garriss 1ca834d
Put workflow pipeline back
james-garriss afca642
tweak docs
james-garriss 74ca59e
remove unused
james-garriss d818a00
exclude dummy
james-garriss d9e7110
list file
james-garriss 807b6da
fix bug in job name
james-garriss aee6bdb
put scriptblock inside {}
james-garriss a14337d
fix path
james-garriss 295ab97
fix path.
james-garriss a6b2e0f
test for exit codes
james-garriss b28ba90
just run it.
james-garriss a72fbed
add missing }
james-garriss 96b9509
write the result
james-garriss ebd9459
Run locally to see fail
james-garriss 21a2d08
see the error
james-garriss aec09b7
Using Pester to test Pester is no
james-garriss 56be848
add trivial pester pass
james-garriss e37f2ac
use trivial test
james-garriss 27b6e93
There is not a dummy fail after all.
james-garriss 667d97d
Fail intentionally
james-garriss 3e70d6c
Set to pass, add comment
james-garriss 228ab42
Undo changes
james-garriss 78510e7
Merge branch 'main' into 1454-pipeline-does-not-fail-on-pester-fail
james-garriss 2128511
fix typo
james-garriss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Ultra trivial Pester test that should always pass. | ||
|
||
Describe "Pester Check" { | ||
It "Passing test should pass." { | ||
$true | Should -Be $true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# The purpose of this test is to have a trivial Pester test that passes. | ||
# This simply verifies that Pester is running. | ||
|
||
Describe "Pester Check" { | ||
It "Passing test should pass." { | ||
$TestFile = Join-Path -Path $PSScriptRoot -ChildPath '../../Testing/PesterTestFile/SimplePassFile.ps1' -Resolve | ||
# Source the function | ||
. utils/workflow/Invoke-PesterTests.ps1 | ||
Invoke-PesterTests -Path $TestFile | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function Invoke-PesterTests { | ||
<# | ||
.SYNOPSIS | ||
Calls the Invoke-Pester command to test the PowerShell files in some location. | ||
.PARAMETER Path | ||
The path to the PowerShell. This can be a directory or a file. | ||
#> | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$Path | ||
) | ||
Write-Warning "The path to test is ${Path}." | ||
# The -PassThru parameter is what allows the output to be passed to the $result output. | ||
# https://pester.dev/docs/commands/Invoke-Pester#-passthru | ||
$result = Try { | ||
Invoke-Pester -Output 'Detailed' -Path $Path -PassThru | ||
} Catch { | ||
# This catches an error with the Pester tests. | ||
Write-Warning "An error occurred while running the Pester tests:" | ||
Write-Warning $_ | ||
exit 1 | ||
} | ||
# This catches an error that causes Pester not to run at all | ||
# (e.g., if the -Path is set to a nonexistent directory). | ||
if ($null -eq $result) { | ||
throw "The Pester tests failed to run." | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our test file process to date was usually to embed the files in a subdirectory under the place where the tests themselves were written. So would it make more sense to put the PesterTestFile directory under workflow?