File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,32 @@ import {readFile} from 'fs/promises';
22import { parse } from 'yaml' ;
33
44export interface Workflow {
5+ // The friendly name of the workflow.
56 name : string ;
7+ // The set of commands to run under timing test for the workflow.
68 workflow : string [ ] ;
9+ // The set of commands to run in preparation for the workflow.
710 prepare ?: string [ ] ;
11+ // The set of commands to run as a cleanup.
812 cleanup ?: string [ ] ;
13+ // Whether the workflow is temporarily disabled.
14+ disabled ?: true ;
915}
1016
1117export async function loadWorkflows ( src : string ) {
18+ /** The set of workflows which can be executed. */
19+ const filteredWorkflows : { [ key : string ] : Workflow } = { } ;
20+ /** The workflow configuration file content as a string. */
1221 const rawWorkflows = await readFile ( src , { encoding : 'utf-8' } ) ;
13- return parse ( rawWorkflows ) . workflows as { [ key : string ] : Workflow } ;
22+ /** The object parsed from the workflow configuration file, holding the workflow configurations. */
23+ const workflows = parse ( rawWorkflows ) . workflows as { [ key : string ] : Workflow } ;
24+
25+ // Remove any workflow which is marked as disabled.
26+ for ( const [ name , workflow ] of Object . entries ( workflows ) ) {
27+ if ( workflow . disabled !== true ) {
28+ filteredWorkflows [ name ] = workflow ;
29+ }
30+ }
31+
32+ return filteredWorkflows ;
1433}
You can’t perform that action at this time.
0 commit comments