@ai-ecoverse/slicc-shared-web 2.14.4 → 2.16.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 +7 -3
- package/harness/chrome.mjs +29 -6
- package/harness/dumps.mjs +2 -1
- package/harness/index.mjs +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ Each reviewer answers with `findings.json`, held to one JSON schema:
|
|
|
118
118
|
|
|
119
119
|
### Which pull requests get a review
|
|
120
120
|
|
|
121
|
-
Every pull request does, except Renovate's: one opened by `renovate[bot]` from a `renovate/` branch, on an event `renovate[bot]` caused (a push by anyone else onto that branch gets a review). A Renovate branch is `renovate/<group slug>`, or `renovate/major-<group slug>` for a major, or `renovate/<dependency>-<version>` outside a group. Its pull request gets a review only when the slug, without `major-`, matches one of the globs in `review-renovate`, one per line:
|
|
121
|
+
Every pull request does, except Renovate's: one opened by `renovate[bot]` from a `renovate/` branch, on an event `renovate[bot]`, or a bot listed in `renovate-bots`, caused (a push by anyone else onto that branch gets a review). A Renovate branch is `renovate/<group slug>`, or `renovate/major-<group slug>` for a major, or `renovate/<dependency>-<version>` outside a group. Its pull request gets a review only when the slug, without `major-`, matches one of the globs in `review-renovate`, one per line:
|
|
122
122
|
|
|
123
123
|
```yaml
|
|
124
124
|
with:
|
|
@@ -129,6 +129,8 @@ Every pull request does, except Renovate's: one opened by `renovate[bot]` from a
|
|
|
129
129
|
|
|
130
130
|
`*` reviews every Renovate pull request. With the default, none, a Renovate pull request is held only by its integration tests.
|
|
131
131
|
|
|
132
|
+
A repo whose own GitHub App pushes onto Renovate's branches (a refresh commit, say) names it in `renovate-bots`, by login, one per line or comma-separated, with or without `[bot]`: `homescoop-renovate-refresh`. A push by a listed bot onto a `renovate/` branch of a pull request `renovate[bot]` opened counts as Renovate's own, so it skips review exactly like Renovate's pushes unless the group matches `review-renovate`, and both reviewers accept the bot as the actor when the group does get a review. A push by it anywhere else gets a review as usual. List only a bot the repo controls. An entry that isn't a plain login (letters, digits and hyphens), `*` or any other wildcard included, fails `lint`.
|
|
133
|
+
|
|
132
134
|
The commands in `lint`, `test`, `deploy`, `review-browser` and `after-release` run with `bash -eo pipefail -c`, so a multi-line command stops at its first failing line, a failure inside a pipe included.
|
|
133
135
|
|
|
134
136
|
| Input | Default | |
|
|
@@ -150,6 +152,7 @@ The commands in `lint`, `test`, `deploy`, `review-browser` and `after-release` r
|
|
|
150
152
|
| `review-timeout-minutes` | `60` | how long each reviewer may take |
|
|
151
153
|
| `review-screenshots` | `30` | the most screenshots a reviewer may attach |
|
|
152
154
|
| `review-renovate` | none | globs of Renovate group slugs whose pull requests get a review |
|
|
155
|
+
| `renovate-bots` | none | logins of bots whose pushes onto Renovate's branches count as Renovate's, [above](#which-pull-requests-get-a-review) |
|
|
153
156
|
| `node-options` | none | node flags added to the test step's `NODE_OPTIONS`, such as `--max-old-space-size=8192` |
|
|
154
157
|
| `require-tests` | `true` | `integration` fails when no test ran |
|
|
155
158
|
| `flaky-retry` | `0` | the most failing files a shard reruns once, [flaky tests](#pipeline); `0` reruns and reports nothing |
|
|
@@ -332,6 +335,7 @@ test('boots', async (t) => {
|
|
|
332
335
|
| `extensions` | Unpacked extension directories to load. They are loaded with `Extensions.loadUnpacked` (behind `--enable-unsafe-extension-debugging`) once the harness is attached, so their service workers start paused like every other target. Their scripts are covered and profiled like the repo's own, and tests then run in the default browser context, closing their tabs when they end, because Chrome does not run extensions in the per-test contexts | none |
|
|
333
336
|
| `extension` | Load the [harness extension](#harness-extension). `false`, or `SLICC_HARNESS_EXTENSION=0` in the environment, leaves it out; any other value of either is an error | `true` |
|
|
334
337
|
| `headless` | Run Chrome headless | `true` unless `CI` is set; `SLICC_HEADLESS=1` or `0` overrides |
|
|
338
|
+
| `nice` | Lower Chrome's CPU priority to nice 10 (or keep the test process's, if that is lower still) right after it starts, so its helpers and every renderer it starts later inherit it, and a suite that runs several files side by side leaves a developer machine responsive | `true` unless `CI` is set; `SLICC_NICE=1` or `0` overrides |
|
|
335
339
|
| `persistent` | Run every test in the default browser context, on the launch's on-disk `slicc-harness-*` profile, instead of a fresh off-the-record context per test. Off-the-record contexts keep OPFS in memory, with a far smaller real budget than `navigator.storage.estimate()` reports, so a suite that stores hundreds of MB there needs this. When a test ends, its tabs are closed and `Storage.clearDataForOrigin` (`storageTypes: 'all'`) clears the server's origin, every origin a page in the context showed (popups the app opened included) and every origin the harness's tabs got a response from, so nothing leaks into the next test. If clearing fails, the test fails | `false` |
|
|
336
340
|
| `executable` | The Chromium binary. Without it, `$CHROME_PATH`, then slicc-cdp's `findBrowser()`, then playwright-core (see above) | found |
|
|
337
341
|
| `args` | Extra Chromium flags, such as `--host-resolver-rules` or `--ignore-certificate-errors` | none |
|
|
@@ -391,8 +395,8 @@ A lane that can't have it opts out explicitly, in one of two ways:
|
|
|
391
395
|
|
|
392
396
|
`close()` stops Chrome and removes its profile. It asks Chrome to close, waits up to 10 s for the exit, sends `SIGKILL`, waits up to 5 s more and then moves on with a warning, so a browser that ignores `Browser.close` or a missed exit never hangs teardown. A test process that ends without `close()` still leaves nothing running:
|
|
393
397
|
- on `exit` and on `SIGINT`, `SIGTERM` or `SIGHUP`, the harness kills every browser it started in that process, with all its helper processes (Chrome runs in its own process group), with `SIGKILL` and removes its profile and crash dump directory, then re-raises the signal so the process ends the way it would have;
|
|
394
|
-
- when the test process dies of `SIGKILL`, no handler runs. A watchdog, a `sh` in its own process group that reads a pipe from the test process, then gets end of file and kills Chrome's process group with `SIGKILL` at once. Chrome also shuts itself down when the CDP pipe closes, but that can take seconds. Only the profile
|
|
395
|
-
- the first `launch()` in a process removes every `slicc-harness-*` directory in `$TMPDIR` that is older than a day, or older than a minute and no running process uses as its `--user-data-dir
|
|
398
|
+
- when the test process dies of `SIGKILL`, no handler runs. A watchdog, a `sh` in its own process group that reads a pipe from the test process, then gets end of file and kills Chrome's process group with `SIGKILL` at once. Chrome also shuts itself down when the CDP pipe closes, but that can take seconds. Only the profile and the crash dump directory stay behind;
|
|
399
|
+
- the first `launch()` in a process removes every `slicc-harness-*` directory in `$TMPDIR` that is older than a day, or older than a minute and no running process uses as its `--user-data-dir`, and every `slicc-crashes-*` crash dump directory that is older than a day, or older than a minute and no running process (crashpad's `--database`) names. It never kills a process.
|
|
396
400
|
|
|
397
401
|
## Crash dumps
|
|
398
402
|
|
package/harness/chrome.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execFile, spawn } from 'node:child_process';
|
|
2
2
|
import { rmSync } from 'node:fs';
|
|
3
3
|
import { lstat, mkdir, mkdtemp, readdir, rm, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
4
|
+
import { getPriority, setPriority, tmpdir } from 'node:os';
|
|
5
5
|
import { basename, join } from 'node:path';
|
|
6
6
|
import { env as inherited } from 'node:process';
|
|
7
7
|
import { promisify } from 'node:util';
|
|
@@ -9,7 +9,7 @@ import { executablePath, explicit } from './browser.mjs';
|
|
|
9
9
|
import { cdn } from './cdn.mjs';
|
|
10
10
|
import { CRASHED, connect, pipe, SEND_TIMEOUT } from './cdp.mjs';
|
|
11
11
|
import { screenFor } from './display.mjs';
|
|
12
|
-
import { crashpad } from './dumps.mjs';
|
|
12
|
+
import { crashpad, DUMPS } from './dumps.mjs';
|
|
13
13
|
import {
|
|
14
14
|
builtinWanted,
|
|
15
15
|
exclusive,
|
|
@@ -53,6 +53,23 @@ export function headlessByDefault(env = inherited) {
|
|
|
53
53
|
return !env.CI || env.CI === 'false' || env.CI === '0';
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
export const NICE = 10;
|
|
57
|
+
|
|
58
|
+
export function niceByDefault(env = inherited) {
|
|
59
|
+
if (env.SLICC_NICE === '1') return true;
|
|
60
|
+
if (env.SLICC_NICE === '0') return false;
|
|
61
|
+
return !env.CI || env.CI === 'false' || env.CI === '0';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function lower(pid, nice = NICE) {
|
|
65
|
+
try {
|
|
66
|
+
setPriority(pid, Math.max(getPriority(pid), nice));
|
|
67
|
+
return true;
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
56
73
|
export const modeFlags = (headless) =>
|
|
57
74
|
headless ? ['--headless=new'] : ['--enable-unsafe-swiftshader'];
|
|
58
75
|
|
|
@@ -106,7 +123,8 @@ export async function start(
|
|
|
106
123
|
profile,
|
|
107
124
|
args = commandLine(profile),
|
|
108
125
|
executable = undefined,
|
|
109
|
-
env = inherited
|
|
126
|
+
env = inherited,
|
|
127
|
+
nice = false
|
|
110
128
|
) {
|
|
111
129
|
const path = executable ?? (await executablePath({ env }));
|
|
112
130
|
const child = spawn(path, args, {
|
|
@@ -114,6 +132,7 @@ export async function start(
|
|
|
114
132
|
detached: true,
|
|
115
133
|
stdio: ['ignore', 'ignore', 'pipe', 'pipe', 'pipe'],
|
|
116
134
|
});
|
|
135
|
+
if (nice && child.pid > 0) lower(child.pid);
|
|
117
136
|
const stderr = lines(child.stderr);
|
|
118
137
|
const drained = new Promise((resolve) => child.stderr.once('close', resolve));
|
|
119
138
|
const exited = new Promise((resolve) => {
|
|
@@ -239,16 +258,18 @@ export async function commandLines() {
|
|
|
239
258
|
export async function prune(dir = tmpdir(), grace = GRACE) {
|
|
240
259
|
const lines = await commandLines().catch(ignore);
|
|
241
260
|
const used = (path) => lines.some((line) => line.includes(`--user-data-dir=${path} `));
|
|
261
|
+
const held = (name) => lines.some((line) => line.includes(`${name} `));
|
|
262
|
+
const busy = (name, path) => (name.startsWith(PREFIX) ? used(path) : held(name));
|
|
242
263
|
const names = await readdir(dir).catch(() => []);
|
|
243
264
|
const now = Date.now();
|
|
244
265
|
const removing = names
|
|
245
|
-
.filter((name) => name.startsWith(PREFIX))
|
|
266
|
+
.filter((name) => name.startsWith(PREFIX) || name.startsWith(DUMPS))
|
|
246
267
|
.map(async (name) => {
|
|
247
268
|
const path = join(dir, name);
|
|
248
269
|
const info = await lstat(path).catch(ignore);
|
|
249
270
|
if (!info?.isDirectory()) return;
|
|
250
271
|
const age = now - info.mtimeMs;
|
|
251
|
-
const orphaned = lines !== null && age > grace && !
|
|
272
|
+
const orphaned = lines !== null && age > grace && !busy(name, path);
|
|
252
273
|
if (age > DAY || orphaned) await rm(path, { recursive: true, force: true }).catch(ignore);
|
|
253
274
|
});
|
|
254
275
|
await Promise.all(removing);
|
|
@@ -332,6 +353,7 @@ export async function launch({
|
|
|
332
353
|
profile = inherited.SLICC_PROFILE === '1',
|
|
333
354
|
realistic = false,
|
|
334
355
|
headless = headlessByDefault(),
|
|
356
|
+
nice = niceByDefault(),
|
|
335
357
|
persistent = false,
|
|
336
358
|
executable,
|
|
337
359
|
} = {}) {
|
|
@@ -354,7 +376,8 @@ export async function launch({
|
|
|
354
376
|
userData,
|
|
355
377
|
commandLine(userData, loaded, args, realistic, builtin, headless),
|
|
356
378
|
browser,
|
|
357
|
-
screen.env
|
|
379
|
+
screen.env,
|
|
380
|
+
nice
|
|
358
381
|
).catch((error) => scrap(error, screen.close));
|
|
359
382
|
const untrack = track(child, [userData, dumps.dir], [screen.child].filter(Boolean));
|
|
360
383
|
const cdp = await connect(pipe(child.stdio[3], child.stdio[4]), {
|
package/harness/dumps.mjs
CHANGED
|
@@ -5,13 +5,14 @@ import { env } from 'node:process';
|
|
|
5
5
|
import { sleep } from './util.mjs';
|
|
6
6
|
|
|
7
7
|
export const DUMP_WAIT = 10000;
|
|
8
|
+
export const DUMPS = 'slicc-crashes-';
|
|
8
9
|
|
|
9
10
|
async function list(dir, sub) {
|
|
10
11
|
return (await readdir(join(dir, sub)).catch(() => [])).map((file) => join(sub, file));
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export async function crashpad() {
|
|
14
|
-
const dir = await mkdtemp(join(tmpdir(),
|
|
15
|
+
const dir = await mkdtemp(join(tmpdir(), DUMPS));
|
|
15
16
|
const kept = new Set();
|
|
16
17
|
const scan = async () => {
|
|
17
18
|
const [pending, completed, writing] = await Promise.all(
|
package/harness/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { connect } from './cdp.mjs';
|
|
2
|
-
export { headlessByDefault, launch, modeFlags } from './chrome.mjs';
|
|
2
|
+
export { headlessByDefault, launch, modeFlags, niceByDefault } from './chrome.mjs';
|
|
3
3
|
export { screenFor } from './display.mjs';
|
|
4
4
|
export {
|
|
5
5
|
BUILTIN_ID as EXTENSION_ID,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.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",
|
|
@@ -75,12 +75,12 @@
|
|
|
75
75
|
"release": "semantic-release"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@ai-ecoverse/slicc-browsers": "1.
|
|
79
|
-
"@ai-ecoverse/slicc-cdp": "1.
|
|
80
|
-
"@biomejs/biome": "2.6.
|
|
78
|
+
"@ai-ecoverse/slicc-browsers": "1.27.2",
|
|
79
|
+
"@ai-ecoverse/slicc-cdp": "1.54.0",
|
|
80
|
+
"@biomejs/biome": "2.6.7",
|
|
81
81
|
"lefthook": "2.2.2",
|
|
82
|
-
"monocart-coverage-reports": "3.2.
|
|
83
|
-
"pnpm": "12.
|
|
82
|
+
"monocart-coverage-reports": "3.2.1",
|
|
83
|
+
"pnpm": "12.19.0",
|
|
84
84
|
"semantic-release": "25.0.9"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|