-
-
Notifications
You must be signed in to change notification settings - Fork 420
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
An option to run full composite despite to errors #2582
Conversation
New option introduced that changes the behavior of composite script to executes all the scripts despite to present errors. Exit code is sum of all the codes. The name of the option 'keep_going' is inspired/reused from 'GNU make' with similar/same purpose.
for more information, see https://pre-commit.ci
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2582 +/- ##
=======================================
Coverage 84.79% 84.80%
=======================================
Files 104 104
Lines 10387 10390 +3
Branches 2272 2273 +1
=======================================
+ Hits 8808 8811 +3
Misses 1105 1105
Partials 474 474
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
src/pdm/cli/commands/run.py
Outdated
return code | ||
if not keep_going: | ||
return code | ||
composite_code += code |
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.
What is the meaning of sum of the return code, if more than one processes return non-zero?
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.
Well, the expectation (mine expectation) is that composite will fail in case of a failure. Only change is that it will run all the "sobcommands", so non-zero code is needed. And so far I believe the exact value of the code does not matter that much, so I chose to do a sum. Anyway any value, even fixed should be appropriate, just the indication that something has failed (non-zero exit code) should remain.
In theory, if all the "subcommands" will fail with code 1 (or any other known value), then yes, I was also thinking that it could be useful information to preserve it somehow in the composite_code, therefore sum. Honestly I do not assume that this can have real use, but still there.
I am not going to accept this patch because I don't think this requirement has been carefully considered.
While your patch only cover a small part of all use cases, yes, your use case, it will bring more confusion compared to not supporting at all. The scope of a feature may be larger than you'd think, large enough that I think it goes beyond the responsibilities of PDM. As a workaround, you can either:
PDM is never built to be an all-in-one tool, we choose to not support some features, leaving the flexibility to users. |
Correct, this covers only an existing use case that I am aware of. Actually it might be rather bad idea if I was implementing a solution for use cases that I am not aware of as the outcome wouldn't be optimal. This proposal doesn't seem to be in conflict with use cases you outlined. For example anyone interested in case Case I understand that there can be many other 'unspoken' and uncovered use cases, however the development should not be stopped by possible conflicts with unknowns, should be? Of course, plenty of solutions outside of pdm already exist, actually neither 'composite' is needed. But it is there luckily and it is very helpful. It can be even better with this small change. I can think of returned code, current sum doesn't seem to be optimal actually. I think fixed value or code of last failure would be much better. I'd like to ask you kindly to reconsider your decision again. I agree this does solve only my requirement, on the other hand I believe that it is fair. The 'composite' feature when implemented also solved only someone's requirement, at the end is useful for everyone. Furthermore as mentioned I think this neither conflicts with anything nor introduces any sign of complexity. Thank You for your time spent on my PR in any case. |
I'd suggest following what Bash's
IMO summing exit codes is not only confusing, it can even be wrong: if all exit codes reach 256 together, then your exit code will be modded to 0! % bash -c 'exit 256'; echo $?
0
% bash -c 'exit 257'; echo $?
1 |
Failure return code of composite/keep_going is the code of last failed script now. This is more predictable behavior, it follows already used pattern and it avoids unexpected buggy behavior.
I updated this PR to return rather the code of last failed job in case of failure. |
New option introduced that changes the behavior of composite script to executes all the scripts despite to present errors. Exit code is sum of all the codes. The name of the option 'keep_going' is inspired/reused from 'GNU make' with similar/same purpose.
Pull Request Checklist
news/
describing what is new.Describe what you have changed in this PR.