MCPcopy Create free account
hub / github.com/actions/starter-workflows / checkWorkflows

Function checkWorkflows

script/validate-data/index.ts:44–71  ·  view source on GitHub ↗
(folders: string[], allowed_categories: object[])

Source from the content-addressed store, hash-verified

42}
43
44async function checkWorkflows(folders: string[], allowed_categories: object[]): Promise<WorkflowWithErrors[]> {
45 const result: WorkflowWithErrors[] = []
46 const workflow_template_names = new Set()
47 for (const folder of folders) {
48 const dir = await fs.readdir(folder, {
49 withFileTypes: true,
50 });
51
52 for (const e of dir) {
53 if (e.isFile() && [".yml", ".yaml"].includes(extname(e.name))) {
54 const fileType = basename(e.name, extname(e.name))
55
56 const workflowFilePath = join(folder, e.name);
57 const propertiesFilePath = join(folder, "properties", `${fileType}.properties.json`)
58
59 const workflowWithErrors = await checkWorkflow(workflowFilePath, propertiesFilePath, allowed_categories);
60 if(workflowWithErrors.name && workflow_template_names.size == workflow_template_names.add(workflowWithErrors.name).size) {
61 workflowWithErrors.errors.push(`Workflow template name "${workflowWithErrors.name}" already exists`)
62 }
63 if (workflowWithErrors.errors.length > 0) {
64 result.push(workflowWithErrors)
65 }
66 }
67 }
68 }
69
70 return result;
71}
72
73async function checkWorkflow(workflowPath: string, propertiesPath: string, allowed_categories: object[]): Promise<WorkflowWithErrors> {
74 let workflowErrors: WorkflowWithErrors = {

Callers 1

index.tsFile · 0.70

Calls 1

checkWorkflowFunction · 0.70

Tested by

no test coverage detected