@ai-ecoverse/slicc-shared-web 2.13.0 → 2.13.2
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 +2 -2
- package/bin/slicc-flaky.mjs +57 -11
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ The caller cancels superseded runs on pull requests only, so a push to `main` ne
|
|
|
82
82
|
windows-test: npm run test:windows
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
**Flaky tests.** With `flaky-retry` above 0 (this repo's own CI sets 3; the default, 0, runs the tests once, as before), a shard whose tests failed reruns its failing files once, right away, on the same runner and commit, through `slicc-flaky retry`, which the test, `integration` and `flaky` jobs take from the pipeline's own commit. A test that fails, then passes is a flip; one that fails twice is a failure. A test is its file and its top-level name, and its key is the first 16 hex digits of `sha256(file \0 name)`. There is no rerun, and the shard fails as before, without a JUnit report or a failing test in it, with more than `flaky-retry` failing files, or when less than the rerun's limit, min(15 min, a quarter of `timeout-minutes`), is left of `timeout-minutes`. The rerun gets `SLICC_TEST_RETRY=1` and only those files, writes `junit/<shard>.retry.xml` (and no second `.files` list), keeps the first run's `artifacts/` and `coverage/` (its own artifacts go to `artifacts/retry/`), and is killed at the limit. `junit/<shard>.flaky.json` records each retried test's first and retry outcome, its first error and the runner. A flip passes the shard only if an open `flaky-test` issue has its key and has seen it on another commit (it has no `new` label, or its commit isn't this one), the test file doesn't match `strict-tests` and the pull request doesn't change it; every other flip stays red, and so does a test that is skipped, cancelled or missing on the rerun, a rerun that ran no test, wrote no JUnit report or timed out, and a test that passed first and failed on the rerun. Only the rerun's results count for those tests; its exit status doesn't, so a check after `node --test` in `test` (such as this repo's `verify.mjs`) doesn't fail a rerun of one file. `lint` reads the open `flaky-test` issues once (with `issues: read`) and the pull request's changed files, and hands them to the shards and `integration`; when it can't, no flake is known and every flip stays red. `integration` judges each shard's flips again from its JUnit reports and that list, counts only the failures it doesn't excuse, keeps every other check on the first run, and names the flakes: `integration: PASS … , 2 known flakes passed on retry (#916, #844)`. Each shard also uploads the tests that finally failed as `failed-<shard>-<attempt>`, and a test that failed on an earlier attempt of the run and passes now counts as a flip in the report, though not for the gate. The `flaky` job (`issues: write`, `actions: read`, `continue-on-error`) writes a table of the run's flips and failures to its step summary and files one issue per test: title `flaky: <file name> › <test name>`, label `flaky-test`, `new` until a second commit, `guard` for a strict row, whose issue and comments name only the test, the run and the commit, and ``Key: `<key>` `` in the body. It finds the issue among the open ones, then among those closed in the last 30 days, which it reopens, and otherwise opens one; it comments at most once per issue per run with the run and attempt, the event, the pull request, the shard, the runner, the commit and the first error (at most 3,000 characters). It posts nothing that holds the job token or a token-shaped string (the same scan the cert review's `post` had), nothing on a branch matching `flaky-quiet-branches`, nothing on a pull request whose run also has a failure or a shard that wasn't rerun, nothing for a test the pull request changes, and nothing at all when a run would open more than 5 issues (`flaky: <n> flips in one run, not filing (infrastructure?)`). In the merge queue, each open issue whose test passed first time gets `<!-- clean: <n> since <date> -->` in its body, which a flip clears; at `flaky-close-after` it is closed with `no flip in <n> clean merge-group runs since <date>; a new flip reopens it`. It needs `node --test` through the shared harness: `$TEST` must honour `SLICC_TEST_FILES` and write node's JUnit report with `file=`.
|
|
85
|
+
**Flaky tests.** With `flaky-retry` above 0 (this repo's own CI sets 3; the default, 0, runs the tests once, as before), a shard whose tests failed reruns its failing files once, right away, on the same runner and commit, through `slicc-flaky retry`, which the test, `integration` and `flaky` jobs take from the pipeline's own commit. A test that fails, then passes is a flip; one that fails twice is a failure. A test is its file and its top-level name, and its key is the first 16 hex digits of `sha256(file \0 name)`. There is no rerun, and the shard fails as before, without a JUnit report or a failing test in it, with more than `flaky-retry` failing files, or when less than the rerun's limit, min(15 min, a quarter of `timeout-minutes`), is left of `timeout-minutes`. A failing test whose JUnit `file=` isn't one of the run's `test-glob` files, such as Go's package directory, is never rerun (`not rerun: a failing test names no test file: <file>`), `integration` never excuses such a flip, whatever a shard's `flaky.json` says, and `flaky` logs it and files nothing. The rerun gets `SLICC_TEST_RETRY=1` and only those files, writes `junit/<shard>.retry.xml` (and no second `.files` list), keeps the first run's `artifacts/` and `coverage/` (its own artifacts go to `artifacts/retry/`), and is killed at the limit. `junit/<shard>.flaky.json` records each retried test's first and retry outcome, its first error and the runner. A flip passes the shard only if an open `flaky-test` issue has its key and has seen it on another commit (it has no `new` label, or its commit isn't this one), the test file doesn't match `strict-tests` and the pull request doesn't change it; every other flip stays red, and so does a test that is skipped, cancelled or missing on the rerun, a rerun that ran no test, wrote no JUnit report or timed out, and a test that passed first and failed on the rerun. Only the rerun's results count for those tests; its exit status doesn't, so a check after `node --test` in `test` (such as this repo's `verify.mjs`) doesn't fail a rerun of one file. `lint` reads the open `flaky-test` issues once (with `issues: read`) and the pull request's changed files, and hands them to the shards and `integration`; when it can't, no flake is known and every flip stays red. `integration` judges each shard's flips again from its JUnit reports and that list, counts only the failures it doesn't excuse, keeps every other check on the first run, and names the flakes: `integration: PASS … , 2 known flakes passed on retry (#916, #844)`. Each shard also uploads the tests that finally failed as `failed-<shard>-<attempt>`, and a test that failed on an earlier attempt of the run and passes now counts as a flip in the report, though not for the gate. The `flaky` job (`issues: write`, `actions: read`, `continue-on-error`) writes a table of the run's flips and failures to its step summary and files one issue per test: title `flaky: <file name> › <test name>`, label `flaky-test`, `new` until a second commit, `guard` for a strict row, whose issue and comments name only the test, the run and the commit, and ``Key: `<key>` `` in the body. It finds the issue among the open ones, then among those closed in the last 30 days, which it reopens, and otherwise opens one; it comments at most once per issue per run with the run and attempt, the event, the pull request, the shard, the runner, the commit and the first error (at most 3,000 characters). It posts nothing that holds the job token or a token-shaped string (the same scan the cert review's `post` had), nothing on a branch matching `flaky-quiet-branches`, nothing on a pull request whose run also has a failure or a shard that wasn't rerun, nothing for a test the pull request changes, and nothing at all when a run would open more than 5 issues (`flaky: <n> flips in one run, not filing (infrastructure?)`). In the merge queue, each open issue whose test passed first time gets `<!-- clean: <n> since <date> -->` in its body, which a flip clears; at `flaky-close-after` it is closed with `no flip in <n> clean merge-group runs since <date>; a new flip reopens it`. It needs `node --test` through the shared harness: `$TEST` must honour `SLICC_TEST_FILES` and write node's JUnit report with `file=`.
|
|
86
86
|
|
|
87
87
|
**Reviewer** runs twice, once with [claude-code-action](https://github.com/anthropics/claude-code-action) and once with [codex-action](https://github.com/openai/codex-action), on the same prompt, whether the tests passed or not. Both run on Amazon Bedrock with the org secret `AWS_BEARER_TOKEN_BEDROCK`, in the region of the org variable `CERT_AWS_REGION` (`us-west-2` without it). Claude uses the model in `CERT_BEDROCK_MODEL` (`global.anthropic.claude-opus-5-5` without it), as the cert reviews do. Codex uses its built-in `amazon-bedrock-runtime` provider (codex-action waits for its OpenAI proxy's `<run id>.json` in `codex-home` whenever it has a prompt, so the job writes a placeholder one) and the model in `CODEX_BEDROCK_MODEL` (`global.openai.gpt-6.1-sol` without it). Models that Bedrock serves only through inference profiles, as Sol 6.1 is, need the runtime provider and the profile's `global.` id; the `amazon-bedrock` provider's endpoint doesn't list them. The job token can only read. Each reviewer gets:
|
|
88
88
|
|
|
@@ -272,7 +272,7 @@ and the PR commits the `.githooks/` directory that the first `npm install` write
|
|
|
272
272
|
|
|
273
273
|
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:
|
|
274
274
|
|
|
275
|
-
- **Which directories are source:** `src/` by default, anywhere in the path, as before. A repo whose code lives elsewhere lists its directories in `package.json`: `"slicc": { "unitSources": ["extension", "six", "scripts"] }`, repo-relative, without `.` or `..` segments. `mcr.config.mjs` then collects coverage only from those directories, and the hook treats a staged file outside them as no code. A malformed list fails the hook.
|
|
275
|
+
- **Which directories are source:** `src/` by default, anywhere in the path, as before. A repo whose code lives elsewhere lists its directories in `package.json`: `"slicc": { "unitSources": ["extension", "six", "scripts"] }`, repo-relative, without `.` or `..` segments. `mcr.config.mjs` then collects coverage only from those directories, and the hook treats a staged file outside them as no code. A malformed list fails the hook. This repo lists its own `bin`, `harness`, `testing` and `unit`, and its `test:unit` uses the root `mcr.config.mjs`.
|
|
276
276
|
- **What counts as changed:** the staged files (`git diff --cached --name-only`), and nothing else. `test/unit/` is gitignored, and repos that keep their unit tests in a store outside git sync the whole store into it before a commit, which brings in tests for code that is on other branches; so a unit test that is new or edited runs only when its imports reach a staged file, like any other. One that reaches nothing staged adds no coverage to the staged lines.
|
|
277
277
|
- **Committing a merge, cherry-pick or rebase:** while `MERGE_HEAD` or `CHERRY_PICK_HEAD` exists, or a rebase is running and has stopped at `REBASE_HEAD`, only lines that are new against `HEAD` and against each of those commits count: conflict resolutions and edits made during the merge, not what the other side brought, which was covered where it was written. Diff coverage checks only those lines; the tests that run and the missing-lcov check follow the files that hold them, and files the merge itself deleted lines from, renamed, added empty or changed the mode of. A merge with no changes of its own is no code staged. A revert counts as usual.
|
|
278
278
|
- **A unit test for code this tree doesn't have:** a test whose imports reach a staged file but also a code module under the sources that doesn't exist, isn't gitignored and isn't a staged deletion (a store test for a module on another branch) is skipped, and the hook names it in one line before the count. A missing `new URL(…, import.meta.url)` target, a missing non-code file such as `.wasm` or `.json`, and a missing file outside the sources or gitignored (a build output such as `dist/` or a bundled worker) don't skip the test.
|
package/bin/slicc-flaky.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
readFileSync,
|
|
12
12
|
realpathSync,
|
|
13
13
|
rmSync,
|
|
14
|
+
statSync,
|
|
14
15
|
writeFileSync,
|
|
15
16
|
} from 'node:fs';
|
|
16
17
|
import { basename, dirname, isAbsolute, join, matchesGlob, relative, sep } from 'node:path';
|
|
@@ -216,7 +217,17 @@ export function isKnown(entry, sha) {
|
|
|
216
217
|
);
|
|
217
218
|
}
|
|
218
219
|
|
|
219
|
-
function
|
|
220
|
+
export function listed(text) {
|
|
221
|
+
try {
|
|
222
|
+
const parsed = JSON.parse(text || '[]');
|
|
223
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
224
|
+
} catch {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function category(test, { known, strict, changed, sha, tests }) {
|
|
230
|
+
if (!tests.includes(test.file)) return 'unattributed';
|
|
220
231
|
if (strict.some((glob) => matchesGlob(test.file, glob))) return 'strict';
|
|
221
232
|
if (changed.includes(test.file)) return 'changed';
|
|
222
233
|
return isKnown(known[key(test)], sha) ? 'known' : 'new';
|
|
@@ -384,14 +395,41 @@ function context(env) {
|
|
|
384
395
|
};
|
|
385
396
|
}
|
|
386
397
|
|
|
387
|
-
function rules(env) {
|
|
398
|
+
function rules(env, tests) {
|
|
388
399
|
const { known, changed } = lint(env.FLAKY);
|
|
389
|
-
return {
|
|
400
|
+
return {
|
|
401
|
+
known,
|
|
402
|
+
changed,
|
|
403
|
+
strict: globs(env.STRICT),
|
|
404
|
+
sha: env.SHA || env.GITHUB_SHA || '',
|
|
405
|
+
tests,
|
|
406
|
+
};
|
|
390
407
|
}
|
|
391
408
|
|
|
392
|
-
function
|
|
409
|
+
function regular(file, root) {
|
|
410
|
+
try {
|
|
411
|
+
return statSync(join(root, file)).isFile();
|
|
412
|
+
} catch {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function skipReason({
|
|
418
|
+
reports,
|
|
419
|
+
failing,
|
|
420
|
+
files,
|
|
421
|
+
tests,
|
|
422
|
+
root,
|
|
423
|
+
most,
|
|
424
|
+
elapsed,
|
|
425
|
+
limit,
|
|
426
|
+
budget,
|
|
427
|
+
options,
|
|
428
|
+
}) {
|
|
393
429
|
if (reports.length === 0) return 'no JUnit report';
|
|
394
430
|
if (failing.length === 0) return 'no failing test in the JUnit report';
|
|
431
|
+
const nameless = files.find((file) => !tests.includes(file) || !regular(file, root));
|
|
432
|
+
if (nameless !== undefined) return `a failing test names no test file: ${nameless}`;
|
|
395
433
|
if (files.length > most) return `${files.length} files failed, more than flaky-retry (${most})`;
|
|
396
434
|
if (elapsed + limit > budget) return 'past the time budget';
|
|
397
435
|
if (!options) return 'NODE_OPTIONS names no JUnit destination';
|
|
@@ -430,17 +468,19 @@ export async function retry(env = process.env) {
|
|
|
430
468
|
Boolean(env.SLICC_TEST_JUNIT) &&
|
|
431
469
|
(env.NODE_OPTIONS ?? '').includes(`--test-reporter-destination=${env.SLICC_TEST_JUNIT}`);
|
|
432
470
|
const most = Number(env.FLAKY_RETRY);
|
|
471
|
+
const given = rules(env, globs(env.SLICC_TEST_ALL));
|
|
433
472
|
const skipped = skipReason({
|
|
434
473
|
reports,
|
|
435
474
|
failing,
|
|
436
475
|
files,
|
|
476
|
+
tests: given.tests,
|
|
477
|
+
root: record.root,
|
|
437
478
|
most,
|
|
438
479
|
elapsed: Date.now() - started,
|
|
439
480
|
limit,
|
|
440
481
|
budget,
|
|
441
482
|
options,
|
|
442
483
|
});
|
|
443
|
-
const given = rules(env);
|
|
444
484
|
if (skipped) {
|
|
445
485
|
record.skipped = skipped;
|
|
446
486
|
record.rows = judge({ first: tests, retry: undefined, rerun: null, ...given }).rows;
|
|
@@ -488,7 +528,7 @@ export async function retry(env = process.env) {
|
|
|
488
528
|
}
|
|
489
529
|
|
|
490
530
|
export function verdict(env = process.env, dir = 'junit') {
|
|
491
|
-
const given = rules(env);
|
|
531
|
+
const given = rules(env, listed(env.FILES));
|
|
492
532
|
const covered = new Set();
|
|
493
533
|
const passed = [];
|
|
494
534
|
let failed = 0;
|
|
@@ -847,7 +887,13 @@ function reportContext(env) {
|
|
|
847
887
|
};
|
|
848
888
|
}
|
|
849
889
|
|
|
850
|
-
function
|
|
890
|
+
function named(entry, tests) {
|
|
891
|
+
if (entry.kind === 'failure' || tests.includes(entry.file)) return true;
|
|
892
|
+
console.log(`flaky: ${entry.file} › ${entry.name}: not filed: it names no test file`);
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
function collect(found, ctx, tests) {
|
|
851
897
|
const entries = [];
|
|
852
898
|
const passing = new Set();
|
|
853
899
|
for (const { record, first } of found) {
|
|
@@ -867,21 +913,21 @@ function collect(found, ctx) {
|
|
|
867
913
|
}
|
|
868
914
|
}
|
|
869
915
|
for (const entry of entries) if (entry.kind !== 'failure') passing.delete(entry.key);
|
|
870
|
-
return { entries, passing };
|
|
916
|
+
return { entries: entries.filter((entry) => named(entry, tests)), passing };
|
|
871
917
|
}
|
|
872
918
|
|
|
873
919
|
export async function report(env = process.env, dir = 'junit') {
|
|
874
920
|
const ctx = reportContext(env);
|
|
875
|
-
const given = rules(env);
|
|
921
|
+
const given = rules(env, listed(env.FILES));
|
|
876
922
|
const found = shards(dir);
|
|
877
|
-
const { entries, passing } = collect(found, ctx);
|
|
923
|
+
const { entries, passing } = collect(found, ctx, given.tests);
|
|
878
924
|
const call = client(ctx);
|
|
879
925
|
const lines = [];
|
|
880
926
|
let notes = new Map();
|
|
881
927
|
try {
|
|
882
928
|
const seen = new Set(entries.map((entry) => entry.key));
|
|
883
929
|
for (const flip of ctx.token ? await earlier(call, ctx, found, given) : []) {
|
|
884
|
-
if (seen.has(flip.key)) continue;
|
|
930
|
+
if (seen.has(flip.key) || !named(flip, given.tests)) continue;
|
|
885
931
|
seen.add(flip.key);
|
|
886
932
|
entries.push({ ...flip, strict: flip.kind === 'strict' });
|
|
887
933
|
passing.delete(flip.key);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.2",
|
|
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",
|
|
@@ -11,6 +11,14 @@
|
|
|
11
11
|
"engines": {
|
|
12
12
|
"node": ">=24"
|
|
13
13
|
},
|
|
14
|
+
"slicc": {
|
|
15
|
+
"unitSources": [
|
|
16
|
+
"bin",
|
|
17
|
+
"harness",
|
|
18
|
+
"testing",
|
|
19
|
+
"unit"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
14
22
|
"fledgling": {
|
|
15
23
|
"provider": "github",
|
|
16
24
|
"workflow": "ci.yml",
|
|
@@ -61,14 +69,14 @@
|
|
|
61
69
|
"lint": "bin/slicc-lint.sh && shellcheck bin/*.sh",
|
|
62
70
|
"pretest": "slicc-cdp install-browser",
|
|
63
71
|
"test": "SLICC_PROFILE=1 node --test --test-global-setup=harness/global.mjs test/integration/*.test.mjs && node test/integration/verify.mjs",
|
|
64
|
-
"test:unit": "mcr -c
|
|
72
|
+
"test:unit": "mcr -c mcr.config.mjs node --test 'test/unit/**/*.test.mjs'",
|
|
65
73
|
"trust": "npx fledgling sync -y --skip-publish",
|
|
66
74
|
"trust:dry": "npx fledgling sync --dry-run -y --skip-publish",
|
|
67
75
|
"release": "semantic-release"
|
|
68
76
|
},
|
|
69
77
|
"devDependencies": {
|
|
70
78
|
"@ai-ecoverse/slicc-browsers": "1.18.15",
|
|
71
|
-
"@ai-ecoverse/slicc-cdp": "1.41.
|
|
79
|
+
"@ai-ecoverse/slicc-cdp": "1.41.22",
|
|
72
80
|
"@biomejs/biome": "2.5.15",
|
|
73
81
|
"lefthook": "2.2.2",
|
|
74
82
|
"monocart-coverage-reports": "2.13.2",
|