Documentation
¶
Overview ¶
Package github provides a client for interacting with GitHub API operations.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) GetLatestRun(workflowName string) (*WorkflowRun, error)
- func (c *Client) GetWorkflowRun(runID int64) (*WorkflowRun, error)
- func (c *Client) GetWorkflowRunJobs(runID int64) ([]Job, error)
- func (c *Client) ListRuns(q RunQuery) ([]WorkflowRun, error)
- func (c *Client) Owner() string
- func (c *Client) Repo() string
- type Job
- type JobsResponse
- type RunQuery
- type RunsResponse
- 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(workflowName string) (*WorkflowRun, error)
GetLatestRun fetches the most recent workflow run, optionally filtered by workflow name.
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.
type Job ¶
type Job struct {
StartedAt time.Time `json:"started_at"`
Name string `json:"name"`
Status string `json:"status"`
Conclusion string `json:"conclusion"`
Steps []Step `json:"steps"`
ID int64 `json:"id"`
}
Job represents a job within a workflow run.
type JobsResponse ¶
JobsResponse represents the API response for listing jobs.
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 RunsResponse ¶
type RunsResponse struct {
WorkflowRuns []WorkflowRun `json:"workflow_runs"`
TotalCount int `json:"total_count"`
}
RunsResponse represents the API response for listing runs.
type Step ¶
type Step struct {
Name string `json:"name"`
Status string `json:"status"`
Conclusion string `json:"conclusion"`
Number int `json:"number"`
}
Step represents a step within a job.
type WorkflowRun ¶
type WorkflowRun struct {
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Name string `json:"name"`
Status string `json:"status"`
Conclusion string `json:"conclusion"`
HTMLURL string `json:"html_url"`
HeadBranch string `json:"head_branch"`
ID int64 `json:"id"`
}
WorkflowRun represents a GitHub Actions workflow run.
func (WorkflowRun) IsActive ¶
func (r WorkflowRun) IsActive() bool
IsActive returns true if the run is still in progress.
func (WorkflowRun) IsSuccess ¶
func (r WorkflowRun) IsSuccess() bool
IsSuccess returns true if the run completed successfully.