Skip to content

Commit 7821ce7

Browse files
nodejs-github-botrichardlau
authored andcommitted
tools: update github_reporter to 1.6.0
PR-URL: #51658 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 19156df commit 7821ce7

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

tools/github_reporter/index.js

+15-8
Original file line numberDiff line numberDiff line change
@@ -19156,6 +19156,18 @@ var DIAGNOSTIC_KEYS = {
1915619156
var DIAGNOSTIC_VALUES = {
1915719157
duration_ms: (value) => `${Number(value).toFixed(3)}ms`
1915819158
};
19159+
function extractLocation(data) {
19160+
let { line, column, file } = data;
19161+
const error = data.details?.error;
19162+
file = getFilePath(file);
19163+
if (error) {
19164+
const errorLocation = parseStack(error, file);
19165+
file = getFilePath(errorLocation?.file ?? file) ?? file;
19166+
line = errorLocation?.line ?? line;
19167+
column = errorLocation?.column ?? column;
19168+
}
19169+
return { file, startLine: line, startColumn: column };
19170+
}
1915919171
module.exports = async function githubReporter(source) {
1916019172
if (!process.env.GITHUB_ACTIONS) {
1916119173
for await (const _ of source)
@@ -19178,23 +19190,18 @@ module.exports = async function githubReporter(source) {
1917819190
if (error?.code === "ERR_TEST_FAILURE" && error?.failureType === "subtestsFailed") {
1917919191
break;
1918019192
}
19181-
let filePath = getFilePath(event.data.file);
19182-
const location = parseStack(error, filePath);
19183-
filePath = getFilePath(location?.file ?? filePath) ?? filePath;
1918419193
core.error(util.inspect(error, { colors: false, breakLength: Infinity }), {
19185-
file: filePath,
19186-
startLine: location?.line,
19187-
startColumn: location?.column,
19194+
...extractLocation(event.data),
1918819195
title: event.data.name
1918919196
});
1919019197
counter.fail += 1;
1919119198
break;
1919219199
}
1919319200
case "test:diagnostic":
19194-
if (event.data.nesting === 0) {
19201+
if (event.data.file === void 0 || event.data.line === void 0 || event.data.column === void 0) {
1919519202
diagnostics.push(event.data.message);
1919619203
} else {
19197-
core.notice(event.data.message, { file: getFilePath(event.data.file) });
19204+
core.notice(event.data.message, extractLocation(event.data));
1919819205
}
1919919206
break;
1920019207
default:

tools/github_reporter/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@reporters/github",
3-
"version": "1.5.4",
3+
"version": "1.6.0",
44
"description": "A github actions reporter for `node:test`",
55
"type": "commonjs",
66
"keywords": [

0 commit comments

Comments
 (0)