Skip to content

Commit

Permalink
fix(core): provide taskGraph for every task calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Aug 1, 2023
1 parent fd6bccd commit 711b8d7
Show file tree
Hide file tree
Showing 7 changed files with 459 additions and 379 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,9 @@ 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: 'true'
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
steps:
- run:
name: Set dynamic nx run variable
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;
}
Loading

0 comments on commit 711b8d7

Please sign in to comment.