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

Release | Crates.io in CD pipeline doesn't handle cargo publish errors #538

Closed
hannobraun opened this issue May 6, 2022 · 12 comments
Closed
Labels
topic: build Anything relating to the build system. type: bug Something isn't working

Comments

@hannobraun
Copy link
Owner

See this run, which has lots of errors: https://github.com/hannobraun/Fornjot/runs/6311042754?check_suite_focus=true#step:9:76

If a cargo publish fails, the whole step should fail. Maybe it would even be better to abort the step, if a single cargo publish fails.

Crate::submit in release-operator seems to be the relevant piece of code:
https://github.com/hannobraun/Fornjot/blob/6df520ae30c2202c381b7cde8489621d0e67d5f4/tools/release-operator/src/registry.rs#L152-L180

I'm not seeing any checking of the command's return value there, so adding that and failing the whole release-operator, if cargo-publish fails, would probably address this issue.

@hannobraun hannobraun added type: bug Something isn't working topic: build Anything relating to the build system. labels May 6, 2022
hannobraun added a commit that referenced this issue Jul 5, 2022
hannobraun added a commit that referenced this issue Jul 6, 2022
hannobraun added a commit that referenced this issue Jul 7, 2022
@hannobraun
Copy link
Owner Author

hannobraun commented Jul 7, 2022

Still is still the case, despite my attempted fix. Possibly my fix was still wrong, or maybe cargo publish doesn't return proper exit codes.

edit:

Here's a run that has lots of errors in the Release | crates.io step, but neither aborts nor reports the build as having failed: https://github.com/hannobraun/Fornjot/runs/7235411115?check_suite_focus=true

@hendrikmaus
Copy link
Contributor

Just a guess: the shell steps in GitHub actions do not exit properly. I haven't looked at the pipeline yet, but we can try to set -e to abort the entire step after the first non-zero exit code. Better yet set -euo pipefail which will also catch errors within pipelines of multiple shell commands.

I will come up with a pull request after experimenting a bit.

@hendrikmaus
Copy link
Contributor

According to this document set -e is active by default. Will have to do some tests to verify this behavior.

@hannobraun
Copy link
Owner Author

hannobraun commented Jul 8, 2022

I will come up with a pull request after experimenting a bit.

Thank you, @hendrikmaus!

I don't have any more insight, unfortunately. The exit code must get swallowed somewhere, but no idea where specifically.

@hendrikmaus
Copy link
Contributor

I confirmed that the piece of code referenced in the description is the culprit: it does not fail if the command executed returns non-zero. I was under the impression that it would, because the cmd_lib macro in use returns a Result type which is handled by ?.

I will take a closer look at it. Already built myself a simulation to reproduce the error.

@hannobraun
Copy link
Owner Author

I confirmed that the piece of code referenced in the description is the culprit: it does not fail if the command executed returns non-zero. I was under the impression that it would, because the cmd_lib macro in use returns a Result type which is handled by ?.

According to the documentation, it only returns an io::Result. So judging from that alone, it must either ignore exit codes, or if it doesn't, at least doesn't allow the caller to handle them. There's another result type that works the same.

I'm very surprised by this. Seems like a huge oversight for a library whose sole purpose is to do this kind of thing. And one at a version >1.0.0 no less. Honestly, this makes me wonder if we shouldn't just stop using it. The standard library might be less convenient, but at least it returns ExitStatus.

I will take a closer look at it. Already built myself a simulation to reproduce the error.

Thank you!

@hannobraun
Copy link
Owner Author

I'm working on publishing the next release right now. I'll take a stab at fixing this, in case that turns out relatively straight-forward. If not, I'll leave it for now.

Sorry, if that conflicts with some of the work you're doing, @hendrikmaus.

@hannobraun
Copy link
Owner Author

@hendrikmaus
Copy link
Contributor

Nice, I was going to submit something quite similar. You beat me to it 😊
Maybe I'll add back the continuous output while the command is running.

@hannobraun
Copy link
Owner Author

Maybe I'll add back the continuous output while the command is running.

I think the output already is continuous? At least it should be. Command inherits stdin/stdout/stderr from the parent process.

@hendrikmaus
Copy link
Contributor

You are correct; I was overthinking it and did not see that Command::status() actually runs the command 🤦🏻 I assumed it would only yield a status after a command was executed.

Good job!

@hannobraun
Copy link
Owner Author

Good job!

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: build Anything relating to the build system. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants