Documentation
¶
Overview ¶
Package githubapi contains the GitHub data shared by Mage reporting targets.
Index ¶
Constants ¶
const ( PageSize = 100 PageLimit = 100 )
Variables ¶
var ( RepoPattern = regexp.MustCompile(`^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$`) SHAPattern = regexp.MustCompile(`^[0-9a-f]{40}$`) )
var CommentRunPattern = regexp.MustCompile(`<!-- atmos-benchmark-run:(\d+):(\d+) -->`)
var ErrPRPaginationLimit = errors.New("PR pagination limit exceeded")
ErrPRPaginationLimit reports that a PR listing exceeded PageLimit pages.
Functions ¶
Types ¶
type HeadRef ¶
type HeadRef struct {
Owner, Branch, SHA string
}
HeadRef identifies a PR head by its fork owner, branch and expected commit.
type PR ¶
type PR struct {
Updated time.Time `json:"updated_at"`
MergeSHA string `json:"merge_commit_sha"`
ChangedFiles *int `json:"changed_files"`
Draft bool `json:"draft"`
Number int `json:"number"`
State string `json:"state"`
// Mergeable is nil until GitHub has lazily computed it after a push or base move.
Mergeable *bool `json:"mergeable"`
MergeableState string `json:"mergeable_state"`
Labels []struct {
Name string `json:"name"`
} `json:"labels"`
User struct {
Login string `json:"login"`
Type string `json:"type"`
} `json:"user"`
Head struct {
SHA string `json:"sha"`
Repo struct {
FullName string `json:"full_name"`
} `json:"repo"`
} `json:"head"`
Base struct {
Ref string `json:"ref"`
SHA string `json:"sha"`
Repo struct {
FullName string `json:"full_name"`
} `json:"repo"`
} `json:"base"`
}
func ListOpenMainPRs ¶
ListOpenMainPRs lists open PRs against main from a paginated pulls endpoint. The path is a complete API path that already carries a query string. When headSHA is set, only PRs whose head is exactly that commit qualify, so a PR whose head moved after an event is never selected for the stale commit.
func OpenPRsForHead ¶
OpenPRsForHead resolves open main PRs by their head branch. GitHub's commit association endpoint lists nothing for a commit that exists only in a fork, but the exact owner:branch lookup is strongly consistent. Every result's head is verified against sha.
type Run ¶
type Run struct {
ID int64 `json:"id"`
Attempt int `json:"run_attempt"`
HeadSHA string `json:"head_sha"`
Branch string `json:"head_branch"`
Event string `json:"event"`
Status string `json:"status"`
Conclusion string `json:"conclusion"`
Path string `json:"path"`
Created time.Time `json:"created_at"`
Updated time.Time `json:"updated_at"`
HeadRepository struct {
FullName string `json:"full_name"`
} `json:"head_repository"`
PullRequests []struct {
Number int `json:"number"`
} `json:"pull_requests"`
}