WordPress.org

Making WordPress.org

Opened 5 weeks ago

Last modified 4 weeks ago

#5052 new enhancement

GitHub integration: Show whether a linked PR is approved

Reported by: noisysocks Owned by:
Milestone: Priority: normal
Component: Trac Keywords:
Cc:

Description

It would be helpful in Trac to see whether the linked PR is 'Approved' or has 'Changes requested' in the 'Pull Requests' section at the top of a ticket.

Potentially this could be integrated into the 'All checks pass' status, e.g:

  • ✅ All checks pass, approved
  • ❌ All checks pass, changes requested
  • ✅ All checks pass

Change History (4)

#1 @dd32
5 weeks ago

Do you have an example of how this is shown in the Github API? or a PR which fits the Approved/Changes-Requested state?

#2 follow-up: @noisysocks
5 weeks ago

It looks like you have to access a separate endpoint:

https://api.github.com/repos/WordPress/gutenberg/pulls/$pr_number/reviews

This returns a JSON list of reviews for the given pull request, and:

  • If the list is empty, there are no reviews.
  • If there are no items in the list with "state" equal to "APPROVED", there are changes requested.
  • If there is ≥ 1 items in the list with "state" equal to "APPROVED", the PR is approved.
Last edited 5 weeks ago by noisysocks (previous) (diff)

#3 in reply to: ↑ 2 @dd32
4 weeks ago

Replying to noisysocks:

It looks like you have to access a separate endpoint:

https://api.github.com/repos/WordPress/gutenberg/pulls/$pr_number/reviews

Unfortunately this is going to require using a higher-access access token, so pending this task via #4903 which is kind of strange given the endpoint is accessible unauthenticated (Just at a low rate limit)

❌ Switch to using a Github App OAuth Token from dd32's personal Github token get_authorization_token() (or change it to select a random users token..)

  class stdClass#4 (2) {
    public $message =>
    string(38) "Resource not accessible by integration"
    public $documentation_url =>
    string(77) "https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request"
  }

#4 @dd32
4 weeks ago

In 9564:

Trac: Github PRs: Switch to using a Github App Token for authentication with Github.

This significantly increases the number of API requests that can be made per hour, and enables access to several additional API endpoints.

This uses the MIT licensed https://github.com/adhocore/php-jwt to generate the JWTs as required by the Github App API.

See #4903, #5052.

Note: See TracTickets for help on using tickets.