shared

package
v0.0.0-...-f5432ee Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Run statuses
	Queued     Status = "queued"
	Completed  Status = "completed"
	InProgress Status = "in_progress"
	Requested  Status = "requested"
	Waiting    Status = "waiting"

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

View Source
var FailedJobAnnotations []Annotation = []Annotation{
	{
		JobName:   "sad job",
		Message:   "the job is sad",
		Path:      "blaze.py",
		Level:     "failure",
		StartLine: 420,
	},
}
View Source
var TestRuns []Run = []Run{
	TestRun("timed out", 1, Completed, TimedOut),
	TestRun("in progress", 2, InProgress, ""),
	SuccessfulRun,
	TestRun("cancelled", 4, Completed, Cancelled),
	FailedRun,
	TestRun("neutral", 6, Completed, Neutral),
	TestRun("skipped", 7, Completed, Skipped),
	TestRun("requested", 8, Requested, ""),
	TestRun("queued", 9, Queued, ""),
	TestRun("stale", 10, Completed, Stale),
}
View Source
var WorkflowRuns []Run = []Run{
	TestRun("in progress", 2, InProgress, ""),
	SuccessfulRun,
	FailedRun,
}

Functions

func AnnotationSymbol

func AnnotationSymbol(cs *iostreams.ColorScheme, a Annotation) string

func IsFailureState

func IsFailureState(c Conclusion) bool

func PromptForRun

func PromptForRun(cs *iostreams.ColorScheme, runs []Run) (string, error)

func PullRequestForRun

func PullRequestForRun(client *api.Client, repo ghrepo.Interface, run Run) (int, error)

func RenderAnnotations

func RenderAnnotations(cs *iostreams.ColorScheme, annotations []Annotation) string

func RenderJobs

func RenderJobs(cs *iostreams.ColorScheme, jobs []Job, verbose bool) string

func RenderRunHeader

func RenderRunHeader(cs *iostreams.ColorScheme, run Run, ago, prNumber string) string

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

func GetAnnotations(client *api.Client, repo ghrepo.Interface, job Job) ([]Annotation, error)

type Artifact

type Artifact struct {
	Name        string `json:"name"`
	Size        uint32 `json:"size_in_bytes"`
	DownloadURL string `json:"archive_download_url"`
	Expired     bool   `json:"expired"`
}

func ListArtifacts

func ListArtifacts(httpClient *http.Client, repo ghrepo.Interface, runID string) ([]Artifact, error)

type CheckRun

type CheckRun struct {
	ID int
}

type Commit

type Commit struct {
	Message string
}

type Conclusion

type Conclusion string

type Job

type Job struct {
	ID          int
	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       int       `json:"run_id"`
}
var FailedJob Job = Job{
	ID:          20,
	Status:      Completed,
	Conclusion:  Failure,
	Name:        "sad job",
	StartedAt:   created(),
	CompletedAt: updated(),
	URL:         "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 SuccessfulJob Job = Job{
	ID:          10,
	Status:      Completed,
	Conclusion:  Success,
	Name:        "cool job",
	StartedAt:   created(),
	CompletedAt: updated(),
	URL:         "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,
		},
	},
}

func GetJobs

func GetJobs(client *api.Client, repo ghrepo.Interface, run Run) ([]Job, error)

type JobsPayload

type JobsPayload struct {
	Jobs []Job
}

type Level

type Level string

type Repo

type Repo struct {
	Owner struct {
		Login string
	}
	Name string
}

type Run

type Run struct {
	Name           string
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	Status         Status
	Conclusion     Conclusion
	Event          string
	ID             int
	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"`
}
var FailedRun Run = TestRun("failed", 1234, Completed, Failure)
var SuccessfulRun Run = TestRun("successful", 3, Completed, Success)

func GetRun

func GetRun(client *api.Client, repo ghrepo.Interface, runID string) (*Run, error)

func GetRuns

func GetRuns(client *api.Client, repo ghrepo.Interface, limit int) ([]Run, error)

func GetRunsByWorkflow

func GetRunsByWorkflow(client *api.Client, repo ghrepo.Interface, limit, workflowID int) ([]Run, error)

func GetRunsWithFilter

func GetRunsWithFilter(client *api.Client, repo ghrepo.Interface, limit int, f func(Run) bool) ([]Run, error)

func TestRun

func TestRun(name string, id int, s Status, c Conclusion) Run

func (Run) CommitMsg

func (r Run) CommitMsg() string

type RunsPayload

type RunsPayload struct {
	TotalCount   int   `json:"total_count"`
	WorkflowRuns []Run `json:"workflow_runs"`
}

type Status

type Status string

type Step

type Step struct {
	Name       string
	Status     Status
	Conclusion Conclusion
	Number     int
	Log        *zip.File
}

type Steps

type Steps []Step

func (Steps) Len

func (s Steps) Len() int

func (Steps) Less

func (s Steps) Less(i, j int) bool

func (Steps) Swap

func (s Steps) Swap(i, j int)

Jump to

Keyboard shortcuts

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