sumlyzer 0.2.0 → 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.
Files changed (3) hide show
  1. package/README.md +23 -7
  2. package/package.json +1 -1
  3. package/src/run.mjs +34 -2
package/README.md CHANGED
@@ -53,7 +53,9 @@ 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 — wire it straight into CI without extra parsing.
56
+ workspaces), `0` otherwise, wire it straight into CI without extra parsing.
57
+ This also applies when `--junit` can't write its report (e.g. an invalid
58
+ `<path>`): the exit code is `1` even if every workspace's tests passed.
57
59
 
58
60
  ## Example
59
61
 
@@ -86,7 +88,6 @@ running gitlab
86
88
  ✓ gitlab 4.3s (8/8 tests)
87
89
 
88
90
  Summary
89
-
90
91
  ┌─────────┬────────────────┬──────────┬────────────┬────────────────┬─────────┬────────┬────────┐
91
92
  │ (index) │ workspace │ status │ duration │ testsDuration │ tests │ pass │ fail │
92
93
  ├─────────┼────────────────┼──────────┼────────────┼────────────────┼─────────┼────────┼────────┤
@@ -110,7 +111,7 @@ Summary
110
111
 
111
112
  ### On failure
112
113
 
113
- Only the failing workspace prints its detail; passing ones stay collapsed to a single line.
114
+ Only the failing workspace prints its detail and passing ones stay collapsed to a single line.
114
115
 
115
116
  ```
116
117
  running contact
@@ -134,7 +135,6 @@ running flags
134
135
  ✓ flags 1.1s (9/9 tests)
135
136
 
136
137
  Summary
137
-
138
138
  ┌─────────┬────────────┬──────────┬────────────┬────────────────┬─────────┬────────┬────────┐
139
139
  │ (index) │ workspace │ status │ duration │ testsDuration │ tests │ pass │ fail │
140
140
  ├─────────┼────────────┼──────────┼────────────┼────────────────┼─────────┼────────┼────────┤
@@ -171,13 +171,29 @@ npx sumlyzer --junit reports/ # writes reports/junit.xml
171
171
  </testsuites>
172
172
  ```
173
173
 
174
+ A workspace whose script never produces a junit file (for example,
175
+ `--script` points at something that isn't `node:test`, or the workspace crashed
176
+ before it could write one) is left out of the aggregated report and sumlyzer
177
+ prints a warning naming it.
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
+
174
191
  ## Why
175
192
 
176
193
  `npm run test --workspaces --if-present` runs every workspace but gives you
177
194
  no aggregated summary and no way to fail fast early. An early failure just
178
- scrolls off screen once later workspaces print their own output. Turborepo
179
- has the [same open issue](https://github.com/vercel/turborepo/issues/1368).
180
- sumlyzer is a small, dependency-free tool that solves just this.
195
+ scrolls off screen once later workspaces print their own output. sumlyzer is
196
+ a small, dependency-free tool that solves just this.
181
197
 
182
198
  ## Contributing
183
199
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumlyzer",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Run every npm workspace's test script, only show output for the ones that fail, and finish with an aggregated pass/fail summary.",
5
5
  "type": "module",
6
6
  "bin": {
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
- printWorkspaceResult(name, result);
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;