From cc9395c521baa50ac4aa6880536db69d3020ba2f Mon Sep 17 00:00:00 2001 From: Hongxiang Jiang Date: Thu, 22 Aug 2024 20:28:45 +0000 Subject: [PATCH] internal/task: add a step in pre-release to ask for user approval A local relui screenshot is at https://go.dev/issue/57643#issuecomment-2305572494 For golang/go#57643 Change-Id: Iab10d6b4adbb04cfa8381d4e4776c3166ae40f41 Reviewed-on: https://go-review.googlesource.com/c/build/+/607896 LUCI-TryBot-Result: Go LUCI Auto-Submit: Hongxiang Jiang Reviewed-by: Robert Findley Reviewed-by: Dmitri Shuralyov Commit-Queue: Hongxiang Jiang --- cmd/relui/main.go | 1 + internal/task/releasegopls.go | 9 ++++++++- internal/task/releasegopls_test.go | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/relui/main.go b/cmd/relui/main.go index 642e9ac0..44ddecec 100644 --- a/cmd/relui/main.go +++ b/cmd/relui/main.go @@ -322,6 +322,7 @@ func main() { CloudBuild: cloudBuildClient, SendMail: mailFunc, AnnounceMailHeader: goplsAnnMail, + ApproveAction: relui.ApproveActionDep(dbPool), } dh.RegisterDefinition("Prepare a pre-release gopls candidate", goplsTasks.NewPrereleaseDefinition()) dh.RegisterDefinition("Release gopls", goplsTasks.NewReleaseDefinition()) diff --git a/internal/task/releasegopls.go b/internal/task/releasegopls.go index 8e701195..d11ae665 100644 --- a/internal/task/releasegopls.go +++ b/internal/task/releasegopls.go @@ -26,6 +26,7 @@ type ReleaseGoplsTasks struct { CloudBuild CloudBuildClient SendMail func(MailHeader, MailContent) error AnnounceMailHeader MailHeader + ApproveAction func(*wf.TaskContext) error } // NewPrereleaseDefinition create a new workflow definition for gopls pre-release. @@ -39,8 +40,9 @@ func (r *ReleaseGoplsTasks) NewPrereleaseDefinition() *wf.Definition { semv := wf.Task1(wd, "validating input version", r.isValidReleaseVersion, version) prerelease := wf.Task1(wd, "find the pre-release version", r.nextPrerelease, semv) + approved := wf.Action2(wd, "wait for release coordinator approval", r.approveVersion, semv, prerelease) - issue := wf.Task1(wd, "create release git issue", r.createReleaseIssue, semv) + issue := wf.Task1(wd, "create release git issue", r.createReleaseIssue, semv, wf.After(approved)) branchCreated := wf.Action1(wd, "creating new branch if minor release", r.createBranchIfMinor, semv, wf.After(issue)) configChangeID := wf.Task3(wd, "updating branch's codereview.cfg", r.updateCodeReviewConfig, semv, reviewers, issue, wf.After(branchCreated)) @@ -59,6 +61,11 @@ func (r *ReleaseGoplsTasks) NewPrereleaseDefinition() *wf.Definition { return wd } +func (r *ReleaseGoplsTasks) approveVersion(ctx *wf.TaskContext, semv semversion, pre string) error { + ctx.Printf("The next release candidate will be v%v.%v.%v-%s", semv.Major, semv.Minor, semv.Patch, pre) + return r.ApproveAction(ctx) +} + // createReleaseIssue attempts to locate the release issue associated with the // given milestone. If no such issue exists, a new one is created. // diff --git a/internal/task/releasegopls_test.go b/internal/task/releasegopls_test.go index 251e722a..64a041cf 100644 --- a/internal/task/releasegopls_test.go +++ b/internal/task/releasegopls_test.go @@ -659,7 +659,8 @@ esac`, tc.wantVersion) 1: fmt.Sprintf("gopls/v%v.%v.%v", tc.semv.Major, tc.semv.Minor, tc.semv.Patch), }, }, - SendMail: func(h MailHeader, c MailContent) error { return nil }, + SendMail: func(h MailHeader, c MailContent) error { return nil }, + ApproveAction: func(tc *workflow.TaskContext) error { return nil }, } wd := tasks.NewPrereleaseDefinition()