-
-
Notifications
You must be signed in to change notification settings - Fork 693
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
feat: Commands should fail the build if their exit code is not zero #534
Conversation
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.
I am just double-checking with you, will we also see the text of the error?
@pdecat WDYT?
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.
Without any testing, the changes look good to me.
However, I'm a bit confused about the closing of the w
file descriptor right above.
package.py
Outdated
exit_code = p.wait() | ||
if exit_code != 0: | ||
raise RuntimeError( | ||
"Script did not run successfully" |
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.
I'd trace the exit code for easier debugging:
"Script did not run successfully" | |
"Script did not run successfully, exit code {}".format(exit_code) |
package.py
Outdated
@@ -893,7 +893,11 @@ def execute(self, build_plan, zip_stream, query): | |||
pass_fds=(w,)) | |||
os.close(w) |
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.
Shouldn't this be closed after p.wait()
has returned?
I don't understand why the test is failing on Github Action. Works fine locally. |
@Fran-Rg I think you need to fix the conflicts, and then GitHub can restart it automatically. If it doesn't happen by itself, I can hit the restart button manually. |
I ended up reformatting the code as the |
The If we look at this code fragment from v6.8.0:
The result of |
But then the result of |
It was just logged in |
I believe this is makes it not powershell friendly since |
In my opinion, passing |
That is right, I've added a comment. So initially what was causing the exit code not caring about the actual problem was the "pwd" being appended. Since it's for a log only removing it cleared the problem |
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.
Awesome, thanks for adding the unit tests!
I'll try this PR ASAP.
Maybe rebase/squash some git commits to cleanup history. |
## [7.1.0](v7.0.0...v7.1.0) (2024-01-22) ### Features * Commands should fail the build if their exit code is not zero ([#534](#534)) ([eebfc36](eebfc36))
This PR is included in version 7.1.0 🎉 |
There was no need to prepare git history because we always squash commits during PR merge. Thank you! |
Unfortunately after this change debugging of custom commands becomes a lot harder since the logs from stdout/stderr are printed only on failure. In addition before we had streaming logs due to the pipes. Now the stderr and out are separated out which makes it harder to correlate them. Also I believe the wrong logger is used? I had to change |
Just for completeness: I believe this PR finally fixes #388 |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Description
When running with some source_path setting a command:
It might happen the commands fails and we want to fail the terraform deployment
Motivation and Context
Before packaging we needed to set some auth token for npm resources. In some rare cases the authentication failed but the build carried on.
Breaking Changes
No
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request