Skip to content

Commit

Permalink
internal/task: finish initial implementation of x/ repo tagging
Browse files Browse the repository at this point in the history
This one got away from me a little, sorry.

Add cycle detection and breaking: we need to break some cycles involving
x/tools. We could consider fixing them by creating nested modules but I
don't want to deal with that now.

Implement UpdateGoMod: fetch the latest Go release, download it to a
buildlet with network access, and run go get to update to the previously
tagged versions. But only do this if there are dependencies, both to
save time and because go get throws an error if you try to get nothing.

Implement Tag: if there hasn't been a change since the last tag, reuse
that one. Otherwise, tag it with the selected new verison.

For golang/go#48523.

Change-Id: I29c05eb639fd748af1e0e356596adc8c3f15ccf0
Reviewed-on: https://go-review.googlesource.com/c/build/+/425091
Run-TryBot: Heschi Kreinick <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Auto-Submit: Heschi Kreinick <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
heschi authored and gopherbot committed Sep 20, 2022
1 parent 03f4f13 commit 1bb28a5
Show file tree
Hide file tree
Showing 5 changed files with 395 additions and 44 deletions.
6 changes: 6 additions & 0 deletions cmd/relui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ func main() {
log.Fatalf("RegisterReleaseWorkflows: %v", err)
}

tagTasks := &task.TagXReposTasks{
Gerrit: gerritClient,
CreateBuildlet: coordinator.CreateBuildlet,
}
dh.RegisterDefinition("Tag x/ repos", tagTasks.NewDefinition())

w := relui.NewWorker(dh, dbPool, relui.NewPGListener(dbPool))
go w.Run(ctx)
if err := w.ResumeAll(ctx); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/task/buildrelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,14 @@ func (b *BuildletStep) BuildMSI(ctx *workflow.TaskContext, binaryArchive io.Read
})
return err
}
return b.fetchFile(ctx, msi, "msi")
return fetchFile(ctx, b.Buildlet, msi, "msi")
}

// fetchFile fetches the specified directory from the given buildlet, and
// writes the first file it finds in that directory to dest.
func (b *BuildletStep) fetchFile(ctx *workflow.TaskContext, dest io.Writer, dir string) error {
func fetchFile(ctx *workflow.TaskContext, client buildlet.RemoteClient, dest io.Writer, dir string) error {
ctx.Printf("Downloading file from %q.", dir)
tgz, err := b.Buildlet.GetTar(context.Background(), dir)
tgz, err := client.GetTar(context.Background(), dir)
if err != nil {
return err
}
Expand Down
6 changes: 6 additions & 0 deletions internal/task/gerrit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type GerritClient interface {
// trybots. If the CL is submitted, returns the submitted commit hash.
// If parentCommit is non-empty, the submitted CL's parent must match it.
Submitted(ctx context.Context, changeID, parentCommit string) (string, bool, error)

GetTag(ctx context.Context, project, tag string) (gerrit.TagInfo, error)
// Tag creates a tag on project at the specified commit.
Tag(ctx context.Context, project, tag, commit string) error
// ListTags returns all the tags on project.
Expand Down Expand Up @@ -146,6 +148,10 @@ func (c *RealGerritClient) ListTags(ctx context.Context, project string) ([]stri
return tagNames, nil
}

func (c *RealGerritClient) GetTag(ctx context.Context, project, tag string) (gerrit.TagInfo, error) {
return c.Client.GetTag(ctx, project, tag)
}

func (c *RealGerritClient) ReadBranchHead(ctx context.Context, project, branch string) (string, error) {
branchInfo, err := c.Client.GetBranch(ctx, project, branch)
if err != nil {
Expand Down
Loading

0 comments on commit 1bb28a5

Please sign in to comment.