@reporters/github 1.7.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +59 -41
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -62,49 +62,51 @@ function extractLocation(data) {
|
|
|
62
62
|
return { file, startLine: line, startColumn: column };
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
core.error(util.inspect(error, { colors: false, breakLength: Infinity }), {
|
|
90
|
-
...extractLocation(event.data),
|
|
91
|
-
title: event.data.name,
|
|
92
|
-
});
|
|
93
|
-
counter.fail += 1;
|
|
94
|
-
break;
|
|
95
|
-
} case 'test:diagnostic':
|
|
96
|
-
if (event.data.file === undefined
|
|
97
|
-
|| event.data.line === undefined
|
|
98
|
-
|| event.data.column === undefined) {
|
|
99
|
-
diagnostics.push(event.data.message);
|
|
100
|
-
} else {
|
|
101
|
-
core.notice(event.data.message, extractLocation(event.data));
|
|
102
|
-
}
|
|
103
|
-
break;
|
|
104
|
-
default:
|
|
65
|
+
const counter = { pass: 0, fail: 0 };
|
|
66
|
+
const diagnostics = [];
|
|
67
|
+
|
|
68
|
+
function isTopLevelDiagnostic(data) {
|
|
69
|
+
return (data.file === undefined
|
|
70
|
+
|| data.line === undefined
|
|
71
|
+
|| data.column === undefined
|
|
72
|
+
|| (data.line === 1 && data.column === 1));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function handleEvent(event) {
|
|
76
|
+
switch (event.type) {
|
|
77
|
+
case 'test:start':
|
|
78
|
+
core.debug(`starting to run ${event.data.name}`);
|
|
79
|
+
break;
|
|
80
|
+
case 'test:pass':
|
|
81
|
+
counter.pass += 1;
|
|
82
|
+
core.debug(`completed running ${event.data.name}`);
|
|
83
|
+
break;
|
|
84
|
+
case 'test:fail': {
|
|
85
|
+
const error = event.data.details?.error;
|
|
86
|
+
if (error?.code === 'ERR_TEST_FAILURE' && error?.failureType === 'subtestsFailed') {
|
|
87
|
+
// This means the failed subtests are already reported
|
|
88
|
+
// no need to re-annotate the file itself
|
|
105
89
|
break;
|
|
106
|
-
|
|
90
|
+
}
|
|
91
|
+
core.error(util.inspect(error, { colors: false, breakLength: Infinity }), {
|
|
92
|
+
...extractLocation(event.data),
|
|
93
|
+
title: event.data.name,
|
|
94
|
+
});
|
|
95
|
+
counter.fail += 1;
|
|
96
|
+
break;
|
|
97
|
+
} case 'test:diagnostic':
|
|
98
|
+
if (isTopLevelDiagnostic(event.data)) {
|
|
99
|
+
diagnostics.push(event.data.message);
|
|
100
|
+
} else if (process.env.GITHUB_ACTIONS_REPORTER_VERBOSE) {
|
|
101
|
+
core.notice(event.data.message, extractLocation(event.data));
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
break;
|
|
107
106
|
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function emitSummary() {
|
|
108
110
|
const formattedDiagnostics = diagnostics.map((d) => {
|
|
109
111
|
const [key, ...rest] = d.split(' ');
|
|
110
112
|
const value = rest.join(' ');
|
|
@@ -123,4 +125,20 @@ module.exports = async function githubReporter(source) {
|
|
|
123
125
|
.addTable(formattedDiagnostics)
|
|
124
126
|
.write();
|
|
125
127
|
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
module.exports = async function githubReporter(source) {
|
|
131
|
+
if (!process.env.GITHUB_ACTIONS) {
|
|
132
|
+
// eslint-disable-next-line no-unused-vars
|
|
133
|
+
for await (const _ of source);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
for await (const event of source) {
|
|
137
|
+
handleEvent(event);
|
|
138
|
+
}
|
|
139
|
+
await emitSummary();
|
|
126
140
|
};
|
|
141
|
+
|
|
142
|
+
module.exports.handleEvent = handleEvent;
|
|
143
|
+
module.exports.emitSummary = emitSummary;
|
|
144
|
+
module.exports.isTopLevelDiagnostic = isTopLevelDiagnostic;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reporters/github",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "A github actions reporter for `node:test`",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./index.js"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"test": "node --test-reporter
|
|
21
|
+
"test": "node --test-reporter=../github-spec/index.js --test"
|
|
22
22
|
},
|
|
23
23
|
"bugs": {
|
|
24
24
|
"url": "https://github.com/MoLow/reporters/issues"
|