Skip to content

Conversation

@hoffie
Copy link
Member

@hoffie hoffie commented Jan 25, 2022

Short description of changes

Currently, build errors such as failure to download Qt do not fail the script. As such, they do not fail the workflow step either. The workflow continues and fails at a very late stage, which is annoying and wastes ressources.

This commit sets $ErrorActionPreference = "Stop" for all relevant PowerShell scripts in order to fail early for PowerShell-internal errors.

This commits also adds exit code checks for all relevant external commands as PowerShell does not consider them to be errors otherwise.

Context: Fixes an issue?

Fixes #2276

Does this change need documentation? What needs to be documented and how?

No. Does not need a ChangeLog entry either.
CHANGELOG: SKIP

Status of this Pull Request

Ready.

What is missing until this pull request can be merged?

Ready.

Checklist

@hoffie hoffie added this to the Release 3.8.2 milestone Jan 25, 2022
Copy link
Member Author

@hoffie hoffie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes one gets to be lucky. CI on this very PR failed. It failed due to Qt download flakiness, which is what I'm mostly after with this PR. And it failed as it should, it failed in the very first stage. There can hardly be a better test case... ;)

https://github.com/jamulussoftware/jamulus/runs/4941257866?check_suite_focus=true
Screenshot 2022-01-25 at 19-11-34 Windows Build Clean up style wording · jamulussoftware jamulus 9a71c65

The checks completed successfully on the second try though.

This PR is now ready for review.

)

# Fail early on all errors
$ErrorActionPreference = "Stop"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered adding this line at the very top of the script, but this breaks param() which has to be the first statement in a script (when used).

echo "Install Qt..."
# Install Qt
pip install aqtinstall
if ( !$? )
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had really hoped for $ErrorActionPreference to cover external command failures as well, but sadly it doesn't. There doesn't seem to be an equivalent to bash's set -eu either. So, manual error checking is all we're left with.

I considered adding a function to do that to avoid code duplication (similar to deploy_windows.ps1's Invoke-Native-Command), but I figured it's not worth it given the low number of repetitions within a single script.

Copy link
Collaborator

@pljones pljones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't see anything wrong. Thanks!

@hoffie hoffie requested a review from ann0see January 25, 2022 22:21
Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small clarifications. I hope I found all.

hoffie and others added 2 commits January 26, 2022 08:32
Currently, build errors such as failure to download Qt do not fail the
script. As such, they do not fail the workflow step either. The workflow
continues and fails at a very late stage, which is annoying and wastes
ressources.

This commit sets `$ErrorActionPreference = "Stop"` for all relevant
PowerShell scripts in order to fail early for PowerShell-internal
errors.

This commits also adds exit code checks for all relevant external
commands as PowerShell does not consider them to be errors otherwise.

Fixes jamulussoftware#2276

Co-authored-by: ann0see <20726856+ann0see@users.noreply.github.com>
@hoffie hoffie force-pushed the win-build-fail-early branch from 9a71c65 to 15db09e Compare January 26, 2022 07:33
@hoffie hoffie requested a review from ann0see January 26, 2022 07:34
Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Thanks

@hoffie hoffie merged commit b324ee8 into jamulussoftware:master Jan 26, 2022
@hoffie hoffie deleted the win-build-fail-early branch March 19, 2022 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Build: Fail workflow early on errors

3 participants