Documentation
¶
Overview ¶
Package graph provides affected project detection for monox.
Package graph provides dependency graph construction and analysis for monox.
Package graph provides task graph construction and scheduling for monox.
Index ¶
- func GetCurrentBranch(workspaceRoot string) (string, error)
- func GetDefaultBranch(workspaceRoot string) string
- type AffectedDetector
- func (d *AffectedDetector) GetAffectedByFiles(files []string) []*api.Project
- func (d *AffectedDetector) GetAffectedGraph(base string, head string) (*ProjectGraph, error)
- func (d *AffectedDetector) GetAffectedProjects(base string, head string) ([]*api.Project, error)
- func (d *AffectedDetector) GetChangedFilesSinceBranch(base string) ([]string, error)
- func (d *AffectedDetector) IsProjectAffected(projectName string, base string, head string) (bool, error)
- type ProjectGraph
- func (g *ProjectGraph) AddDependency(from, to string) error
- func (g *ProjectGraph) AddProject(project *api.Project)
- func (g *ProjectGraph) DetectCycles() [][]string
- func (g *ProjectGraph) Filter(names []string) *ProjectGraph
- func (g *ProjectGraph) GetAllDependencies(name string) []string
- func (g *ProjectGraph) GetAllDependents(name string) []string
- func (g *ProjectGraph) GetDependencies(name string) []string
- func (g *ProjectGraph) GetDependents(name string) []string
- func (g *ProjectGraph) GetProject(name string) (*api.Project, bool)
- func (g *ProjectGraph) Projects() []*api.Project
- func (g *ProjectGraph) Size() int
- func (g *ProjectGraph) Subgraph(name string, includeDependents bool) *ProjectGraph
- func (g *ProjectGraph) TopologicalSort() ([]string, error)
- type TaskGraph
- func (g *TaskGraph) AddDependency(from, to TaskID) error
- func (g *TaskGraph) AddTask(project *api.Project, task api.Task) TaskID
- func (g *TaskGraph) AllComplete() bool
- func (g *TaskGraph) GetReadyTasks() []*TaskNode
- func (g *TaskGraph) GetStats() TaskStats
- func (g *TaskGraph) GetTask(id TaskID) (*TaskNode, bool)
- func (g *TaskGraph) HasFailures() bool
- func (g *TaskGraph) Nodes() []*TaskNode
- func (g *TaskGraph) SetCached(id TaskID, cached bool)
- func (g *TaskGraph) SetHash(id TaskID, hash string)
- func (g *TaskGraph) SetStatus(id TaskID, status TaskStatus)
- func (g *TaskGraph) Size() int
- func (g *TaskGraph) TopologicalSort() ([]TaskID, error)
- type TaskID
- type TaskNode
- type TaskStats
- type TaskStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCurrentBranch ¶
GetCurrentBranch returns the current git branch.
func GetDefaultBranch ¶
GetDefaultBranch returns the default branch (main or master).
Types ¶
type AffectedDetector ¶
type AffectedDetector struct {
// contains filtered or unexported fields
}
AffectedDetector detects projects affected by changes.
func NewAffectedDetector ¶
func NewAffectedDetector(workspaceRoot string, projectGraph *ProjectGraph) *AffectedDetector
NewAffectedDetector creates a new affected detector.
func (*AffectedDetector) GetAffectedByFiles ¶
func (d *AffectedDetector) GetAffectedByFiles(files []string) []*api.Project
GetAffectedByFiles returns projects affected by specific files.
func (*AffectedDetector) GetAffectedGraph ¶
func (d *AffectedDetector) GetAffectedGraph(base string, head string) (*ProjectGraph, error)
GetAffectedGraph returns a project graph of only affected projects.
func (*AffectedDetector) GetAffectedProjects ¶
GetAffectedProjects returns projects affected by changes since the base ref.
func (*AffectedDetector) GetChangedFilesSinceBranch ¶
func (d *AffectedDetector) GetChangedFilesSinceBranch(base string) ([]string, error)
GetChangedFilesSinceBranch returns files changed since branching from base.
func (*AffectedDetector) IsProjectAffected ¶
func (d *AffectedDetector) IsProjectAffected(projectName string, base string, head string) (bool, error)
IsProjectAffected checks if a specific project is affected.
type ProjectGraph ¶
type ProjectGraph struct {
// contains filtered or unexported fields
}
ProjectGraph represents the dependency graph between projects.
func BuildFromWorkspace ¶
func BuildFromWorkspace(projects map[string]*api.Project) (*ProjectGraph, error)
BuildFromWorkspace constructs a project graph from workspace projects.
func NewProjectGraph ¶
func NewProjectGraph() *ProjectGraph
NewProjectGraph creates a new project dependency graph.
func (*ProjectGraph) AddDependency ¶
func (g *ProjectGraph) AddDependency(from, to string) error
AddDependency adds a dependency edge between projects.
func (*ProjectGraph) AddProject ¶
func (g *ProjectGraph) AddProject(project *api.Project)
AddProject adds a project to the graph.
func (*ProjectGraph) DetectCycles ¶
func (g *ProjectGraph) DetectCycles() [][]string
DetectCycles returns any cycles found in the graph.
func (*ProjectGraph) Filter ¶
func (g *ProjectGraph) Filter(names []string) *ProjectGraph
Filter returns a new graph containing only the specified projects.
func (*ProjectGraph) GetAllDependencies ¶
func (g *ProjectGraph) GetAllDependencies(name string) []string
GetAllDependencies returns all transitive dependencies of a project.
func (*ProjectGraph) GetAllDependents ¶
func (g *ProjectGraph) GetAllDependents(name string) []string
GetAllDependents returns all transitive dependents of a project.
func (*ProjectGraph) GetDependencies ¶
func (g *ProjectGraph) GetDependencies(name string) []string
GetDependencies returns the dependencies of a project.
func (*ProjectGraph) GetDependents ¶
func (g *ProjectGraph) GetDependents(name string) []string
GetDependents returns the projects that depend on the given project.
func (*ProjectGraph) GetProject ¶
func (g *ProjectGraph) GetProject(name string) (*api.Project, bool)
GetProject returns a project by name.
func (*ProjectGraph) Projects ¶
func (g *ProjectGraph) Projects() []*api.Project
Projects returns all projects in the graph.
func (*ProjectGraph) Size ¶
func (g *ProjectGraph) Size() int
Size returns the number of projects in the graph.
func (*ProjectGraph) Subgraph ¶
func (g *ProjectGraph) Subgraph(name string, includeDependents bool) *ProjectGraph
Subgraph returns a subgraph containing the project and all its dependencies.
func (*ProjectGraph) TopologicalSort ¶
func (g *ProjectGraph) TopologicalSort() ([]string, error)
TopologicalSort returns projects in dependency order (dependencies first).
type TaskGraph ¶
type TaskGraph struct {
// contains filtered or unexported fields
}
TaskGraph represents the execution graph of tasks.
func BuildTaskGraph ¶
func BuildTaskGraph(projectGraph *ProjectGraph, taskNames []string, projects []*api.Project, taskConfig map[string]api.TaskPipelineConfig) (*TaskGraph, error)
BuildTaskGraph constructs a task graph for running tasks on projects.
func NewTaskGraph ¶
func NewTaskGraph(projectGraph *ProjectGraph) *TaskGraph
NewTaskGraph creates a new task graph.
func (*TaskGraph) AddDependency ¶
AddDependency adds a dependency between tasks.
func (*TaskGraph) AllComplete ¶
AllComplete returns true if all tasks are complete.
func (*TaskGraph) GetReadyTasks ¶
GetReadyTasks returns tasks that are ready to execute.
func (*TaskGraph) HasFailures ¶
HasFailures returns true if any task failed.
func (*TaskGraph) SetStatus ¶
func (g *TaskGraph) SetStatus(id TaskID, status TaskStatus)
SetStatus updates the status of a task.
func (*TaskGraph) TopologicalSort ¶
TopologicalSort returns tasks in dependency order.
type TaskNode ¶
type TaskNode struct {
ID TaskID
Project *api.Project
Task api.Task
Dependencies []TaskID
Status TaskStatus
Hash string
Cached bool
}
TaskNode represents a task in the task graph.
type TaskStats ¶
type TaskStats struct {
Total int
Pending int
Running int
Completed int
Failed int
Skipped int
Cached int
}
TaskStats holds task execution statistics.
type TaskStatus ¶
type TaskStatus int
TaskStatus represents the execution status of a task.
const ( TaskPending TaskStatus = iota TaskRunning TaskCompleted TaskFailed TaskSkipped TaskCached )
func (TaskStatus) String ¶
func (s TaskStatus) String() string