github

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const GraphQLBatchSize = 20

GraphQLBatchSize is the max number of runs fetched per GraphQL query. Each run with jobs+steps costs ~1-4 rate limit points.

Variables

This section is empty.

Functions

func ResolveToken

func ResolveToken() (string, error)

ResolveToken returns a GitHub API token. It checks GITHUB_TOKEN env var first, then falls back to `gh auth token`.

Types

type Client

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

Client wraps the GitHub API for fetching Actions workflow data.

func NewClient

func NewClient(token, ownerRepo string, opts ...ClientOption) (*Client, error)

NewClient creates a Client for the given owner/repo.

func (*Client) FetchJobs

func (c *Client) FetchJobs(ctx context.Context, runID int64) ([]model.Job, error)

FetchJobs fetches jobs and steps for a single workflow run.

func (*Client) FetchRunDetails

func (c *Client) FetchRunDetails(ctx context.Context, runs []model.WorkflowRun) (details []model.RunDetail, warnings []Warning)

FetchRunDetails hydrates a slice of workflow runs with their jobs and steps. Uses a worker pool for bounded concurrency. Returns partial results and warnings for runs that failed to fetch.

func (*Client) FetchRunDetailsGraphQL

func (c *Client) FetchRunDetailsGraphQL(ctx context.Context, runs []model.WorkflowRun) (details []model.RunDetail, warnings []Warning)

FetchRunDetailsGraphQL hydrates runs with jobs+steps using batched GraphQL queries. Falls back to REST for runs whose node_id is empty.

func (*Client) FetchRuns

func (c *Client) FetchRuns(ctx context.Context, workflowID int64, since time.Time, branch string) ([]model.WorkflowRun, []Warning, error)

FetchRuns fetches completed workflow runs for a specific workflow since the given time. Uses sliding date windows to avoid the GitHub API 1,000-result cap. If branch is empty, runs from all branches are returned.

func (*Client) ListWorkflows

func (c *Client) ListWorkflows(ctx context.Context) ([]model.Workflow, error)

ListWorkflows returns all workflows in the repository.

func (*Client) RateLimit

func (c *Client) RateLimit(ctx context.Context) (RateLimitStatus, error)

RateLimit returns the current GitHub API rate limit status.

type ClientOption

type ClientOption func(*Client)

ClientOption configures optional Client behaviour.

func WithLogger

func WithLogger(l *slog.Logger) ClientOption

WithLogger sets a structured logger for the client.

func WithMaxConcurrentJobs

func WithMaxConcurrentJobs(n int) ClientOption

WithMaxConcurrentJobs sets the maximum number of concurrent job-fetch API calls.

type RateLimitStatus

type RateLimitStatus struct {
	Remaining int
	Limit     int
	ResetAt   time.Time
}

RateLimitStatus contains the current rate limit state.

type Warning

type Warning = diag.Diagnostic

Warning is a deprecated alias for diag.Diagnostic. Use diag.Diagnostic directly.

Jump to

Keyboard shortcuts

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