Skip to content

Commit

Permalink
internal/task: avoid updating gopls version in vscode-go release branch
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
h9jiang committed Aug 30, 2024
1 parent a15ffe2 commit c511972
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 43 deletions.
71 changes: 29 additions & 42 deletions internal/task/releasegopls.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func (r *ReleaseGoplsTasks) NewPrereleaseDefinition() *wf.Definition {
prereleaseVerified := wf.Action1(wd, "verify installing latest gopls using release branch pre-release version", r.verifyGoplsInstallation, prereleaseVersion)
wf.Action4(wd, "mail announcement", r.mailAnnouncement, semv, prereleaseVersion, dependencyCommit, issue, wf.After(prereleaseVerified))

vsCodeGoChanges := wf.Task3(wd, "update gopls version in vscode-go project", r.updateGoplsVersionInVSCodeGo, reviewers, issue, prereleaseVersion, wf.After(prereleaseVerified))
_ = wf.Task1(wd, "await gopls version update CL submission in vscode-go project", clAwaiter{r.Gerrit}.awaitSubmissions, vsCodeGoChanges)
vscodeGoChange := wf.Task4(wd, "update gopls version in vscode-go project", r.updateGoplsVersionInVSCodeGo, reviewers, issue, prereleaseVersion, wf.Const("master"), wf.After(prereleaseVerified))
_ = wf.Task1(wd, "await gopls version update CL submission in vscode-go project", clAwaiter{r.Gerrit}.awaitSubmission, vscodeGoChange)

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

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

func (r *ReleaseGoplsTasks) updateGoplsVersionInVSCodeGo(ctx *wf.TaskContext, reviewers []string, issue int64, version string) ([]string, error) {
releaseBranch, err := vsCodeGoActiveReleaseBranch(ctx, r.Gerrit)
func (r *ReleaseGoplsTasks) updateGoplsVersionInVSCodeGo(ctx *wf.TaskContext, reviewers []string, issue int64, version, branch string) (string, error) {
clTitle := fmt.Sprintf(`extension/src/goToolsInformation: update gopls version %s`, version)
if branch != "master" {
clTitle = "[" + branch + "] " + clTitle
}
openCL, err := openCL(ctx, r.Gerrit, "vscode-go", branch, clTitle)
if err != nil {
return nil, err
return "", fmt.Errorf("failed to find the open CL of title %q in branch %q: %w", clTitle, branch, err)
}
if openCL != "" {
ctx.Printf("not creating CL: found existing CL %s", openCL)
return openCL, nil
}
const script = `go run -C extension tools/generate.go -tools`
changedFiles, err := executeAndMonitorChange(ctx, r.CloudBuild, "vscode-go", branch, script, []string{"extension/src/goToolsInformation.ts"})
if err != nil {
return "", err
}
var changes []string
for _, branch := range []string{"master", releaseBranch} {
clTitle := fmt.Sprintf(`extension/src/goToolsInformation: update gopls version %s`, version)
if branch != "master" {
clTitle = "[" + branch + "] " + clTitle
}
openCL, err := openCL(ctx, r.Gerrit, "vscode-go", branch, clTitle)
if err != nil {
return nil, fmt.Errorf("failed to find the open CL of title %q in branch %q: %w", clTitle, branch, err)
}
if openCL != "" {
ctx.Printf("not creating CL: found existing CL %s", openCL)
changes = append(changes, openCL)
continue
}
const script = `go run -C extension tools/generate.go -tools`
changedFiles, err := executeAndMonitorChange(ctx, r.CloudBuild, "vscode-go", branch, script, []string{"extension/src/goToolsInformation.ts"})
if err != nil {
return nil, err
}

// Skip CL creation as nothing changed.
if len(changedFiles) == 0 {
return nil, nil
}

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

ctx.Printf("creating auto-submit change under branch %q in vscode-go repo.", branch)
changeID, err := r.Gerrit.CreateAutoSubmitChange(ctx, changeInput, reviewers, changedFiles)
if err != nil {
return nil, err
}
changes = append(changes, changeID)
changeInput := gerrit.ChangeInput{
Project: "vscode-go",
Branch: branch,
Subject: fmt.Sprintf("%s\n\nThis is an automated CL which updates the gopls version.\n\nFor golang/go#%v", clTitle, issue),
}
return changes, nil

ctx.Printf("creating auto-submit change under branch %q in vscode-go repo.", branch)
return r.Gerrit.CreateAutoSubmitChange(ctx, changeInput, reviewers, changedFiles)
}

func (r *ReleaseGoplsTasks) isValidReleaseVersion(ctx *wf.TaskContext, ver string) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/task/releasegopls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ esac`, tc.wantVersion)
repo: "vscode-go",
branch: "release-v0.44",
path: "extension/src/goToolsInformation.ts",
want: "bar",
want: "foo",
},
}
for _, check := range contentChecks {
Expand Down

0 comments on commit c511972

Please sign in to comment.