From 0de8e023aea0be435fa01a317d36fe8d955fec7c Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Wed, 14 Aug 2024 19:27:04 +0000 Subject: [PATCH 1/7] Better errors if not enough reviewers to test --- .ci/magician/cmd/request_reviewer_test.go | 3 +++ .ci/magician/github/reviewer_assignment_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.ci/magician/cmd/request_reviewer_test.go b/.ci/magician/cmd/request_reviewer_test.go index f40288ddb2ab..b2af19be6b2d 100644 --- a/.ci/magician/cmd/request_reviewer_test.go +++ b/.ci/magician/cmd/request_reviewer_test.go @@ -25,6 +25,9 @@ import ( func TestExecRequestReviewer(t *testing.T) { availableReviewers := github.AvailableReviewers() + if len(availableReviewers) < 3 { + t.Fatalf("not enough available reviewers (%v) to run TestExecRequestReviewer (need at least 3)", availableReviewers) + } cases := map[string]struct { pullRequest github.PullRequest requestedReviewers []string diff --git a/.ci/magician/github/reviewer_assignment_test.go b/.ci/magician/github/reviewer_assignment_test.go index ad85f5232c32..6a2cb33b6a25 100644 --- a/.ci/magician/github/reviewer_assignment_test.go +++ b/.ci/magician/github/reviewer_assignment_test.go @@ -24,6 +24,9 @@ import ( ) func TestChooseCoreReviewers(t *testing.T) { + if len(AvailableReviewers()) < 2 { + t.Fatalf("not enough available reviewers (%v) to test (need at least 2)", AvailableReviewers()) + } firstCoreReviewer := AvailableReviewers()[0] secondCoreReviewer := AvailableReviewers()[1] cases := map[string]struct { From 03ec2bc7676da28f4764cd37c3e7823da183ac4d Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Wed, 14 Aug 2024 20:00:17 +0000 Subject: [PATCH 2/7] Split reviewer data out from membship.go --- .ci/magician/github/membership.go | 91 -------------------------- .ci/magician/github/membership_data.go | 89 +++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 91 deletions(-) create mode 100644 .ci/magician/github/membership_data.go diff --git a/.ci/magician/github/membership.go b/.ci/magician/github/membership.go index c627cc14624a..d3694ccd7255 100644 --- a/.ci/magician/github/membership.go +++ b/.ci/magician/github/membership.go @@ -24,97 +24,6 @@ import ( "golang.org/x/exp/maps" ) -var ( - // This is for the random-assignee rotation. - reviewerRotation = map[string]struct{}{ - "slevenick": struct{}{}, - "c2thorn": struct{}{}, - "rileykarson": struct{}{}, - "melinath": struct{}{}, - "ScottSuarez": struct{}{}, - "shuyama1": struct{}{}, - "SarahFrench": struct{}{}, - "roaks3": struct{}{}, - "zli82016": struct{}{}, - "trodge": struct{}{}, - "hao-nan-li": struct{}{}, - "NickElliot": struct{}{}, - "BBBmau": struct{}{}, - } - - // This is for new team members who are onboarding - trustedContributors = map[string]struct{}{} - - // This is for reviewers who are "on vacation": will not receive new review assignments but will still receive re-requests for assigned PRs. - // User can specify the time zone like this, and following the example below: - pdtLoc, _ = time.LoadLocation("America/Los_Angeles") - bstLoc, _ = time.LoadLocation("Europe/London") - onVacationReviewers = []onVacationReviewer{ - // Example: taking vacation from 2024-03-28 to 2024-04-02 in pdt time zone. - // both ends are inclusive: - // { - // id: "xyz", - // startDate: newDate(2024, 3, 28, pdtLoc), - // endDate: newDate(2024, 4, 2, pdtLoc), - // }, - { - id: "hao-nan-li", - startDate: newDate(2024, 4, 11, pdtLoc), - endDate: newDate(2024, 6, 14, pdtLoc), - }, - { - id: "ScottSuarez", - startDate: newDate(2024, 4, 30, pdtLoc), - endDate: newDate(2024, 7, 31, pdtLoc), - }, - { - id: "SarahFrench", - startDate: newDate(2024, 8, 2, bstLoc), - endDate: newDate(2024, 8, 6, bstLoc), - }, - { - id: "shuyama1", - startDate: newDate(2024, 5, 22, pdtLoc), - endDate: newDate(2024, 5, 28, pdtLoc), - }, - { - id: "melinath", - startDate: newDate(2024, 6, 26, pdtLoc), - endDate: newDate(2024, 7, 22, pdtLoc), - }, - { - id: "slevenick", - startDate: newDate(2024, 7, 5, pdtLoc), - endDate: newDate(2024, 7, 16, pdtLoc), - }, - { - id: "c2thorn", - startDate: newDate(2024, 7, 10, pdtLoc), - endDate: newDate(2024, 7, 16, pdtLoc), - }, - { - id: "rileykarson", - startDate: newDate(2024, 7, 18, pdtLoc), - endDate: newDate(2024, 8, 10, pdtLoc), - }, - { - id: "roaks3", - startDate: newDate(2024, 8, 2, pdtLoc), - endDate: newDate(2024, 8, 9, pdtLoc), - }, - { - id: "slevenick", - startDate: newDate(2024, 8, 10, pdtLoc), - endDate: newDate(2024, 8, 17, pdtLoc), - }, - { - id: "trodge", - startDate: newDate(2024, 8, 24, pdtLoc), - endDate: newDate(2024, 9, 2, pdtLoc), - }, - } -) - type UserType int64 type date struct { diff --git a/.ci/magician/github/membership_data.go b/.ci/magician/github/membership_data.go new file mode 100644 index 000000000000..362e076140de --- /dev/null +++ b/.ci/magician/github/membership_data.go @@ -0,0 +1,89 @@ +package github + +import "time" + +var ( + // This is for the random-assignee rotation. + reviewerRotation = map[string]struct{}{ + "slevenick": {}, + "c2thorn": {}, + "rileykarson": {}, + "melinath": {}, + "ScottSuarez": {}, + "shuyama1": {}, + "SarahFrench": {}, + "roaks3": {}, + "zli82016": {}, + "trodge": {}, + "hao-nan-li": {}, + "NickElliot": {}, + "BBBmau": {}, + } + + // This is for new team members who are onboarding + trustedContributors = map[string]struct{}{} + + // This is for reviewers who are "on vacation": will not receive new review assignments but will still receive re-requests for assigned PRs. + // User can specify the time zone like this, and following the example below: + pdtLoc, _ = time.LoadLocation("America/Los_Angeles") + bstLoc, _ = time.LoadLocation("Europe/London") + onVacationReviewers = []onVacationReviewer{ + // Example: taking vacation from 2024-03-28 to 2024-04-02 in pdt time zone. + // both ends are inclusive: + // { + // id: "xyz", + // startDate: newDate(2024, 3, 28, pdtLoc), + // endDate: newDate(2024, 4, 2, pdtLoc), + // }, + { + id: "hao-nan-li", + startDate: newDate(2024, 4, 11, pdtLoc), + endDate: newDate(2024, 6, 14, pdtLoc), + }, + { + id: "ScottSuarez", + startDate: newDate(2024, 4, 30, pdtLoc), + endDate: newDate(2024, 7, 31, pdtLoc), + }, + { + id: "SarahFrench", + startDate: newDate(2024, 8, 2, bstLoc), + endDate: newDate(2024, 8, 6, bstLoc), + }, + { + id: "shuyama1", + startDate: newDate(2024, 5, 22, pdtLoc), + endDate: newDate(2024, 5, 28, pdtLoc), + }, + { + id: "melinath", + startDate: newDate(2024, 6, 26, pdtLoc), + endDate: newDate(2024, 7, 22, pdtLoc), + }, + { + id: "slevenick", + startDate: newDate(2024, 7, 5, pdtLoc), + endDate: newDate(2024, 7, 16, pdtLoc), + }, + { + id: "c2thorn", + startDate: newDate(2024, 7, 10, pdtLoc), + endDate: newDate(2024, 7, 16, pdtLoc), + }, + { + id: "rileykarson", + startDate: newDate(2024, 7, 18, pdtLoc), + endDate: newDate(2024, 8, 10, pdtLoc), + }, + { + id: "roaks3", + startDate: newDate(2024, 8, 2, pdtLoc), + endDate: newDate(2024, 8, 9, pdtLoc), + }, + { + id: "slevenick", + startDate: newDate(2024, 8, 10, pdtLoc), + endDate: newDate(2024, 8, 17, pdtLoc), + }, + } +) From 124c7c02817a6342e861738cf5474f78b5c2499f Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Wed, 14 Aug 2024 20:04:55 +0000 Subject: [PATCH 3/7] Make workflow use main branch reviewer data --- .github/workflows/request-reviewer.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/request-reviewer.yml b/.github/workflows/request-reviewer.yml index 45c5ffacd4e6..4f320b5dd851 100644 --- a/.github/workflows/request-reviewer.yml +++ b/.github/workflows/request-reviewer.yml @@ -24,6 +24,13 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2 + - name: Checkout membership data from main branch + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2 + with: + ref: main + sparse-checkout: | + .ci/magician/github/membership_data.go + sparse-checkout-cone-mode: false - name: Set up Go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: From 00c4479fbf802f3c3e19b0a0dfadd90a77dc5c57 Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Wed, 14 Aug 2024 20:05:18 +0000 Subject: [PATCH 4/7] Test with trodge not considered core reviewer --- .ci/magician/github/membership.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.ci/magician/github/membership.go b/.ci/magician/github/membership.go index d3694ccd7255..da6065f69609 100644 --- a/.ci/magician/github/membership.go +++ b/.ci/magician/github/membership.go @@ -91,6 +91,10 @@ func IsCoreContributor(user string) bool { } func IsCoreReviewer(user string) bool { + // TESTING PURPOSES + if user == "trodge" { + return false + } _, isCoreReviewer := reviewerRotation[user] return isCoreReviewer } From 9cd4b968069069fa6b7cace1b26c1ae4ba5add3c Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Wed, 14 Aug 2024 20:14:18 +0000 Subject: [PATCH 5/7] Checkout to . instead of empty --- .github/workflows/request-reviewer.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/request-reviewer.yml b/.github/workflows/request-reviewer.yml index 4f320b5dd851..3fa0656ce5f2 100644 --- a/.github/workflows/request-reviewer.yml +++ b/.github/workflows/request-reviewer.yml @@ -28,6 +28,7 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2 with: ref: main + path: . sparse-checkout: | .ci/magician/github/membership_data.go sparse-checkout-cone-mode: false From fa473746aa17888d5ffe1a4bf0315b94c9662585 Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Thu, 22 Aug 2024 08:49:35 -0700 Subject: [PATCH 6/7] Update .ci/magician/github/membership_data.go --- .ci/magician/github/membership_data.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.ci/magician/github/membership_data.go b/.ci/magician/github/membership_data.go index 362e076140de..7b8f2964faee 100644 --- a/.ci/magician/github/membership_data.go +++ b/.ci/magician/github/membership_data.go @@ -85,5 +85,10 @@ var ( startDate: newDate(2024, 8, 10, pdtLoc), endDate: newDate(2024, 8, 17, pdtLoc), }, + { + id: "trodge", + startDate: newDate(2024, 8, 24, pdtLoc), + endDate: newDate(2024, 9, 2, pdtLoc), + }, } ) From 3fd6ba7b91ccb4e23e03ae43d8ddd23bd53b9792 Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Thu, 22 Aug 2024 17:30:53 +0000 Subject: [PATCH 7/7] Remove testing exception --- .ci/magician/github/membership.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.ci/magician/github/membership.go b/.ci/magician/github/membership.go index da6065f69609..d3694ccd7255 100644 --- a/.ci/magician/github/membership.go +++ b/.ci/magician/github/membership.go @@ -91,10 +91,6 @@ func IsCoreContributor(user string) bool { } func IsCoreReviewer(user string) bool { - // TESTING PURPOSES - if user == "trodge" { - return false - } _, isCoreReviewer := reviewerRotation[user] return isCoreReviewer }