rdev/internal/domain/ci.go

140 lines
3.1 KiB
Go

// Package domain contains core business entities.
package domain
import "time"
// CIRepo represents a repository's CI/CD configuration.
type CIRepo struct {
// ID is the CI system's internal ID for this repo
ID int64
// ForgeRemoteID is the ID from the forge (e.g., Gitea repo ID)
ForgeRemoteID int64
// Owner is the repository owner (org or user)
Owner string
// Name is the repository name
Name string
// FullName is owner/name
FullName string
// CloneURL is the URL to clone the repo
CloneURL string
// Active indicates if CI is enabled for this repo
Active bool
// AllowPullRequests allows PRs to trigger builds
AllowPullRequests bool
// Visibility: public, private, internal
Visibility string
// CreatedAt is when CI was activated
CreatedAt time.Time
// UpdatedAt is when CI config was last modified
UpdatedAt time.Time
}
// CISecret represents a secret for use in CI pipelines.
type CISecret struct {
// Name is the secret name (e.g., "DOCKER_PASSWORD")
Name string
// Value is the secret value (encrypted at rest)
Value string
// Events controls when the secret is available (e.g., "push", "pull_request")
Events []string
// Images limits which container images can use this secret
Images []string
}
// CIPipelineError represents an error from the CI system.
type CIPipelineError struct {
// Type: linter, deprecation, compiler, generic, bad_habit
Type string `json:"type"`
// Message is the error description
Message string `json:"message"`
// IsWarning indicates this is a warning, not a fatal error
IsWarning bool `json:"is_warning"`
}
// CIPipeline represents a CI pipeline execution.
type CIPipeline struct {
// ID is the pipeline ID
ID int64
// Number is the pipeline number (increments per repo)
Number int64
// Status: pending, running, success, failure, killed, blocked, error
Status string
// Event: push, pull_request, tag, cron, manual
Event string
// Branch that triggered the pipeline
Branch string
// Commit SHA
Commit string
// Message is the commit message
Message string
// Author who triggered the pipeline
Author string
// Started timestamp
Started time.Time
// Finished timestamp (zero if still running)
Finished time.Time
// Errors contains any pipeline errors (e.g., YAML validation failures)
Errors []CIPipelineError
}
// CIPipelineStep represents a step within a CI pipeline.
type CIPipelineStep struct {
// ID is the step's unique ID (used for fetching logs)
ID int64
// Name is the step name from the pipeline config
Name string
// Status: pending, running, success, failure, killed, skipped, error
Status string
// ExitCode from the step's command (nil if not finished)
ExitCode *int
// Duration in seconds
Duration int
// Error message if step failed
Error string
// Log contains the last N lines of output (only populated for failed steps)
Log string
}
// CIPipelineSteps contains step details for a pipeline.
type CIPipelineSteps struct {
// PipelineNumber is the pipeline number
PipelineNumber int64
// URL is the direct link to view this pipeline in the CI UI
URL string
// Steps in execution order
Steps []CIPipelineStep
}