Documentation
¶
Overview ¶
Package github provides a client for interacting with GitHub API operations.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) CancelRun(runID int64) error
- func (c *Client) GetLatestRun(workflowFile string) (*WorkflowRun, error)
- func (c *Client) GetWorkflowRun(runID int64) (*WorkflowRun, error)
- func (c *Client) GetWorkflowRunJobs(runID int64) ([]Job, error)
- func (c *Client) LatestRunsOnBranch(branch string, within time.Duration) ([]WorkflowRun, error)
- func (c *Client) ListEnvironments() ([]string, error)
- func (c *Client) ListRuns(q RunQuery) ([]WorkflowRun, error)
- func (c *Client) Owner() string
- func (c *Client) PullRequestsInScope(scope PRScope) ([]PullRequest, error)
- func (c *Client) Repo() string
- func (c *Client) RerunFailedJobs(runID int64) error
- type Job
- type JobsResponse
- type PRScope
- type PullRequest
- type RunQuery
- type Step
- type WorkflowRun
Constants ¶
const ( StatusQueued = "queued" StatusInProgress = "in_progress" StatusCompleted = "completed" )
RunStatus constants.
const ( ConclusionSuccess = "success" ConclusionFailure = "failure" ConclusionCancelled = "cancelled" //nolint:misspell // matches GitHub Actions API's actual conclusion value ConclusionSkipped = "skipped" )
Conclusion constants.
Variables ¶
var ErrInvalidRepositoryFormat = errors.New("invalid repository format (expected owner/repo)")
ErrInvalidRepositoryFormat indicates a repository string was not in "owner/repo" format.
var ErrNoWorkflowRuns = errors.New("no workflow runs found")
ErrNoWorkflowRuns indicates no workflow runs matched the query.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the GitHub API via gh CLI.
func NewClient ¶
NewClient creates a new GitHub API client for the specified repository. Uses the real gh CLI executor by default.
func NewClientWithExecutor ¶
func NewClientWithExecutor(repoFullName string, executor exec.CommandExecutor) (*Client, error)
NewClientWithExecutor creates a new GitHub API client with a custom executor. This allows injecting a mock executor for testing.
func (*Client) GetLatestRun ¶
func (c *Client) GetLatestRun(workflowFile string) (*WorkflowRun, error)
GetLatestRun fetches the most recent run of a workflow file, or the most recent run in the repository when workflowFile is empty.
func (*Client) GetWorkflowRun ¶
func (c *Client) GetWorkflowRun(runID int64) (*WorkflowRun, error)
GetWorkflowRun fetches a single workflow run by ID.
func (*Client) GetWorkflowRunJobs ¶
GetWorkflowRunJobs fetches the jobs for a workflow run, with the per-step timings the timeline lays out.
func (*Client) LatestRunsOnBranch ¶ added in v1.6.0
LatestRunsOnBranch returns the newest run of each workflow on a branch, which is the branch's current state rather than its history. A run older than within is dropped unless it is still going; a zero within keeps every age.
func (*Client) ListEnvironments ¶ added in v1.10.0
ListEnvironments names the repository's deployment environments, which is what a workflow input of type "environment" has to be one of. A repository that declares none answers with an empty list rather than an error.
func (*Client) ListRuns ¶ added in v1.3.0
func (c *Client) ListRuns(q RunQuery) ([]WorkflowRun, error)
ListRuns fetches recent workflow runs matching q, newest first.
func (*Client) PullRequestsInScope ¶ added in v1.9.0
func (c *Client) PullRequestsInScope(scope PRScope) ([]PullRequest, error)
PullRequestsInScope returns every pull request matching scope, each with its own check rollup.
The rollup is the answer rather than a run listing because runs are keyed by branch: one page of a repository's recent runs is filled by whichever branch ran last, so every other pull request in it reports nothing.
func (*Client) RerunFailedJobs ¶ added in v1.10.0
RerunFailedJobs re-runs only the failed jobs of a run, which is what a run that failed on one flaky job needs rather than a whole second run.
type JobsResponse ¶
JobsResponse represents the API response for listing jobs.
type PRScope ¶ added in v1.7.0
type PRScope string
PRScope names which pull requests a run listing should cover. Both are search queries rather than API filters, because "mine" and "awaiting my review" are questions only the search index answers.
type PullRequest ¶ added in v1.9.0
type PullRequest = forge.PullRequest
PullRequest is aragonite's pull request model, which already carries the check rollup that answers whether a pull request is green.
type RunQuery ¶ added in v1.3.0
type RunQuery struct {
// Workflow is a workflow filename ("ci.yml"), not its display name.
Workflow string
Branch string
Status string
Event string
Limit int
}
RunQuery narrows a run listing. A zero value lists the most recent runs across every workflow.
type WorkflowRun ¶
type WorkflowRun = forge.WorkflowRun
WorkflowRun is one Actions run, as aragonite models it. Every read in this package goes through aragonite, so a local struct would only be a conversion of this one.