Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("pipeline not found")
ErrNotFound is returned when a pipeline is not found.
Functions ¶
This section is empty.
Types ¶
type CISummary ¶
type CISummary struct {
TotalPipelines int `json:"total_pipelines"`
PassRate float64 `json:"pass_rate"`
AvgDurationMs float64 `json:"avg_duration_ms"`
FlakyTests []FlakyTest `json:"flaky_tests"`
ByProvider map[string]int `json:"by_provider"`
}
CISummary provides an overall CI health overview.
type FlakyTest ¶
type FlakyTest struct {
Suite string `json:"suite"`
Name string `json:"name"`
PassRate float64 `json:"pass_rate"`
Runs int `json:"runs"`
}
FlakyTest is a test that has mixed pass/fail results.
type GitHubWorkflowRun ¶
type GitHubWorkflowRun struct {
Action string `json:"action"` // "completed", "requested", etc.
WorkflowRun struct {
ID int64 `json:"id"`
Name string `json:"name"`
HeadBranch string `json:"head_branch"`
HeadSHA string `json:"head_sha"`
Status string `json:"status"` // "completed", "in_progress", "queued"
Conclusion string `json:"conclusion"` // "success", "failure", "cancelled", "skipped"
HTMLURL string `json:"html_url"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
RunStarted time.Time `json:"run_started_at"`
Jobs []struct {
Name string `json:"name"`
Status string `json:"status"`
Conclusion string `json:"conclusion"`
StartedAt time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at"`
} `json:"jobs,omitempty"`
} `json:"workflow_run"`
Repository struct {
FullName string `json:"full_name"`
} `json:"repository"`
}
GitHubWorkflowRun represents the relevant fields from a GitHub Actions workflow_run webhook payload.
type GitLabPipelineEvent ¶
type GitLabPipelineEvent struct {
ObjectKind string `json:"object_kind"` // "pipeline"
ObjectAttributes struct {
ID int64 `json:"id"`
Ref string `json:"ref"`
SHA string `json:"sha"`
Status string `json:"status"` // success, failed, running, pending, canceled, skipped...
Duration int64 `json:"duration"` // seconds
CreatedAt string `json:"created_at"`
FinishedAt string `json:"finished_at"`
URL string `json:"url"`
} `json:"object_attributes"`
Project struct {
PathWithNamespace string `json:"path_with_namespace"`
WebURL string `json:"web_url"`
} `json:"project"`
User struct {
Name string `json:"name"`
} `json:"user"`
Builds []struct {
Name string `json:"name"`
Status string `json:"status"`
StartedAt string `json:"started_at"`
FinishedAt string `json:"finished_at"`
} `json:"builds"`
}
GitLabPipelineEvent represents the relevant fields from a GitLab CI "Pipeline Hook" webhook payload (object_kind: "pipeline").
type Job ¶
type Job struct {
Name string `json:"name"`
Status string `json:"status"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
DurationMs int64 `json:"duration_ms"`
}
Job represents a single job within a pipeline.
type Pipeline ¶
type Pipeline struct {
ID string `json:"id"`
Provider string `json:"provider"` // "github_actions", "gitlab_ci", "jenkins"
Repo string `json:"repo"`
Branch string `json:"branch"`
CommitHash string `json:"commit_hash"`
Status string `json:"status"` // "running", "success", "failure", "cancelled"
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
DurationMs int64 `json:"duration_ms"`
URL string `json:"url"` // link to CI provider
Jobs []Job `json:"jobs"`
}
Pipeline represents a CI/CD pipeline run.
func ParseGitHubWorkflowRun ¶
func ParseGitHubWorkflowRun(wh GitHubWorkflowRun) Pipeline
ParseGitHubWorkflowRun converts a GitHub Actions workflow_run webhook payload into our Pipeline type.
func ParseGitLabPipeline ¶
func ParseGitLabPipeline(ev GitLabPipelineEvent) Pipeline
ParseGitLabPipeline converts a GitLab Pipeline Hook payload into our Pipeline type, mirroring ParseGitHubWorkflowRun.
type Store ¶
type Store interface {
SavePipeline(p Pipeline) error
GetPipeline(id string) (*Pipeline, error)
ListPipelines(limit int) []Pipeline
SaveTestResults(pipelineID string, results []TestResult) error
GetTestResults(pipelineID string) ([]TestResult, error)
Summary() CISummary
}
Store defines the interface for CI/CD pipeline and test result persistence.
type TestResult ¶
type TestResult struct {
PipelineID string `json:"pipeline_id"`
Suite string `json:"suite"`
Name string `json:"name"`
Status string `json:"status"` // "passed", "failed", "skipped"
DurationMs float64 `json:"duration_ms"`
Error string `json:"error,omitempty"`
}
TestResult represents a single test result within a pipeline run.