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

refactor: removed logic of contributor approvals #23

Closed
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/helpers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export async function getMergeTimeoutAndApprovalRequiredCount(context: Context,
};
const timeoutContributor = {
mergeTimeout: mergeTimeout?.contributor,
requiredApprovalCount: approvalsRequired?.contributor,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that is proper. If the user is a contributor then no requiredApprovalCount will be returned, which subsequently is most likely to fail when calling attemptMerging. Could you provide some QA?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I'm modifying the logic and creating QA tests.

};

/**
Expand Down
5 changes: 0 additions & 5 deletions src/types/plugin-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {} }
);
Expand Down
12 changes: 0 additions & 12 deletions tests/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe("Configuration tests", () => {
settings: JSON.stringify({
approvalsRequired: {
collaborator: 0,
contributor: 0,
},
mergeTimeout: {
collaborator: "3.5 days",
Expand Down Expand Up @@ -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,
},
],
});
});
Expand Down
8 changes: 4 additions & 4 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
)
Expand Down Expand Up @@ -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,
Expand All @@ -229,7 +231,6 @@ describe("Action tests", () => {
},
approvalsRequired: {
collaborator: collaboratorMinimumApprovalsRequired,
contributor: contributorMinimumApprovalsRequired,
},
allowedReviewerRoles: ["COLLABORATOR", "MEMBER", "OWNER"],
},
Expand All @@ -250,7 +251,6 @@ describe("Action tests", () => {
);
await expect(githubHelpers.getMergeTimeoutAndApprovalRequiredCount(context, "CONTRIBUTOR")).resolves.toEqual({
mergeTimeout: contributorMergeTimeout,
requiredApprovalCount: contributorMinimumApprovalsRequired,
});
});

Expand Down