Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): match tasks by id in run-many terminal output lifecycles #17460

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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