Skip to content

Commit c511972

Browse files
committed
internal/task: avoid updating gopls version in vscode-go release branch
For gopls pre-release, the flow only need to update gopls version in vscode-go master branch. For gopls release, the flow will need to update gopls version in vscode-go master and current active release branch. (Next cl) To make the function resusable in future, the branch varaiable will be taken out and determined by the caller. For golang/vscode-go#3500 Change-Id: I4778f3ce5ae133b1e495b2660fe41fccfa59c2e6 Reviewed-on: https://go-review.googlesource.com/c/build/+/609376 Reviewed-by: Hyang-Ah Hana Kim <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent a15ffe2 commit c511972

File tree

2 files changed

+30
-43
lines changed

2 files changed

+30
-43
lines changed

internal/task/releasegopls.go

Lines changed: 29 additions & 42 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, semv, prereleaseVersion, dependencyCommit, issue, wf.After(prereleaseVerified))
6363

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)
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)
6666

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

@@ -470,51 +470,38 @@ func (r *ReleaseGoplsTasks) mailAnnouncement(ctx *wf.TaskContext, semv semversio
470470
return r.SendMail(r.AnnounceMailHeader, content)
471471
}
472472

473-
func (r *ReleaseGoplsTasks) updateGoplsVersionInVSCodeGo(ctx *wf.TaskContext, reviewers []string, issue int64, version string) ([]string, error) {
474-
releaseBranch, err := vsCodeGoActiveReleaseBranch(ctx, r.Gerrit)
473+
func (r *ReleaseGoplsTasks) updateGoplsVersionInVSCodeGo(ctx *wf.TaskContext, reviewers []string, issue int64, version, branch string) (string, error) {
474+
clTitle := fmt.Sprintf(`extension/src/goToolsInformation: update gopls version %s`, version)
475+
if branch != "master" {
476+
clTitle = "[" + branch + "] " + clTitle
477+
}
478+
openCL, err := openCL(ctx, r.Gerrit, "vscode-go", branch, clTitle)
475479
if err != nil {
476-
return nil, err
480+
return "", fmt.Errorf("failed to find the open CL of title %q in branch %q: %w", clTitle, branch, err)
481+
}
482+
if openCL != "" {
483+
ctx.Printf("not creating CL: found existing CL %s", openCL)
484+
return openCL, nil
485+
}
486+
const script = `go run -C extension tools/generate.go -tools`
487+
changedFiles, err := executeAndMonitorChange(ctx, r.CloudBuild, "vscode-go", branch, script, []string{"extension/src/goToolsInformation.ts"})
488+
if err != nil {
489+
return "", err
477490
}
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-
}
503491

504-
changeInput := gerrit.ChangeInput{
505-
Project: "vscode-go",
506-
Branch: branch,
507-
Subject: fmt.Sprintf("%s\n\nThis is an automated CL which updates the gopls version.\n\nFor golang/go#%v", clTitle, issue),
508-
}
492+
// Skip CL creation as nothing changed.
493+
if len(changedFiles) == 0 {
494+
return "", nil
495+
}
509496

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)
497+
changeInput := gerrit.ChangeInput{
498+
Project: "vscode-go",
499+
Branch: branch,
500+
Subject: fmt.Sprintf("%s\n\nThis is an automated CL which updates the gopls version.\n\nFor golang/go#%v", clTitle, issue),
516501
}
517-
return changes, nil
502+
503+
ctx.Printf("creating auto-submit change under branch %q in vscode-go repo.", branch)
504+
return r.Gerrit.CreateAutoSubmitChange(ctx, changeInput, reviewers, changedFiles)
518505
}
519506

520507
func (r *ReleaseGoplsTasks) isValidReleaseVersion(ctx *wf.TaskContext, ver string) error {

internal/task/releasegopls_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ esac`, tc.wantVersion)
787787
repo: "vscode-go",
788788
branch: "release-v0.44",
789789
path: "extension/src/goToolsInformation.ts",
790-
want: "bar",
790+
want: "foo",
791791
},
792792
}
793793
for _, check := range contentChecks {

0 commit comments

Comments
 (0)