From 3d3a8989da86042be0f85add8cfa276bf6324f11 Mon Sep 17 00:00:00 2001 From: Pascal Haakmat Date: Fri, 2 Sep 2022 13:58:50 +0200 Subject: [PATCH 1/7] Add option to disable octokit throttling Signed-off-by: Pascal Haakmat --- .../actions/builtin/publish/githubPullRequest.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts index 20b0ba83aa..e0822c7c13 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts @@ -66,6 +66,7 @@ export const defaultClientFactory = async ({ repo, host = 'github.com', token: providedToken, + throttling, }: CreateGithubPullRequestClientFactoryInput): Promise => { const [encodedHost, encodedOwner, encodedRepo] = [host, owner, repo].map( encodeURIComponent, @@ -79,7 +80,10 @@ export const defaultClientFactory = async ({ }); const OctokitPR = Octokit.plugin(createPullRequest); - return new OctokitPR(octokitOptions); + return new OctokitPR({ + ...octokitOptions, + ...(!throttling && { throttle: { enabled: false } }), + }); }; /** @@ -129,6 +133,7 @@ export const createPublishGithubPullRequestAction = ({ token?: string; reviewers?: string[]; teamReviewers?: string[]; + throttling?: boolean; }>({ id: 'publish:github:pull-request', schema: { @@ -195,6 +200,11 @@ export const createPublishGithubPullRequestAction = ({ description: 'The teams that will be added as reviewers to the pull request', }, + throttling: { + title: 'Github Throttling', + type: 'boolean', + description: 'Whether to enable Github request throttling', + }, }, }, output: { @@ -226,6 +236,7 @@ export const createPublishGithubPullRequestAction = ({ token: providedToken, reviewers, teamReviewers, + throttling, } = ctx.input; const { owner, repo, host } = parseRepoUrl(repoUrl, integrations); @@ -243,6 +254,7 @@ export const createPublishGithubPullRequestAction = ({ owner, repo, token: providedToken, + throttling, }); const fileRoot = sourcePath From 83c037cd46ff32fbefd85616cecf9dd638d97a44 Mon Sep 17 00:00:00 2001 From: Pascal Haakmat Date: Fri, 2 Sep 2022 14:11:53 +0200 Subject: [PATCH 2/7] Add changeset Signed-off-by: Pascal Haakmat --- .changeset/tame-trainers-rule.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tame-trainers-rule.md diff --git a/.changeset/tame-trainers-rule.md b/.changeset/tame-trainers-rule.md new file mode 100644 index 0000000000..baa17487c7 --- /dev/null +++ b/.changeset/tame-trainers-rule.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Add throttling option to publish:github:pull-request From a1b9263517b756994f92d1f3d8392ed3144b2ed5 Mon Sep 17 00:00:00 2001 From: Pascal Haakmat Date: Fri, 2 Sep 2022 14:23:59 +0200 Subject: [PATCH 3/7] Fix tsc errors. Signed-off-by: Pascal Haakmat --- .../src/scaffolder/actions/builtin/publish/githubPullRequest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts index e0822c7c13..77a3353b18 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts @@ -57,6 +57,7 @@ export type CreateGithubPullRequestClientFactoryInput = { owner: string; repo: string; token?: string; + throttling?: boolean; }; export const defaultClientFactory = async ({ From b757a6325317ae777d75918d860c252235cbf437 Mon Sep 17 00:00:00 2001 From: Pascal Haakmat Date: Fri, 2 Sep 2022 14:47:46 +0200 Subject: [PATCH 4/7] Update api-report.md Signed-off-by: Pascal Haakmat --- plugins/scaffolder-backend/api-report.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 066b201918..46e4576bff 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -169,6 +169,7 @@ export type CreateGithubPullRequestClientFactoryInput = { owner: string; repo: string; token?: string; + throttling?: boolean; }; // @public @@ -391,6 +392,7 @@ export const createPublishGithubPullRequestAction: ({ token?: string | undefined; reviewers?: string[] | undefined; teamReviewers?: string[] | undefined; + throttling?: boolean | undefined; }>; // @public From 059e7818cffa63c5bc0429a4b99439cd4822d3e2 Mon Sep 17 00:00:00 2001 From: Pascal Haakmat Date: Tue, 6 Sep 2022 14:30:48 +0200 Subject: [PATCH 5/7] Remove throttling option => always disable it Signed-off-by: Pascal Haakmat --- .../actions/builtin/publish/githubPullRequest.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts index 77a3353b18..d0ee979be3 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts @@ -57,7 +57,6 @@ export type CreateGithubPullRequestClientFactoryInput = { owner: string; repo: string; token?: string; - throttling?: boolean; }; export const defaultClientFactory = async ({ @@ -67,7 +66,6 @@ export const defaultClientFactory = async ({ repo, host = 'github.com', token: providedToken, - throttling, }: CreateGithubPullRequestClientFactoryInput): Promise => { const [encodedHost, encodedOwner, encodedRepo] = [host, owner, repo].map( encodeURIComponent, @@ -83,7 +81,7 @@ export const defaultClientFactory = async ({ const OctokitPR = Octokit.plugin(createPullRequest); return new OctokitPR({ ...octokitOptions, - ...(!throttling && { throttle: { enabled: false } }), + ...{ throttle: { enabled: false } }, }); }; @@ -134,7 +132,6 @@ export const createPublishGithubPullRequestAction = ({ token?: string; reviewers?: string[]; teamReviewers?: string[]; - throttling?: boolean; }>({ id: 'publish:github:pull-request', schema: { @@ -201,11 +198,6 @@ export const createPublishGithubPullRequestAction = ({ description: 'The teams that will be added as reviewers to the pull request', }, - throttling: { - title: 'Github Throttling', - type: 'boolean', - description: 'Whether to enable Github request throttling', - }, }, }, output: { @@ -237,7 +229,6 @@ export const createPublishGithubPullRequestAction = ({ token: providedToken, reviewers, teamReviewers, - throttling, } = ctx.input; const { owner, repo, host } = parseRepoUrl(repoUrl, integrations); @@ -255,7 +246,6 @@ export const createPublishGithubPullRequestAction = ({ owner, repo, token: providedToken, - throttling, }); const fileRoot = sourcePath From 0fbf7c146ee3148dbf5a96eb4c7a85146e664b92 Mon Sep 17 00:00:00 2001 From: Pascal Haakmat Date: Tue, 6 Sep 2022 14:41:04 +0200 Subject: [PATCH 6/7] Update api-report.md Signed-off-by: Pascal Haakmat --- plugins/scaffolder-backend/api-report.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 46e4576bff..066b201918 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -169,7 +169,6 @@ export type CreateGithubPullRequestClientFactoryInput = { owner: string; repo: string; token?: string; - throttling?: boolean; }; // @public @@ -392,7 +391,6 @@ export const createPublishGithubPullRequestAction: ({ token?: string | undefined; reviewers?: string[] | undefined; teamReviewers?: string[] | undefined; - throttling?: boolean | undefined; }>; // @public From d215d5b347cdeb7e8a1748b3d92351d2c8b57783 Mon Sep 17 00:00:00 2001 From: Pascal Haakmat Date: Tue, 6 Sep 2022 14:43:20 +0200 Subject: [PATCH 7/7] Update changeset Signed-off-by: Pascal Haakmat --- .changeset/tame-trainers-rule.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/tame-trainers-rule.md b/.changeset/tame-trainers-rule.md index baa17487c7..c51eb868d4 100644 --- a/.changeset/tame-trainers-rule.md +++ b/.changeset/tame-trainers-rule.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder-backend': patch --- -Add throttling option to publish:github:pull-request +Disable octokit throttling in publish:github:pull-request