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

Add option to fail on error when running with upload-to-github #327

Merged

Conversation

wmartins
Copy link
Contributor

@wmartins wmartins commented Dec 7, 2023

This PR potentially fixes #326 and adds an option to fail on error when running upload-to-github.

Disclaimer: I'm not well versed in Rust, so feel free to suggest any modifications.

Also, if you don't agree with the solution for the problem itself, I don't mind closing this one and the issue.

Thank you!

Copy link

netlify bot commented Dec 7, 2023

👷 Deploy request for squawkhq pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit c97702f

@wmartins wmartins force-pushed the issue/326/add-option-to-exit-on-error branch from 7355e20 to e7a76b0 Compare December 7, 2023 16:56
@@ -167,5 +174,10 @@ pub fn check_and_comment_on_pr(
&comment_body,
)?;
}

if !is_empty && exit_on_error {
Copy link
Owner

Choose a reason for hiding this comment

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

isn't !is_empty always true because we'll return on line 143 if is_empty is true?

Suggested change
if !is_empty && exit_on_error {
if exit_on_error {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're absolutely right! Done in e5de367.

&gh,
&github_repo_owner,
&github_repo_name,
github_pr_number,
&comment_body,
)?);
)?;
}
}
if let Some(github_token) = github_token {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if let Some(github_token) = github_token {
else if let Some(github_token) = github_token {

so we don't have a case where we could have commont_on_pr run twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed that, thanks for mentioning. Done in fcc2dca.

@@ -59,6 +61,9 @@ pub enum Command {
/// --exclude=require-concurrent-index-creation,ban-drop-database
#[structopt(short, long, use_delimiter = true)]
exclude: Option<Vec<RuleViolationKind>>,
/// Exits with an error code when specified
#[structopt(long)]
exit_on_error: bool,
Copy link
Owner

Choose a reason for hiding this comment

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

thoughts on calling it something like:

Suggested change
exit_on_error: bool,
exit_on_violations: bool,

or maybe

Suggested change
exit_on_error: bool,
exit_with_code_on_violations: bool,

since we do exit with an error already, just not when there's violations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which one do you prefer? Another option on the table would be instead of using exit using something like fail: fail_on_violations

Copy link
Owner

Choose a reason for hiding this comment

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

Oh I like fail_on_violations!!

@sbdchd
Copy link
Owner

sbdchd commented Dec 9, 2023

Looks good, added a few minor comments!

@chdsbd chdsbd requested a review from sbdchd December 9, 2023 16:50
@chdsbd
Copy link
Collaborator

chdsbd commented Dec 9, 2023

@sbdchd I made some changes. I think this is good to merge

@sbdchd sbdchd added the automerge automerge with kodiak label Dec 9, 2023
@kodiakhq kodiakhq bot merged commit ddeed02 into sbdchd:master Dec 9, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge automerge with kodiak
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing an option to add an exit code for when squawk upload-to-github reports errors
3 participants