Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion ng-dev/perf/workflow/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@ import {readFile} from 'fs/promises';
import {parse} from 'yaml';

export interface Workflow {
// The friendly name of the workflow.
name: string;
// The set of commands to run under timing test for the workflow.
workflow: string[];
// The set of commands to run in preparation for the workflow.
prepare?: string[];
// The set of commands to run as a cleanup.
cleanup?: string[];
// Whether the workflow is temporarily disabled.
disabled?: true;
}

export async function loadWorkflows(src: string) {
/** The set of workflows which can be executed. */
const filteredWorkflows: {[key: string]: Workflow} = {};
/** The workflow configuration file content as a string. */
const rawWorkflows = await readFile(src, {encoding: 'utf-8'});
return parse(rawWorkflows).workflows as {[key: string]: Workflow};
/** The object parsed from the workflow configuration file, holding the workflow configurations. */
const workflows = parse(rawWorkflows).workflows as {[key: string]: Workflow};

// Remove any workflow which is marked as disabled.
for (const [name, workflow] of Object.entries(workflows)) {
if (workflow.disabled !== true) {
filteredWorkflows[name] = workflow;
}
}

return filteredWorkflows;
}
Loading