Skip to content

Commit 85d76c1

Browse files
trodgeiyabchen
authored andcommitted
Make reviewer assignment always use main branch (GoogleCloudPlatform#11445)
1 parent 3e77368 commit 85d76c1

File tree

5 files changed

+102
-91
lines changed

5 files changed

+102
-91
lines changed

.ci/magician/cmd/request_reviewer_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import (
2525

2626
func TestExecRequestReviewer(t *testing.T) {
2727
availableReviewers := github.AvailableReviewers()
28+
if len(availableReviewers) < 3 {
29+
t.Fatalf("not enough available reviewers (%v) to run TestExecRequestReviewer (need at least 3)", availableReviewers)
30+
}
2831
cases := map[string]struct {
2932
pullRequest github.PullRequest
3033
requestedReviewers []string

.ci/magician/github/membership.go

-91
Original file line numberDiff line numberDiff line change
@@ -24,97 +24,6 @@ import (
2424
"golang.org/x/exp/maps"
2525
)
2626

27-
var (
28-
// This is for the random-assignee rotation.
29-
reviewerRotation = map[string]struct{}{
30-
"slevenick": struct{}{},
31-
"c2thorn": struct{}{},
32-
"rileykarson": struct{}{},
33-
"melinath": struct{}{},
34-
"ScottSuarez": struct{}{},
35-
"shuyama1": struct{}{},
36-
"SarahFrench": struct{}{},
37-
"roaks3": struct{}{},
38-
"zli82016": struct{}{},
39-
"trodge": struct{}{},
40-
"hao-nan-li": struct{}{},
41-
"NickElliot": struct{}{},
42-
"BBBmau": struct{}{},
43-
}
44-
45-
// This is for new team members who are onboarding
46-
trustedContributors = map[string]struct{}{}
47-
48-
// This is for reviewers who are "on vacation": will not receive new review assignments but will still receive re-requests for assigned PRs.
49-
// User can specify the time zone like this, and following the example below:
50-
pdtLoc, _ = time.LoadLocation("America/Los_Angeles")
51-
bstLoc, _ = time.LoadLocation("Europe/London")
52-
onVacationReviewers = []onVacationReviewer{
53-
// Example: taking vacation from 2024-03-28 to 2024-04-02 in pdt time zone.
54-
// both ends are inclusive:
55-
// {
56-
// id: "xyz",
57-
// startDate: newDate(2024, 3, 28, pdtLoc),
58-
// endDate: newDate(2024, 4, 2, pdtLoc),
59-
// },
60-
{
61-
id: "hao-nan-li",
62-
startDate: newDate(2024, 4, 11, pdtLoc),
63-
endDate: newDate(2024, 6, 14, pdtLoc),
64-
},
65-
{
66-
id: "ScottSuarez",
67-
startDate: newDate(2024, 4, 30, pdtLoc),
68-
endDate: newDate(2024, 7, 31, pdtLoc),
69-
},
70-
{
71-
id: "SarahFrench",
72-
startDate: newDate(2024, 8, 2, bstLoc),
73-
endDate: newDate(2024, 8, 6, bstLoc),
74-
},
75-
{
76-
id: "shuyama1",
77-
startDate: newDate(2024, 5, 22, pdtLoc),
78-
endDate: newDate(2024, 5, 28, pdtLoc),
79-
},
80-
{
81-
id: "melinath",
82-
startDate: newDate(2024, 6, 26, pdtLoc),
83-
endDate: newDate(2024, 7, 22, pdtLoc),
84-
},
85-
{
86-
id: "slevenick",
87-
startDate: newDate(2024, 7, 5, pdtLoc),
88-
endDate: newDate(2024, 7, 16, pdtLoc),
89-
},
90-
{
91-
id: "c2thorn",
92-
startDate: newDate(2024, 7, 10, pdtLoc),
93-
endDate: newDate(2024, 7, 16, pdtLoc),
94-
},
95-
{
96-
id: "rileykarson",
97-
startDate: newDate(2024, 7, 18, pdtLoc),
98-
endDate: newDate(2024, 8, 10, pdtLoc),
99-
},
100-
{
101-
id: "roaks3",
102-
startDate: newDate(2024, 8, 2, pdtLoc),
103-
endDate: newDate(2024, 8, 9, pdtLoc),
104-
},
105-
{
106-
id: "slevenick",
107-
startDate: newDate(2024, 8, 10, pdtLoc),
108-
endDate: newDate(2024, 8, 17, pdtLoc),
109-
},
110-
{
111-
id: "trodge",
112-
startDate: newDate(2024, 8, 24, pdtLoc),
113-
endDate: newDate(2024, 9, 2, pdtLoc),
114-
},
115-
}
116-
)
117-
11827
type UserType int64
11928

12029
type date struct {
+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package github
2+
3+
import "time"
4+
5+
var (
6+
// This is for the random-assignee rotation.
7+
reviewerRotation = map[string]struct{}{
8+
"slevenick": {},
9+
"c2thorn": {},
10+
"rileykarson": {},
11+
"melinath": {},
12+
"ScottSuarez": {},
13+
"shuyama1": {},
14+
"SarahFrench": {},
15+
"roaks3": {},
16+
"zli82016": {},
17+
"trodge": {},
18+
"hao-nan-li": {},
19+
"NickElliot": {},
20+
"BBBmau": {},
21+
}
22+
23+
// This is for new team members who are onboarding
24+
trustedContributors = map[string]struct{}{}
25+
26+
// This is for reviewers who are "on vacation": will not receive new review assignments but will still receive re-requests for assigned PRs.
27+
// User can specify the time zone like this, and following the example below:
28+
pdtLoc, _ = time.LoadLocation("America/Los_Angeles")
29+
bstLoc, _ = time.LoadLocation("Europe/London")
30+
onVacationReviewers = []onVacationReviewer{
31+
// Example: taking vacation from 2024-03-28 to 2024-04-02 in pdt time zone.
32+
// both ends are inclusive:
33+
// {
34+
// id: "xyz",
35+
// startDate: newDate(2024, 3, 28, pdtLoc),
36+
// endDate: newDate(2024, 4, 2, pdtLoc),
37+
// },
38+
{
39+
id: "hao-nan-li",
40+
startDate: newDate(2024, 4, 11, pdtLoc),
41+
endDate: newDate(2024, 6, 14, pdtLoc),
42+
},
43+
{
44+
id: "ScottSuarez",
45+
startDate: newDate(2024, 4, 30, pdtLoc),
46+
endDate: newDate(2024, 7, 31, pdtLoc),
47+
},
48+
{
49+
id: "SarahFrench",
50+
startDate: newDate(2024, 8, 2, bstLoc),
51+
endDate: newDate(2024, 8, 6, bstLoc),
52+
},
53+
{
54+
id: "shuyama1",
55+
startDate: newDate(2024, 5, 22, pdtLoc),
56+
endDate: newDate(2024, 5, 28, pdtLoc),
57+
},
58+
{
59+
id: "melinath",
60+
startDate: newDate(2024, 6, 26, pdtLoc),
61+
endDate: newDate(2024, 7, 22, pdtLoc),
62+
},
63+
{
64+
id: "slevenick",
65+
startDate: newDate(2024, 7, 5, pdtLoc),
66+
endDate: newDate(2024, 7, 16, pdtLoc),
67+
},
68+
{
69+
id: "c2thorn",
70+
startDate: newDate(2024, 7, 10, pdtLoc),
71+
endDate: newDate(2024, 7, 16, pdtLoc),
72+
},
73+
{
74+
id: "rileykarson",
75+
startDate: newDate(2024, 7, 18, pdtLoc),
76+
endDate: newDate(2024, 8, 10, pdtLoc),
77+
},
78+
{
79+
id: "roaks3",
80+
startDate: newDate(2024, 8, 2, pdtLoc),
81+
endDate: newDate(2024, 8, 9, pdtLoc),
82+
},
83+
{
84+
id: "slevenick",
85+
startDate: newDate(2024, 8, 10, pdtLoc),
86+
endDate: newDate(2024, 8, 17, pdtLoc),
87+
},
88+
{
89+
id: "trodge",
90+
startDate: newDate(2024, 8, 24, pdtLoc),
91+
endDate: newDate(2024, 9, 2, pdtLoc),
92+
},
93+
}
94+
)

.ci/magician/github/reviewer_assignment_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import (
2424
)
2525

2626
func TestChooseCoreReviewers(t *testing.T) {
27+
if len(AvailableReviewers()) < 2 {
28+
t.Fatalf("not enough available reviewers (%v) to test (need at least 2)", AvailableReviewers())
29+
}
2730
firstCoreReviewer := AvailableReviewers()[0]
2831
secondCoreReviewer := AvailableReviewers()[1]
2932
cases := map[string]struct {

.github/workflows/request-reviewer.yml

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
steps:
2525
- name: Checkout Repository
2626
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2
27+
with:
28+
ref: main
2729
- name: Set up Go
2830
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
2931
with:

0 commit comments

Comments
 (0)