diff --git a/tooling/measures/nx-performance/audit/project-task.audit.ts b/tooling/measures/nx-performance/audit/project-task.audit.ts index 2160bf5d..e65cc88a 100644 --- a/tooling/measures/nx-performance/audit/project-task.audit.ts +++ b/tooling/measures/nx-performance/audit/project-task.audit.ts @@ -1,9 +1,5 @@ import { AuditOutput, Audit, Table, Issue } from '@code-pushup/models'; -import { - executeProcess, - slugify, - formatDuration, -} from '@code-pushup/utils'; +import { executeProcess, slugify, formatDuration } from '@code-pushup/utils'; import { logger, readJsonFile } from '@nx/devkit'; import { DEFAULT_PLUGIN_OUTPUT } from '../constant'; import { join } from 'node:path'; @@ -102,7 +98,7 @@ export async function projectTaskCacheSizeData( }; }); - const { project, target } = task.split(':'); + const [project, target] = task.split(':'); results.push({ data: { title: `Task time for ${task}`, diff --git a/tooling/measures/nx-performance/audit/task-graph.audit.ts b/tooling/measures/nx-performance/audit/task-graph.audit.ts index 92425004..71de07c3 100644 --- a/tooling/measures/nx-performance/audit/task-graph.audit.ts +++ b/tooling/measures/nx-performance/audit/task-graph.audit.ts @@ -1,6 +1,8 @@ import { Audit, AuditOutputs } from '@code-pushup/models'; import { execFile } from 'node:child_process'; import { slugify } from '@code-pushup/utils'; +import { promisify } from 'node:util'; +import { join } from 'node:path'; export const DEFAULT_MAX_TASK_GRAPH_TIME = 300; export const TASK_GRAPH_TIME_AUDIT_POSTFIX = 'graph-time-task'; @@ -25,8 +27,10 @@ export type TaskGraphAuditOptions = { export async function taskGraphAudits( options?: TaskGraphAuditOptions ): Promise { - const { maxTaskGraphTime = DEFAULT_MAX_TASK_GRAPH_TIME, taskGraphTasks } = - options ?? {}; + const { + maxTaskGraphTime = DEFAULT_MAX_TASK_GRAPH_TIME, + taskGraphTasks = [], + } = options ?? {}; const results = await taskGraphTiming(taskGraphTasks); return results.map(({ duration, task }) => ({ @@ -54,10 +58,28 @@ export async function taskGraphTiming( tasks: string[] ): Promise<{ duration: number; task: string }[]> { const results: { duration: number; task: string }[] = []; + const isWindows = process.platform === 'win32'; for (const task of tasks) { const start = performance.now(); - execFile( - `NX_DAEMON=true NX_CACHE_PROJECT_GRAPH=false NX_ISOLATE_PLUGINS=true npx nx run-many -t ${task} --graph tmp/nx-performance/task-graph/${task}.graph.json` + await promisify(execFile)( + 'npx', + [ + 'nx', + 'run-many', + '-t', + task, + '--graph', + join('tmp', 'nx-performance', 'task-graph', `${task}.graph.json`), + ], + { + shell: isWindows, + env: { + ...process.env, + NX_CACHE_PROJECT_GRAPH: 'false', + NX_ISOLATE_PLUGINS: 'true', + NX_DAEMON: 'false', + }, + } ); const execFileDuration = Number((performance.now() - start).toFixed(3)); results.push({