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

feat: add gnoweb codeowners #3890

Merged
merged 2 commits into from
Mar 7, 2025
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
11 changes: 11 additions & 0 deletions contribs/github-bot/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@
),
),
},
{
Description: "Changes related to gnoweb must be reviewed by its codeowners",
If: c.And(
c.BaseBranch("^master$"),
c.FileChanged(gh, "^gno.land/pkg/gnoweb/"),
),
Then: r.Or(
r.ReviewByUser(gh, "alexiscolin"),
r.ReviewByUser(gh, "gfanton"),
Comment on lines +66 to +67
Copy link
Member

Choose a reason for hiding this comment

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

This should have actually been either a review or the author being one of the two...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hesitated when creating this rule to do something similar as the docs one, I know that both want to be assigned as reviewers and review each other. So I think that even if one of them makes a PR (e.g., gfanton), it should be reviewed by the other (e.g., alexiscolin).
No problem making the change in any case.

),
},

Check warning on line 69 in contribs/github-bot/internal/config/config.go

View check run for this annotation

Codecov / codecov/patch

contribs/github-bot/internal/config/config.go#L59-L69

Added lines #L59 - L69 were not covered by tests
{
Description: "Must not contain the \"don't merge\" label",
If: c.Label("don't merge"),
Expand Down
11 changes: 11 additions & 0 deletions contribs/github-bot/internal/requirements/reviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,21 @@ func deduplicateReviews(reviews []*github.PullRequestReview) []*github.PullReque
result = append(result, rev)
added[rev.User.GetLogin()] = len(result) - 1
}
case utils.ReviewStateDismissed:
// this state just dismisses any previous review, so remove previous
// entry for this user if it exists.
if ok {
result[idx] = nil
}
default:
panic(fmt.Sprintf("invalid review state %q", rev.GetState()))
}
}
// Remove nil entries from the result (dismissed reviews).
result = slices.DeleteFunc(result, func(r *github.PullRequestReview) bool {
return r == nil
})

return result
}

Expand Down
10 changes: 10 additions & 0 deletions contribs/github-bot/internal/requirements/reviewer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ func Test_deduplicateReviews(t *testing.T) {
{User: &github.User{Login: github.String("userB")}, State: github.String("CHANGES_REQUESTED")},
},
},
{
name: "two authors - approval/changes requested then dismissed",
reviews: []*github.PullRequestReview{
{User: &github.User{Login: github.String("user1")}, State: github.String("APPROVED")},
{User: &github.User{Login: github.String("user1")}, State: github.String("DISMISSED")},
{User: &github.User{Login: github.String("user2")}, State: github.String("CHANGES_REQUESTED")},
{User: &github.User{Login: github.String("user2")}, State: github.String("DISMISSED")},
},
expected: []*github.PullRequestReview{},
},
}

for _, tt := range tests {
Expand Down
1 change: 1 addition & 0 deletions contribs/github-bot/internal/utils/github_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
ReviewStateApproved ReviewState = "APPROVED"
ReviewStateChangesRequested ReviewState = "CHANGES_REQUESTED"
ReviewStateCommented ReviewState = "COMMENTED"
ReviewStateDismissed ReviewState = "DISMISSED"
)

// Valid determines whether the ReviewState is one of the known ReviewStates.
Expand Down
Loading