fix(core): move getDetails to top (#28158)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes https://github.com/nrwl/nx/issues/28035
This commit is contained in:
parent
153451f32b
commit
1a4959f9a7
@ -5,12 +5,12 @@ import { getInputs, TaskHasher } from './task-hasher';
|
|||||||
import { ProjectGraph } from '../config/project-graph';
|
import { ProjectGraph } from '../config/project-graph';
|
||||||
import { NxJsonConfiguration } from '../config/nx-json';
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
import { readNxJson } from '../config/nx-json';
|
import { readNxJson } from '../config/nx-json';
|
||||||
import { IS_WASM, TaskDetails } from '../native';
|
import { HashedTask, IS_WASM, TaskDetails } from '../native';
|
||||||
import { getDbConnection } from '../utils/db-connection';
|
import { getDbConnection } from '../utils/db-connection';
|
||||||
|
|
||||||
let taskDetails: TaskDetails;
|
let taskDetails: TaskDetails;
|
||||||
|
|
||||||
function getTaskDetails() {
|
export function getTaskDetails(): TaskDetails | null {
|
||||||
// TODO: Remove when wasm supports sqlite
|
// TODO: Remove when wasm supports sqlite
|
||||||
if (process.env.NX_DISABLE_DB === 'true' || IS_WASM) {
|
if (process.env.NX_DISABLE_DB === 'true' || IS_WASM) {
|
||||||
return null;
|
return null;
|
||||||
@ -25,12 +25,11 @@ export async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(
|
|||||||
hasher: TaskHasher,
|
hasher: TaskHasher,
|
||||||
projectGraph: ProjectGraph,
|
projectGraph: ProjectGraph,
|
||||||
taskGraph: TaskGraph,
|
taskGraph: TaskGraph,
|
||||||
nxJson: NxJsonConfiguration
|
nxJson: NxJsonConfiguration,
|
||||||
|
tasksDetails: TaskDetails | null
|
||||||
) {
|
) {
|
||||||
performance.mark('hashMultipleTasks:start');
|
performance.mark('hashMultipleTasks:start');
|
||||||
|
|
||||||
const taskDetails = getTaskDetails();
|
|
||||||
|
|
||||||
const tasks = Object.values(taskGraph.tasks);
|
const tasks = Object.values(taskGraph.tasks);
|
||||||
const tasksWithHashers = await Promise.all(
|
const tasksWithHashers = await Promise.all(
|
||||||
tasks.map(async (task) => {
|
tasks.map(async (task) => {
|
||||||
@ -58,9 +57,8 @@ export async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(
|
|||||||
tasksToHash[i].hash = hashes[i].value;
|
tasksToHash[i].hash = hashes[i].value;
|
||||||
tasksToHash[i].hashDetails = hashes[i].details;
|
tasksToHash[i].hashDetails = hashes[i].details;
|
||||||
}
|
}
|
||||||
// TODO: Remove if when sqlite is always on
|
if (tasksDetails?.recordTaskDetails) {
|
||||||
if (taskDetails) {
|
tasksDetails.recordTaskDetails(
|
||||||
taskDetails.recordTaskDetails(
|
|
||||||
tasksToHash.map((task) => ({
|
tasksToHash.map((task) => ({
|
||||||
hash: task.hash,
|
hash: task.hash,
|
||||||
project: task.target.project,
|
project: task.target.project,
|
||||||
@ -83,11 +81,11 @@ export async function hashTask(
|
|||||||
projectGraph: ProjectGraph,
|
projectGraph: ProjectGraph,
|
||||||
taskGraph: TaskGraph,
|
taskGraph: TaskGraph,
|
||||||
task: Task,
|
task: Task,
|
||||||
env: NodeJS.ProcessEnv
|
env: NodeJS.ProcessEnv,
|
||||||
|
taskDetails: TaskDetails | null
|
||||||
) {
|
) {
|
||||||
performance.mark('hashSingleTask:start');
|
performance.mark('hashSingleTask:start');
|
||||||
|
|
||||||
const taskDetails = getTaskDetails();
|
|
||||||
const customHasher = getCustomHasher(task, projectGraph);
|
const customHasher = getCustomHasher(task, projectGraph);
|
||||||
const projectsConfigurations =
|
const projectsConfigurations =
|
||||||
readProjectsConfigurationFromProjectGraph(projectGraph);
|
readProjectsConfigurationFromProjectGraph(projectGraph);
|
||||||
@ -106,8 +104,7 @@ export async function hashTask(
|
|||||||
task.hash = value;
|
task.hash = value;
|
||||||
task.hashDetails = details;
|
task.hashDetails = details;
|
||||||
|
|
||||||
// TODO: Remove if when wasm supports sqlite
|
if (taskDetails?.recordTaskDetails) {
|
||||||
if (taskDetails) {
|
|
||||||
taskDetails.recordTaskDetails([
|
taskDetails.recordTaskDetails([
|
||||||
{
|
{
|
||||||
hash: task.hash,
|
hash: task.hash,
|
||||||
|
|||||||
@ -32,7 +32,7 @@ export type TaskWithCachedResult = { task: Task; cachedResult: CachedResult };
|
|||||||
export function getCache(
|
export function getCache(
|
||||||
nxJson: NxJsonConfiguration,
|
nxJson: NxJsonConfiguration,
|
||||||
options: DefaultTasksRunnerOptions
|
options: DefaultTasksRunnerOptions
|
||||||
) {
|
): DbCache | Cache {
|
||||||
return process.env.NX_DISABLE_DB !== 'true' &&
|
return process.env.NX_DISABLE_DB !== 'true' &&
|
||||||
(nxJson.enableDbCache === true || process.env.NX_DB_CACHE === 'true')
|
(nxJson.enableDbCache === true || process.env.NX_DB_CACHE === 'true')
|
||||||
? new DbCache({
|
? new DbCache({
|
||||||
|
|||||||
@ -11,7 +11,10 @@ import { Task, TaskGraph } from '../config/task-graph';
|
|||||||
import { TargetDependencyConfig } from '../config/workspace-json-project-json';
|
import { TargetDependencyConfig } from '../config/workspace-json-project-json';
|
||||||
import { daemonClient } from '../daemon/client/client';
|
import { daemonClient } from '../daemon/client/client';
|
||||||
import { createTaskHasher } from '../hasher/create-task-hasher';
|
import { createTaskHasher } from '../hasher/create-task-hasher';
|
||||||
import { hashTasksThatDoNotDependOnOutputsOfOtherTasks } from '../hasher/hash-task';
|
import {
|
||||||
|
getTaskDetails,
|
||||||
|
hashTasksThatDoNotDependOnOutputsOfOtherTasks,
|
||||||
|
} from '../hasher/hash-task';
|
||||||
import { IS_WASM } from '../native';
|
import { IS_WASM } from '../native';
|
||||||
import { createProjectGraphAsync } from '../project-graph/project-graph';
|
import { createProjectGraphAsync } from '../project-graph/project-graph';
|
||||||
import { NxArgs } from '../utils/command-line-utils';
|
import { NxArgs } from '../utils/command-line-utils';
|
||||||
@ -589,6 +592,9 @@ export async function invokeTasksRunner({
|
|||||||
}): Promise<{ [id: string]: TaskResult }> {
|
}): Promise<{ [id: string]: TaskResult }> {
|
||||||
setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles);
|
setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles);
|
||||||
|
|
||||||
|
// this needs to be done before we start to run the tasks
|
||||||
|
const taskDetails = getTaskDetails();
|
||||||
|
|
||||||
const { tasksRunner, runnerOptions } = getRunner(nxArgs, nxJson);
|
const { tasksRunner, runnerOptions } = getRunner(nxArgs, nxJson);
|
||||||
|
|
||||||
let hasher = createTaskHasher(projectGraph, nxJson, runnerOptions);
|
let hasher = createTaskHasher(projectGraph, nxJson, runnerOptions);
|
||||||
@ -601,7 +607,8 @@ export async function invokeTasksRunner({
|
|||||||
hasher,
|
hasher,
|
||||||
projectGraph,
|
projectGraph,
|
||||||
taskGraph,
|
taskGraph,
|
||||||
nxJson
|
nxJson,
|
||||||
|
taskDetails
|
||||||
);
|
);
|
||||||
const taskResultsLifecycle = new TaskResultsLifeCycle();
|
const taskResultsLifecycle = new TaskResultsLifeCycle();
|
||||||
const compositedLifeCycle: LifeCycle = new CompositeLifeCycle([
|
const compositedLifeCycle: LifeCycle = new CompositeLifeCycle([
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { writeFileSync } from 'fs';
|
|||||||
import { TaskHasher } from '../hasher/task-hasher';
|
import { TaskHasher } from '../hasher/task-hasher';
|
||||||
import runCommandsImpl from '../executors/run-commands/run-commands.impl';
|
import runCommandsImpl from '../executors/run-commands/run-commands.impl';
|
||||||
import { ForkedProcessTaskRunner } from './forked-process-task-runner';
|
import { ForkedProcessTaskRunner } from './forked-process-task-runner';
|
||||||
import { getCache } from './cache';
|
import { Cache, DbCache, getCache } from './cache';
|
||||||
import { DefaultTasksRunnerOptions } from './default-tasks-runner';
|
import { DefaultTasksRunnerOptions } from './default-tasks-runner';
|
||||||
import { TaskStatus } from './tasks-runner';
|
import { TaskStatus } from './tasks-runner';
|
||||||
import {
|
import {
|
||||||
@ -22,7 +22,7 @@ import { TaskMetadata } from './life-cycle';
|
|||||||
import { ProjectGraph } from '../config/project-graph';
|
import { ProjectGraph } from '../config/project-graph';
|
||||||
import { Task, TaskGraph } from '../config/task-graph';
|
import { Task, TaskGraph } from '../config/task-graph';
|
||||||
import { DaemonClient } from '../daemon/client/client';
|
import { DaemonClient } from '../daemon/client/client';
|
||||||
import { hashTask } from '../hasher/hash-task';
|
import { getTaskDetails, hashTask } from '../hasher/hash-task';
|
||||||
import {
|
import {
|
||||||
getEnvVariablesForBatchProcess,
|
getEnvVariablesForBatchProcess,
|
||||||
getEnvVariablesForTask,
|
getEnvVariablesForTask,
|
||||||
@ -32,9 +32,11 @@ import { workspaceRoot } from '../utils/workspace-root';
|
|||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import { combineOptionsForExecutor } from '../utils/params';
|
import { combineOptionsForExecutor } from '../utils/params';
|
||||||
import { NxJsonConfiguration } from '../config/nx-json';
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
|
import type { TaskDetails } from '../native';
|
||||||
|
|
||||||
export class TaskOrchestrator {
|
export class TaskOrchestrator {
|
||||||
private cache = getCache(this.nxJson, this.options);
|
private taskDetails: TaskDetails | null = getTaskDetails();
|
||||||
|
private cache: DbCache | Cache = getCache(this.nxJson, this.options);
|
||||||
private forkedProcessTaskRunner = new ForkedProcessTaskRunner(this.options);
|
private forkedProcessTaskRunner = new ForkedProcessTaskRunner(this.options);
|
||||||
|
|
||||||
private tasksSchedule = new TasksSchedule(
|
private tasksSchedule = new TasksSchedule(
|
||||||
@ -163,7 +165,8 @@ export class TaskOrchestrator {
|
|||||||
this.projectGraph,
|
this.projectGraph,
|
||||||
this.taskGraph,
|
this.taskGraph,
|
||||||
task,
|
task,
|
||||||
taskSpecificEnv
|
taskSpecificEnv,
|
||||||
|
this.taskDetails
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +184,8 @@ export class TaskOrchestrator {
|
|||||||
this.projectGraph,
|
this.projectGraph,
|
||||||
this.taskGraph,
|
this.taskGraph,
|
||||||
task,
|
task,
|
||||||
this.batchEnv
|
this.batchEnv,
|
||||||
|
this.taskDetails
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await this.options.lifeCycle.scheduleTask(task);
|
await this.options.lifeCycle.scheduleTask(task);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user