Documentation
¶
Index ¶
- Constants
- Variables
- func AnnotationSymbol(cs *iostreams.ColorScheme, a Annotation) string
- func IsFailureState(c Conclusion) bool
- func IsSkipped(c Conclusion) bool
- func PullRequestForRun(client *api.Client, repo ghrepo.Interface, run Run) (int, error)
- func RenderAnnotations(cs *iostreams.ColorScheme, annotations []Annotation) string
- func RenderJobs(cs *iostreams.ColorScheme, jobs []Job, verbose bool) string
- func RenderJobsCompact(cs *iostreams.ColorScheme, jobs []Job) string
- func RenderRunHeader(cs *iostreams.ColorScheme, run Run, ago, prNumber string, attempt uint64) string
- func SelectRun(p Prompter, cs *iostreams.ColorScheme, runs []Run) (string, error)
- func Symbol(cs *iostreams.ColorScheme, status Status, conclusion Conclusion) (string, colorFunc)
- type Annotation
- type Artifact
- type CheckRun
- type Commit
- type Conclusion
- type FilterOptions
- type Job
- type JobsPayload
- type Level
- type Prompter
- type Repo
- type Run
- func GetRun(client *api.Client, repo ghrepo.Interface, runID string, attempt uint64) (*Run, error)
- func GetRunsWithFilter(client *api.Client, repo ghrepo.Interface, opts *FilterOptions, limit int, ...) ([]Run, error)
- func TestRun(id int64, s Status, c Conclusion) Run
- func TestRunWithCommit(id int64, s Status, c Conclusion, commit string) Run
- func TestRunWithOrgRequiredWorkflow(id int64, s Status, c Conclusion, commit string) Run
- func TestRunWithWorkflowAndCommit(workflowId, runId int64, s Status, c Conclusion, commit string) Run
- type RunsPayload
- type Status
- type Step
- type Steps
- type TestExporter
Constants ¶
const ( // Run statuses Queued Status = "queued" Completed Status = "completed" InProgress Status = "in_progress" Requested Status = "requested" Waiting Status = "waiting" Pending Status = "pending" // Run conclusions ActionRequired Conclusion = "action_required" Cancelled Conclusion = "cancelled" Failure Conclusion = "failure" Neutral Conclusion = "neutral" Skipped Conclusion = "skipped" Stale Conclusion = "stale" StartupFailure Conclusion = "startup_failure" Success Conclusion = "success" TimedOut Conclusion = "timed_out" AnnotationFailure Level = "failure" AnnotationWarning Level = "warning" )
Variables ¶
var AllStatuses = []string{
"queued",
"completed",
"in_progress",
"requested",
"waiting",
"pending",
"action_required",
"cancelled",
"failure",
"neutral",
"skipped",
"stale",
"startup_failure",
"success",
"timed_out",
}
var ErrMissingAnnotationsPermissions = errors.New("missing annotations permissions error")
var FailedJobAnnotations []Annotation = []Annotation{
{
JobName: "sad job",
Message: "the job is sad",
Path: "blaze.py",
Level: "failure",
StartLine: 420,
},
}
var RunFields = []string{
"name",
"displayTitle",
"headBranch",
"headSha",
"createdAt",
"updatedAt",
"startedAt",
"attempt",
"status",
"conclusion",
"event",
"number",
"databaseId",
"workflowDatabaseId",
"workflowName",
"url",
}
var SingleRunFields = append(RunFields, "jobs")
var SuccessfulJobAnnotations []Annotation = []Annotation{
{
JobName: "cool job",
Message: "the job is happy",
Path: "blaze.py",
Level: "notice",
StartLine: 420,
},
}
var TestRunStartTime, _ = time.Parse("2006-01-02 15:04:05", "2021-02-23 04:51:00")
var TestRuns []Run = []Run{ TestRun(1, Completed, TimedOut), TestRun(2, InProgress, ""), SuccessfulRun, TestRun(4, Completed, Cancelled), FailedRun, TestRun(6, Completed, Neutral), TestRun(7, Completed, Skipped), TestRun(8, Requested, ""), TestRun(9, Queued, ""), TestRun(10, Completed, Stale), }
var TestRunsWithOrgRequiredWorkflows []Run = []Run{ TestRunWithOrgRequiredWorkflow(1, Completed, TimedOut, "cool commit"), TestRunWithOrgRequiredWorkflow(2, InProgress, "", "cool commit"), TestRunWithOrgRequiredWorkflow(3, Completed, Success, "cool commit"), TestRunWithOrgRequiredWorkflow(4, Completed, Cancelled, "cool commit"), TestRun(5, Completed, Failure), TestRun(6, Completed, Neutral), TestRun(7, Completed, Skipped), TestRun(8, Requested, ""), TestRun(9, Queued, ""), }
var TestWorkflow workflowShared.Workflow = workflowShared.Workflow{
Name: "CI",
ID: 123,
}
var WorkflowRuns []Run = []Run{ TestRun(2, InProgress, ""), SuccessfulRun, FailedRun, }
Functions ¶
func AnnotationSymbol ¶
func AnnotationSymbol(cs *iostreams.ColorScheme, a Annotation) string
func IsFailureState ¶
func IsFailureState(c Conclusion) bool
func IsSkipped ¶ added in v2.76.0
func IsSkipped(c Conclusion) bool
func PullRequestForRun ¶
func RenderAnnotations ¶
func RenderAnnotations(cs *iostreams.ColorScheme, annotations []Annotation) string
func RenderJobs ¶
func RenderJobs(cs *iostreams.ColorScheme, jobs []Job, verbose bool) string
func RenderJobsCompact ¶ added in v2.74.0
func RenderJobsCompact(cs *iostreams.ColorScheme, jobs []Job) string
func RenderRunHeader ¶
func SelectRun ¶ added in v2.27.0
SelectRun prompts the user to select a run from a list of runs by using the recommended prompter interface
func Symbol ¶
func Symbol(cs *iostreams.ColorScheme, status Status, conclusion Conclusion) (string, colorFunc)
Types ¶
type Annotation ¶
type Annotation struct {
JobName string
Message string
Path string
Level Level `json:"annotation_level"`
StartLine int `json:"start_line"`
}
func GetAnnotations ¶
GetAnnotations fetches annotations from the REST API.
If the job has no annotations, an empty slice is returned. If the API returns a 403, a custom ErrMissingAnnotationsPermissions error is returned.
When fine-grained PATs support checks:read permission, we can remove the need for this at the call sites.
type Artifact ¶
type Conclusion ¶
type Conclusion string
type FilterOptions ¶ added in v2.5.0
type Job ¶
type Job struct {
ID int64
Status Status
Conclusion Conclusion
Name string
Steps Steps
StartedAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at"`
URL string `json:"html_url"`
RunID int64 `json:"run_id"`
}
var FailedJob Job = Job{ ID: 20, Status: Completed, Conclusion: Failure, Name: "sad job", StartedAt: TestRunStartTime, CompletedAt: TestRunStartTime.Add(time.Minute*4 + time.Second*34), URL: "https://github.com/jobs/20", RunID: 1234, Steps: []Step{ { Name: "barf the quux", Status: Completed, Conclusion: Success, Number: 1, }, { Name: "quux the barf", Status: Completed, Conclusion: Failure, Number: 2, }, }, }
var FailedJobWithoutStepLogs Job = Job{ ID: 21, Status: Completed, Conclusion: Failure, Name: "sad job with no step logs", StartedAt: TestRunStartTime, CompletedAt: TestRunStartTime.Add(time.Minute*4 + time.Second*34), URL: "https://github.com/jobs/21", RunID: 1234, Steps: []Step{ { Name: "barf the quux", Status: Completed, Conclusion: Success, Number: 1, }, { Name: "quux the barf", Status: Completed, Conclusion: Failure, Number: 2, }, }, }
Note that this run *has* steps, but in the ZIP archive the step logs are not included.
var LegacyFailedJobWithoutStepLogs Job = Job{ ID: 22, Status: Completed, Conclusion: Failure, Name: "legacy sad job with no step logs", StartedAt: TestRunStartTime, CompletedAt: TestRunStartTime.Add(time.Minute*4 + time.Second*34), URL: "https://github.com/jobs/22", RunID: 1234, Steps: []Step{ { Name: "barf the quux", Status: Completed, Conclusion: Success, Number: 1, }, { Name: "quux the barf", Status: Completed, Conclusion: Failure, Number: 2, }, }, }
Note that this run *has* steps, but in the ZIP archive the step logs are not included.
var LegacySuccessfulJobWithoutStepLogs Job = Job{ ID: 12, Status: Completed, Conclusion: Success, Name: "legacy cool job with no step logs", StartedAt: TestRunStartTime, CompletedAt: TestRunStartTime.Add(time.Minute*4 + time.Second*34), URL: "https://github.com/jobs/12", RunID: 3, Steps: []Step{ { Name: "fob the barz", Status: Completed, Conclusion: Success, Number: 1, }, { Name: "barz the fob", Status: Completed, Conclusion: Success, Number: 2, }, }, }
Note that this run *has* steps, but in the ZIP archive the step logs are not included.
var SkippedJob Job = Job{ ID: 13, Status: Completed, Conclusion: Skipped, Name: "cool job", StartedAt: TestRunStartTime, CompletedAt: TestRunStartTime, URL: "https://github.com/jobs/13", RunID: 3, Steps: []Step{}, }
var SuccessfulJob Job = Job{ ID: 10, Status: Completed, Conclusion: Success, Name: "cool job", StartedAt: TestRunStartTime, CompletedAt: TestRunStartTime.Add(time.Minute*4 + time.Second*34), URL: "https://github.com/jobs/10", RunID: 3, Steps: []Step{ { Name: "fob the barz", Status: Completed, Conclusion: Success, Number: 1, }, { Name: "barz the fob", Status: Completed, Conclusion: Success, Number: 2, }, }, }
var SuccessfulJobWithoutStepLogs Job = Job{ ID: 11, Status: Completed, Conclusion: Success, Name: "cool job with no step logs", StartedAt: TestRunStartTime, CompletedAt: TestRunStartTime.Add(time.Minute*4 + time.Second*34), URL: "https://github.com/jobs/11", RunID: 3, Steps: []Step{ { Name: "fob the barz", Status: Completed, Conclusion: Success, Number: 1, }, { Name: "barz the fob", Status: Completed, Conclusion: Success, Number: 2, }, }, }
Note that this run *has* steps, but in the ZIP archive the step logs are not included.
type JobsPayload ¶
type Run ¶
type Run struct {
Name string `json:"name"` // the semantics of this field are unclear
DisplayTitle string `json:"display_title"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
StartedAt time.Time `json:"run_started_at"`
Status Status
Conclusion Conclusion
Event string
ID int64
WorkflowID int64 `json:"workflow_id"`
Number int64 `json:"run_number"`
Attempt uint64 `json:"run_attempt"`
HeadBranch string `json:"head_branch"`
JobsURL string `json:"jobs_url"`
HeadCommit Commit `json:"head_commit"`
HeadSha string `json:"head_sha"`
URL string `json:"html_url"`
HeadRepository Repo `json:"head_repository"`
Jobs []Job `json:"-"` // populated by GetJobs
// contains filtered or unexported fields
}
func GetRunsWithFilter ¶
func GetRunsWithFilter(client *api.Client, repo ghrepo.Interface, opts *FilterOptions, limit int, f func(Run) bool) ([]Run, error)
GetRunsWithFilter fetches 50 runs from the API and filters them in-memory
func TestRunWithCommit ¶ added in v2.16.0
func TestRunWithCommit(id int64, s Status, c Conclusion, commit string) Run
func TestRunWithOrgRequiredWorkflow ¶ added in v2.70.0
func TestRunWithOrgRequiredWorkflow(id int64, s Status, c Conclusion, commit string) Run
func TestRunWithWorkflowAndCommit ¶ added in v2.52.0
func TestRunWithWorkflowAndCommit(workflowId, runId int64, s Status, c Conclusion, commit string) Run
func (*Run) ExportData ¶ added in v2.4.0
func (*Run) StartedTime ¶ added in v2.14.3
func (Run) Title ¶ added in v2.16.0
Title is the display title for a run, falling back to the commit subject if unavailable
func (Run) WorkflowName ¶ added in v2.16.0
WorkflowName returns the human-readable name of the workflow that this run belongs to. TODO: consider lazy-loading the underlying API data to avoid extra API calls unless necessary
type RunsPayload ¶
type RunsPayload struct {
TotalCount int `json:"total_count"`
WorkflowRuns []Run `json:"workflow_runs"`
}
func GetRuns ¶
func GetRuns(client *api.Client, repo ghrepo.Interface, opts *FilterOptions, limit int) (*RunsPayload, error)
type TestExporter ¶ added in v2.34.0
type TestExporter struct {
// contains filtered or unexported fields
}
func MakeTestExporter ¶ added in v2.34.0
func MakeTestExporter(fields []string, wh func(io *iostreams.IOStreams, data interface{}) error) *TestExporter
func (*TestExporter) Fields ¶ added in v2.34.0
func (t *TestExporter) Fields() []string