sumlyzer 0.2.1 → 0.3.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/README.md +13 -1
- package/package.json +1 -1
- package/src/run.mjs +34 -2
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ Options:
|
|
|
53
53
|
| `-h, --help` | | print usage |
|
|
54
54
|
|
|
55
55
|
Exit code is `1` if any workspace fails (or if the project has no
|
|
56
|
-
workspaces), `0` otherwise
|
|
56
|
+
workspaces), `0` otherwise, wire it straight into CI without extra parsing.
|
|
57
57
|
This also applies when `--junit` can't write its report (e.g. an invalid
|
|
58
58
|
`<path>`): the exit code is `1` even if every workspace's tests passed.
|
|
59
59
|
|
|
@@ -176,6 +176,18 @@ A workspace whose script never produces a junit file (for example,
|
|
|
176
176
|
before it could write one) is left out of the aggregated report and sumlyzer
|
|
177
177
|
prints a warning naming it.
|
|
178
178
|
|
|
179
|
+
### GitHub Actions log folding
|
|
180
|
+
|
|
181
|
+
On GitHub Actions (detected via `GITHUB_ACTIONS=true`), each workspace's full
|
|
182
|
+
`node:test` output is wrapped in a collapsible `::group::`/`::endgroup::`
|
|
183
|
+
section instead of the terminal's collapsed-line-or-failure-detail format.
|
|
184
|
+
This is automatic, no flag needed, and keeps the job log short by default
|
|
185
|
+
while still letting you expand any workspace, passing or failing, to see its
|
|
186
|
+
full suite output.
|
|
187
|
+
|
|
188
|
+
No other CI provider is currently supported: GitHub is the
|
|
189
|
+
only one whose log folding sumlyzer has actually verified end-to-end.
|
|
190
|
+
|
|
179
191
|
## Why
|
|
180
192
|
|
|
181
193
|
`npm run test --workspaces --if-present` runs every workspace but gives you
|
package/package.json
CHANGED
package/src/run.mjs
CHANGED
|
@@ -124,10 +124,35 @@ async function runWorkspaceScript(root, wsPath, scriptName, junitDestPath) {
|
|
|
124
124
|
durationMs: Date.now() - start,
|
|
125
125
|
counts: parseTestCounts(output),
|
|
126
126
|
failingTests: parseFailingTests(output),
|
|
127
|
-
junitDestPath
|
|
127
|
+
junitDestPath,
|
|
128
|
+
rawOutput: output
|
|
128
129
|
};
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
// GitHub Actions: https://docs.github.com/actions/how-tos/write-workflows/choose-what-workflows-do/workflow-commands#grouping-log-lines
|
|
133
|
+
export function ciGroupSyntax(env) {
|
|
134
|
+
if (env.GITHUB_ACTIONS === "true") {
|
|
135
|
+
return {
|
|
136
|
+
start: (title) => `::group::${title}`,
|
|
137
|
+
end: () => "::endgroup::"
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function ciGroupTitle(name, result) {
|
|
144
|
+
const seconds = formatSeconds(result.durationMs);
|
|
145
|
+
const countsLabel = result.counts ? ` (${result.counts.pass}/${result.counts.tests} tests)` : "";
|
|
146
|
+
const icon = result.exitCode === 0 ? "✓" : "✗";
|
|
147
|
+
return `${icon} ${name} ${seconds}${countsLabel}`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function printWorkspaceResultCi(name, result, ciGroup) {
|
|
151
|
+
process.stdout.write(`${ciGroup.start(ciGroupTitle(name, result))}\n`);
|
|
152
|
+
process.stdout.write(`${result.rawOutput || "(no output captured)"}\n`);
|
|
153
|
+
process.stdout.write(`${ciGroup.end()}\n`);
|
|
154
|
+
}
|
|
155
|
+
|
|
131
156
|
async function collectJunitEntries(results) {
|
|
132
157
|
const entries = [];
|
|
133
158
|
const missing = [];
|
|
@@ -178,6 +203,7 @@ function printWorkspaceResult(name, result) {
|
|
|
178
203
|
|
|
179
204
|
async function runWorkspaces({ root, workspacesToRun, scriptName, ff, junitDir }) {
|
|
180
205
|
const results = [];
|
|
206
|
+
const ciGroup = ciGroupSyntax(process.env);
|
|
181
207
|
|
|
182
208
|
for (const [index, wsPath] of workspacesToRun.entries()) {
|
|
183
209
|
const name = workspaceName(wsPath);
|
|
@@ -194,7 +220,13 @@ async function runWorkspaces({ root, workspacesToRun, scriptName, ff, junitDir }
|
|
|
194
220
|
process.exit(1);
|
|
195
221
|
}
|
|
196
222
|
results.push(result);
|
|
197
|
-
|
|
223
|
+
|
|
224
|
+
if (ciGroup) {
|
|
225
|
+
printWorkspaceResultCi(name, result, ciGroup);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
printWorkspaceResult(name, result);
|
|
229
|
+
}
|
|
198
230
|
|
|
199
231
|
if (result.exitCode !== 0 && ff) {
|
|
200
232
|
break;
|