From 980ed5852415248271ae0c3cd87a3cd7175ff7be Mon Sep 17 00:00:00 2001 From: Yan Victor Date: Tue, 8 Oct 2024 11:36:01 -0300 Subject: [PATCH] refactor: contributor approvals should should not be considered --- README.md | 1 - src/helpers/github.ts | 1 - src/types/plugin-inputs.ts | 5 ----- tests/configuration.test.ts | 12 ------------ tests/main.test.ts | 8 ++++---- 5 files changed, 4 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index ce6090b..cc95fab 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ on the association of the pull-request author. with: approvalsRequired: collaborator: 1 # defaults to 1 - contributor: 2 # defaults to 2 mergeTimeout: collaborator: "3.5 days" # defaults to 3.5 days contributor: "7 days" # defaults to 7 days diff --git a/src/helpers/github.ts b/src/helpers/github.ts index cd99bb9..c4e8ff1 100644 --- a/src/helpers/github.ts +++ b/src/helpers/github.ts @@ -33,7 +33,6 @@ export async function getMergeTimeoutAndApprovalRequiredCount(context: Context, }; const timeoutContributor = { mergeTimeout: mergeTimeout?.contributor, - requiredApprovalCount: approvalsRequired?.contributor, }; /** diff --git a/src/types/plugin-inputs.ts b/src/types/plugin-inputs.ts index cae4f52..8b1b636 100644 --- a/src/types/plugin-inputs.ts +++ b/src/types/plugin-inputs.ts @@ -18,11 +18,6 @@ export const approvalsRequiredSchema = T.Object( * merge, defaults to 1. */ collaborator: T.Number({ default: 1, minimum: 1 }), - /** - * The amount of validations needed to consider a pull-request by a contributor to be deemed eligible for merge, - * defaults to 2. - */ - contributor: T.Number({ default: 2, minimum: 1 }), }, { default: {} } ); diff --git a/tests/configuration.test.ts b/tests/configuration.test.ts index 189d790..c631284 100644 --- a/tests/configuration.test.ts +++ b/tests/configuration.test.ts @@ -21,7 +21,6 @@ describe("Configuration tests", () => { settings: JSON.stringify({ approvalsRequired: { collaborator: 0, - contributor: 0, }, mergeTimeout: { collaborator: "3.5 days", @@ -57,17 +56,6 @@ describe("Configuration tests", () => { type: 39, value: 0, }, - { - message: "Expected number to be greater or equal to 1", - path: "/approvalsRequired/contributor", - schema: { - default: 2, - minimum: 1, - type: "number", - }, - type: 39, - value: 0, - }, ], }); }); diff --git a/tests/main.test.ts b/tests/main.test.ts index af73097..257d989 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -160,7 +160,10 @@ describe("Action tests", () => { http.get( "https://api.github.com/repos/:org/:repo/pulls/:id/reviews", () => { - return HttpResponse.json([{ id: 1, state: "COMMENTED", author_association: "CONTRIBUTOR" }, { id: 2, state: "APPROVED", author_association: "NONE" }]); + return HttpResponse.json([ + { id: 1, state: "COMMENTED", author_association: "CONTRIBUTOR" }, + { id: 2, state: "APPROVED", author_association: "NONE" }, + ]); }, { once: true } ) @@ -212,7 +215,6 @@ describe("Action tests", () => { const contributorMergeTimeout = "7 days"; const collaboratorMergeTimeout = "3.5 days"; const collaboratorMinimumApprovalsRequired = 2; - const contributorMinimumApprovalsRequired = 1; const context = { logger: { debug: console.log, @@ -229,7 +231,6 @@ describe("Action tests", () => { }, approvalsRequired: { collaborator: collaboratorMinimumApprovalsRequired, - contributor: contributorMinimumApprovalsRequired, }, allowedReviewerRoles: ["COLLABORATOR", "MEMBER", "OWNER"], }, @@ -250,7 +251,6 @@ describe("Action tests", () => { ); await expect(githubHelpers.getMergeTimeoutAndApprovalRequiredCount(context, "CONTRIBUTOR")).resolves.toEqual({ mergeTimeout: contributorMergeTimeout, - requiredApprovalCount: contributorMinimumApprovalsRequired, }); });