task

package
v0.0.0-...-4f1971e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: BSD-3-Clause Imports: 88 Imported by: 0

README

Go Reference

golang.org/x/build/internal/task

Package task implements tasks involved in making a Go release.

Documentation

Overview

Package task implements tasks involved in making a Go release.

Index

Constants

This section is empty.

Variables

View Source
var AwaitDivisor int = 1
View Source
var ErrTweetTooLong = fmt.Errorf("tweet text length exceeded Twitter's limit")

ErrTweetTooLong is the error when a tweet is too long.

Functions

func AwaitCondition

func AwaitCondition[T any](ctx *wf.TaskContext, period time.Duration, condition func() (T, bool, error)) (T, error)

AwaitCondition calls the condition function every period until it returns true to indicate success, or an error. If the condition succeeds, AwaitCondition returns its result.

func ChangeLink(changeID string) string

ChangeLink returns a link to the review page for the CL with the specified change ID. The change ID must be in the project~cl# form.

func CheckCoordinators

func CheckCoordinators(users []string) error

CheckCoordinators checks that all users are known and have required information (name, Gerrit email).

func ConvertZIPToTGZ

func ConvertZIPToTGZ(r io.ReaderAt, size int64, w io.Writer) error

func ExtractFile

func ExtractFile(tgz io.Reader, dest io.Writer, glob string) error

ExtractFile copies the first file in tgz matching glob to dest.

func IsValid

func IsValid(x string) bool

IsValid reports whether the version x is valid.

func NewMastodonClient

func NewMastodonClient(config secret.MastodonCredentials) (realMastodonClient, error)

NewMastodonClient creates a Mastodon API client authenticated to make Mastodon API calls using the provided credentials. The resulting client may have been permission-limited at its creation (e.g., only allowed to upload media and write posts). For tests, use NewTestMastodonClient, which creates private messages instead.

func NewSendGridMailClient

func NewSendGridMailClient(sendgridAPIKey string) realSendGridMailClient

NewSendGridMailClient creates a SendGrid mail client authenticated with the given API key.

func NewTestMastodonClient

func NewTestMastodonClient(config secret.MastodonCredentials, pmTarget string) (realMastodonClient, error)

NewTestMastodonClient creates a client that will DM the announcement to the designated recipient for end-to-end testing. config.TestRecipient cannot be empty; that would result in a public message, which should not happen unintentionally.

func NewTwitterClient

func NewTwitterClient(t secret.TwitterCredentials) realTwitterClient

NewTwitterClient creates a Twitter API client authenticated to make Twitter API calls using the provided credentials.

func ReadBinariesFromPKG

func ReadBinariesFromPKG(pkg io.Reader) (map[string][]byte, error)

ReadBinariesFromPKG reads pkg, the Go installer .pkg file, and returns binaries in bin and pkg/tool directories within GOROOT which we expect to have been signed by the macOS signing process.

The map key is a relative path starting with "go/", like "go/bin/gofmt" or "go/pkg/tool/darwin_arm64/test2json". The map value holds its bytes.

func ServeTarball

func ServeTarball(pathMatch string, files map[string]string, w http.ResponseWriter, r *http.Request)

ServeTarball serves files as a .tar.gz to w, only if path contains pathMatch.

func TarToModFiles

func TarToModFiles(target *releasetargets.Target, version string, t time.Time, tgz io.Reader, w io.Writer) (mod string, info string, _ error)

TarToModFiles converts the distribution archive with the given name and content to a collection of module files.

func ToolchainModuleVersion

func ToolchainModuleVersion(target *releasetargets.Target, version string) string

func ToolchainZipPrefix

func ToolchainZipPrefix(target *releasetargets.Target, version string) string

Types

type AnnounceMailTasks

type AnnounceMailTasks struct {
	// SendMail sends an email with the given header and content
	// using an externally-provided implementation.
	//
	// Email delivery happens asynchronously, so SendMail returns a nil error
	// if the transmission was started successfully, but that error value
	// doesn't indicate anything about the status of the delivery.
	SendMail func(MailHeader, MailContent) error

	// AnnounceMailHeader is the header to use for the release (pre-)announcement email.
	AnnounceMailHeader MailHeader
	// contains filtered or unexported fields
}

AnnounceMailTasks contains tasks related to the release (pre-)announcement email.

func (AnnounceMailTasks) AnnounceRelease

func (t AnnounceMailTasks) AnnounceRelease(ctx *workflow.TaskContext, kind ReleaseKind, published []Published, security []string, users []string) (SentMail, error)

AnnounceRelease sends an email to Google Groups announcing that a Go release has been published.

func (AnnounceMailTasks) AwaitAnnounceMail

func (t AnnounceMailTasks) AwaitAnnounceMail(ctx *workflow.TaskContext, m SentMail) (announcementURL string, _ error)

AwaitAnnounceMail waits for an announcement email with the specified subject to show up on Google Groups, and returns its canonical URL.

func (AnnounceMailTasks) PreAnnounceRelease

func (t AnnounceMailTasks) PreAnnounceRelease(ctx *workflow.TaskContext, versions []string, target Date, security string, cves []string, users []string) (SentMail, error)

PreAnnounceRelease sends an email pre-announcing a Go release containing PRIVATE track security fixes planned for the target date.

type BuildBucketClient

type BuildBucketClient interface {
	// ListBuilders lists all the builders in bucket, keyed by their builder names.
	ListBuilders(ctx context.Context, bucket string) (map[string]*pb.BuilderConfig, error)
	// RunBuild runs a builder at commit with properties and returns its ID.
	RunBuild(ctx context.Context, bucket, builder string, commit *pb.GitilesCommit, properties map[string]*structpb.Value) (int64, error)
	// Completed reports whether a build has finished, returning an error if
	// it's failed. It's suitable for use with AwaitCondition.
	Completed(ctx context.Context, id int64) (string, bool, error)
	// SearchBuilds searches for builds matching pred and returns their IDs.
	SearchBuilds(ctx context.Context, pred *pb.BuildPredicate) ([]int64, error)
}

type BundleNSSRootsTask

type BundleNSSRootsTask struct {
	Gerrit     GerritClient
	CloudBuild CloudBuildClient
}

func (*BundleNSSRootsTask) NewDefinition

func (x *BundleNSSRootsTask) NewDefinition() *wf.Definition

func (*BundleNSSRootsTask) UpdateBundle

func (x *BundleNSSRootsTask) UpdateBundle(ctx *wf.TaskContext, reviewers []string) (string, error)

type CloudBuild

type CloudBuild struct {
	Project, ID string
	ResultURL   string
}

CloudBuild represents a Cloud Build that can be queried with the status methods on CloudBuildClient.

type CloudBuildClient

type CloudBuildClient interface {
	// RunBuildTrigger runs an existing trigger in project with the given
	// substitutions.
	RunBuildTrigger(ctx context.Context, project, trigger string, substitutions map[string]string) (CloudBuild, error)
	// RunScript runs the given script under bash -eux -o pipefail in
	// ScriptProject. Outputs are collected into the build's ResultURL,
	// readable with ResultFS. The script will have the latest version of Go
	// and some version of gsutil on $PATH.
	// If gerritProject is specified, the script will run in the root of a
	// checkout of the tip version of that repository.
	RunScript(ctx context.Context, script string, gerritProject string, outputs []string) (CloudBuild, error)
	// Completed reports whether a build has finished, returning an error if
	// it's failed. It's suitable for use with AwaitCondition.
	Completed(ctx context.Context, build CloudBuild) (detail string, completed bool, _ error)
	// ResultFS returns an FS that contains the results of the given build.
	ResultFS(ctx context.Context, build CloudBuild) (fs.FS, error)
}

type CommunicationTasks

type CommunicationTasks struct {
	AnnounceMailTasks
	SocialMediaTasks
}

CommunicationTasks combines communication tasks together.

type Date

type Date struct {
	Year  int        // Year (for example, 2009).
	Month time.Month // Month of the year (January = 1, ...).
	Day   int        // Day of the month, starting at 1.
}

A Date represents a single calendar day (year, month, day).

This type does not include location information, and therefore does not describe a unique 24-hour timespan.

TODO(go.dev/issue/19700): Start using time.Day or so when available.

func (Date) After

func (d Date) After(year int, month time.Month, day int) bool

func (Date) Format

func (d Date) Format(layout string) string

func (Date) String

func (d Date) String() string

type FakeBuildBucketClient

type FakeBuildBucketClient struct {
	Bucket        string
	FailBuilds    []string
	MissingBuilds []string

	GerritURL, Branch string
	Projects          []string
	// contains filtered or unexported fields
}

func NewFakeBuildBucketClient

func NewFakeBuildBucketClient(major int, url, bucket string, projects []string) *FakeBuildBucketClient

func (*FakeBuildBucketClient) Completed

func (c *FakeBuildBucketClient) Completed(ctx context.Context, id int64) (string, bool, error)

func (*FakeBuildBucketClient) ListBuilders

func (c *FakeBuildBucketClient) ListBuilders(ctx context.Context, bucket string) (map[string]*pb.BuilderConfig, error)

func (*FakeBuildBucketClient) RunBuild

func (c *FakeBuildBucketClient) RunBuild(ctx context.Context, bucket string, builder string, commit *pb.GitilesCommit, properties map[string]*structpb.Value) (int64, error)

func (*FakeBuildBucketClient) SearchBuilds

func (c *FakeBuildBucketClient) SearchBuilds(ctx context.Context, pred *pb.BuildPredicate) ([]int64, error)

type FakeCloudBuild

type FakeCloudBuild struct {
	// contains filtered or unexported fields
}

func NewFakeCloudBuild

func NewFakeCloudBuild(t *testing.T, gerrit *FakeGerrit, project string, allowedTriggers map[string]map[string]string, fakeGo string) *FakeCloudBuild

func (*FakeCloudBuild) Completed

func (cb *FakeCloudBuild) Completed(ctx context.Context, build CloudBuild) (string, bool, error)

func (*FakeCloudBuild) ResultFS

func (c *FakeCloudBuild) ResultFS(ctx context.Context, build CloudBuild) (fs.FS, error)

func (*FakeCloudBuild) RunBuildTrigger

func (cb *FakeCloudBuild) RunBuildTrigger(ctx context.Context, project string, trigger string, substitutions map[string]string) (CloudBuild, error)

func (*FakeCloudBuild) RunScript

func (cb *FakeCloudBuild) RunScript(ctx context.Context, script string, gerritProject string, outputs []string) (CloudBuild, error)

type FakeGerrit

type FakeGerrit struct {
	// contains filtered or unexported fields
}

func NewFakeGerrit

func NewFakeGerrit(t *testing.T, repos ...*FakeRepo) *FakeGerrit

func (*FakeGerrit) CreateAutoSubmitChange

func (g *FakeGerrit) CreateAutoSubmitChange(_ *wf.TaskContext, input gerrit.ChangeInput, reviewers []string, contents map[string]string) (string, error)

func (*FakeGerrit) GerritURL

func (g *FakeGerrit) GerritURL() string

func (*FakeGerrit) GetChange

func (*FakeGerrit) GetCommitsInRefs

func (g *FakeGerrit) GetCommitsInRefs(ctx context.Context, project string, commits, refs []string) (map[string][]string, error)

func (*FakeGerrit) GetTag

func (g *FakeGerrit) GetTag(ctx context.Context, project string, tag string) (gerrit.TagInfo, error)

func (*FakeGerrit) GitilesURL

func (g *FakeGerrit) GitilesURL() string

func (*FakeGerrit) ListProjects

func (g *FakeGerrit) ListProjects(ctx context.Context) ([]string, error)

func (*FakeGerrit) ListTags

func (g *FakeGerrit) ListTags(ctx context.Context, project string) ([]string, error)

func (*FakeGerrit) QueryChanges

func (*FakeGerrit) QueryChanges(_ context.Context, query string) ([]*gerrit.ChangeInfo, error)

func (*FakeGerrit) ReadBranchHead

func (g *FakeGerrit) ReadBranchHead(ctx context.Context, project, branch string) (string, error)

func (*FakeGerrit) ReadFile

func (g *FakeGerrit) ReadFile(ctx context.Context, project string, commit string, file string) ([]byte, error)

func (*FakeGerrit) SetHashtags

func (*FakeGerrit) SetHashtags(_ context.Context, changeID string, _ gerrit.HashtagsInput) error

func (*FakeGerrit) Submitted

func (g *FakeGerrit) Submitted(ctx context.Context, changeID, baseCommit string) (string, bool, error)

func (*FakeGerrit) Tag

func (g *FakeGerrit) Tag(ctx context.Context, project, tag, commit string) error

type FakeRepo

type FakeRepo struct {
	// contains filtered or unexported fields
}

func NewFakeRepo

func NewFakeRepo(t *testing.T, name string) *FakeRepo

func (*FakeRepo) Branch

func (repo *FakeRepo) Branch(branch, commit string)

func (*FakeRepo) Commit

func (repo *FakeRepo) Commit(contents map[string]string) string

func (*FakeRepo) CommitOnBranch

func (repo *FakeRepo) CommitOnBranch(branch string, contents map[string]string) string

func (*FakeRepo) History

func (repo *FakeRepo) History() []string

func (*FakeRepo) ReadFile

func (repo *FakeRepo) ReadFile(commit, file string) ([]byte, error)

func (*FakeRepo) Tag

func (repo *FakeRepo) Tag(tag, commit string)

type FakeSignService

type FakeSignService struct {
	// contains filtered or unexported fields
}

func NewFakeSignService

func NewFakeSignService(t *testing.T, outputDir string) *FakeSignService

NewFakeSignService returns a fake signing service that can sign PKGs, MSIs, and generate GPG signatures. MSIs are "signed" by adding a suffix to them. PKGs must actually be tarballs with a prefix of "I'm a PKG!\n". Any files they contain that look like binaries will be "signed".

func (*FakeSignService) ArtifactSigningStatus

func (s *FakeSignService) ArtifactSigningStatus(_ context.Context, jobID string) (_ sign.Status, desc string, out []string, _ error)

func (*FakeSignService) CancelSigning

func (s *FakeSignService) CancelSigning(_ context.Context, jobID string) error

func (*FakeSignService) SignArtifact

func (s *FakeSignService) SignArtifact(_ context.Context, bt sign.BuildType, in []string) (jobID string, _ error)

type FakeSwarmingClient

type FakeSwarmingClient struct {
	// contains filtered or unexported fields
}

func NewFakeSwarmingClient

func NewFakeSwarmingClient(t *testing.T, fakeGo string) *FakeSwarmingClient

func (*FakeSwarmingClient) Completed

func (c *FakeSwarmingClient) Completed(ctx context.Context, id string) (string, bool, error)

func (*FakeSwarmingClient) RunTask

func (c *FakeSwarmingClient) RunTask(ctx context.Context, dims map[string]string, script string, env map[string]string) (string, error)

type GerritClient

type GerritClient interface {
	// GitilesURL returns the URL to the Gitiles server for this Gerrit instance.
	GitilesURL() string
	// CreateAutoSubmitChange creates a change with the given metadata and
	// contents, starts trybots with auto-submit enabled, and returns its change ID.
	// If the content of a file is empty, that file will be deleted from the repository.
	// If the requested contents match the state of the repository, no change
	// is created and the returned change ID will be empty.
	// Reviewers is the username part of a golang.org or google.com email address.
	CreateAutoSubmitChange(ctx *wf.TaskContext, input gerrit.ChangeInput, reviewers []string, contents map[string]string) (string, error)
	// Submitted checks if the specified change has been submitted or failed
	// 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 returns tag information for a specified tag.
	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.
	ListTags(ctx context.Context, project string) ([]string, error)
	// ReadBranchHead returns the head of a branch in project.
	// If the branch doesn't exist, it returns an error matching gerrit.ErrResourceNotExist.
	ReadBranchHead(ctx context.Context, project, branch string) (string, error)
	// ListProjects lists all the projects on the server.
	ListProjects(ctx context.Context) ([]string, error)
	// ReadFile reads a file from project at the specified commit.
	// If the file doesn't exist, it returns an error matching gerrit.ErrResourceNotExist.
	ReadFile(ctx context.Context, project, commit, file string) ([]byte, error)
	// GetCommitsInRefs gets refs in which the specified commits were merged into.
	GetCommitsInRefs(ctx context.Context, project string, commits, refs []string) (map[string][]string, error)
	// QueryChanges gets changes which match the query.
	QueryChanges(ctx context.Context, query string) ([]*gerrit.ChangeInfo, error)
	// SetHashtags modifies the hashtags for a CL.
	SetHashtags(ctx context.Context, changeID string, hashtags gerrit.HashtagsInput) error
	// GetChange gets information about a specific change.
	GetChange(ctx context.Context, changeID string, opts ...gerrit.QueryChangesOpt) (*gerrit.ChangeInfo, error)
}

type Git

type Git struct {
	// contains filtered or unexported fields
}

A Git manages a set of Git repositories.

func (*Git) Clone

func (g *Git) Clone(ctx context.Context, origin string) (*GitDir, error)

Clone checks out the repository at origin into a temporary directory owned by the resulting GitDir.

func (*Git) UseOAuth2Auth

func (g *Git) UseOAuth2Auth(ts oauth2.TokenSource) error

UseOAuth2Auth configures Git authentication using ts.

type GitDir

type GitDir struct {
	// contains filtered or unexported fields
}

A GitDir is a single Git repository.

func (*GitDir) Close

func (g *GitDir) Close() error

Close cleans up the repository.

func (*GitDir) RunCommand

func (g *GitDir) RunCommand(ctx context.Context, args ...string) ([]byte, error)

RunCommand runs a Git command, returning its stdout if it succeeds, or an error containing its stderr if it fails.

type GitHubClient

type GitHubClient struct {
	V3 *github.Client
	V4 *githubv4.Client
}

func (*GitHubClient) EditIssue

func (c *GitHubClient) EditIssue(ctx context.Context, owner string, repo string, number int, issue *github.IssueRequest) (*github.Issue, *github.Response, error)

func (*GitHubClient) EditMilestone

func (c *GitHubClient) EditMilestone(ctx context.Context, owner string, repo string, number int, milestone *github.Milestone) (*github.Milestone, *github.Response, error)

func (*GitHubClient) FetchMilestone

func (c *GitHubClient) FetchMilestone(ctx context.Context, owner, repo, name string, create bool) (int, error)

func (*GitHubClient) FetchMilestoneIssues

func (c *GitHubClient) FetchMilestoneIssues(ctx context.Context, owner, repo string, milestoneID int) (map[int]map[string]bool, error)

func (*GitHubClient) PostComment

func (c *GitHubClient) PostComment(ctx context.Context, id githubv4.ID, body string) error

type GitHubClientInterface

type GitHubClientInterface interface {
	// FetchMilestone returns the number of the GitHub milestone with the specified name.
	// If create is true, and the milestone doesn't exist, it will be created.
	FetchMilestone(ctx context.Context, owner, repo, name string, create bool) (int, error)

	// FetchMilestoneIssues returns all the open issues in the specified milestone
	// and their labels.
	FetchMilestoneIssues(ctx context.Context, owner, repo string, milestoneID int) (map[int]map[string]bool, error)

	// See github.Client.Issues.Edit.
	EditIssue(ctx context.Context, owner string, repo string, number int, issue *github.IssueRequest) (*github.Issue, *github.Response, error)

	// See github.Client.Issues.EditMilestone.
	EditMilestone(ctx context.Context, owner string, repo string, number int, milestone *github.Milestone) (*github.Milestone, *github.Response, error)

	// PostComment creates a comment on a GitHub issue or pull request
	// identified by the given GitHub Node ID.
	PostComment(_ context.Context, id githubv4.ID, body string) error
}

GitHubClientInterface is a wrapper around the GitHub v3 and v4 APIs, for testing and dry-run support.

type LogWriter

type LogWriter struct {
	Logger wf.Logger
	// contains filtered or unexported fields
}

LogWriter is an io.Writer that writes to a workflow task's log, flushing its buffer periodically to avoid too many writes.

func (*LogWriter) Run

func (w *LogWriter) Run(ctx context.Context)

func (*LogWriter) Write

func (w *LogWriter) Write(b []byte) (int, error)

type MailContent

type MailContent struct {
	Subject  string
	BodyHTML string
	BodyText string
}

A MailContent holds the content of an email.

type MailHeader

type MailHeader struct {
	From mail.Address // An RFC 5322 address. For example, "Barry Gibbs <bg@example.com>".
	To   mail.Address
	BCC  []mail.Address
}

A MailHeader is an email header.

type MilestoneTasks

type MilestoneTasks struct {
	Client              GitHubClientInterface
	RepoOwner, RepoName string
	ApproveAction       func(*wf.TaskContext) error
}

MilestoneTasks contains the tasks used to check and modify GitHub issues' milestones.

func (*MilestoneTasks) CheckBlockers

func (m *MilestoneTasks) CheckBlockers(ctx *wf.TaskContext, milestones ReleaseMilestones, version string, kind ReleaseKind) error

CheckBlockers returns an error if there are open release blockers in the current milestone.

func (*MilestoneTasks) FetchMilestones

func (m *MilestoneTasks) FetchMilestones(ctx *wf.TaskContext, currentVersion string, kind ReleaseKind) (ReleaseMilestones, error)

FetchMilestones returns the milestone numbers for the version currently being released, and the next version that outstanding issues should be moved to. If this is a major release, it also creates its first minor release milestone.

func (*MilestoneTasks) PingEarlyIssues

func (m *MilestoneTasks) PingEarlyIssues(ctx *wf.TaskContext, develVersion int, openTreeURL string) (result struct{}, _ error)

PingEarlyIssues pings early-in-cycle issues in the development major release milestone. This is done once at the opening of a release cycle, currently via a standalone workflow.

develVersion is a value like 22 representing that Go 1.22 is the major version whose development has recently started, and whose early-in-cycle issues are to be pinged.

func (*MilestoneTasks) PushIssues

func (m *MilestoneTasks) PushIssues(ctx *wf.TaskContext, milestones ReleaseMilestones, version string, kind ReleaseKind) error

PushIssues updates issues to reflect a finished release. For major and minor releases, it moves issues to the next milestone and closes the current milestone. For pre-releases, it cleans up any "okay-after-..." labels in the current milestone that are done serving their purpose.

type Poster

type Poster interface {
	// PostTweet posts a tweet with the given text and PNG image,
	// both of which must be non-empty, and returns the tweet URL.
	//
	// ErrTweetTooLong error is returned if posting fails
	// due to the tweet text length exceeding Twitter's limit.
	PostTweet(text string, imagePNG []byte, altText string) (tweetURL string, _ error)
}

type PrivXPatch

type PrivXPatch struct {
	Git           *Git
	PublicGerrit  GerritClient
	PrivateGerrit GerritClient
	// PublicRepoURL returns a git clone URL for repo
	PublicRepoURL func(repo string) string

	ApproveAction      func(*wf.TaskContext) error
	SendMail           func(MailHeader, MailContent) error
	AnnounceMailHeader MailHeader
}

func (*PrivXPatch) NewDefinition

func (x *PrivXPatch) NewDefinition(tagx *TagXReposTasks) *wf.Definition

type PrivateMasterSyncTask

type PrivateMasterSyncTask struct {
	Git              *Git
	PrivateGerritURL string
	Ref              string
}

func (*PrivateMasterSyncTask) NewDefinition

func (t *PrivateMasterSyncTask) NewDefinition() *wf.Definition

type Published

type Published struct {
	Version string        // Version that's published, in the same format as Go tags. For example, "go1.21rc1".
	Files   []WebsiteFile // Files that are published.
}

Published holds information for a Go release that by this time has already been published.

Published in this context refers to it being available for download at https://go.dev/dl/. It doesn't mean it has been announced by now; that step happens sometime after publication.

type RealBuildBucketClient

type RealBuildBucketClient struct {
	BuildersClient pb.BuildersClient
	BuildsClient   pb.BuildsClient
}

func (*RealBuildBucketClient) Completed

func (c *RealBuildBucketClient) Completed(ctx context.Context, id int64) (string, bool, error)

func (*RealBuildBucketClient) ListBuilders

func (c *RealBuildBucketClient) ListBuilders(ctx context.Context, bucket string) (map[string]*pb.BuilderConfig, error)

func (*RealBuildBucketClient) RunBuild

func (c *RealBuildBucketClient) RunBuild(ctx context.Context, bucket, builder string, commit *pb.GitilesCommit, properties map[string]*structpb.Value) (int64, error)

func (*RealBuildBucketClient) SearchBuilds

func (c *RealBuildBucketClient) SearchBuilds(ctx context.Context, pred *pb.BuildPredicate) ([]int64, error)

type RealCloudBuildClient

type RealCloudBuildClient struct {
	BuildClient   *cloudbuild.Client
	StorageClient *storage.Client
	ScriptProject string
	ScriptAccount string
	ScratchURL    string
}

func (*RealCloudBuildClient) Completed

func (c *RealCloudBuildClient) Completed(ctx context.Context, build CloudBuild) (string, bool, error)

func (*RealCloudBuildClient) ResultFS

func (c *RealCloudBuildClient) ResultFS(ctx context.Context, build CloudBuild) (fs.FS, error)

func (*RealCloudBuildClient) RunBuildTrigger

func (c *RealCloudBuildClient) RunBuildTrigger(ctx context.Context, project, trigger string, substitutions map[string]string) (CloudBuild, error)

func (*RealCloudBuildClient) RunScript

func (c *RealCloudBuildClient) RunScript(ctx context.Context, script string, gerritProject string, outputs []string) (CloudBuild, error)

type RealGerritClient

type RealGerritClient struct {
	Gitiles string
	Client  *gerrit.Client
}

func (*RealGerritClient) CreateAutoSubmitChange

func (c *RealGerritClient) CreateAutoSubmitChange(ctx *wf.TaskContext, input gerrit.ChangeInput, reviewers []string, files map[string]string) (_ string, err error)

func (*RealGerritClient) GetChange

func (c *RealGerritClient) GetChange(ctx context.Context, changeID string, opts ...gerrit.QueryChangesOpt) (*gerrit.ChangeInfo, error)

func (*RealGerritClient) GetCommitsInRefs

func (c *RealGerritClient) GetCommitsInRefs(ctx context.Context, project string, commits, refs []string) (map[string][]string, error)

func (*RealGerritClient) GetTag

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

func (*RealGerritClient) GitilesURL

func (c *RealGerritClient) GitilesURL() string

func (*RealGerritClient) ListProjects

func (c *RealGerritClient) ListProjects(ctx context.Context) ([]string, error)

func (*RealGerritClient) ListTags

func (c *RealGerritClient) ListTags(ctx context.Context, project string) ([]string, error)

func (*RealGerritClient) QueryChanges

func (c *RealGerritClient) QueryChanges(ctx context.Context, query string) ([]*gerrit.ChangeInfo, error)

func (*RealGerritClient) ReadBranchHead

func (c *RealGerritClient) ReadBranchHead(ctx context.Context, project, branch string) (string, error)

func (*RealGerritClient) ReadFile

func (c *RealGerritClient) ReadFile(ctx context.Context, project, commit, file string) ([]byte, error)

func (*RealGerritClient) SetHashtags

func (c *RealGerritClient) SetHashtags(ctx context.Context, changeID string, hashtags gerrit.HashtagsInput) error

func (*RealGerritClient) Submitted

func (c *RealGerritClient) Submitted(ctx context.Context, changeID, parentCommit string) (string, bool, error)

func (*RealGerritClient) Tag

func (c *RealGerritClient) Tag(ctx context.Context, project, tag, commit string) error

type RealSwarmingClient

type RealSwarmingClient struct {
	SwarmingClient                           swarming.Client
	SwarmingURL, ServiceAccount, Realm, Pool string
}

func (*RealSwarmingClient) Completed

func (c *RealSwarmingClient) Completed(ctx context.Context, id string) (string, bool, error)

func (*RealSwarmingClient) RunTask

func (c *RealSwarmingClient) RunTask(ctx context.Context, dims map[string]string, script string, env map[string]string) (string, error)

type ReleaseKind

type ReleaseKind int

ReleaseKind is the type of release being run.

const (
	KindUnknown ReleaseKind = iota
	KindBeta
	KindRC
	KindMajor
	KindMinor
)

func (ReleaseKind) GoString

func (k ReleaseKind) GoString() string

type ReleaseMilestones

type ReleaseMilestones struct {
	// Current is the GitHub milestone number for the current Go release.
	// For example, 279 for the "Go1.21" milestone (https://github.com/golang/go/milestone/279).
	Current int
	// Next is the GitHub milestone number for the next Go release of the same kind.
	Next int
}

type ScratchFS

type ScratchFS struct {
	BaseURL string // BaseURL is a gs:// or file:// URL, no trailing slash. E.g., "gs://golang-release-staging/relui-scratch".
	GCS     *storage.Client
}

ScratchFS manages scratch storage for workflows.

func (*ScratchFS) OpenRead

func (s *ScratchFS) OpenRead(ctx *wf.TaskContext, name string) (fs.File, error)

OpenRead opens a file in the workflow's scratch storage.

func (*ScratchFS) OpenWrite

func (s *ScratchFS) OpenWrite(ctx *wf.TaskContext, baseName string) (name string, _ gcsfs.WriterFile, _ error)

OpenWrite creates a new file in the workflow's scratch storage, with a name based on baseName. It returns that name, as well as the open file.

func (*ScratchFS) ReadFile

func (s *ScratchFS) ReadFile(ctx *wf.TaskContext, name string) ([]byte, error)

ReadFile fully reads a file in the workflow's scratch storage.

func (*ScratchFS) URL

func (s *ScratchFS) URL(ctx *wf.TaskContext, name string) string

URL returns the URL of a file in the workflow's scratch storage, suitable for passing to external systems.

func (*ScratchFS) WriteFilename

func (s *ScratchFS) WriteFilename(ctx *wf.TaskContext, baseName string) string

WriteFilename returns a filename that can be used to write a new scratch file suitable for writing from an external systems.

type SentMail

type SentMail struct {
	Subject string // Subject of the email. Expected to be unique so it can be used to identify the email.
}

SentMail represents an email that was sent.

type SocialMediaTasks

type SocialMediaTasks struct {
	// TwitterClient can be used to post a tweet.
	TwitterClient  Poster
	MastodonClient Poster

	// RandomSeed is the pseudo-random number generator seed to use for presentational
	// choices, such as selecting one out of many available emoji or release archives.
	// The zero value means to use time.Now().UnixNano().
	RandomSeed int64
}

SocialMediaTasks contains tasks related to the release tweet.

func (SocialMediaTasks) TrumpetRelease

func (t SocialMediaTasks) TrumpetRelease(ctx *workflow.TaskContext, kind ReleaseKind, published []Published, security string, announcement string) (_ string, _ error)

TrumpetRelease posts a tweet announcing that a Go release has been published.

func (SocialMediaTasks) TweetRelease

func (t SocialMediaTasks) TweetRelease(ctx *workflow.TaskContext, kind ReleaseKind, published []Published, security string, announcement string) (_ string, _ error)

TweetRelease posts a tweet announcing that a Go release has been published. ErrTweetTooLong is returned if the inputs result in a tweet that's too long.

type SwarmingClient

type SwarmingClient interface {
	// RunTask runs script on a machine running port with env set.
	// The script will have the latest version of Go and some version of gsutil
	// on $PATH. To facilitate Windows/Unix compatibility, . will be at the end
	// of $PATH.
	RunTask(ctx context.Context, dims map[string]string, script string, env map[string]string) (string, error)
	// Completed reports whether a build has finished, returning an error if
	// it's failed. It's suitable for use with AwaitCondition.
	Completed(ctx context.Context, id string) (string, bool, error)
}

type TagDep

type TagDep struct {
	ModPath string // Module path, e.g., "golang.org/x/sys".
	Wait    bool   // Wait controls whether to wait for this dependency to be processed first.
}

TagDep represents a dependency of a repo being updated and possibly tagged.

type TagRepo

type TagRepo struct {
	Name         string    // Gerrit project name, e.g., "tools".
	ModPath      string    // Module path, e.g., "golang.org/x/tools".
	Deps         []*TagDep // Dependency modules.
	Compat       string    // The Go version to pass to go mod tidy -compat for this repository.
	StartVersion string    // The version of the module when the workflow started. Empty string means repo hasn't begun release version tagging yet.
	NewerVersion string    // The version of the module that will be tagged, or the empty string when the repo is being updated only and not tagged.
}

TagRepo contains information about a repo that can be updated and possibly tagged.

func (TagRepo) UpdateOnlyAndNotTag

func (r TagRepo) UpdateOnlyAndNotTag() bool

UpdateOnlyAndNotTag reports whether repo r should be updated only, and not tagged.

type TagTelemetryTasks

type TagTelemetryTasks struct {
	Gerrit     GerritClient
	CloudBuild CloudBuildClient
}

TagTelemetryTasks implements a new workflow definition to tag x/telemetry/config whenever the generated config.json changes.

func (*TagTelemetryTasks) AwaitSubmission

func (t *TagTelemetryTasks) AwaitSubmission(ctx *wf.TaskContext, changeID string) error

AwaitSubmission waits for the CL with the given change ID to be submitted.

The return value is the submitted commit hash, or "" if changeID is "".

func (*TagTelemetryTasks) GenerateConfig

func (t *TagTelemetryTasks) GenerateConfig(ctx *wf.TaskContext, reviewers []string) (string, error)

GenerateConfig runs the upload config generator in a buildlet, extracts the resulting config.json, and creates a CL with the result if anything changed.

It returns the change ID, or "" if the CL was not created.

func (*TagTelemetryTasks) MaybeTag

func (t *TagTelemetryTasks) MaybeTag(ctx *wf.TaskContext) (string, error)

MaybeTag tags x/telemetry/config with the next version if config/config.json has changed.

It returns the tag that was created, or "" if no tagging occurred.

func (*TagTelemetryTasks) NewDefinition

func (t *TagTelemetryTasks) NewDefinition() *wf.Definition

type TagXReposTasks

type TagXReposTasks struct {
	IgnoreProjects map[string]bool // project name -> ignore
	Gerrit         GerritClient
	CloudBuild     CloudBuildClient
	BuildBucket    BuildBucketClient
}

func (*TagXReposTasks) AwaitGoMod

func (x *TagXReposTasks) AwaitGoMod(ctx *wf.TaskContext, changeID, repo, branch string) (string, error)

func (*TagXReposTasks) AwaitGreen

func (x *TagXReposTasks) AwaitGreen(ctx *wf.TaskContext, repo TagRepo, commit string) (string, error)

func (*TagXReposTasks) BuildPlan

func (x *TagXReposTasks) BuildPlan(wd *wf.Definition, repos []TagRepo, reviewers []string) (wf.Value[string], error)

BuildPlan adds the tasks needed to update repos to wd.

func (*TagXReposTasks) BuildSingleRepoPlan

func (x *TagXReposTasks) BuildSingleRepoPlan(wd *wf.Definition, repoSlice []TagRepo, name string, skipPostSubmit bool, reviewers []string) (wf.Value[TagRepo], error)

func (*TagXReposTasks) MailGoMod

func (x *TagXReposTasks) MailGoMod(ctx *wf.TaskContext, repo, branch string, files map[string]string, reviewers []string) (string, error)

func (*TagXReposTasks) MaybeTag

func (x *TagXReposTasks) MaybeTag(ctx *wf.TaskContext, repo TagRepo, commit string) (TagRepo, error)

MaybeTag tags repo at commit with the next version, unless commit is already the latest tagged version. repo is returned with NewerVersion populated.

func (*TagXReposTasks) NewDefinition

func (x *TagXReposTasks) NewDefinition() *wf.Definition

func (*TagXReposTasks) NewSingleDefinition

func (x *TagXReposTasks) NewSingleDefinition() *wf.Definition

func (*TagXReposTasks) SelectRepos

func (x *TagXReposTasks) SelectRepos(ctx *wf.TaskContext) ([]TagRepo, error)

func (*TagXReposTasks) UpdateGoMod

func (x *TagXReposTasks) UpdateGoMod(ctx *wf.TaskContext, repo TagRepo, deps []TagRepo, branch string) (files map[string]string, _ error)

type UpdateProxyTestRepoTasks

type UpdateProxyTestRepoTasks struct {
	Git       *Git
	GerritURL string
	Branch    string
}

func (*UpdateProxyTestRepoTasks) UpdateProxyTestRepo

func (t *UpdateProxyTestRepoTasks) UpdateProxyTestRepo(ctx *wf.TaskContext, published Published) (string, error)

type VSCodeGoReleaseTask

type VSCodeGoReleaseTask struct {
	CloudBuild CloudBuildClient
	*ScratchFS
	Revision string
}

VSCodeGoReleaseTask releases vscode go.

1. cross-compile github.com/golang/vscode-go/vscgo and store the artifacts in the scratchFS. 2. (TODO) sign the artifacts. 3. (TODO) tag the repository. 4. (TODO) trigger the GCB workflow that reads the signed artifacts, packages, and publishes them. 5. (TODO) announce (SNS)

func (*VSCodeGoReleaseTask) NewDefinition

func (t *VSCodeGoReleaseTask) NewDefinition() *wf.Definition

type VersionTasks

type VersionTasks struct {
	Gerrit     GerritClient
	CloudBuild CloudBuildClient
	GoProject  string
	UpdateProxyTestRepoTasks
}

VersionTasks contains tasks related to versioning the release.

func (*VersionTasks) AwaitCL

func (t *VersionTasks) AwaitCL(ctx *workflow.TaskContext, changeID, baseCommit string) (string, error)

AwaitCL waits for the specified CL to be submitted, and returns the new branch head. Callers can pass baseCommit, the current branch head, to verify that no CLs were submitted between when the CL was created and when it was merged. If changeID is blank because the intended CL was a no-op, baseCommit is returned immediately.

func (*VersionTasks) CreateAutoSubmitVersionCL

func (t *VersionTasks) CreateAutoSubmitVersionCL(ctx *workflow.TaskContext, branch, version string, reviewers []string, versionFile string) (string, error)

CreateAutoSubmitVersionCL mails an auto-submit change to update VERSION file on branch.

func (*VersionTasks) CreateUpdateStdlibIndexCL

func (t *VersionTasks) CreateUpdateStdlibIndexCL(ctx *workflow.TaskContext, reviewers []string, version string) (string, error)

func (*VersionTasks) GenerateVersionFile

func (t *VersionTasks) GenerateVersionFile(_ *workflow.TaskContext, version string, timestamp time.Time) (string, error)

func (*VersionTasks) GetCurrentMajor

func (t *VersionTasks) GetCurrentMajor(ctx context.Context) (int, time.Time, error)

GetCurrentMajor returns the most recent major Go version, and the time at which its tag was created.

func (*VersionTasks) GetDevelVersion

func (t *VersionTasks) GetDevelVersion(ctx context.Context) (int, error)

GetDevelVersion returns the current major Go 1.x version in development.

This value is determined by reading the value of the Version constant in the internal/goversion package of the main Go repository at HEAD commit.

func (*VersionTasks) GetNextMinorVersions

func (t *VersionTasks) GetNextMinorVersions(ctx context.Context, majors []int) ([]string, error)

GetNextMinorVersions returns the next minor for each of the given major series. It uses the same format as Go tags (for example, "go1.23.4").

func (*VersionTasks) GetNextVersion

func (t *VersionTasks) GetNextVersion(ctx context.Context, major int, kind ReleaseKind) (string, error)

GetNextVersion returns the next for the given major series and kind of release. It uses the same format as Go tags (for example, "go1.23.4").

func (*VersionTasks) MailDLCL

func (t *VersionTasks) MailDLCL(ctx *workflow.TaskContext, major int, kind ReleaseKind, version string, reviewers []string, dryRun bool) (changeID string, _ error)

MailDLCL mails a golang.org/dl CL that adds commands for the specified Go version.

The version string must use the same format as Go tags. For example:

  • "go1.21rc2" for a pre-release
  • "go1.21.0" for a major Go release
  • "go1.21.1" for a minor Go release

On success, the ID of the change is returned, like "dl~1234".

func (*VersionTasks) ReadBranchHead

func (t *VersionTasks) ReadBranchHead(ctx *workflow.TaskContext, branch string) (string, error)

ReadBranchHead returns the current HEAD revision of branch.

func (*VersionTasks) TagRelease

func (t *VersionTasks) TagRelease(ctx *workflow.TaskContext, version, commit string) error

TagRelease tags commit as version.

func (*VersionTasks) UnwaitWaitReleaseCLs

func (t *VersionTasks) UnwaitWaitReleaseCLs(ctx *workflow.TaskContext) (result struct{}, _ error)

UnwaitWaitReleaseCLs changes all open Gerrit CLs with hashtag "wait-release" into "ex-wait-release". This is done once at the opening of a release cycle, currently via a standalone workflow.

type WebsiteFile

type WebsiteFile struct {
	Filename       string `json:"filename"`
	OS             string `json:"os"`
	Arch           string `json:"arch"`
	Version        string `json:"version"`
	ChecksumSHA256 string `json:"sha256"`
	Size           int64  `json:"size"`
	Kind           string `json:"kind"` // "archive", "installer", "source"
}

WebsiteFile represents a file on the go.dev downloads page. It should be kept in sync with the download code in x/website/internal/dl.

func (WebsiteFile) GOARCH

func (f WebsiteFile) GOARCH() string

type WebsiteRelease

type WebsiteRelease struct {
	Version        string        `json:"version"`
	Stable         bool          `json:"stable"`
	Files          []WebsiteFile `json:"files"`
	Visible        bool          `json:"-"` // show files on page load
	SplitPortTable bool          `json:"-"` // whether files should be split by primary/other ports.
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL