Skip to content

Commit

Permalink
fix(core): provide taskGraph for every task calculation (#18410)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Aug 1, 2023
1 parent 8c72338 commit ce2c6d6
Show file tree
Hide file tree
Showing 10 changed files with 501 additions and 382 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ jobs:
executor: macos
environment:
NX_E2E_CI_CACHE_KEY: e2e-circleci-macos
NX_DAEMON: 'false' # TODO: Fix the hashing issue and re-enable this
NX_DAEMON: 'false' # TODO: set to true after #18410
NX_PERF_LOGGING: 'false'
SELECTED_PM: 'npm' # explicitly define npm for macOS tests
NX_SKIP_NX_CACHE: 'true' # TODO: Figure out what is going on with the cache and renable it
NX_SKIP_NX_CACHE: 'true' # TODO: Remove after #18410
steps:
- run:
name: Set dynamic nx run variable
Expand Down
2 changes: 1 addition & 1 deletion packages/linter/src/executors/eslint/hasher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default async function run(
projectsConfigurations: ProjectsConfigurations;
}
): Promise<Hash> {
const res = await context.hasher.hashTask(task);
const res = await context.hasher.hashTask(task, context.taskGraph);
if (task.overrides['hasTypeAwareRules'] === true) {
return res;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/nx/src/command-line/affected/print-affected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ async function createTasks(
{},
[],
projectGraph,
taskGraph,
nxJson,
{},
fileHasher
Expand All @@ -85,7 +84,7 @@ async function createTasks(
const tasks = Object.values(taskGraph.tasks);

await Promise.all(
tasks.map((t) => hashTask(hasher, projectGraph, {} as any, t))
tasks.map((t) => hashTask(hasher, projectGraph, taskGraph, t))
);

return tasks.map((task) => ({
Expand Down
7 changes: 3 additions & 4 deletions packages/nx/src/daemon/server/handle-hash-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { setHashEnv } from '../../hasher/set-hash-env';
* TaskHasher has a cache inside, so keeping it around results in faster performance
*/
let storedProjectGraph: any = null;
let storedTaskGraph: any = null;
let storedHasher: InProcessTaskHasher | null = null;

export async function handleHashTasks(payload: {
Expand All @@ -27,18 +26,18 @@ export async function handleHashTasks(payload: {

if (projectGraph !== storedProjectGraph) {
storedProjectGraph = projectGraph;
storedTaskGraph = payload.taskGraph;
storedHasher = new InProcessTaskHasher(
projectFileMap,
allWorkspaceFiles,
projectGraph,
payload.taskGraph,
nxJson,
payload.runnerOptions,
fileHasher
);
}
const response = JSON.stringify(await storedHasher.hashTasks(payload.tasks));
const response = JSON.stringify(
await storedHasher.hashTasks(payload.tasks, payload.taskGraph)
);
return {
response,
description: 'handleHashTasks',
Expand Down
4 changes: 2 additions & 2 deletions packages/nx/src/hasher/hash-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(
})
.map((t) => t.task);

const hashes = await hasher.hashTasks(tasksToHash);
const hashes = await hasher.hashTasks(tasksToHash, taskGraph);
for (let i = 0; i < tasksToHash.length; i++) {
tasksToHash[i].hash = hashes[i].value;
tasksToHash[i].hashDetails = hashes[i].details;
Expand All @@ -59,7 +59,7 @@ export async function hashTask(
projectsConfigurations,
nxJsonConfiguration: readNxJson(),
} as any)
: hasher.hashTask(task));
: hasher.hashTask(task, taskGraph));
task.hash = value;
task.hashDetails = details;
}

1 comment on commit ce2c6d6

@vercel
Copy link

@vercel vercel bot commented on ce2c6d6 Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev

Please sign in to comment.