Skip to content

Commit

Permalink
fix(core): match tasks by id in run-many terminal output lifecycles (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Jun 8, 2023
1 parent f0be962 commit 2d87f77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export async function createRunManyDynamicOutputRenderer({
lifeCycle.endTasks = (taskResults) => {
for (let t of taskResults) {
totalCompletedTasks++;
const matchingTaskRow = taskRows.find((r) => r.task === t.task);
const matchingTaskRow = taskRows.find((r) => r.task.id === t.task.id);
if (matchingTaskRow) {
matchingTaskRow.status = t.status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { formatFlags, formatTargetsAndProjects } from './formatting-utils';
export class StaticRunManyTerminalOutputLifeCycle implements LifeCycle {
failedTasks = [] as Task[];
cachedTasks = [] as Task[];
allCompletedTasks = new Set<Task>();
allCompletedTasks = new Map<string, Task>();

constructor(
private readonly projectNames: string[],
Expand Down Expand Up @@ -123,14 +123,14 @@ export class StaticRunManyTerminalOutputLifeCycle implements LifeCycle {
}

private skippedTasks() {
return this.tasks.filter((t) => !this.allCompletedTasks.has(t));
return this.tasks.filter((t) => !this.allCompletedTasks.has(t.id));
}

endTasks(
taskResults: { task: Task; status: TaskStatus; code: number }[]
): void {
for (let t of taskResults) {
this.allCompletedTasks.add(t.task);
this.allCompletedTasks.set(t.task.id, t.task);
if (t.status === 'failure') {
this.failedTasks.push(t.task);
} else if (t.status === 'local-cache') {
Expand Down
9 changes: 3 additions & 6 deletions packages/nx/src/tasks-runner/task-orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class TaskOrchestrator {
task: Task;
status: 'local-cache' | 'local-cache-kept-existing' | 'remote-cache';
}> {
const startTime = new Date().getTime();
task.startTime = Date.now();
const cachedResult = await this.cache.get(task);
if (!cachedResult || cachedResult.code !== 0) return null;

Expand All @@ -155,6 +155,7 @@ export class TaskOrchestrator {
if (shouldCopyOutputsFromCache) {
await this.cache.copyFilesFromCache(task.hash, cachedResult, outputs);
}
task.endTime = Date.now();
const status = cachedResult.remote
? 'remote-cache'
: shouldCopyOutputsFromCache
Expand All @@ -166,11 +167,7 @@ export class TaskOrchestrator {
cachedResult.terminalOutput
);
return {
task: {
...task,
startTime,
endTime: Date.now(),
},
task,
status,
};
}
Expand Down

1 comment on commit 2d87f77

@vercel
Copy link

@vercel vercel bot commented on 2d87f77 Jun 8, 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-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

Please sign in to comment.