Documentation
¶
Overview ¶
Package prcheck validates pull request bodies against the repository's "## Changelog" contract (parity with the migrated JavaScript verifier workflow).
Packages in prcheck MUST NOT read environment variables or touch the filesystem; callers inject GitHub/network via PullRequestFetcher.
Index ¶
- Constants
- func BuildFailureCommentBody(marker string, errs []string) string
- func BuildNoChangelogPassCommentBody(marker string) string
- func BuildPassCommentBody(marker string) string
- func UpsertVerdictIssueComment(ctx context.Context, rest IssueCommentsREST, owner, repo string, ...) error
- type Comment
- type IssueCommentsREST
- type PullRequest
- type PullRequestFetcher
- type Status
- type ValidateOptions
- type Verdict
Constants ¶
const ( // StatusPass is written to Verdict.Status when validation succeeds or no-changelog bypass applies. StatusPass = "pass" // StatusFail is written to Verdict.Status when validation reports one or more errors. StatusFail = "fail" )
const MarkerForPRCheck = "<!-- pr-changelog-check -->"
MarkerForPRCheck is embedded in verdict comments so later runs locate the same comment.
Variables ¶
This section is empty.
Functions ¶
func BuildFailureCommentBody ¶
BuildFailureCommentBody matches the legacy failure comment template (byte-compatible).
func BuildNoChangelogPassCommentBody ¶
BuildNoChangelogPassCommentBody matches the legacy no-changelog pass comment template verbatim.
func BuildPassCommentBody ¶
BuildPassCommentBody matches the legacy pass comment template verbatim.
func UpsertVerdictIssueComment ¶
func UpsertVerdictIssueComment(ctx context.Context, rest IssueCommentsREST, owner, repo string, issueNumber int, verdict Verdict) error
UpsertVerdictIssueComment mirrors pr-changelog-check/check.js comment upsert semantics.
Types ¶
type Comment ¶
Comment is a minimal snapshot of an issue comment for upsert lookups.
func FindExistingComment ¶
FindExistingComment returns the first github-actions[bot] comment containing marker, or nil.
type IssueCommentsREST ¶
type IssueCommentsREST interface {
ListIssueComments(ctx context.Context, owner, repo string, issueNumber int) ([]Comment, error)
CreateIssueComment(ctx context.Context, owner, repo string, issueNumber int, body string) error
UpdateIssueComment(ctx context.Context, owner, repo string, commentID int64, body string) error
}
IssueCommentsREST lists and mutates GitHub issue comments (used for PR threads).
type PullRequest ¶
PullRequest is the validator input trimmed from GitHub PR APIs.
type PullRequestFetcher ¶
type PullRequestFetcher interface {
GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)
}
PullRequestFetcher retrieves PR payload for Validate.
type Status ¶
type Status string
Status is serialized as the JSON status string ("pass" | "fail").
func (Status) MarshalJSON ¶
MarshalJSON encodes Status as a JSON string literal.
func (*Status) UnmarshalJSON ¶
UnmarshalJSON decodes Status from JSON string literals ("pass", "fail").
type ValidateOptions ¶
type ValidateOptions struct {
Owner string
Repo string
Number int
Fetcher PullRequestFetcher
NoChangelogLabel string
}
ValidateOptions configures Validate (no environment access).
type Verdict ¶
type Verdict struct {
Status Status `json:"status"`
// Errors lists validation diagnostics when Status is StatusFail (JS errors array parity).
Errors []string `json:"errors,omitempty"`
// NoChangelogSkip is true when validation was bypassed via the configured no-changelog label.
NoChangelogSkip bool `json:"no_changelog_skip,omitempty"`
}
Verdict is the canonical JSON verdict for workflows (see GitHub Actions result_json consumer).
func Validate ¶
func Validate(ctx context.Context, opts ValidateOptions) (Verdict, error)
Validate loads the PR, applies optional no-changelog suppression, parses via section.Parse, and validates via section.ValidateChangelogSectionFull (default options).
Operational errors from Fetcher bubble up wrapped; validation failures return Verdict.StatusFail and a nil error.