turbo icon indicating copy to clipboard operation
turbo copied to clipboard

Report which packages/tasks have failed at the end of a task without having to scroll terminal output.

Open sppatel opened this issue 2 years ago • 1 comments

Describe the feature you'd like to request

This is similar to nature to 1279 but we have a repo that has hundreds of packages . In addition we have received feedback that on CI (atleast) devs do not like the default behavior of exiting exiting early because they do not get a complete picture of what other failures exist. While they could run the command locally, some operations such as Jest on 100's of packages would eat up local compute or take a really long time to finish running tests across all affected packages (which in some cases could be all of them).

The ask for us was to switch to --continue. However this introduces a usability concern in that you have to scroll up the terminal output to find all the failures which is not ideal. For something like Jest this isn't too big of an issue because we generate html reports that can be looked at for a complete summary but for other operations such as webpack, lint, etc. this is not the case.

At minimum - need a way at the end to report on which packages failed a task.

Describe the solution you'd like

At the end of the run, please report the failed tasks and which specific packages failed for that task. Also include this in the json summary as requested in 1279

Describe alternatives you've considered

None.

sppatel avatar Jun 10 '22 12:06 sppatel

I like this idea, as well as the json output.

gsoltis avatar Jun 21 '22 03:06 gsoltis

Just ran into this and have been scrolling for a couple of minutes through my logs now. Very annoying! Is there a plan to resolve this?

Irvenae avatar Mar 30 '23 13:03 Irvenae

@sppatel For my case, I added a step in the CI that runs a small script to extract and print a failed tasks report from Turbo generated summary file:

// print-turbo-failed-tasks.js
const fs = require('node:fs');
const path = require('node:path');

const { WORK_DIR } = process.env;

const TURBO_RUNS_DIR = path.join(WORK_DIR, '.turbo/runs');

const turboRunFiles = fs.readdirSync(TURBO_RUNS_DIR);

const { file: latestRunFile } = turboRunFiles
  .map((file) => {
    const { mtime: lastModifiedAt } = fs.statSync(path.join(TURBO_RUNS_DIR, file));

    return { file, lastModifiedAt }
  })
  .reduce((result, current) => current.lastModifiedAt > result.lastModifiedAt ? current : result)

const runSummary = JSON.parse(fs.readFileSync(path.join(TURBO_RUNS_DIR, latestRunFile)).toString());

const { execution, tasks } = runSummary;

if (execution.failed > 0) {
  const taskFailedExecutions = tasks
    .filter((task) => task.execution.exitCode !== 0)
    .map((task) => `${task.taskId} exit code: ${task.execution.exitCode}`);

  console.log(taskFailedExecutions.join('\n'));
}

Usage: WORK_DIR=$(pwd) node print-turbo-failed-tasks.js

I wonder if there is a straighter way to retrieve the run summary file path (instead of scanning .turbo/runs folder).

cbm-egoubely avatar May 15 '23 17:05 cbm-egoubely

We have a Nushell script to log the last lines of each failed task:

#!/usr/bin/env nu

def showLog [task] {
    $"-----------------------------------------------------------------------------
# ($task.taskId):
-----------------------------------------------------------------------------
(tail -n 50 $task.logFile)
"
}

(ls .turbo/runs/
    | sort-by modified -r
    | first
    | open $in.name
    | get tasks
    | where { |task| $task.execution.exitCode != 0 }
    | each { |task| showLog $task }
    | to text)

robaca avatar May 15 '23 19:05 robaca

This was done in https://github.com/vercel/turbo/pull/4965! We output failed task at the bottom of a run now.

mehulkar avatar Oct 20 '23 17:10 mehulkar