@@ -61,6 +61,9 @@ func (r *ReleaseGoplsTasks) NewPrereleaseDefinition() *wf.Definition {
61
61
prereleaseVerified := wf .Action1 (wd , "verify installing latest gopls using release branch pre-release version" , r .verifyGoplsInstallation , prereleaseVersion )
62
62
wf .Action4 (wd , "mail announcement" , r .mailAnnouncement , semv , prereleaseVersion , dependencyCommit , issue , wf .After (prereleaseVerified ))
63
63
64
+ vsCodeGoChanges := wf .Task3 (wd , "update gopls version in vscode-go project" , r .updateGoplsVersionInVSCodeGo , reviewers , issue , prereleaseVersion , wf .After (prereleaseVerified ))
65
+ _ = wf .Task1 (wd , "await gopls version update CL submission in vscode-go project" , clAwaiter {r .Gerrit }.awaitSubmissions , vsCodeGoChanges )
66
+
64
67
wf .Output (wd , "version" , prereleaseVersion )
65
68
66
69
return wd
@@ -221,9 +224,9 @@ func (r *ReleaseGoplsTasks) createBranchIfMinor(ctx *wf.TaskContext, semv semver
221
224
//
222
225
// It returns an empty string if no such CL is found, otherwise it returns the
223
226
// CL's change ID.
224
- func openCL (ctx * wf.TaskContext , gerrit GerritClient , branch , title string ) (string , error ) {
227
+ func openCL (ctx * wf.TaskContext , gerrit GerritClient , repo , branch , title string ) (string , error ) {
225
228
// Query for an existing pending config CL, to avoid duplication.
226
- query := fmt .
Sprintf (
`message:%q status:open owner:[email protected] repo:tools branch:%q -age:7d` ,
title ,
branch )
229
+ query := fmt .
Sprintf (
`message:%q status:open owner:[email protected] repo:%s branch:%q -age:7d` ,
title , repo ,
branch )
227
230
changes , err := gerrit .QueryChanges (ctx , query )
228
231
if err != nil {
229
232
return "" , err
@@ -245,7 +248,7 @@ func (r *ReleaseGoplsTasks) updateCodeReviewConfig(ctx *wf.TaskContext, semv sem
245
248
branch := goplsReleaseBranchName (semv )
246
249
clTitle := fmt .Sprintf ("all: update %s for %s" , configFile , branch )
247
250
248
- openCL , err := openCL (ctx , r .Gerrit , branch , clTitle )
251
+ openCL , err := openCL (ctx , r .Gerrit , "tools" , branch , clTitle )
249
252
if err != nil {
250
253
return "" , fmt .Errorf ("failed to find the open CL of title %q in branch %q: %w" , clTitle , branch , err )
251
254
}
@@ -342,7 +345,7 @@ func (r *ReleaseGoplsTasks) updateXToolsDependency(ctx *wf.TaskContext, semv sem
342
345
343
346
branch := goplsReleaseBranchName (semv )
344
347
clTitle := fmt .Sprintf ("gopls: update go.mod for v%v.%v.%v-%s" , semv .Major , semv .Minor , semv .Patch , pre )
345
- openCL , err := openCL (ctx , r .Gerrit , branch , clTitle )
348
+ openCL , err := openCL (ctx , r .Gerrit , "tools" , branch , clTitle )
346
349
if err != nil {
347
350
return "" , fmt .Errorf ("failed to find the open CL of title %q in branch %q: %w" , clTitle , branch , err )
348
351
}
@@ -363,7 +366,7 @@ go get golang.org/x/tools@%s
363
366
go mod tidy -compat=1.19
364
367
` , head )
365
368
366
- changedFiles , err := executeAndMonitorChange (ctx , r .CloudBuild , branch , script , []string {"gopls/go.mod" , "gopls/go.sum" })
369
+ changedFiles , err := executeAndMonitorChange (ctx , r .CloudBuild , "tools" , branch , script , []string {"gopls/go.mod" , "gopls/go.sum" })
367
370
if err != nil {
368
371
return "" , err
369
372
}
@@ -467,6 +470,53 @@ func (r *ReleaseGoplsTasks) mailAnnouncement(ctx *wf.TaskContext, semv semversio
467
470
return r .SendMail (r .AnnounceMailHeader , content )
468
471
}
469
472
473
+ func (r * ReleaseGoplsTasks ) updateGoplsVersionInVSCodeGo (ctx * wf.TaskContext , reviewers []string , issue int64 , version string ) ([]string , error ) {
474
+ releaseBranch , err := vsCodeGoActiveReleaseBranch (ctx , r .Gerrit )
475
+ if err != nil {
476
+ return nil , err
477
+ }
478
+ var changes []string
479
+ for _ , branch := range []string {"master" , releaseBranch } {
480
+ clTitle := fmt .Sprintf (`extension/src/goToolsInformation: update gopls version %s` , version )
481
+ if branch != "master" {
482
+ clTitle = "[" + branch + "] " + clTitle
483
+ }
484
+ openCL , err := openCL (ctx , r .Gerrit , "vscode-go" , branch , clTitle )
485
+ if err != nil {
486
+ return nil , fmt .Errorf ("failed to find the open CL of title %q in branch %q: %w" , clTitle , branch , err )
487
+ }
488
+ if openCL != "" {
489
+ ctx .Printf ("not creating CL: found existing CL %s" , openCL )
490
+ changes = append (changes , openCL )
491
+ continue
492
+ }
493
+ const script = `go run -C extension tools/generate.go -tools`
494
+ changedFiles , err := executeAndMonitorChange (ctx , r .CloudBuild , "vscode-go" , branch , script , []string {"extension/src/goToolsInformation.ts" })
495
+ if err != nil {
496
+ return nil , err
497
+ }
498
+
499
+ // Skip CL creation as nothing changed.
500
+ if len (changedFiles ) == 0 {
501
+ return nil , nil
502
+ }
503
+
504
+ changeInput := gerrit.ChangeInput {
505
+ Project : "vscode-go" ,
506
+ Branch : branch ,
507
+ Subject : fmt .Sprintf ("%s\n \n This is an automated CL which updates the gopls version.\n \n For golang/go#%v" , clTitle , issue ),
508
+ }
509
+
510
+ ctx .Printf ("creating auto-submit change under branch %q in vscode-go repo." , branch )
511
+ changeID , err := r .Gerrit .CreateAutoSubmitChange (ctx , changeInput , reviewers , changedFiles )
512
+ if err != nil {
513
+ return nil , err
514
+ }
515
+ changes = append (changes , changeID )
516
+ }
517
+ return changes , nil
518
+ }
519
+
470
520
func (r * ReleaseGoplsTasks ) isValidReleaseVersion (ctx * wf.TaskContext , ver string ) error {
471
521
if ! semver .IsValid (ver ) {
472
522
return fmt .Errorf ("the input %q version does not follow semantic version schema" , ver )
@@ -706,7 +756,7 @@ func (r *ReleaseGoplsTasks) updateDependencyIfMinor(ctx *wf.TaskContext, reviewe
706
756
}
707
757
708
758
clTitle := fmt .Sprintf ("gopls/go.mod: update dependencies following the v%v.%v.%v release" , semv .Major , semv .Minor , semv .Patch )
709
- openCL , err := openCL (ctx , r .Gerrit , "master" , clTitle )
759
+ openCL , err := openCL (ctx , r .Gerrit , "tools" , " master" , clTitle )
710
760
if err != nil {
711
761
return "" , fmt .Errorf ("failed to find the open CL of title %q in master branch: %w" , clTitle , err )
712
762
}
722
772
go get -u all
723
773
go mod tidy -compat=1.19
724
774
`
725
- changed , err := executeAndMonitorChange (ctx , r .CloudBuild , "master" , script , []string {"gopls/go.mod" , "gopls/go.sum" })
775
+ changed , err := executeAndMonitorChange (ctx , r .CloudBuild , "tools" , " master" , script , []string {"gopls/go.mod" , "gopls/go.sum" })
726
776
if err != nil {
727
777
return "" , err
728
778
}
@@ -747,7 +797,7 @@ go mod tidy -compat=1.19
747
797
//
748
798
// Returns a map where keys are the filenames of modified files and values are
749
799
// their corresponding content after script execution.
750
- func executeAndMonitorChange (ctx * wf.TaskContext , cloudBuild CloudBuildClient , branch , script string , watchFiles []string ) (map [string ]string , error ) {
800
+ func executeAndMonitorChange (ctx * wf.TaskContext , cloudBuild CloudBuildClient , project , branch , script string , watchFiles []string ) (map [string ]string , error ) {
751
801
// Checkout to the provided branch.
752
802
fullScript := fmt .Sprintf (`git checkout %s
753
803
git rev-parse --abbrev-ref HEAD
775
825
outputFiles = append (outputFiles , file + ".before" )
776
826
outputFiles = append (outputFiles , file )
777
827
}
778
- build , err := cloudBuild .RunScript (ctx , fullScript , "tools" , outputFiles )
828
+ build , err := cloudBuild .RunScript (ctx , fullScript , project , outputFiles )
779
829
if err != nil {
780
830
return nil , err
781
831
}
@@ -801,6 +851,8 @@ type clAwaiter struct {
801
851
GerritClient
802
852
}
803
853
854
+ // awaitSubmission waits for the specified change to be submitted, then returns
855
+ // the corresponding commit hash.
804
856
func (c clAwaiter ) awaitSubmission (ctx * wf.TaskContext , changeID string ) (string , error ) {
805
857
if changeID == "" {
806
858
ctx .Printf ("not awaiting: no CL was created" )
@@ -812,3 +864,24 @@ func (c clAwaiter) awaitSubmission(ctx *wf.TaskContext, changeID string) (string
812
864
return c .Submitted (ctx , changeID , "" )
813
865
})
814
866
}
867
+
868
+ // awaitSubmissions waits for the specified changes to be submitted, then
869
+ // returns a slice of commit hashes corresponding to the input change IDs,
870
+ // maintaining the original input order.
871
+ func (c clAwaiter ) awaitSubmissions (ctx * wf.TaskContext , changeIDs []string ) ([]string , error ) {
872
+ if len (changeIDs ) == 0 {
873
+ ctx .Printf ("not awaiting: no CL was created" )
874
+ return nil , nil
875
+ }
876
+
877
+ var commits []string
878
+ for _ , changeID := range changeIDs {
879
+ commit , err := c .awaitSubmission (ctx , changeID )
880
+ if err != nil {
881
+ return nil , err
882
+ }
883
+ commits = append (commits , commit )
884
+ }
885
+
886
+ return commits , nil
887
+ }
0 commit comments