Skip to content

Added status checks#37

Merged
Bullrich merged 18 commits into
mainfrom
checks
Aug 8, 2023
Merged

Added status checks#37
Bullrich merged 18 commits into
mainfrom
checks

Conversation

@Bullrich

@Bullrich Bullrich commented Aug 1, 2023

Copy link
Copy Markdown
Contributor

Added ability to generate a status check and the ability to overwrite the latest one.

This resolves #33 and closes #26 as it merged it into one ticket.

There are some limitations as we can not select the check suite that the check will belong (see #33 (comment)), but the name will be constant, making it validable.

@Bullrich Bullrich added this to the Project launch milestone Aug 1, 2023
@Bullrich Bullrich self-assigned this Aug 1, 2023
@Bullrich Bullrich requested review from mordamax and removed request for mordamax August 1, 2023 14:44
@Bullrich Bullrich force-pushed the checks branch 2 times, most recently from ca0b91a to 4564f87 Compare August 2, 2023 11:28
@Bullrich Bullrich requested review from mutantcornholio and removed request for mutantcornholio August 2, 2023 11:32
@Bullrich Bullrich force-pushed the checks branch 2 times, most recently from 0cb863c to bbe8ad4 Compare August 3, 2023 10:32

@mutantcornholio mutantcornholio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

testing testing

@mutantcornholio mutantcornholio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

testing again

@Bullrich Bullrich force-pushed the checks branch 2 times, most recently from bce87d3 to dae2bdc Compare August 3, 2023 13:45
@Bullrich Bullrich marked this pull request as ready for review August 7, 2023 14:24
@Bullrich Bullrich requested a review from a team as a code owner August 7, 2023 14:24
@Bullrich

Bullrich commented Aug 7, 2023

Copy link
Copy Markdown
Contributor Author

Comment thread src/github/pullRequest.ts
Comment thread src/github/pullRequest.ts

/**
* Generates a Check Run or modifies the existing one.
* This way we can aggregate all the results from different causes into a single one

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does it mean that you have solved the problem of two status checks - from pull_request and from pull_request_review triggers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Kind of yes. you will still find two triggers if it is triggered from both events.

But now they create an extra check which contains the final result, so we only use that one as the blocker.

@rzadp rzadp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No objections from my side.

@Bullrich

Bullrich commented Aug 8, 2023

Copy link
Copy Markdown
Contributor Author

@mutantcornholio @mordamax any objections or should I merge it?

Comment thread src/runner.ts
const success = await this.validatePullRequest(config);
const reports = await this.validatePullRequest(config);

this.logger.info(reports.length > 0 ? "There was an error with the PR reviews." : "The PR has been successful");

@mutantcornholio mutantcornholio Aug 8, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This log line feels off.
Judging by the code of generateCheckRunData, we can have reports > 0, while still having enough reviews to mark the PR green, if there aren't any missingReviews.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not really. validatePullRequest will only return reports for failed rules, but if no rule failed, it will return an empty array.

So, unless it failed, generateCheckRunData will be working with an empty array and returning a positive case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess, I got confused by it because there is two different ways to check for success/failure. One is reports.length > 0, and another is reports.reduce((a, b) => a + b.missingReviews, 0) > 0.
Also, it's a bit more clear now when the annotation on what this.validatePullRequest() returns is updated.

Comment thread src/runner.ts
Comment thread src/runner.ts Outdated
Comment thread src/runner.ts
const success = await this.validatePullRequest(config);
const reports = await this.validatePullRequest(config);

this.logger.info(reports.length > 0 ? "There was an error with the PR reviews." : "The PR has been successful");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess, I got confused by it because there is two different ways to check for success/failure. One is reports.length > 0, and another is reports.reduce((a, b) => a + b.missingReviews, 0) > 0.
Also, it's a bit more clear now when the annotation on what this.validatePullRequest() returns is updated.

@Bullrich Bullrich merged commit a36f225 into main Aug 8, 2023
@Bullrich Bullrich deleted the checks branch August 8, 2023 11:27
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.

Create a status check Generate a summary of the output

4 participants