@ai-ecoverse/slicc-shared-web 1.20.0 → 1.21.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 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:
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-shared-web",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
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,7 +62,7 @@
61
62
  "release": "semantic-release"
62
63
  },
63
64
  "devDependencies": {
64
- "@ai-ecoverse/slicc-browsers": "1.7.0",
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",