sumlyzer 1.3.0 → 1.3.1

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 (2) hide show
  1. package/README.md +32 -148
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -11,33 +11,15 @@
11
11
  <a href="./LICENSE"><img src="https://img.shields.io/npm/l/sumlyzer.svg" alt="license" /></a>
12
12
  </p>
13
13
 
14
- ## Ever wished a faster feedback when testing your npm workspaces?
14
+ <p align="center"><b>A better feedback loop for monorepos organized under npm workspaces</b></p>
15
15
 
16
- `npm run test --workspaces --if-present` runs every workspace, but gives no
17
- aggregated summary, no fail-fast, and lets an early failure scroll off screen
18
- unnoticed.
16
+ `npm run test --workspaces --if-present` runs every workspace but gives no
17
+ summary, no fail-fast, and buries an early failure under everyone else's
18
+ output. Sumlyzer fixes that, and runs workspaces concurrently too (~3.5x
19
+ faster, see [Benchmark](#benchmark)).
19
20
 
20
- Sumlyzer gives you all those possibilities and even more like concurrency
21
- (~3.5x faster on a real 15-workspace monorepo, see [Benchmark](#benchmark)) or JUnit reports.
22
-
23
- ## Requirements
24
-
25
- - Node.js >= 22.0.0
26
- - An npm workspaces project (`package.json` with a `workspaces` field)
27
-
28
- ## Scope
29
-
30
- Intentionally narrow: **npm workspaces** running **`node:test`**. It does not
31
- support pnpm/yarn workspaces or other test runners (Jest, Vitest, Mocha etc.) for the moment.
32
-
33
- It runs each workspace's script directly (no `npm run` in between) but still
34
- chains its `pre`/`post` lifecycle scripts (e.g. `pretest`) itself, with the
35
- same semantics as `npm run`: a failing `pre<script>` skips the rest, and a
36
- failing `post<script>` still fails the workspace even if the main script passed.
37
-
38
- sumlyzer forces its own `node:test` reporter via `NODE_OPTIONS`, so a
39
- workspace that sets its own `--test-reporter` is detected ahead of time
40
- and skipped instead of colliding with it.
21
+ Scope: **npm workspaces** running **`node:test`** only, for now. No
22
+ pnpm/yarn, no Jest/Vitest/Mocha.
41
23
 
42
24
  ## Install
43
25
 
@@ -51,151 +33,53 @@ npm install --save-dev sumlyzer
51
33
  npx sumlyzer [options]
52
34
  ```
53
35
 
54
- Run from the root of an npm workspaces project (where `package.json` has a
55
- `workspaces` field).
56
-
57
- Options:
36
+ Run from the root of an npm workspaces project.
58
37
 
59
38
  | Flag | Default | Description |
60
39
  | --- | --- | --- |
61
40
  | `--script <name>` | `test` | npm script to run per workspace |
62
- | `--ff` | off | fail fast: stop at the first failing workspace |
63
- | `--junit <path>` | off | write an aggregated JUnit XML report to `<path>` |
41
+ | `--ff` | off | stop at the first failing workspace |
64
42
  | `-c, --concurrency <n>` | `1` | run up to `<n>` workspaces at once |
65
- | `--changed` | off | only run workspaces with changed files (git ref auto-detected, see `--ref`) |
43
+ | `--changed` | off | only run workspaces with changed files |
44
+ | `--junit <path>` | off | write an aggregated JUnit XML report |
66
45
  | `--ref <ref>` | auto-detect | git ref to diff against for `--changed` |
67
46
  | `-h, --help` | | print usage |
68
47
 
69
- Exit code is `1` if any workspace fails, `0` otherwise. Safe to wire straight
70
- into CI without extra parsing. This also applies when `--junit` can't write
71
- its report.
72
-
73
- ## Benchmark
74
-
75
- Measured on a real 15-workspace monorepo where each workspace's `test` script does real work (coverage + type-checking), averaged over a few runs on the same machine:
76
-
77
- | Command | Wall-clock time |
78
- | ----------------------------------------- | ---------------- |
79
- | `npm run test --workspaces --if-present` | ~22s |
80
- | `sumlyzer` (default, sequential) | ~21s |
81
- | `sumlyzer --concurrency 8` | **~6s** |
82
-
83
- See [Concurrency](#concurrency) for where that gain comes from.
84
-
85
- ## Roadmap
86
-
87
- - **Watch mode**: walking the workspace dependency graph (topological sort) so a change in
88
- one workspace also re-runs the workspaces that depend on it.
89
-
90
- ## Example
48
+ Exit code is `1` if any workspace fails, `0` otherwise — safe to drop straight into CI.
91
49
 
92
50
  ![fail fast example](https://github.com/ErwanRaulo/sumlyzer/blob/main/example.png?raw=true)
93
51
 
94
- ### Summary columns
52
+ ## Benchmark
95
53
 
96
- | Column | Meaning |
97
- | --------------- | ------------------------------------------------------------------------------------------------ |
98
- | `(index)` | Workspace name |
99
- | `status` | `PASS`, `FAIL`, or `SKIPPED` (reached when `--ff` stopped scheduling before this workspace ran) |
100
- | `duration` | Wall-clock time for the workspace's script process, including spawn overhead |
101
- | `tests` | Total number of tests node:test ran in that workspace |
102
- | `pass` | Number of passing tests |
103
- | `fail` | Number of failing tests |
54
+ 15-workspace monorepo, each workspace's `test` script doing real work (coverage + type-checking):
104
55
 
105
- Skipped (`t.skip()`), todo (`t.todo()`), and cancelled tests are rare enough
106
- that a column of zeros for every workspace would just bury the one row that
107
- has a nonzero count. Instead, sumlyzer prints a footnote below the table,
108
- naming only the workspaces that actually have some, e.g. `skipped tests:
109
- flags (2)`.
56
+ | Command | Wall-clock time |
57
+ | --- | --- |
58
+ | `npm run test --workspaces --if-present` | ~22s |
59
+ | `sumlyzer` (sequential) | ~21s |
60
+ | `sumlyzer --concurrency 8` | **~6s** |
110
61
 
111
62
  ## Reference
112
63
 
113
- ### JUnit report
114
-
115
- `--junit <path>` writes a single aggregated JUnit XML report to `<path>`, merging
116
- every workspace's own `node:test` results. Each workspace runs with `node:test`'s
117
- built-in `junit` reporter enabled alongside the terminal one, and sumlyzer combines
118
- the resulting files into one document, prefixing every `<testsuite>` name with the
119
- workspace it came from so CI test-report UIs (GitLab, Jenkins, Azure DevOps, ...)
120
- can tell them apart.
121
-
122
- ```
123
- npx sumlyzer --junit reports/junit.xml
124
- npx sumlyzer --junit reports/ # writes reports/junit.xml
125
- ```
126
-
127
- ```xml
128
- <testsuites>
129
- <testsuite name="contact › contact tests">...</testsuite>
130
- <testsuite name="scanner">...</testsuite>
131
- </testsuites>
132
- ```
133
-
134
- A workspace whose script never produces a junit file is left out of the aggregated report and sumlyzer
135
- prints a warning naming it.
136
-
137
- ### GitHub Actions log folding
138
-
139
- On GitHub Actions (detected via `GITHUB_ACTIONS=true`), each workspace's full
140
- `node:test` output is wrapped in a collapsible `::group::`/`::endgroup::`
141
- section instead of the terminal's format.
142
-
143
- This is automatic, no flag needed, keeping the job log short while still
144
- letting you expand any workspace's full output.
145
-
146
- No other CI provider is currently supported: GitHub is the
147
- only one whose log folding sumlyzer has actually verified end-to-end.
148
-
149
- ### Concurrency
150
-
151
- `--concurrency <n>` runs up to `<n>` workspaces' scripts at the same time
152
- instead of one after another (something npm doesn't support natively)
153
- which can noticeably cut wall-clock time on projects with
154
- many workspaces (see [Benchmark](#benchmark)).
64
+ - **JUnit** (`--junit <path>`): merges every workspace's `node:test` JUnit output into one file, each `<testsuite>` prefixed with its workspace name. A workspace whose script never produces one is left out, with a warning naming it.
65
+ - **GitHub Actions**: on `GITHUB_ACTIONS=true`, each workspace's output is auto-wrapped in a collapsible `::group::` block. No other CI provider has folding support yet.
66
+ - **Concurrency** (`--concurrency <n>`): workspaces finish in whatever order they complete, so output interleaves. With `--ff`, only workspaces that haven't started yet are skipped — in-flight ones run to completion.
67
+ - **Changed workspaces** (`--changed`): maps changed files to the workspace directory containing them. Ref auto-detection: uncommitted changes → diff against `HEAD`; clean tree with upstream → merge-base with upstream; clean tree with no upstream → `HEAD`.
68
+ - Own `--test-reporter` in a workspace's script is detected ahead of time and that workspace is skipped, to avoid colliding with sumlyzer's own reporter.
155
69
 
156
- Since workspaces can now finish in any order, their output interleaves in
157
- whatever order they complete, rather than following the `workspaces` list
158
- order.
70
+ npm doesn't have native fail-fast on `--workspaces` yet — discussed in
71
+ [npm/rfcs#575](https://github.com/npm/rfcs/issues/575) (open) and
72
+ [npm/rfcs#602](https://github.com/npm/rfcs/issues/602) (closed), see also this
73
+ [Stack Overflow answer](https://stackoverflow.com/questions/71300870/npm-workspace-command-does-not-stop-executing-when-command-fails-for-a-workspace/79989284#79989284).
74
+ Sumlyzer's `--ff` gets you there in the meantime.
159
75
 
160
- With `--ff`, a failure only stops workspaces that haven't started yet; any
161
- workspace already running when the failure is detected runs to completion
162
- (sumlyzer doesn't kill in-flight processes).
163
-
164
- ![Concurrent run stopping early on failure](https://github.com/ErwanRaulo/sumlyzer/blob/main/concurrency-failed.png?raw=true)
165
-
166
- ### Changed workspaces
167
-
168
- `--changed` only runs workspaces whose own files changed according to git,
169
- skipping the rest. It maps each changed file to the workspace directory that
170
- contains it.
171
-
172
- ```
173
- npx sumlyzer --changed
174
- npx sumlyzer --changed --ref origin/main
175
- ```
176
-
177
- Without `--ref`, the git ref to diff against is auto-detected:
178
-
179
- - Uncommitted changes present → diff against `HEAD` (the local dev loop).
180
- - Clean working tree with an upstream branch configured → diff against the
181
- merge-base with that upstream, so commits already on the branch count as
182
- "changed" without pulling in unrelated commits the upstream picked up in
183
- the meantime.
184
- - Clean working tree with no upstream configured (or no common ancestor, e.g.
185
- a shallow clone) → `HEAD`, which reports "no changes".
186
-
187
- ## Why
76
+ ## Roadmap
188
77
 
189
- This fail-fast behavior at the `--workspaces` level has been requested from
190
- npm more than once: [npm/rfcs#575](https://github.com/npm/rfcs/issues/575)
191
- (open) and [npm/rfcs#602](https://github.com/npm/rfcs/issues/602) (closed).
192
- Until it lands, sumlyzer's `--ff` flag gets you there, see also this
193
- [Stack Overflow answer](https://stackoverflow.com/questions/71300870/npm-workspace-command-does-not-stop-executing-when-command-fails-for-a-workspace/79989284#79989284)
194
- on the same problem.
78
+ **Watch mode** — walk the workspace dependency graph so a change in one workspace also re-runs the ones that depend on it.
195
79
 
196
80
  ## Contributing
197
81
 
198
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup, conventions, and how to submit changes.
82
+ See [CONTRIBUTING.md](./CONTRIBUTING.md).
199
83
 
200
84
  ## License
201
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumlyzer",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
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": {