@ai-ecoverse/slicc-shared-web 1.20.0 → 1.21.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.
- package/README.md +13 -1
- package/bin/slicc-memory-peak.sh +43 -0
- package/harness/trace.mjs +3 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Configuration shared by SLICC's web repos ([slicc-bios](https://github.com/ai-ec
|
|
|
10
10
|
| `tsconfig.json` | TypeScript base for Node's type stripping | `tsconfig.json`: `{ "extends": "@ai-ecoverse/slicc-shared-web/tsconfig.json", "include": ["src/**/*.ts"] }` |
|
|
11
11
|
| `lefthook.yml` | Pre-commit hooks: Biome, typecheck, no comments, no unit tests in git, AGENTS.md, and diff coverage over [only the unit tests the change reaches](#which-unit-tests-a-commit-runs) | `lefthook.yml`: `extends: [node_modules/@ai-ecoverse/slicc-shared-web/lefthook.yml]` |
|
|
12
12
|
| `mcr.config.mjs` | Unit-test coverage for JS and TS sources in `src/` (TS types are stripped first), written to `coverage/unit/lcov.info`. With `SLICC_UNIT_TESTS` set, `node --test` runs only those files ([below](#which-unit-tests-a-commit-runs)) | `test:unit`: `mcr -c node_modules/@ai-ecoverse/slicc-shared-web/mcr.config.mjs node --test 'test/unit/**/*.test.mjs'` |
|
|
13
|
-
| `bin/` | `slicc-lint` runs every check below plus Biome and, if the repo has one, `typecheck`. `slicc-lint-comments` runs the [slicc no-comment checker](https://github.com/ai-ecoverse/slicc/tree/main/packages/dev-tools/no-comment) at a pinned commit, allowing AGENTS.md and [`# renovate:` annotations](#versions-pinned-in-workflow-files) in workflow and action files. `slicc-agents-md`, `slicc-no-unit-tests` and `slicc-diff-cover` complete the set, and `slicc-unit-cover` is the diff-coverage hook. `slicc-minidump <file.dmp>...` prints a crash dump's stack, described [below](#crash-dumps) | `lint`: `slicc-lint`, and the hooks above |
|
|
13
|
+
| `bin/` | `slicc-lint` runs every check below plus Biome and, if the repo has one, `typecheck`. `slicc-lint-comments` runs the [slicc no-comment checker](https://github.com/ai-ecoverse/slicc/tree/main/packages/dev-tools/no-comment) at a pinned commit, allowing AGENTS.md and [`# renovate:` annotations](#versions-pinned-in-workflow-files) in workflow and action files. `slicc-agents-md`, `slicc-no-unit-tests` and `slicc-diff-cover` complete the set, and `slicc-unit-cover` is the diff-coverage hook. `slicc-minidump <file.dmp>...` prints a crash dump's stack, described [below](#crash-dumps). `slicc-memory-peak` prints the job's [memory peak](#memory-peak) | `lint`: `slicc-lint`, and the hooks above |
|
|
14
14
|
| `pnpmfile.mjs` | pnpm's counterpart to the Renovate preset: an `updateConfig` hook that adds `@ai-ecoverse/*` to `minimumReleaseAgeExclude`, so pnpm 12 doesn't hold back our own fresh releases (`ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION`) while third-party packages keep its age check | in a repo with a pnpm lockfile, as a [config dependency](https://pnpm.io/config-dependencies) in `pnpm-workspace.yaml`: `configDependencies: { '@ai-ecoverse/slicc-shared-web': X.Y.Z }` plus `pnpmfile: node_modules/.pnpm-config/@ai-ecoverse/slicc-shared-web/pnpmfile.mjs` |
|
|
15
15
|
| `harness/` | The CDP integration-test harness, described [below](#integration-test-harness) | `import { launch } from '@ai-ecoverse/slicc-shared-web/harness'`, and `--test-global-setup=node_modules/@ai-ecoverse/slicc-shared-web/harness/global.mjs` |
|
|
16
16
|
|
|
@@ -64,6 +64,17 @@ When a command needs the version more than once, as actionlint's download does,
|
|
|
64
64
|
|
|
65
65
|
Pin only where a fixed version is genuinely needed. When a workflow rolls forward to whatever is certified, as with `@ai-ecoverse/slicc-kernel` and its certified siblings, resolve "the newest certified" at run time instead (from the npm `latest` dist-tag, say) rather than pinning and annotating it.
|
|
66
66
|
|
|
67
|
+
## Memory peak
|
|
68
|
+
|
|
69
|
+
The reusable workflow's last step, which runs even when an earlier one failed, writes one line to the log and the job summary. It gives the job's memory peak and limit in MiB, `nproc` and the runner's name, so a runner that later "lost communication" can be compared with the peak of the same job's good runs. The numbers come from cgroup v2 (`memory.peak`, `memory.max`), from the job's own cgroup first and then the root one, or else from cgroup v1 (`memory.max_usage_in_bytes`, `memory.limit_in_bytes`), and the line names the file each one came from. A value it can't read is `n/a`, and the step never fails the job. A repo whose `@ai-ecoverse/slicc-shared-web` predates the script still gets `nproc` and the runner name.
|
|
70
|
+
|
|
71
|
+
A workflow of its own (not this reusable one) gets the same line from the composite action, as its last step:
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
- uses: ai-ecoverse/slicc-shared-web/.github/actions/memory-peak@<tag or sha>
|
|
75
|
+
if: always()
|
|
76
|
+
```
|
|
77
|
+
|
|
67
78
|
## Which unit tests a commit runs
|
|
68
79
|
|
|
69
80
|
The diff-coverage hook, `slicc-unit-cover`, runs only the unit tests that cover the staged change, then `slicc-diff-cover` on their `coverage/unit/lcov.info`, so every staged line in `src/` still has to run:
|
|
@@ -145,6 +156,7 @@ test('boots', async (t) => {
|
|
|
145
156
|
- when profiling is on, it saves a CPU profile sample of every page and worker in the test, including workers started by other workers, as `stall-<n>-<target>-<session>.cpuprofile`;
|
|
146
157
|
- it adds a line per target to `console.log`, saying whether that target is running or paused;
|
|
147
158
|
- on the first stall, it records a 10 s browser trace as `stall-1-trace.json` (open it in DevTools' Performance panel or Perfetto). The browser collects it with V8 CPU samples per thread, task, IPC, Blink and loading events, so it shows what a page's main thread is doing even when that thread no longer answers CDP. It logs each process's CPU time over the window, and for each renderer its main thread's task count, the call chain of its longest or still open task (function, file, line and URL of a request), and where its CPU samples fall. The targets are sampled after the trace starts, so their new profiles carry their call frames into it. A call that started before the trace shows only as a node id, since its frames were named before; a thread that is blocked keeps `Tracing.start` waiting, which the harness logs and traces through;
|
|
159
|
+
- the summary runs in the test process, which also serves the page's files and talks CDP, so it is linear in the trace's events: a busy page's half-million-event trace takes well under a second, and the page's fetches keep getting answers meanwhile;
|
|
148
160
|
- it adds a line for every debugger pause still held in the browser, in any target, with its id, URL, start time, reason and top call frames.
|
|
149
161
|
|
|
150
162
|
A pause in one target blocks every page in the same renderer process, so those pause lines name the culprit even when it isn't the page under test. The harness resumes its own coverage pauses (`beforeunload`, worker exits) within 10 s, even when collecting coverage fails. Downloads of intercepted URLs time out after 60 s and are tried up to three times; a `4xx` is not retried. `chrome.requests` lists the paths the server saw in this test, `chrome.overrides` is a `Map` of paths to bodies served instead of files, and `chrome.cdn` takes `status` (answer every intercepted request with it), `corrupt` (flip the last byte) and lists the intercepted `requests`. All of them reset with each test. `serve(options)` starts the same server on its own, for an `npm start`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set +e
|
|
3
|
+
own=$(sed -n 's/^0:://p' /proc/self/cgroup 2>/dev/null)
|
|
4
|
+
first() {
|
|
5
|
+
found=n/a
|
|
6
|
+
from=-
|
|
7
|
+
for file in "$@"; do
|
|
8
|
+
if [ -r "$file" ]; then
|
|
9
|
+
value=$(cat "$file" 2>/dev/null)
|
|
10
|
+
if [ -n "$value" ]; then
|
|
11
|
+
found=$value
|
|
12
|
+
from=$file
|
|
13
|
+
return
|
|
14
|
+
fi
|
|
15
|
+
fi
|
|
16
|
+
done
|
|
17
|
+
}
|
|
18
|
+
mib() {
|
|
19
|
+
case "$1" in
|
|
20
|
+
max) printf 'unlimited' ;;
|
|
21
|
+
'' | *[!0-9]*) printf 'n/a' ;;
|
|
22
|
+
*)
|
|
23
|
+
if [ "${#1}" -gt 15 ]; then
|
|
24
|
+
printf 'unlimited'
|
|
25
|
+
else
|
|
26
|
+
printf '%s MiB' $(($1 / 1048576))
|
|
27
|
+
fi
|
|
28
|
+
;;
|
|
29
|
+
esac
|
|
30
|
+
}
|
|
31
|
+
first "/sys/fs/cgroup$own/memory.peak" /sys/fs/cgroup/memory.peak /sys/fs/cgroup/memory/memory.max_usage_in_bytes
|
|
32
|
+
peak=$found
|
|
33
|
+
peak_file=$from
|
|
34
|
+
first "/sys/fs/cgroup$own/memory.max" /sys/fs/cgroup/memory.max /sys/fs/cgroup/memory/memory.limit_in_bytes
|
|
35
|
+
limit=$found
|
|
36
|
+
limit_file=$from
|
|
37
|
+
cpus=$(nproc 2>/dev/null || echo n/a)
|
|
38
|
+
line="memory peak $(mib "$peak") ($peak_file), limit $(mib "$limit") ($limit_file), nproc $cpus, runner ${SLICC_RUNNER_NAME:-${RUNNER_NAME:-n/a}}"
|
|
39
|
+
echo "$line"
|
|
40
|
+
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
|
|
41
|
+
printf '### Memory\n\n%s\n' "$line" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null
|
|
42
|
+
fi
|
|
43
|
+
exit 0
|
package/harness/trace.mjs
CHANGED
|
@@ -87,7 +87,9 @@ function mains(events, { names, processes }) {
|
|
|
87
87
|
for (const event of events) {
|
|
88
88
|
const ours = names.get(`${event.pid}:${event.tid}`) === 'CrRendererMain';
|
|
89
89
|
if (!ours || processes.get(event.pid) !== 'Renderer' || event.ph === 'M') continue;
|
|
90
|
-
|
|
90
|
+
const list = found.get(event.pid);
|
|
91
|
+
if (list) list.push(event);
|
|
92
|
+
else found.set(event.pid, [event]);
|
|
91
93
|
}
|
|
92
94
|
return [...found].map(([pid, slices]) => main(pid, slices, last));
|
|
93
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.1",
|
|
4
4
|
"description": "Shared Renovate, Biome, TypeScript, lefthook and GitHub Actions configuration, plus the CDP integration-test harness, for SLICC's web repos",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"slicc-diff-cover": "bin/slicc-diff-cover.sh",
|
|
37
37
|
"slicc-lint": "bin/slicc-lint.sh",
|
|
38
38
|
"slicc-lint-comments": "bin/slicc-lint-comments.sh",
|
|
39
|
+
"slicc-memory-peak": "bin/slicc-memory-peak.sh",
|
|
39
40
|
"slicc-minidump": "bin/slicc-minidump.mjs",
|
|
40
41
|
"slicc-no-unit-tests": "bin/slicc-no-unit-tests.sh",
|
|
41
42
|
"slicc-unit-cover": "bin/slicc-unit-cover.mjs"
|
|
@@ -61,11 +62,11 @@
|
|
|
61
62
|
"release": "semantic-release"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
|
-
"@ai-ecoverse/slicc-browsers": "1.7.
|
|
65
|
+
"@ai-ecoverse/slicc-browsers": "1.7.3",
|
|
65
66
|
"@biomejs/biome": "2.5.15",
|
|
66
67
|
"monocart-coverage-reports": "2.13.2",
|
|
67
68
|
"playwright-core": "1.64.0",
|
|
68
|
-
"pnpm": "12.
|
|
69
|
+
"pnpm": "12.11.0",
|
|
69
70
|
"semantic-release": "25.0.9"
|
|
70
71
|
},
|
|
71
72
|
"peerDependencies": {
|