Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions action.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

async function run() {
try {
const body = core.getInput('body', {required: true});
const body = core.getInput('body', { required: true });
const milestone = parseInt(core.getInput('milestone'));
const state = core.getInput('state');
const token = core.getInput('token');
Expand All @@ -20,7 +20,7 @@ async function run() {
await Promise.all(milestoneIssues.map(async issue => {
await issues.createComment(client, repo.owner, repo.repo, issue.number, body);

core.debug(`Waiting 2 seconds between requests: https://docs.github.com/en/rest/guides/best-practices-for-integrators#dealing-with-abuse-rate-limits`);
core.debug(`Waiting 2 seconds between requests: https://docs.github.com/en/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits`);
await sleep(2000);
}));

Expand Down
44 changes: 22 additions & 22 deletions action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ describe('action test suite', () => {

const scope = nock('https://api.github.com')
.get(`/repos/testowner/testrepo/issues`)
.query({milestone: '1', state: 'all'})
.query({ milestone: '1', state: 'all' })
.reply(200, mockIssues)
.post(`/repos/${repo}/issues/1/comments`, {body: body})
.post(`/repos/${repo}/issues/1/comments`, { body: body })
.reply(200)
.post(`/repos/${repo}/issues/2/comments`, {body: body})
.post(`/repos/${repo}/issues/2/comments`, { body: body })
.reply(200);

const action = require('./action');
await expect(await action()).toEqual({ids: "1,2"});
await expect(await action()).toEqual({ ids: "1,2" });
await expect(scope.isDone()).toBeTruthy();
});

Expand All @@ -62,22 +62,22 @@ describe('action test suite', () => {

const scope = nock('https://api.github.com')
.get(`/repos/testowner/testrepo/issues`)
.query({milestone: '1', state: 'all'})
.query({ milestone: '1', state: 'all' })
.reply(500, 'expected transient error')
.get(`/repos/testowner/testrepo/issues`)
.query({milestone: '1', state: 'all'})
.query({ milestone: '1', state: 'all' })
.reply(200, mockIssues)
.post(`/repos/${repo}/issues/1/comments`, {body: body})
.post(`/repos/${repo}/issues/1/comments`, { body: body })
.reply(200)
.post(`/repos/${repo}/issues/2/comments`, {body: body})
.post(`/repos/${repo}/issues/2/comments`, { body: body })
.reply(200);

const action = require('./action');
await expect(await action()).toEqual({ids: "1,2"});
await expect(await action()).toEqual({ ids: "1,2" });
await expect(scope.isDone()).toBeTruthy();
});

test('Retries abuse limit errors', async () => {
test('Retries secondary rate limit errors', async () => {
process.env['GITHUB_EVENT_PATH'] = path.join(__dirname, 'milestone-closed-payload.json');
process.env['INPUT_BODY'] = body;

Expand All @@ -92,20 +92,20 @@ describe('action test suite', () => {

const scope = nock('https://api.github.com')
.get(`/repos/testowner/testrepo/issues`)
.query({milestone: '1', state: 'all'})
.query({ milestone: '1', state: 'all' })
.reply(200, mockIssues)
.post(`/repos/${repo}/issues/1/comments`, {body: body})
.post(`/repos/${repo}/issues/1/comments`, { body: body })
.reply(200)
.post(`/repos/${repo}/issues/2/comments`, {body: body})
.post(`/repos/${repo}/issues/2/comments`, { body: body })
.reply(403, {
message: "You have triggered an abuse detection mechanism and have been temporarily blocked from content creation. Please retry your request again later.",
documentation_url: "https://docs.github.com/rest/overview/resources-in-the-rest-api#abuse-rate-limits"
message: "You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.",
documentation_url: "https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits"
})
.post(`/repos/${repo}/issues/2/comments`, {body: body})
.post(`/repos/${repo}/issues/2/comments`, { body: body })
.reply(200);

const action = require('./action');
await expect(await action()).toEqual({ids: "1,2"});
await expect(await action()).toEqual({ ids: "1,2" });
await expect(scope.isDone()).toBeTruthy();
});

Expand All @@ -124,18 +124,18 @@ describe('action test suite', () => {

const scope = nock('https://api.github.com')
.get(`/repos/testowner/testrepo/issues`)
.query({milestone: '1', state: 'all'})
.query({ milestone: '1', state: 'all' })
.reply(429, 'expected rate limit error')
.get(`/repos/testowner/testrepo/issues`)
.query({milestone: '1', state: 'all'})
.query({ milestone: '1', state: 'all' })
.reply(200, mockIssues)
.post(`/repos/${repo}/issues/1/comments`, {body: body})
.post(`/repos/${repo}/issues/1/comments`, { body: body })
.reply(200)
.post(`/repos/${repo}/issues/2/comments`, {body: body})
.post(`/repos/${repo}/issues/2/comments`, { body: body })
.reply(200);

const action = require('./action');
await expect(await action()).toEqual({ids: "1,2"});
await expect(await action()).toEqual({ ids: "1,2" });
await expect(scope.isDone()).toBeTruthy();
});
});
Loading