@@ -34,10 +34,14 @@ func (r *ReleaseGoplsTasks) NewDefinition() *wf.Definition {
3434 reviewers := wf .Param (wd , reviewersParam )
3535 semversion := wf .Task1 (wd , "validating input version" , r .isValidVersion , version )
3636 branchCreated := wf .Action1 (wd , "creating new branch if minor release" , r .createBranchIfMinor , semversion )
37- changeID := wf .Task2 (wd , "updating branch's codereview.cfg" , r .updateCodeReviewConfig , semversion , reviewers , wf .After (branchCreated ))
38- submitted := wf .Action1 (wd , "await config CL submission" , r .AwaitSubmission , changeID )
39- changeID = wf .Task2 (wd , "updating gopls' x/tools dependency" , r .updateXToolsDependency , semversion , reviewers , wf .After (submitted ))
40- _ = wf .Action1 (wd , "await gopls' x/tools dependency CL submission" , r .AwaitSubmission , changeID )
37+
38+ configChangeID := wf .Task2 (wd , "updating branch's codereview.cfg" , r .updateCodeReviewConfig , semversion , reviewers , wf .After (branchCreated ))
39+ configCommit := wf .Task1 (wd , "await config CL submission" , r .AwaitSubmission , configChangeID )
40+
41+ dependencyChangeID := wf .Task2 (wd , "updating gopls' x/tools dependency" , r .updateXToolsDependency , semversion , reviewers , wf .After (configCommit ))
42+ dependencyCommit := wf .Task1 (wd , "await gopls' x/tools dependency CL submission" , r .AwaitSubmission , dependencyChangeID )
43+
44+ _ = wf .Action1 (wd , "verify installing latest gopls in release branch using go install" , r .verifyGoplsInstallation , dependencyCommit )
4145 return wd
4246}
4347
@@ -101,10 +105,6 @@ func (r *ReleaseGoplsTasks) openCL(ctx *wf.TaskContext, branch, title string) (s
101105// otherwise it returns an empty string indicating no update is necessary.
102106func (r * ReleaseGoplsTasks ) updateCodeReviewConfig (ctx * wf.TaskContext , semv semversion , reviewers []string ) (string , error ) {
103107 const configFile = "codereview.cfg"
104- const configFmt = `issuerepo: golang/go
105- branch: %s
106- parent-branch: master
107- `
108108
109109 branch := goplsReleaseBranchName (semv )
110110 clTitle := fmt .Sprintf ("all: update %s for %s" , configFile , branch )
@@ -127,7 +127,10 @@ parent-branch: master
127127 if err != nil && ! errors .Is (err , gerrit .ErrResourceNotExist ) {
128128 return "" , err
129129 }
130-
130+ const configFmt = `issuerepo: golang/go
131+ branch: %s
132+ parent-branch: master
133+ `
131134 after := fmt .Sprintf (configFmt , branch )
132135 // Skip CL creation as config has not changed.
133136 if string (before ) == after {
@@ -148,7 +151,7 @@ parent-branch: master
148151 return r .Gerrit .CreateAutoSubmitChange (ctx , changeInput , reviewers , files )
149152}
150153
151- // nextPrerelease go through the tags in tools repo that matches with the given
154+ // nextPrerelease inspects the tags in tools repo that match with the given
152155// version and find the next pre-release version.
153156func (r * ReleaseGoplsTasks ) nextPrerelease (ctx * wf.TaskContext , semv semversion ) (int , error ) {
154157 tags , err := r .Gerrit .ListTags (ctx , "tools" )
@@ -187,14 +190,6 @@ func (r *ReleaseGoplsTasks) nextPrerelease(ctx *wf.TaskContext, semv semversion)
187190//
188191// It returns the change ID, or "" if the CL was not created.
189192func (r * ReleaseGoplsTasks ) updateXToolsDependency (ctx * wf.TaskContext , semv semversion , reviewers []string ) (string , error ) {
190- const scriptFmt = `cp gopls/go.mod gopls/go.mod.before
191- cp gopls/go.sum gopls/go.sum.before
192- cd gopls
193- go mod edit -dropreplace=golang.org/x/tools
194- go get -u golang.org/x/tools@%s
195- go mod tidy -compat=1.19
196- `
197-
198193 pre , err := r .nextPrerelease (ctx , semv )
199194 if err != nil {
200195 return "" , fmt .Errorf ("failed to find the next prerelease version: %w" , err )
@@ -212,13 +207,16 @@ go mod tidy -compat=1.19
212207 }
213208
214209 outputFiles := []string {"gopls/go.mod.before" , "gopls/go.mod" , "gopls/go.sum.before" , "gopls/go.sum" }
215- // TODO(hxjiang): Replacing branch with the latest non-pinned commit in the
216- // release branch. Rationale:
217- // 1. Module proxy might return an outdated commit when using the branch name
218- // (to be confirmed with samthanawalla@).
219- // 2. Pinning x/tools using the latest commit from a branch isn't idempotent.
220- // It's best to avoid pinning x/tools to a version that's effectively another
221- // pin.
210+ const scriptFmt = `cp gopls/go.mod gopls/go.mod.before
211+ cp gopls/go.sum gopls/go.sum.before
212+ cd gopls
213+ go mod edit -dropreplace=golang.org/x/tools
214+ go get -u golang.org/x/tools@%s
215+ go mod tidy -compat=1.19
216+ `
217+ // TODO(hxjiang): Replacing branch with the latest commit in the release
218+ // branch. Module proxy might return an outdated commit when using the branch
219+ // name (to be confirmed with samthanawalla@).
222220 build , err := r .CloudBuild .RunScript (ctx , fmt .Sprintf (scriptFmt , branch ), "tools" , outputFiles )
223221 if err != nil {
224222 return "" , err
@@ -252,20 +250,50 @@ go mod tidy -compat=1.19
252250 return r .Gerrit .CreateAutoSubmitChange (ctx , changeInput , reviewers , changedFiles )
253251}
254252
253+ func (r * ReleaseGoplsTasks ) verifyGoplsInstallation (ctx * wf.TaskContext , commit string ) error {
254+ if commit == "" {
255+ return fmt .Errorf ("the input commit should not be empty" )
256+ }
257+ const scriptFmt = `go install golang.org/x/tools/gopls@%s &> install.log
258+ $(go env GOPATH)/bin/gopls version &> version.log
259+ echo -n "package main
260+
261+ func main () {
262+ const a = 2
263+ b := a
264+ }" > main.go
265+ $(go env GOPATH)/bin/gopls references -d main.go:4:8 &> smoke.log
266+ `
267+
268+ ctx .Printf ("verify gopls with commit %s\n " , commit )
269+ build , err := r .CloudBuild .RunScript (ctx , fmt .Sprintf (scriptFmt , commit ), "" , []string {"install.log" , "version.log" , "smoke.log" })
270+ if err != nil {
271+ return err
272+ }
273+
274+ outputs , err := buildToOutputs (ctx , r .CloudBuild , build )
275+ if err != nil {
276+ return err
277+ }
278+ ctx .Printf ("verify gopls installation process:\n %s\n " , outputs ["install.log" ])
279+ ctx .Printf ("verify gopls version:\n %s\n " , outputs ["version.log" ])
280+ ctx .Printf ("verify gopls functionality with gopls references smoke test:\n %s\n " , outputs ["smoke.log" ])
281+ return nil
282+ }
283+
255284// AwaitSubmission waits for the CL with the given change ID to be submitted.
256285//
257286// The return value is the submitted commit hash, or "" if changeID is "".
258- func (r * ReleaseGoplsTasks ) AwaitSubmission (ctx * wf.TaskContext , changeID string ) error {
287+ func (r * ReleaseGoplsTasks ) AwaitSubmission (ctx * wf.TaskContext , changeID string ) ( string , error ) {
259288 if changeID == "" {
260289 ctx .Printf ("not awaiting: no CL was created" )
261- return nil
290+ return "" , nil
262291 }
263292
264293 ctx .Printf ("awaiting review/submit of %v" , ChangeLink (changeID ))
265- _ , err := AwaitCondition (ctx , 10 * time .Second , func () (string , bool , error ) {
294+ return AwaitCondition (ctx , 10 * time .Second , func () (string , bool , error ) {
266295 return r .Gerrit .Submitted (ctx , changeID , "" )
267296 })
268- return err
269297}
270298
271299func (r * ReleaseGoplsTasks ) isValidVersion (ctx * wf.TaskContext , ver string ) (semversion , error ) {
0 commit comments