-
-
Notifications
You must be signed in to change notification settings - Fork 135
chore: update @octokit/rest from v16 to v17 #371
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,32 +4,41 @@ const { findLatestCommitInPr } = require('../../lib/push-jenkins-update') | |
|
|
||
| const nock = require('nock') | ||
| const readFixture = require('../read-fixture') | ||
| const { ignoreQueryParams } = require('../common') | ||
|
|
||
| tap.test('findLatestCommitInPr: paginates results when more than 100 commits in a PR', async (t) => { | ||
| const commitsFixturePage1 = readFixture('pull-requests-commits-page-1.json') | ||
| const commitsFixturePage104 = readFixture('pull-requests-commits-page-104.json') | ||
| const commitsFixturePage1 = readFixture('pull-request-commits-page-1.json') | ||
| const commitsFixturePage2 = readFixture('pull-request-commits-page-2.json') | ||
| const commitsFixturePage3 = readFixture('pull-request-commits-page-3.json') | ||
| const commitsFixturePage4 = readFixture('pull-request-commits-page-4.json') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hooray for tests being maintained and adjusted accordingly |
||
| const owner = 'nodejs' | ||
| const repo = 'node' | ||
| const pr = 9745 | ||
|
|
||
| const headers = { | ||
| Link: '<https://api.github.com/repos/nodejs/node/pulls/9745/commits?page=104>; rel="last"' | ||
| } | ||
| const firstPageScope = nock('https://api.github.com') | ||
| .filteringPath(ignoreQueryParams) | ||
| .get(`/repos/${owner}/${repo}/pulls/${pr}/commits`) | ||
| .reply(200, commitsFixturePage1, headers) | ||
| .reply(200, commitsFixturePage1, { link: '<https://api.github.com/repositories/27193779/pulls/9745/commits?page=2>; rel="next", <https://api.github.com/repositories/27193779/pulls/9745/commits?page=4>; rel="last"' }) | ||
|
|
||
| const lastPageScope = nock('https://api.github.com') | ||
| .get(`/repos/${owner}/${repo}/pulls/${pr}/commits`) | ||
| .query({ page: 104, per_page: 100 }) | ||
| .reply(200, commitsFixturePage104) | ||
| const secondPageScope = nock('https://api.github.com') | ||
| .get(`/repositories/27193779/pulls/${pr}/commits`) | ||
| .query({ page: 2 }) | ||
| .reply(200, commitsFixturePage2, { link: '<https://api.github.com/repositories/27193779/pulls/9745/commits?page=1>; rel="prev", <https://api.github.com/repositories/27193779/pulls/9745/commits?page=3>; rel="next", <https://api.github.com/repositories/27193779/pulls/9745/commits?page=4>; rel="last", <https://api.github.com/repositories/27193779/pulls/9745/commits?page=1>; rel="first"' }) | ||
|
|
||
| const thirdPageScope = nock('https://api.github.com') | ||
| .get(`/repositories/27193779/pulls/${pr}/commits`) | ||
| .query({ page: 3 }) | ||
| .reply(200, commitsFixturePage3, { link: '<https://api.github.com/repositories/27193779/pulls/9745/commits?page=2>; rel="prev", <https://api.github.com/repositories/27193779/pulls/9745/commits?page=4>; rel="next", <https://api.github.com/repositories/27193779/pulls/9745/commits?page=4>; rel="last", <https://api.github.com/repositories/27193779/pulls/9745/commits?page=1>; rel="first"' }) | ||
|
|
||
| const fourthPageScope = nock('https://api.github.com') | ||
| .get(`/repositories/27193779/pulls/${pr}/commits`) | ||
| .query({ page: 4 }) | ||
| .reply(200, commitsFixturePage4, { link: '<https://api.github.com/repositories/27193779/pulls/9745/commits?page=3>; rel="prev", <https://api.github.com/repositories/27193779/pulls/9745/commits?page=1>; rel="first"' }) | ||
|
|
||
| t.plan(1) | ||
|
|
||
| const commit = await findLatestCommitInPr({ owner, repo, pr }) | ||
| t.equal(commit.sha, 'c1aa949064892dbe693750686c06f4ad5673e577') | ||
| firstPageScope.done() | ||
| lastPageScope.done() | ||
| secondPageScope.done() | ||
| thirdPageScope.done() | ||
| fourthPageScope.done() | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it deliberate to not use
githubClientfrom line 3?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was probably a blunder. Sorry about that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this why we're hitting rate limits? The github-bot logs now have lots of "API rate limit exceeded for 23.253.100.79. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)" errors, e.g.
{"name":"bot","hostname":"infra-rackspace-debian8-x64-1","pid":15899,"req_id":"e62c49d0-bbaa-11ed-9410-77b81a7c3334","identifier":"node-test-linux-ubuntu1804-64","event":"end","level":50,"err":{"message":"API rate limit exceeded for 23.253.100.79. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","name":"HttpError","stack":"HttpError: API rate limit exceeded for 23.253.100.79. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)\n at /home/iojs/github-bot/node_modules/@octokit/request/dist-node/index.js:86:21\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (internal/process/task_queues.js:93:5)\n at async Object.next (/home/iojs/github-bot/node_modules/@octokit/plugin-paginate-rest/dist-node/index.js:112:28)\n at async findLatestCommitInPr (/home/iojs/github-bot/lib/push-jenkins-update.js:88:23)","code":403},"msg":"Error while handling Jenkins end event","time":"2023-03-05T23:10:20.025Z","v":0}Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, sending a PR momentarily. I wouldn't have realized this would caused this kind of problem. Sorry about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opportunity to learn why Github requests better be authenticated 👍🏻