MCPcopy Create free account
hub / github.com/angular/dev-infra / measureWorkflow

Function measureWorkflow

ng-dev/perf/workflow/workflow.ts:5–43  ·  view source on GitHub ↗
({name, workflow, prepare, cleanup}: Workflow)

Source from the content-addressed store, hash-verified

3import path from 'path';
4import {getBazelBin} from '../../utils/bazel-bin.js';
5import {ChildProcess} from '../../utils/child-process.js';
6import {
7 getExcludedDirsForCwd,
8 getPathFromEnvironment,
9 resolveSafeExecutable,
10} from '../../utils/environment.js';
11import {Spinner} from '../../utils/spinner.js';
12import {Workflow} from './loader.js';
13
14export async function measureWorkflow({name, workflow, prepare, cleanup}: Workflow) {
15 const spinner = new Spinner();
16 const bazelShimDir = createFallbackBazelBinDir();
17 const commandEnv = bazelShimDir
18 ? {
19 ...process.env,
20 PATH: [bazelShimDir, getPathFromEnvironment(process.env)]
21 .filter(Boolean)
22 .join(path.delimiter),
23 }
24 : undefined;
25
26 try {
27 if (prepare) {
28 spinner.update('Preparing environment for workflow execution');
29 // Run the `prepare` commands to establish the environment, caching, etc prior to running the
30 // workflow.
31 await runCommands(prepare, commandEnv);
32 spinner.update('Environment preperation completed');
33 }
34
35 spinner.update(`Executing workflow (${name})`);
36 // Mark the start time of the workflow, execute all of the commands provided in the workflow and
37 // then mark the ending time.
38 performance.mark('start');
39 await runCommands(workflow, commandEnv);
40 performance.mark('end');
41
42 spinner.update('Workflow completed');
43
44 if (cleanup) {
45 spinner.update('Cleaning up environment after workflow');
46 // Run the clean up commands to reset the environment and undo changes made during the workflow.

Callers 1

handlerFunction · 0.85

Calls 4

updateMethod · 0.95
successMethod · 0.95
completeMethod · 0.95
runCommandsFunction · 0.85

Tested by

no test coverage detected