MCPcopy
hub / github.com/nektos/act / NewWorkflowPlanner

Function NewWorkflowPlanner

pkg/model/planner.go:59–158  ·  view source on GitHub ↗

NewWorkflowPlanner will load a specific workflow, all workflows from a directory or all workflows from a directory and its subdirectories

(path string, noWorkflowRecurse, strict bool)

Source from the content-addressed store, hash-verified

57
58// NewWorkflowPlanner will load a specific workflow, all workflows from a directory or all workflows from a directory and its subdirectories
59func NewWorkflowPlanner(path string, noWorkflowRecurse, strict bool) (WorkflowPlanner, error) {
60 path, err := filepath.Abs(path)
61 if err != nil {
62 return nil, err
63 }
64
65 fi, err := os.Stat(path)
66 if err != nil {
67 return nil, err
68 }
69
70 var workflows []WorkflowFiles
71
72 if fi.IsDir() {
73 log.Debugf("Loading workflows from '%s'", path)
74 if noWorkflowRecurse {
75 files, err := os.ReadDir(path)
76 if err != nil {
77 return nil, err
78 }
79
80 for _, v := range files {
81 workflows = append(workflows, WorkflowFiles{
82 dirPath: path,
83 workflowDirEntry: v,
84 })
85 }
86 } else {
87 log.Debug("Loading workflows recursively")
88 if err := filepath.Walk(path,
89 func(p string, f os.FileInfo, err error) error {
90 if err != nil {
91 return err
92 }
93
94 if !f.IsDir() {
95 log.Debugf("Found workflow '%s' in '%s'", f.Name(), p)
96 workflows = append(workflows, WorkflowFiles{
97 dirPath: filepath.Dir(p),
98 workflowDirEntry: fs.FileInfoToDirEntry(f),
99 })
100 }
101
102 return nil
103 }); err != nil {
104 return nil, err
105 }
106 }
107 } else {
108 log.Debugf("Loading workflow '%s'", path)
109 dirname := filepath.Dir(path)
110
111 workflows = append(workflows, WorkflowFiles{
112 dirPath: dirname,
113 workflowDirEntry: fs.FileInfoToDirEntry(fi),
114 })
115 }
116

Callers 12

TestGraphMissingEventFunction · 0.92
TestGraphMissingFirstFunction · 0.92
TestGraphWithMissingFunction · 0.92
TestGraphWithSomeMissingFunction · 0.92
TestGraphEventFunction · 0.92
runTestMethod · 0.92
runTestJobFileFunction · 0.92
newRunCommandFunction · 0.92
TestPlannerFunction · 0.85

Calls 7

ReadWorkflowFunction · 0.85
validateJobNameFunction · 0.85
IsDirMethod · 0.80
NameMethod · 0.80
WalkMethod · 0.65
OpenMethod · 0.65
CloseMethod · 0.65

Tested by 10

TestGraphMissingEventFunction · 0.74
TestGraphMissingFirstFunction · 0.74
TestGraphWithMissingFunction · 0.74
TestGraphWithSomeMissingFunction · 0.74
TestGraphEventFunction · 0.74
runTestMethod · 0.74
runTestJobFileFunction · 0.74
TestPlannerFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…