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 { NxJsonConfiguration } 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';
|
||||
|
||||
let taskDetails: TaskDetails;
|
||||
|
||||
function getTaskDetails() {
|
||||
export function getTaskDetails(): TaskDetails | null {
|
||||
// TODO: Remove when wasm supports sqlite
|
||||
if (process.env.NX_DISABLE_DB === 'true' || IS_WASM) {
|
||||
return null;
|
||||
@ -25,12 +25,11 @@ export async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(
|
||||
hasher: TaskHasher,
|
||||
projectGraph: ProjectGraph,
|
||||
taskGraph: TaskGraph,
|
||||
nxJson: NxJsonConfiguration
|
||||
nxJson: NxJsonConfiguration,
|
||||
tasksDetails: TaskDetails | null
|
||||
) {
|
||||
performance.mark('hashMultipleTasks:start');
|
||||
|
||||
const taskDetails = getTaskDetails();
|
||||
|
||||
const tasks = Object.values(taskGraph.tasks);
|
||||
const tasksWithHashers = await Promise.all(
|
||||
tasks.map(async (task) => {
|
||||
@ -58,9 +57,8 @@ export async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(
|
||||
tasksToHash[i].hash = hashes[i].value;
|
||||
tasksToHash[i].hashDetails = hashes[i].details;
|
||||
}
|
||||
// TODO: Remove if when sqlite is always on
|
||||
if (taskDetails) {
|
||||
taskDetails.recordTaskDetails(
|
||||
if (tasksDetails?.recordTaskDetails) {
|
||||
tasksDetails.recordTaskDetails(
|
||||
tasksToHash.map((task) => ({
|
||||
hash: task.hash,
|
||||
project: task.target.project,
|
||||
@ -83,11 +81,11 @@ export async function hashTask(
|
||||
projectGraph: ProjectGraph,
|
||||
taskGraph: TaskGraph,
|
||||
task: Task,
|
||||
env: NodeJS.ProcessEnv
|
||||
env: NodeJS.ProcessEnv,
|
||||
taskDetails: TaskDetails | null
|
||||
) {
|
||||
performance.mark('hashSingleTask:start');
|
||||
|
||||
const taskDetails = getTaskDetails();
|
||||
const customHasher = getCustomHasher(task, projectGraph);
|
||||
const projectsConfigurations =
|
||||
readProjectsConfigurationFromProjectGraph(projectGraph);
|
||||
@ -106,8 +104,7 @@ export async function hashTask(
|
||||
task.hash = value;
|
||||
task.hashDetails = details;
|
||||
|
||||
// TODO: Remove if when wasm supports sqlite
|
||||
if (taskDetails) {
|
||||
if (taskDetails?.recordTaskDetails) {
|
||||
taskDetails.recordTaskDetails([
|
||||
{
|
||||
hash: task.hash,
|
||||
|
||||
@ -32,7 +32,7 @@ export type TaskWithCachedResult = { task: Task; cachedResult: CachedResult };
|
||||
export function getCache(
|
||||
nxJson: NxJsonConfiguration,
|
||||
options: DefaultTasksRunnerOptions
|
||||
) {
|
||||
): DbCache | Cache {
|
||||
return process.env.NX_DISABLE_DB !== 'true' &&
|
||||
(nxJson.enableDbCache === true || process.env.NX_DB_CACHE === 'true')
|
||||
? new DbCache({
|
||||
|
||||
@ -11,7 +11,10 @@ import { Task, TaskGraph } from '../config/task-graph';
|
||||
import { TargetDependencyConfig } from '../config/workspace-json-project-json';
|
||||
import { daemonClient } from '../daemon/client/client';
|
||||
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 { createProjectGraphAsync } from '../project-graph/project-graph';
|
||||
import { NxArgs } from '../utils/command-line-utils';
|
||||
@ -589,6 +592,9 @@ export async function invokeTasksRunner({
|
||||
}): Promise<{ [id: string]: TaskResult }> {
|
||||
setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles);
|
||||
|
||||
// this needs to be done before we start to run the tasks
|
||||
const taskDetails = getTaskDetails();
|
||||
|
||||
const { tasksRunner, runnerOptions } = getRunner(nxArgs, nxJson);
|
||||
|
||||
let hasher = createTaskHasher(projectGraph, nxJson, runnerOptions);
|
||||
@ -601,7 +607,8 @@ export async function invokeTasksRunner({
|
||||
hasher,
|
||||
projectGraph,
|
||||
taskGraph,
|
||||
nxJson
|
||||
nxJson,
|
||||
taskDetails
|
||||
);
|
||||
const taskResultsLifecycle = new TaskResultsLifeCycle();
|
||||
const compositedLifeCycle: LifeCycle = new CompositeLifeCycle([
|
||||
|
||||
@ -5,7 +5,7 @@ import { writeFileSync } from 'fs';
|
||||
import { TaskHasher } from '../hasher/task-hasher';
|
||||
import runCommandsImpl from '../executors/run-commands/run-commands.impl';
|
||||
import { ForkedProcessTaskRunner } from './forked-process-task-runner';
|
||||
import { getCache } from './cache';
|
||||
import { Cache, DbCache, getCache } from './cache';
|
||||
import { DefaultTasksRunnerOptions } from './default-tasks-runner';
|
||||
import { TaskStatus } from './tasks-runner';
|
||||
import {
|
||||
@ -22,7 +22,7 @@ import { TaskMetadata } from './life-cycle';
|
||||
import { ProjectGraph } from '../config/project-graph';
|
||||
import { Task, TaskGraph } from '../config/task-graph';
|
||||
import { DaemonClient } from '../daemon/client/client';
|
||||
import { hashTask } from '../hasher/hash-task';
|
||||
import { getTaskDetails, hashTask } from '../hasher/hash-task';
|
||||
import {
|
||||
getEnvVariablesForBatchProcess,
|
||||
getEnvVariablesForTask,
|
||||
@ -32,9 +32,11 @@ import { workspaceRoot } from '../utils/workspace-root';
|
||||
import { output } from '../utils/output';
|
||||
import { combineOptionsForExecutor } from '../utils/params';
|
||||
import { NxJsonConfiguration } from '../config/nx-json';
|
||||
import type { TaskDetails } from '../native';
|
||||
|
||||
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 tasksSchedule = new TasksSchedule(
|
||||
@ -163,7 +165,8 @@ export class TaskOrchestrator {
|
||||
this.projectGraph,
|
||||
this.taskGraph,
|
||||
task,
|
||||
taskSpecificEnv
|
||||
taskSpecificEnv,
|
||||
this.taskDetails
|
||||
);
|
||||
}
|
||||
|
||||
@ -181,7 +184,8 @@ export class TaskOrchestrator {
|
||||
this.projectGraph,
|
||||
this.taskGraph,
|
||||
task,
|
||||
this.batchEnv
|
||||
this.batchEnv,
|
||||
this.taskDetails
|
||||
);
|
||||
}
|
||||
await this.options.lifeCycle.scheduleTask(task);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user