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

Cherry pick script: make authenticated requests #62473

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

vcanales
Copy link
Member

@vcanales vcanales commented Jun 11, 2024

What?

Make authenticated requests to the GitHub API.

Why?

During the 6.6 Beta 2 release, we ran into rate limiting issues due to conflicts that had to be resolved, which meant that we had to run the script multiple times.

Non-authenticated requests have a 60 per hour limit, even on public endpoints.

How?

In order to avoid it in the future, we can grab the token generated by gh and use it to make authenticated requests instead, which have a 5000-per hour limit.

➜  gutenberg git:(trunk) curl -v --request GET \
--url "https://api.github.com/octocat" \
--header "Authorization: Bearer <TOKEN_GENERATED_BY_GH_CLI>" \
--header "X-GitHub-Api-Version: 2022-11-28"
...
< HTTP/2 200
< server: GitHub.com
< date: Tue, 11 Jun 2024 10:36:15 GMT
< content-type: application/octocat-stream
< content-length: 917
< x-github-api-version-selected: 2022-11-28
< x-ratelimit-limit: 5000
< x-ratelimit-remaining: 4992

Testing Instructions

Testing Instructions for Keyboard

During the 6.6 Beta 2 release, we ran into rate limiting issues due to
conflicts that had to be resolved, which meant that we had to run the
script multiple times.

Non-authenticated requests have a 60 per hour limit.

In order to avoid it in the future, we can grab the token generated by `gh` and use
it to make authenticated requests instead, which have a 5000-per hour
limit.

```sh
➜  gutenberg git:(trunk) curl -vvvv --request GET \
--url "https://api.github.com/octocat" \
--header "Authorization: Bearer <TOKEN_GENERATED_BY_GH_CLI>" \
--header "X-GitHub-Api-Version: 2022-11-28"
...
< HTTP/2 200
< server: GitHub.com
< date: Tue, 11 Jun 2024 10:36:15 GMT
< content-type: application/octocat-stream
< content-length: 917
< x-github-api-version-selected: 2022-11-28
< x-ratelimit-limit: 5000
< x-ratelimit-remaining: 4992
```
@vcanales vcanales added the [Type] Bug An existing feature does not function as intended label Jun 11, 2024
@vcanales vcanales requested a review from ellatrix June 11, 2024 10:45
Copy link

github-actions bot commented Jun 11, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: vcanales <vcanales@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@vcanales
Copy link
Member Author

I've tested this running the script on a dummy label, and logging the rate limit header on the requests:

// print response headers
console.log( 'Rate limit: ' + response.headers.get( 'X-RateLimit-Limit' ) );

output:

Rate limit: 5000
@vcanales vcanales force-pushed the try/improve-cherry-pick-script branch from e4f4e68 to e0584b0 Compare June 11, 2024 11:10
@ellatrix
Copy link
Member

I'll cherry-pick this on the release branch to try it.

@ellatrix
Copy link
Member

I tested this in #62641 and it works great.

@ellatrix ellatrix merged commit 0181965 into trunk Jun 18, 2024
119 of 123 checks passed
@ellatrix ellatrix deleted the try/improve-cherry-pick-script branch June 18, 2024 07:37
@github-actions github-actions bot added this to the Gutenberg 18.7 milestone Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
2 participants