Skip to content

Commit

Permalink
fix(audit): improve project graph audit execution
Browse files Browse the repository at this point in the history
  • Loading branch information
getlarge committed Sep 19, 2024
1 parent 8e7e089 commit 4c8def6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 12 additions & 3 deletions tooling/measures/nx-performance/audit/project-graph.audit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AuditOutput } from '@code-pushup/models';
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';

export const DEFAULT_MAX_PROJECT_GRAPH_TIME = 300;

Expand Down Expand Up @@ -44,9 +45,17 @@ export function scoreProjectGraphDuration(

export async function projectGraphTiming(): Promise<{ duration: number }> {
const start = performance.now();
execFile(
'NX_DAEMON=true NX_CACHE_PROJECT_GRAPH=false NX_ISOLATE_PLUGINS=true npx nx show projects'
);
const isWindows = process.platform === 'win32';
await promisify(execFile)('npx nx show projects', {
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));
return { duration: Number(execFileDuration.toFixed(3)) };
}
3 changes: 1 addition & 2 deletions tooling/measures/nx-performance/audit/project-task.audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
executeProcess,
slugify,
formatDuration,
formatBytes,
} from '@code-pushup/utils';
import { logger, readJsonFile } from '@nx/devkit';
import { DEFAULT_PLUGIN_OUTPUT } from '../constant';
Expand Down Expand Up @@ -33,7 +32,7 @@ export type ProjectTaskAuditOptions = {
export async function taskTimeAudits(
options?: ProjectTaskAuditOptions
): Promise<AuditOutput[]> {
const { taskTimeTasks, maxTaskTime = DEFAULT_MAX_PROJECT_TARGET_TIME } =
const { taskTimeTasks = [], maxTaskTime = DEFAULT_MAX_PROJECT_TARGET_TIME } =
options ?? {};

// Get the timings for each task
Expand Down

0 comments on commit 4c8def6

Please sign in to comment.