@@ -34,10 +34,14 @@ func (r *ReleaseGoplsTasks) NewDefinition() *wf.Definition {
34
34
reviewers := wf .Param (wd , reviewersParam )
35
35
semversion := wf .Task1 (wd , "validating input version" , r .isValidVersion , version )
36
36
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 )
41
45
return wd
42
46
}
43
47
@@ -101,10 +105,6 @@ func (r *ReleaseGoplsTasks) openCL(ctx *wf.TaskContext, branch, title string) (s
101
105
// otherwise it returns an empty string indicating no update is necessary.
102
106
func (r * ReleaseGoplsTasks ) updateCodeReviewConfig (ctx * wf.TaskContext , semv semversion , reviewers []string ) (string , error ) {
103
107
const configFile = "codereview.cfg"
104
- const configFmt = `issuerepo: golang/go
105
- branch: %s
106
- parent-branch: master
107
- `
108
108
109
109
branch := goplsReleaseBranchName (semv )
110
110
clTitle := fmt .Sprintf ("all: update %s for %s" , configFile , branch )
@@ -127,7 +127,10 @@ parent-branch: master
127
127
if err != nil && ! errors .Is (err , gerrit .ErrResourceNotExist ) {
128
128
return "" , err
129
129
}
130
-
130
+ const configFmt = `issuerepo: golang/go
131
+ branch: %s
132
+ parent-branch: master
133
+ `
131
134
after := fmt .Sprintf (configFmt , branch )
132
135
// Skip CL creation as config has not changed.
133
136
if string (before ) == after {
@@ -148,7 +151,7 @@ parent-branch: master
148
151
return r .Gerrit .CreateAutoSubmitChange (ctx , changeInput , reviewers , files )
149
152
}
150
153
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
152
155
// version and find the next pre-release version.
153
156
func (r * ReleaseGoplsTasks ) nextPrerelease (ctx * wf.TaskContext , semv semversion ) (int , error ) {
154
157
tags , err := r .Gerrit .ListTags (ctx , "tools" )
@@ -187,14 +190,6 @@ func (r *ReleaseGoplsTasks) nextPrerelease(ctx *wf.TaskContext, semv semversion)
187
190
//
188
191
// It returns the change ID, or "" if the CL was not created.
189
192
func (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
-
198
193
pre , err := r .nextPrerelease (ctx , semv )
199
194
if err != nil {
200
195
return "" , fmt .Errorf ("failed to find the next prerelease version: %w" , err )
@@ -212,13 +207,16 @@ go mod tidy -compat=1.19
212
207
}
213
208
214
209
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@).
222
220
build , err := r .CloudBuild .RunScript (ctx , fmt .Sprintf (scriptFmt , branch ), "tools" , outputFiles )
223
221
if err != nil {
224
222
return "" , err
@@ -252,20 +250,50 @@ go mod tidy -compat=1.19
252
250
return r .Gerrit .CreateAutoSubmitChange (ctx , changeInput , reviewers , changedFiles )
253
251
}
254
252
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
+
255
284
// AwaitSubmission waits for the CL with the given change ID to be submitted.
256
285
//
257
286
// 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 ) {
259
288
if changeID == "" {
260
289
ctx .Printf ("not awaiting: no CL was created" )
261
- return nil
290
+ return "" , nil
262
291
}
263
292
264
293
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 ) {
266
295
return r .Gerrit .Submitted (ctx , changeID , "" )
267
296
})
268
- return err
269
297
}
270
298
271
299
func (r * ReleaseGoplsTasks ) isValidVersion (ctx * wf.TaskContext , ver string ) (semversion , error ) {
0 commit comments