Making WordPress.org

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#5052 closed enhancement (fixed)

GitHub integration: Show whether a linked PR is approved

Reported by: noisysocks's profile noisysocks Owned by: dd32's profile dd32
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 (8)

#1 @dd32
5 years 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 years 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 years ago by noisysocks (previous) (diff)

#3 in reply to: ↑ 2 @dd32
5 years 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
5 years 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.

#5 @dd32
4 years ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In 9898:

Trac: Attempt to include PR Review status in the PR status on trac.

Fixes #5052.

#6 @dd32
4 years ago

In 9899:

Trac: Bump scripts version after r9897 and r9898

See #5052, #4903.

#7 @dd32
4 years ago

In 9912:

Trac: Handle PRs with no code reviews better.

Amends [9898].
See #5052.

#8 @dd32
4 years ago

In 9914:

Trac: Bump scripts versions.

See #5052.

Note: See TracTickets for help on using tickets.