microplane icon indicating copy to clipboard operation
microplane copied to clipboard

Correctly fetch Github PR status

Open benwaffle opened this issue 2 years ago • 5 comments

Fetch everything that makes a PR green, including the Status API and the Checks API.

Fixes #107

benwaffle avatar Jun 07 '22 01:06 benwaffle

@benwaffle thanks for the contribution! Didn't realize that there was a distinction between commit statuses and checks. The graphql addition is neat but I am hesitant to add it since we don't use graphql at Clever and so something like the query struct with all of it's graphql annotations would present a challenge for the team to understand and maintain. If there's a way to do this with the non-graphql API that would be preferred. Thanks again for this PR.

rgarcia avatar Jun 22 '22 13:06 rgarcia

@robherley there's a REST API for this too, right? but you said it was expensive to call?

@rgarcia Alternatively, we can still use the GraphQL API but avoid the Go annotations - just using JSON directly - see here

benwaffle avatar Jun 22 '22 15:06 benwaffle

👋 @benwaffle @rgarcia Unfortunately there isn't an equivalent REST API for CombinedStatus (CheckRun states + Status states)

Alternatively if you wanted to use purely REST there's the List check suites for a Git reference API, which will get you all the check suites for a specific commit, and that covers checks (including actions). But, it's paginated and a bit slower than using the GraphQL query. You'd still need to call the Statuses API that you are doing today, in combination with the new Checks call.

My vote would be to just use the GraphQL call 👍

robherley avatar Jun 22 '22 16:06 robherley

Is this PR still needed? Discovering this repo now and looking into using it internally, we don't fear GraphQL and absolutely do need to check for all statuses and checks :) I'm likely needing to fork this repo anyway to support forking a repo where a push fails due to a lack of write permissions.

Thanks!

Enrico2 avatar Feb 15 '23 01:02 Enrico2

It's still relevant, but the maintainers would like it to be written using the REST API instead. Personally I've just been opening and merging all the PRs manually when green, and that's been good enough for me.

benwaffle avatar Feb 15 '23 04:02 benwaffle