Skip to content

Allow anyone to approve#117

Open
philn-delphia wants to merge 2 commits into
trstringer:mainfrom
Delphia:allow-anyone-to-approve
Open

Allow anyone to approve#117
philn-delphia wants to merge 2 commits into
trstringer:mainfrom
Delphia:allow-anyone-to-approve

Conversation

@philn-delphia

Copy link
Copy Markdown

Make the approvers field optional, and allow anyone to approve if it's empty.

I had to rework approvalFromComments to make this work, since it worked by removing names from the required approvers list until the list was small enough.

closes #108

Anyone can approve except the workflow initiator if they're not allowed.
fix length of issue approvers
@trstringer

Copy link
Copy Markdown
Owner

What kind of testing did you do for this PR? And also thanks for contributing!

@zchenyu

zchenyu commented Jul 18, 2024

Copy link
Copy Markdown

bump, this would be a nice feature :)

@philn-delphia

Copy link
Copy Markdown
Author

What kind of testing did you do for this PR? And also thanks for contributing!

I've been using this internally with no issues, but honestly we always have it set to allow all reviewers since it's private repos.

@MichalLeszczynski

Copy link
Copy Markdown

Hello, bumping as it'd be really helpful for me. Is there anything blocking us from merging it?

Comment thread action.yaml
@@ -6,7 +6,7 @@ branding:
inputs:
approvers:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

add your input here

Comment thread approval.go
approverIdx := approversIndex(remainingApprovers, commentUser)
if approverIdx < 0 {

if approversIndex(disallowedUsers, commentUser) >= 0 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think nonApprovers is a little more concise and clear

Comment thread approval_test.go
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
actual, err := approvalFromComments(testCase.comments, testCase.approvers, testCase.minimumApprovals)
actual, err := approvalFromComments(testCase.comments, testCase.approvers, testCase.minimumApprovals, testCase.disallowedUsers)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

would like to see a test for this specifically - as well as a test for if the same user is in the disallowed and allowed lists

Comment thread action.yaml
approvers:
description: Required approvers
required: true
required: false

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would suggest keeping this field as required and adding a keyword for your use case.
If we have a keyword instead of an empty field it could save potential security catastrophies caused by a mere oversight.

Comment thread approval.go
}

issueApproversText := "Anyone can approve."
if len(a.issueApprovers) > 0 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of overwriting a variable, it would be better to use if...else.

Comment thread approvers.go
approvers := []string{}
requiredApproversRaw := os.Getenv(envVarApprovers)
requiredApprovers := strings.Split(requiredApproversRaw, ",")
requiredApprovers := []string{}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of overwriting a variable, it would be better to use if...else.

@snskArora

Copy link
Copy Markdown
Collaborator

Also, please rebase on the main branch to account the new changes.

@snskArora

Copy link
Copy Markdown
Collaborator

Hi @philn-delphia

Thank you for your contribution!
There are a few open comments, can you please address them.

@snskArora snskArora added the Changes Requested Awaiting for a response on the open commnets label Jun 13, 2025
@adrian-chang

Copy link
Copy Markdown

@philn-delphia any update on this? would be useful ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changes Requested Awaiting for a response on the open commnets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let anyone approve an issue

7 participants