Skip to content

Commit 3029cba

Browse files
heschigopherbot
authored andcommitted
internal/task: final touches on x/ repo tagging
Tagging has now run to completion and I'm comfortable turning it loose. Remove the approval requirement and send CLs to specified reviewers so that it can be run as a scheduled workflow. For golang/go#48523. Change-Id: I2411a2680b09f877b8f4e5905ed51ae2e9ef2bdd Reviewed-on: https://go-review.googlesource.com/c/build/+/449038 Run-TryBot: Heschi Kreinick <[email protected]> Reviewed-by: Jenny Rakoczy <[email protected]> Auto-Submit: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 7459da6 commit 3029cba

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

cmd/relui/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ func main() {
212212
CreateBuildlet: coordinator.CreateBuildlet,
213213
LatestGoBinaries: task.LatestGoBinaries,
214214
DashboardURL: "https://build.golang.org",
215-
ApproveAction: relui.ApproveActionDep(dbPool),
216215
}
217216
dh.RegisterDefinition("Tag x/ repos", tagTasks.NewDefinition())
218217
dh.RegisterDefinition("Tag a single x/ repo", tagTasks.NewSingleDefinition())

internal/task/tagx.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,32 @@ type TagXReposTasks struct {
3535
CreateBuildlet func(context.Context, string) (buildlet.RemoteClient, error)
3636
LatestGoBinaries func(context.Context) (string, error)
3737
DashboardURL string
38-
ApproveAction func(*wf.TaskContext) error
3938
}
4039

4140
func (x *TagXReposTasks) NewDefinition() *wf.Definition {
4241
wd := wf.New()
42+
reviewers := wf.Param(wd, reviewersParam)
4343
repos := wf.Task0(wd, "Select repositories", x.SelectRepos)
44-
wf.Expand1(wd, "Create plan", x.BuildPlan, repos)
44+
wf.Expand2(wd, "Create plan", x.BuildPlan, repos, reviewers)
4545
return wd
4646
}
4747

4848
func (x *TagXReposTasks) NewSingleDefinition() *wf.Definition {
4949
wd := wf.New()
50+
reviewers := wf.Param(wd, reviewersParam)
5051
repos := wf.Task0(wd, "Load all repositories", x.SelectRepos)
5152
name := wf.Param(wd, wf.ParamDef[string]{Name: "Repository name", Example: "tools"})
52-
wf.Expand2(wd, "Create single-repo plan", x.BuildSingleRepoPlan, repos, name)
53+
wf.Expand3(wd, "Create single-repo plan", x.BuildSingleRepoPlan, repos, name, reviewers)
5354
return wd
5455
}
5556

57+
var reviewersParam = wf.ParamDef[[]string]{
58+
Name: "Reviewer usernames (optional)",
59+
ParamType: wf.SliceShort,
60+
Doc: `Send code reviews to these users.`,
61+
Example: "heschi",
62+
}
63+
5664
// TagRepo contains information about a repo that can be tagged.
5765
type TagRepo struct {
5866
Name string // Gerrit project name, e.g. "tools".
@@ -222,7 +230,7 @@ func checkCycles1(reposByModule map[string]TagRepo, repo TagRepo, stack []string
222230
}
223231

224232
// BuildPlan adds the tasks needed to update repos to wd.
225-
func (x *TagXReposTasks) BuildPlan(wd *wf.Definition, repos []TagRepo) error {
233+
func (x *TagXReposTasks) BuildPlan(wd *wf.Definition, repos []TagRepo, reviewers []string) error {
226234
// repo.ModPath to the wf.Value produced by updating it.
227235
updated := map[string]wf.Value[TagRepo]{}
228236

@@ -234,7 +242,7 @@ func (x *TagXReposTasks) BuildPlan(wd *wf.Definition, repos []TagRepo) error {
234242
if _, ok := updated[repo.ModPath]; ok {
235243
continue
236244
}
237-
dep, ok := x.planRepo(wd, repo, updated)
245+
dep, ok := x.planRepo(wd, repo, updated, reviewers)
238246
if !ok {
239247
continue
240248
}
@@ -261,7 +269,7 @@ func (x *TagXReposTasks) BuildPlan(wd *wf.Definition, repos []TagRepo) error {
261269
return nil
262270
}
263271

264-
func (x *TagXReposTasks) BuildSingleRepoPlan(wd *wf.Definition, repoSlice []TagRepo, name string) error {
272+
func (x *TagXReposTasks) BuildSingleRepoPlan(wd *wf.Definition, repoSlice []TagRepo, name string, reviewers []string) error {
265273
repos := map[string]TagRepo{}
266274
updatedRepos := map[string]wf.Value[TagRepo]{}
267275
for _, r := range repoSlice {
@@ -275,7 +283,7 @@ func (x *TagXReposTasks) BuildSingleRepoPlan(wd *wf.Definition, repoSlice []TagR
275283
if !ok {
276284
return fmt.Errorf("no repository %q", name)
277285
}
278-
tagged, ok := x.planRepo(wd, repo, updatedRepos)
286+
tagged, ok := x.planRepo(wd, repo, updatedRepos, reviewers)
279287
if !ok {
280288
return fmt.Errorf("%q doesn't have all of its dependencies (%q)", repo.Name, repo.Deps)
281289
}
@@ -286,7 +294,7 @@ func (x *TagXReposTasks) BuildSingleRepoPlan(wd *wf.Definition, repoSlice []TagR
286294
// planRepo adds tasks to wf to update and tag repo. It returns a Value
287295
// containing the tagged repository's information, or nil, false if its
288296
// dependencies haven't been planned yet.
289-
func (x *TagXReposTasks) planRepo(wd *wf.Definition, repo TagRepo, updated map[string]wf.Value[TagRepo]) (_ wf.Value[TagRepo], ready bool) {
297+
func (x *TagXReposTasks) planRepo(wd *wf.Definition, repo TagRepo, updated map[string]wf.Value[TagRepo], reviewers []string) (_ wf.Value[TagRepo], ready bool) {
290298
var deps []wf.Value[TagRepo]
291299
for _, repoDeps := range repo.Deps {
292300
if dep, ok := updated[repoDeps]; ok {
@@ -303,7 +311,7 @@ func (x *TagXReposTasks) planRepo(wd *wf.Definition, repo TagRepo, updated map[s
303311
tagCommit = wf.Task2(wd, "read branch head", x.Gerrit.ReadBranchHead, repoName, branch)
304312
} else {
305313
gomod := wf.Task3(wd, "generate updated go.mod", x.UpdateGoMod, wf.Const(repo), wf.Slice(deps...), branch)
306-
cl := wf.Task2(wd, "mail updated go.mod", x.MailGoMod, repoName, gomod)
314+
cl := wf.Task3(wd, "mail updated go.mod", x.MailGoMod, repoName, gomod, wf.Const(reviewers))
307315
tagCommit = wf.Task3(wd, "wait for submit", x.AwaitGoMod, cl, repoName, branch)
308316
}
309317
greenCommit := wf.Task2(wd, "wait for green post-submit", x.AwaitGreen, wf.Const(repo), tagCommit)
@@ -457,7 +465,7 @@ func LatestGoBinaries(ctx context.Context) (string, error) {
457465
return "", fmt.Errorf("no linux-amd64??")
458466
}
459467

460-
func (x *TagXReposTasks) MailGoMod(ctx *wf.TaskContext, repo string, files map[string]string) (string, error) {
468+
func (x *TagXReposTasks) MailGoMod(ctx *wf.TaskContext, repo string, files map[string]string, reviewers []string) (string, error) {
461469
const subject = `go.mod: update golang.org/x dependencies
462470
463471
Update golang.org/x dependencies to their latest tagged versions.
@@ -469,7 +477,7 @@ will be tagged with its next minor version.
469477
Project: repo,
470478
Branch: "master",
471479
Subject: subject,
472-
}, nil, files)
480+
}, reviewers, files)
473481
}
474482

475483
func (x *TagXReposTasks) AwaitGoMod(ctx *wf.TaskContext, changeID, repo, branch string) (string, error) {
@@ -658,11 +666,7 @@ func (x *TagXReposTasks) MaybeTag(ctx *wf.TaskContext, repo TagRepo, commit stri
658666
return TagRepo{}, fmt.Errorf("couldn't pick next version for %v: %v", repo.Name, err)
659667
}
660668

661-
// TODO(heschi): delete after first couple uses
662-
ctx.Printf("Waiting for approval to tag %v at %v as %v", repo.Name, commit, repo.Version)
663-
if err := x.ApproveAction(ctx); err != nil {
664-
return TagRepo{}, err
665-
}
669+
ctx.Printf("Tagging %v at %v as %v", repo.Name, commit, repo.Version)
666670
return repo, x.Gerrit.Tag(ctx, repo.Name, repo.Version, commit)
667671
}
668672

internal/task/tagx_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,6 @@ func newTagXTestDeps(t *testing.T, repos ...*FakeRepo) *tagXTestDeps {
410410
return goServer.URL + "/dl/go1.19.linux-amd64.tar.gz", nil
411411
},
412412
DashboardURL: dashServer.URL,
413-
ApproveAction: func(tc *workflow.TaskContext) error {
414-
return nil
415-
},
416413
}
417414
return &tagXTestDeps{
418415
ctx: ctx,
@@ -449,7 +446,9 @@ func TestTagXRepos(t *testing.T) {
449446
deps := newTagXTestDeps(t, sys, mod, tools)
450447

451448
wd := deps.tagXTasks.NewDefinition()
452-
w, err := workflow.Start(wd, nil)
449+
w, err := workflow.Start(wd, map[string]interface{}{
450+
reviewersParam.Name: []string(nil),
451+
})
453452
if err != nil {
454453
t.Fatal(err)
455454
}
@@ -521,7 +520,8 @@ func TestTagSingleRepo(t *testing.T) {
521520
wd := deps.tagXTasks.NewSingleDefinition()
522521
ctx, cancel := context.WithTimeout(deps.ctx, time.Minute)
523522
w, err := workflow.Start(wd, map[string]interface{}{
524-
"Repository name": "foo",
523+
"Repository name": "foo",
524+
reviewersParam.Name: []string(nil),
525525
})
526526
if err != nil {
527527
t.Fatal(err)

0 commit comments

Comments
 (0)