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

Windows auto builds don't terminate when an external process fails #20

Open
oblivioncth opened this issue May 25, 2022 · 5 comments
Open
Labels
bug Something isn't working

Comments

@oblivioncth
Copy link
Owner

Issue with PS. Current solution would require adding last error code check to every external process start.

Instead, waiting on feature new to have this behavior be automatic in 7.3.0

PowerShell/PowerShell-RFC#277
https://docs.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-73?view=powershell-7.2

@oblivioncth oblivioncth added the bug Something isn't working label May 25, 2022
@oblivioncth
Copy link
Owner Author

The feature is now available in 7.3.0 as an experimental feature. This means that in order to use it, one must execute the following and then restart Powershell:
Enable-ExperimentalFeature PSNativeCommandErrorActionPreference

This means that every workflow job would need to have an extra step that does the above, which would be quite inconvenient, especially given that the jobs also need a step for enabling the feature on that specific "script":
$PSNativeCommandUseErrorActionPreference = $true.

Probably will wait until the feature isn't experimental unless there's an easier way to enable experimental features in PS for workflows globally. Additionally, research needs to be done to see if there is a similarly easy way to set the preference itself globally.

@oblivioncth
Copy link
Owner Author

Starting with 7.4.0 $PSNativeCommandUseErrorActionPreference = $true is the default, so currently the only remaining blocker is that the feature is still experimental and therefore cannot be activated conveniently for workflows.

@oblivioncth
Copy link
Owner Author

oblivioncth commented Jul 10, 2024

Looks like it actually went mainstream with 7.4.0 so I just need to add it to the script and test that it works.

Might also have to set $ErrorActionPreference to Stop

@oblivioncth
Copy link
Owner Author

oblivioncth commented Aug 23, 2024

I believe we just want:

$ErrorActionPreference= "Stop"
$PSNativeCommandUseErrorActionPreference = $true

At the top of applicable pwsh scripts, though this could still be quite a number of usages. Would be better if this can be applied once as an env. var. perhaps.

@oblivioncth
Copy link
Owner Author

Seems like in theory GitHub should be open to enabling this by default based on their existing default settings for pwsh and bash that prefer "fail-fast" behavior. This was addressed once before, but left alone as it was believed that pwsh 7.4 was going to have the feature enabled by default anyway; however, that ended up not being the case:

actions/runner-images#8900

Probably should make a new issue if this point is ignored for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant