task

package
Version: v0.0.0-...-357881e Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: BSD-3-Clause Imports: 69 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 ConvertTGZToZIP

func ConvertTGZToZIP(r io.Reader, w io.Writer) error

func LatestGoBinaries

func LatestGoBinaries(ctx context.Context) (string, error)

LatestGoBinaries returns a URL to the latest linux/amd64 Go distribution archive using the go.dev/dl/ JSON API.

func NewSendGridMailClient

func NewSendGridMailClient(sendgridAPIKey string) realSendGridMailClient

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

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 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 WriteSourceArchive

func WriteSourceArchive(ctx *workflow.TaskContext, client *http.Client, gerritURL, revision, version string, out io.Writer) error

WriteSourceArchive writes a source archive to out, based on revision with version written in as VERSION.

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, versions []string, security []string, users []string) (SentMail, error)

AnnounceRelease sends an email announcing a Go release to Google Groups.

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, users []string) (SentMail, error)

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

type BuildletStep

type BuildletStep struct {
	Target      *releasetargets.Target
	Buildlet    buildlet.RemoteClient
	BuildConfig *dashboard.BuildConfig
	LogWriter   io.Writer
}

func (*BuildletStep) BuildBinary

func (b *BuildletStep) BuildBinary(ctx *workflow.TaskContext, sourceArchive io.Reader, out io.Writer) error

BuildBinary builds a binary distribution from sourceArchive and writes it to out.

func (*BuildletStep) BuildDarwinPKG

func (b *BuildletStep) BuildDarwinPKG(ctx *workflow.TaskContext, binaryArchive io.Reader, goVersion string, pkg io.Writer) error

BuildDarwinPKG builds an unsigned macOS installer for the given Go version and binary archive. It writes the result to pkg.

func (*BuildletStep) BuildWindowsMSI

func (b *BuildletStep) BuildWindowsMSI(ctx *workflow.TaskContext, binaryArchive io.Reader, msi io.Writer) error

func (*BuildletStep) ConvertPKGToTGZ

func (b *BuildletStep) ConvertPKGToTGZ(ctx *workflow.TaskContext, in io.Reader, out io.Writer) error

ConvertPKGToTGZ converts a macOS installer (.pkg) to a .tar.gz tarball.

func (*BuildletStep) RunTryBot

func (b *BuildletStep) RunTryBot(ctx *workflow.TaskContext, sourceArchive io.Reader) (bool, error)

func (*BuildletStep) TestTarget

func (b *BuildletStep) TestTarget(ctx *workflow.TaskContext, binaryArchive io.Reader) error

type CommunicationTasks

type CommunicationTasks struct {
	AnnounceMailTasks
	TweetTasks
}

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 FakeBuildlets

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

func NewFakeBuildlets

func NewFakeBuildlets(t *testing.T, httpServer string, sysCmds map[string]string) *FakeBuildlets

NewFakeBuildlets creates a set of fake buildlets. httpServer is the base URL of form http://host with no trailing slash where PutTarFromURL downloads remote URLs from. sysCmds optionally allows overriding the named system commands during testing with the given executable content.

func (*FakeBuildlets) CreateBuildlet

func (b *FakeBuildlets) CreateBuildlet(_ context.Context, kind string) (buildlet.RemoteClient, error)

func (*FakeBuildlets) DumpLogs

func (b *FakeBuildlets) DumpLogs()

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(ctx context.Context, input gerrit.ChangeInput, reviewers []string, contents map[string]string) (string, error)

func (*FakeGerrit) GerritURL

func (g *FakeGerrit) GerritURL() string

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

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

func (*FakeRepo) GetRepoContent

func (repo *FakeRepo) GetRepoContent(commit string) (map[string]string, error)

GetRepoContent returns the content of repo based on the value of commit: - commit is "master": return content of the most recent revision - commit is tag: return content of the repo associating with the commit that the tag maps to - commit is neither "master" or tag: return content of the repo associated with that commit

func (*FakeRepo) Tag

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

type GerritClient

type GerritClient interface {
	// CreateAutoSubmitChange creates a change with the given metadata and
	// contents, sets Run-TryBots and Auto-Submit, 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 google.com or golang.org email address.
	CreateAutoSubmitChange(ctx context.Context, 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.
	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.
	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)
}

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)

type GitHubClientInterface

type GitHubClientInterface interface {
	// FetchMilestone returns the number of the requested milestone. 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)
}

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

type RealGerritClient struct {
	Client *gerrit.Client
}

func (*RealGerritClient) CreateAutoSubmitChange

func (c *RealGerritClient) CreateAutoSubmitChange(ctx context.Context, input gerrit.ChangeInput, reviewers []string, files map[string]string) (string, 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) 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) 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) 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 ReleaseKind

type ReleaseKind int

ReleaseKind is the type of release being run.

const (
	KindUnknown ReleaseKind = iota
	KindBeta
	KindRC
	KindMajor
	KindCurrentMinor
	KindPrevMinor
)

type ReleaseMilestones

type ReleaseMilestones struct {
	Current, Next int
}

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 TagRepo

type TagRepo struct {
	Name         string   // Gerrit project name, e.g. "tools".
	ModPath      string   // Module path, e.g. "golang.org/x/tools".
	Deps         []string // Dependency module paths.
	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.
	Version      string   // After a tagging decision has been made, the version dependencies should upgrade to.
}

TagRepo contains information about a repo that can be tagged.

type TagXReposTasks

type TagXReposTasks struct {
	IgnoreProjects   map[string]bool // project name -> ignore
	Gerrit           GerritClient
	GerritURL        string
	CreateBuildlet   func(context.Context, string) (buildlet.RemoteClient, error)
	LatestGoBinaries func(context.Context) (string, error)
	DashboardURL     string
}

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) 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, reviewers []string) error

func (*TagXReposTasks) MailGoMod

func (x *TagXReposTasks) MailGoMod(ctx *wf.TaskContext, repo 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 Version 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 TweetTasks

type TweetTasks struct {
	// TwitterClient can be used to post a tweet.
	TwitterClient 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) (tweetURL string, _ error)
	}

	// 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
}

TweetTasks contains tasks related to the release tweet.

func (TweetTasks) TweetRelease

func (t TweetTasks) TweetRelease(ctx *workflow.TaskContext, versions []string, security string, announcement string) (tweetURL string, _ error)

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

type VersionTasks

type VersionTasks struct {
	Gerrit           GerritClient
	GerritURL        string
	GoProject        string
	CreateBuildlet   func(context.Context, string) (buildlet.RemoteClient, error)
	LatestGoBinaries func(context.Context) (string, error)
}

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 string, reviewers []string, version string) (string, error)

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

func (*VersionTasks) CreateUpdateStdlibIndexCL

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

func (*VersionTasks) GetCurrentMajor

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

func (*VersionTasks) GetNextVersion

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

GetNextVersion returns the next for the given type of release.

func (*VersionTasks) GetNextVersions

func (t *VersionTasks) GetNextVersions(ctx context.Context, kinds []ReleaseKind) ([]string, error)

GetNextVersions returns the next for each of the given types of release.

func (*VersionTasks) MailDLCL

func (t *VersionTasks) MailDLCL(ctx *workflow.TaskContext, versions []string, reviewers []string, dryRun bool) (changeID string, _ error)

MailDLCL mails a golang.org/dl CL that adds commands for the specified Go versions. It accepts one or two versions only.

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

  • "go1.17.2" and "go1.16.9" for a minor Go release
  • "go1.18" for a major Go release
  • "go1.18beta1" or "go1.18rc1" for a pre-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.

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.
}

Directories

Path Synopsis
Command releaselet does buildlet-side release construction tasks.
Command releaselet does buildlet-side release construction tasks.

Jump to

Keyboard shortcuts

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