graph

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2025 License: MIT Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentBranch

func GetCurrentBranch(workspaceRoot string) (string, error)

GetCurrentBranch returns the current git branch.

func GetDefaultBranch

func GetDefaultBranch(workspaceRoot string) string

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

func (d *AffectedDetector) GetAffectedProjects(base string, head string) ([]*api.Project, error)

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

func (g *TaskGraph) AddDependency(from, to TaskID) error

AddDependency adds a dependency between tasks.

func (*TaskGraph) AddTask

func (g *TaskGraph) AddTask(project *api.Project, task api.Task) TaskID

AddTask adds a task to the graph.

func (*TaskGraph) AllComplete

func (g *TaskGraph) AllComplete() bool

AllComplete returns true if all tasks are complete.

func (*TaskGraph) GetReadyTasks

func (g *TaskGraph) GetReadyTasks() []*TaskNode

GetReadyTasks returns tasks that are ready to execute.

func (*TaskGraph) GetStats

func (g *TaskGraph) GetStats() TaskStats

GetStats returns execution statistics.

func (*TaskGraph) GetTask

func (g *TaskGraph) GetTask(id TaskID) (*TaskNode, bool)

GetTask returns a task node by ID.

func (*TaskGraph) HasFailures

func (g *TaskGraph) HasFailures() bool

HasFailures returns true if any task failed.

func (*TaskGraph) Nodes

func (g *TaskGraph) Nodes() []*TaskNode

Nodes returns all task nodes.

func (*TaskGraph) SetCached

func (g *TaskGraph) SetCached(id TaskID, cached bool)

SetCached marks a task as cached.

func (*TaskGraph) SetHash

func (g *TaskGraph) SetHash(id TaskID, hash string)

SetHash updates the hash of a task.

func (*TaskGraph) SetStatus

func (g *TaskGraph) SetStatus(id TaskID, status TaskStatus)

SetStatus updates the status of a task.

func (*TaskGraph) Size

func (g *TaskGraph) Size() int

Size returns the number of tasks.

func (*TaskGraph) TopologicalSort

func (g *TaskGraph) TopologicalSort() ([]TaskID, error)

TopologicalSort returns tasks in dependency order.

type TaskID

type TaskID struct {
	Project string
	Task    string
}

TaskID uniquely identifies a task.

func (TaskID) String

func (t TaskID) String() string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL