Documentation
¶
Overview ¶
Package ingot provides the data model and persistence layer for Ingots.
An Ingot is a compound record that bundles a bead, PR, worker lifecycle, and structured test results into a single queryable record.
Index ¶
- func InsertIngot(db *sql.DB, ingot *Ingot) error
- func InsertTestResult(db *sql.DB, tr *TestResult) error
- func UpdateIngotPR(db *sql.DB, beadID, anvil string, prNum int, prURL string, prID *int) error
- func UpdateIngotStatus(db *sql.DB, beadID, anvil string, status Status) error
- func UpdateIngotTemperResults(db *sql.DB, beadID, anvil string, passed bool, failedStep string, ...) error
- type Ingot
- type Status
- type TestResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InsertIngot ¶
InsertIngot inserts a new ingot row. It sets CreatedAt and UpdatedAt to now and writes the generated ID back to ingot.ID.
func InsertTestResult ¶
func InsertTestResult(db *sql.DB, tr *TestResult) error
InsertTestResult inserts a test result row, setting RecordedAt to now if it is zero. It writes the generated ID back to tr.ID.
func UpdateIngotPR ¶
UpdateIngotPR updates pr_number, pr_url, pr_id, and updated_at. prID may be nil when the internal PR row has not yet been resolved, in which case the column is stored as NULL to avoid a FK violation.
func UpdateIngotStatus ¶
UpdateIngotStatus updates the status and updated_at of the ingot identified by (beadID, anvil).
Types ¶
type Ingot ¶
type Ingot struct {
ID int `json:"id"`
BeadID string `json:"bead_id"`
Anvil string `json:"anvil"`
PRID *int `json:"pr_id,omitempty"` // FK to prs.id, NULL until PR created
WorkerID string `json:"worker_id"`
Status Status `json:"status"`
TemperPassed bool `json:"temper_passed"`
TemperFailedStep string `json:"temper_failed_step,omitempty"`
TemperDurationMs int `json:"temper_duration_ms"`
PRNumber *int `json:"pr_number,omitempty"` // GitHub PR number
PRURL string `json:"pr_url,omitempty"`
Title string `json:"title"`
Branch string `json:"branch"`
TestResults []TestResult `json:"test_results,omitempty"` // eager-loaded
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Ingot bundles a bead, PR, worker lifecycle, and test results into a single queryable record.
func GetIngot ¶
GetIngot fetches a single ingot by (beadID, anvil), eager-loading its TestResults. Returns nil, nil if not found.
func GetIngotByBeadID ¶
GetIngotByBeadID fetches all ingots matching beadID across any anvil, ordered deterministically by anvil name. Returns (nil, nil) when not found. When multiple rows are returned the caller should ask the user to supply --anvil to disambiguate.
type TestResult ¶
type TestResult struct {
ID int `json:"id"`
IngotID int `json:"ingot_id"`
StepIndex int `json:"step_index"`
StepName string `json:"step_name"`
Command string `json:"command"`
ExitCode int `json:"exit_code"`
DurationMs int `json:"duration_ms"`
Passed bool `json:"passed"`
Optional bool `json:"optional"`
OutputSummary string `json:"output_summary,omitempty"` // first ~1000 chars or key errors
FullOutputPath string `json:"full_output_path,omitempty"`
RecordedAt time.Time `json:"recorded_at"`
}
TestResult stores the outcome of a single temper step for an ingot.
func GetTestResults ¶
func GetTestResults(db *sql.DB, ingotID int) ([]TestResult, error)
GetTestResults fetches all test results for an ingot ordered by step_index.