Skip to content

Commit 050a692

Browse files
h9jianggopherbot
authored andcommitted
internal/task: update the gopls version in vscode-go project
- For pre-release flow, update only the master branch. - For release flow, update both master and active release branch. A local relui screenshot is at golang/vscode-go#3500 (comment) For golang/vscode-go#3500 Change-Id: I0f171e1adfaabe58b69f8765331c038d3a58e724 Reviewed-on: https://go-review.googlesource.com/c/build/+/610539 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Hongxiang Jiang <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 5243639 commit 050a692

File tree

1 file changed

+66
-36
lines changed

1 file changed

+66
-36
lines changed

internal/task/releasegopls.go

Lines changed: 66 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func (r *ReleaseGoplsTasks) NewPrereleaseDefinition() *wf.Definition {
6161
prereleaseVerified := wf.Action1(wd, "verify installing latest gopls using release branch pre-release version", r.verifyGoplsInstallation, prereleaseVersion)
6262
wf.Action4(wd, "mail announcement", r.mailAnnouncement, release, prereleaseVersion, dependencyCommit, issue, wf.After(prereleaseVerified))
6363

64-
vscodeGoChange := wf.Task4(wd, "update gopls version in vscode-go project", r.updateGoplsVersionInVSCodeGo, reviewers, issue, prereleaseVersion, wf.Const("master"), wf.After(prereleaseVerified))
65-
_ = wf.Task1(wd, "await gopls version update CL submission in vscode-go project", clAwaiter{r.Gerrit}.awaitSubmission, vscodeGoChange)
64+
vscodeGoChanges := wf.Task4(wd, "update gopls version in vscode-go", r.updateVSCodeGoGoplsVersion, reviewers, issue, release, prerelease, wf.After(prereleaseVerified))
65+
_ = wf.Task1(wd, "await gopls version update CLs submission in vscode-go", clAwaiter{r.Gerrit}.awaitSubmissions, vscodeGoChanges)
6666

6767
wf.Output(wd, "version", prereleaseVersion)
6868

@@ -501,40 +501,6 @@ func (r *ReleaseGoplsTasks) mailAnnouncement(ctx *wf.TaskContext, semv semversio
501501
return r.SendMail(r.AnnounceMailHeader, content)
502502
}
503503

504-
func (r *ReleaseGoplsTasks) updateGoplsVersionInVSCodeGo(ctx *wf.TaskContext, reviewers []string, issue int64, version, branch string) (string, error) {
505-
clTitle := fmt.Sprintf(`extension/src/goToolsInformation: update gopls version %s`, version)
506-
if branch != "master" {
507-
clTitle = "[" + branch + "] " + clTitle
508-
}
509-
openCL, err := openCL(ctx, r.Gerrit, "vscode-go", branch, clTitle)
510-
if err != nil {
511-
return "", fmt.Errorf("failed to find the open CL of title %q in branch %q: %w", clTitle, branch, err)
512-
}
513-
if openCL != "" {
514-
ctx.Printf("not creating CL: found existing CL %s", openCL)
515-
return openCL, nil
516-
}
517-
const script = `go run -C extension tools/generate.go -tools`
518-
changedFiles, err := executeAndMonitorChange(ctx, r.CloudBuild, "vscode-go", branch, script, []string{"extension/src/goToolsInformation.ts"})
519-
if err != nil {
520-
return "", err
521-
}
522-
523-
// Skip CL creation as nothing changed.
524-
if len(changedFiles) == 0 {
525-
return "", nil
526-
}
527-
528-
changeInput := gerrit.ChangeInput{
529-
Project: "vscode-go",
530-
Branch: branch,
531-
Subject: fmt.Sprintf("%s\n\nThis is an automated CL which updates the gopls version.\n\nFor golang/go#%v", clTitle, issue),
532-
}
533-
534-
ctx.Printf("creating auto-submit change under branch %q in vscode-go repo.", branch)
535-
return r.Gerrit.CreateAutoSubmitChange(ctx, changeInput, reviewers, changedFiles)
536-
}
537-
538504
func (r *ReleaseGoplsTasks) isValidReleaseVersion(ctx *wf.TaskContext, ver string) error {
539505
if !semver.IsValid(ver) {
540506
return fmt.Errorf("the input %q version does not follow semantic version schema", ver)
@@ -680,6 +646,9 @@ func (r *ReleaseGoplsTasks) NewReleaseDefinition() *wf.Definition {
680646
changeID := wf.Task3(wd, "updating x/tools dependency in master branch in gopls sub dir", r.updateDependencyIfMinor, reviewers, release, issue, wf.After(tagged))
681647
_ = wf.Task1(wd, "await x/tools gopls dependency CL submission in gopls sub dir", clAwaiter{r.Gerrit}.awaitSubmission, changeID)
682648

649+
vscodeGoChanges := wf.Task4(wd, "update gopls version in vscode-go", r.updateVSCodeGoGoplsVersion, reviewers, issue, release, wf.Const(""), wf.After(tagged))
650+
_ = wf.Task1(wd, "await gopls version update CLs submission in vscode-go", clAwaiter{r.Gerrit}.awaitSubmissions, vscodeGoChanges)
651+
683652
return wd
684653
}
685654

@@ -704,6 +673,67 @@ func (r *ReleaseGoplsTasks) latestPrerelease(ctx *wf.TaskContext, semv semversio
704673
return rc.Pre, nil
705674
}
706675

676+
// updateVSCodeGoGoplsVersion updates the gopls version in the vscode-go project.
677+
// For releases (input param prerelease is empty), it updates both the master
678+
// and release branches.
679+
// For pre-releases (input param prerelease is not empty), it updates only the
680+
// master branch.
681+
func (r *ReleaseGoplsTasks) updateVSCodeGoGoplsVersion(ctx *wf.TaskContext, reviewers []string, issue int64, release semversion, prerelease string) ([]string, error) {
682+
version := fmt.Sprintf("v%v.%v.%v", release.Major, release.Minor, release.Patch)
683+
if prerelease != "" {
684+
version = version + "-" + prerelease
685+
}
686+
branches := []string{"master"}
687+
if prerelease == "" {
688+
releaseBranch, err := vsCodeGoActiveReleaseBranch(ctx, r.Gerrit)
689+
if err != nil {
690+
return nil, err
691+
}
692+
branches = append(branches, releaseBranch)
693+
}
694+
695+
var cls []string
696+
for _, branch := range branches {
697+
clTitle := fmt.Sprintf(`extension/src/goToolsInformation: update gopls version %s`, version)
698+
if branch != "master" {
699+
clTitle = "[" + branch + "] " + clTitle
700+
}
701+
openCL, err := openCL(ctx, r.Gerrit, "vscode-go", branch, clTitle)
702+
if err != nil {
703+
return nil, fmt.Errorf("failed to find the open CL of title %q in branch %q: %w", clTitle, branch, err)
704+
}
705+
if openCL != "" {
706+
ctx.Printf("not creating CL: found existing CL %s", openCL)
707+
cls = append(cls, openCL)
708+
continue
709+
}
710+
const script = `go run -C extension tools/generate.go -tools`
711+
changedFiles, err := executeAndMonitorChange(ctx, r.CloudBuild, "vscode-go", branch, script, []string{"extension/src/goToolsInformation.ts"})
712+
if err != nil {
713+
return nil, err
714+
}
715+
716+
// Skip CL creation as nothing changed.
717+
if len(changedFiles) == 0 {
718+
continue
719+
}
720+
721+
changeInput := gerrit.ChangeInput{
722+
Project: "vscode-go",
723+
Branch: branch,
724+
Subject: fmt.Sprintf("%s\n\nThis is an automated CL which updates the gopls version.\n\nFor golang/go#%v", clTitle, issue),
725+
}
726+
727+
cl, err := r.Gerrit.CreateAutoSubmitChange(ctx, changeInput, reviewers, changedFiles)
728+
if err != nil {
729+
return nil, err
730+
}
731+
ctx.Printf("created auto-submit change %s under branch %q in vscode-go.", cl, branch)
732+
cls = append(cls, cl)
733+
}
734+
return cls, nil
735+
}
736+
707737
// tagRelease locates the commit associated with the pre-release version and
708738
// applies the official release tag in form of "gopls/vX.Y.Z" to the same commit.
709739
func (r *ReleaseGoplsTasks) tagRelease(ctx *wf.TaskContext, semv semversion, prerelease string) error {

0 commit comments

Comments
 (0)