-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(core): add id, start and end time to lifecycle hooks #32583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
973825d
2671af6
7d92e48
ba957a5
7573182
e409e9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import type { ProjectGraph } from '../../config/project-graph'; | ||
| import { readNxJson, type PluginConfiguration } from '../../config/nx-json'; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are unused |
||
| import { type PluginConfiguration } from '../../config/nx-json'; | ||
| import { | ||
| AggregateCreateNodesError, | ||
| isAggregateCreateNodesError, | ||
|
|
@@ -15,7 +15,6 @@ import type { | |
| PreTasksExecutionContext, | ||
| ProjectsMetadata, | ||
| } from './public-api'; | ||
| import { createNodesFromFiles } from './utils'; | ||
| import { isIsolationEnabled } from './isolation/enabled'; | ||
| import { isDaemonEnabled } from '../../daemon/client/client'; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,15 +190,19 @@ export type NxPluginV2<TOptions = unknown> = { | |
| }; | ||
|
|
||
| export type PreTasksExecutionContext = { | ||
| readonly taskId: string; | ||
|
||
| readonly workspaceRoot: string; | ||
| readonly nxJsonConfiguration: NxJsonConfiguration; | ||
| readonly argv: string[]; | ||
| }; | ||
| export type PostTasksExecutionContext = { | ||
| readonly taskId: string; | ||
| readonly workspaceRoot: string; | ||
| readonly nxJsonConfiguration: NxJsonConfiguration; | ||
| readonly taskResults: TaskResults; | ||
| readonly argv: string[]; | ||
| readonly startTime: number; | ||
| readonly endTime: number; | ||
| }; | ||
|
|
||
| export type PreTasksExecution<TOptions = unknown> = ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,14 +22,6 @@ export interface TaskMetadata { | |
| groupId: number; | ||
| } | ||
|
|
||
| interface RustRunningTask extends RunningTask { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was unused |
||
| getResults(): Promise<{ code: number; terminalOutput: string }>; | ||
|
|
||
| onExit(cb: (code: number, terminalOutput: string) => void): void; | ||
|
|
||
| kill(signal?: NodeJS.Signals): Promise<void> | void; | ||
| } | ||
|
|
||
| export interface LifeCycle { | ||
| startCommand?(parallel?: number): void | Promise<void>; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ import { | |
| getTaskDetails, | ||
| hashTasksThatDoNotDependOnOutputsOfOtherTasks, | ||
| } from '../hasher/hash-task'; | ||
| import { logDebug, RunMode } from '../native'; | ||
| import { hashArray, logDebug, RunMode } from '../native'; | ||
| import { | ||
| runPostTasksExecution, | ||
| runPreTasksExecution, | ||
|
|
@@ -68,6 +68,7 @@ import { TasksRunner, TaskStatus } from './tasks-runner'; | |
| import { shouldStreamOutput } from './utils'; | ||
| import { signalToCode } from '../utils/exit-codes'; | ||
| import chalk = require('chalk'); | ||
| import { randomUUID } from 'node:crypto'; | ||
|
||
|
|
||
| const originalStdoutWrite = process.stdout.write.bind(process.stdout); | ||
| const originalStderrWrite = process.stderr.write.bind(process.stderr); | ||
|
|
@@ -133,8 +134,6 @@ async function getTerminalOutputLifeCycle( | |
| const isRunOne = initiatingProject != null; | ||
|
|
||
| const pinnedTasks: string[] = []; | ||
| const taskText = tasks.length === 1 ? 'task' : 'tasks'; | ||
| const projectText = projectNames.length === 1 ? 'project' : 'projects'; | ||
| let titleText = ''; | ||
|
|
||
| if (isRunOne) { | ||
|
|
@@ -439,12 +438,15 @@ export async function runCommand( | |
| const status = await handleErrors( | ||
| process.env.NX_VERBOSE_LOGGING === 'true', | ||
| async () => { | ||
| const taskId = hashArray([...process.argv, Date.now().toString()]); | ||
| await runPreTasksExecution({ | ||
| taskId, | ||
| workspaceRoot, | ||
| nxJsonConfiguration: nxJson, | ||
| argv: process.argv, | ||
| }); | ||
|
|
||
| const startTime = Date.now(); | ||
| const { taskResults, completed } = await runCommandForTasks( | ||
| projectsToRun, | ||
| currentProjectGraph, | ||
|
|
@@ -461,6 +463,7 @@ export async function runCommand( | |
| extraTargetDependencies, | ||
| extraOptions | ||
| ); | ||
| const endTime = Date.now(); | ||
|
|
||
| const exitCode = !completed | ||
| ? signalToCode('SIGINT') | ||
|
|
@@ -472,10 +475,13 @@ export async function runCommand( | |
| : 0; | ||
|
|
||
| await runPostTasksExecution({ | ||
| taskId, | ||
| taskResults, | ||
| workspaceRoot, | ||
| nxJsonConfiguration: nxJson, | ||
| argv: process.argv, | ||
| startTime, | ||
| endTime, | ||
| }); | ||
|
|
||
| return exitCode; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call this a
tasksExecutionIdorexecutionId... or even just id. Just definitely nottask.id