Documentation
¶
Overview ¶
Package github fetches workflow runs and logs, from the live API or from local fixtures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
Message string
// RetryAfter is populated from rate-limit headers when the server tells us
// exactly how long to wait.
RetryAfter time.Duration
// contains filtered or unexported fields
}
APIError carries an HTTP status and whether the call is worth repeating.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the live GitHub API source.
func NewClient ¶
NewClient builds an authenticated client. A token is optional for public repositories but raises the rate limit from 60 to 5000 requests an hour, which is the difference between scanning one repo and scanning a fleet.
func (*Client) DownloadJobLog ¶
DownloadJobLog fetches the zip log archive for one job.
The API answers with a redirect to a short-lived blob URL, which go-github surfaces rather than following. The redirect target is fetched with a bare client on purpose: forwarding the Authorization header to the storage host would leak the token to a third party.
func (*Client) For ¶
For sets the repository this client operates on. Kept separate from the constructor so one authenticated client can scan several repositories.
func (*Client) ListJobResults ¶
func (c *Client) ListJobResults(ctx context.Context, opts ListOptions) ([]detector.JobResult, error)
ListJobResults walks workflow runs in the window and flattens them to jobs.
Every attempt of every run is needed, not just the latest: a rerun is exactly where the flaky signature lives, and the runs endpoint returns only the most recent attempt of each run by default.
type FixtureSource ¶
type FixtureSource struct {
// contains filtered or unexported fields
}
FixtureSource reads job results and logs from a local directory instead of the GitHub API.
This is not a test double bolted on afterwards — it is a supported mode. A reviewer with no token, no network and no repository access can run the full scan → classify → report pipeline and see real output, which is the difference between a tool someone evaluates and a tool someone reads about.
func NewFixtureSource ¶
func NewFixtureSource(dir string) (*FixtureSource, error)
NewFixtureSource builds an offline source rooted at dir.
func (*FixtureSource) Describe ¶
func (f *FixtureSource) Describe() string
Describe names the source.
func (*FixtureSource) DownloadJobLog ¶
DownloadJobLog reads the archive a fixture job points at.
func (*FixtureSource) ListJobResults ¶
func (f *FixtureSource) ListJobResults(_ context.Context, opts ListOptions) ([]detector.JobResult, error)
ListJobResults reads the fixture index.
type ListOptions ¶
type ListOptions struct {
Owner string
Repo string
// Days is how far back to look.
Days int
// WorkflowFile optionally restricts to a single workflow, e.g. "ci.yml".
WorkflowFile string
// MaxRuns caps how many runs are fetched, bounding both time and API quota.
MaxRuns int
}
ListOptions narrows a scan.
func DefaultListOptions ¶
func DefaultListOptions() ListOptions
DefaultListOptions returns sensible scan defaults.
type Source ¶
type Source interface {
// ListJobResults returns every decisive job execution in the window.
ListJobResults(ctx context.Context, opts ListOptions) ([]detector.JobResult, error)
// DownloadJobLog returns the raw zip archive for one job.
DownloadJobLog(ctx context.Context, runID, jobID int64) ([]byte, error)
// Describe names the source for report provenance.
Describe() string
}
Source supplies job results and logs, from the live API or from fixtures.
The whole ingestion layer sits behind this interface so that --offline is a first-class mode rather than a test hack: a reviewer with no credentials runs exactly the same pipeline a maintainer does.