@ai-ecoverse/slicc-shared-web 2.7.11 → 2.8.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 +6 -3
- package/harness/chrome.mjs +4 -6
- package/harness/recorder.mjs +14 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ permissions:
|
|
|
43
43
|
pull-requests: write
|
|
44
44
|
statuses: write
|
|
45
45
|
id-token: write
|
|
46
|
+
attestations: write
|
|
46
47
|
|
|
47
48
|
concurrency:
|
|
48
49
|
group: ci-${{ github.ref }}
|
|
@@ -94,7 +95,7 @@ Each reviewer answers with `findings.json`, held to one JSON schema:
|
|
|
94
95
|
|
|
95
96
|
**Post** is the only job that writes to GitHub. Per reviewer it sets the commit status `review / claude` or `review / codex` (`success` for `approved`, `failure` for `denied`, `error` without findings), keeps one comment with its latest verdict and summary on the pull request (edited on each run), posts each comment on its line (or, for a line outside the diff, as a pull request comment naming it) unless the same comment is already there, and opens each issue unless one with the same title is already open. An issue in another repo of the same org needs `SLICC_ISSUES_TOKEN`, a token that can open issues there; without it, or when it is refused, the issue becomes a pull request comment instead. One outside the org is logged and skipped.
|
|
96
97
|
|
|
97
|
-
**Release** runs `semantic-release` after lint, on a push to `main` only, without any test: what reached `main` went through the merge queue. GitHub sometimes rejects a push right after the tag push with a bare `(failed)`, most often semantic-release's push of `refs/notes/semantic-release-vX.Y.Z`, so the step puts a small `git` wrapper first on `PATH`: it retries `git push` and `git fetch` up to five times, 5, 10, 15 and 20 seconds apart, and runs every other git command once, as well as semantic-release's `git fetch --unshallow`, which fails on the job's full clone by design before semantic-release falls back to a plain fetch. When the push still fails, semantic-release fails before it publishes. With `release-environment`, the job runs in that GitHub environment, and `after-release` is a command run after semantic-release when it released, that is when a new `v*` tag points at the commit, with that version as `RELEASE_VERSION` (a production deploy, say). It gets the job's OIDC token and
|
|
98
|
+
**Release** runs `semantic-release` after lint, on a push to `main` only, without any test: what reached `main` went through the merge queue. GitHub sometimes rejects a push right after the tag push with a bare `(failed)`, most often semantic-release's push of `refs/notes/semantic-release-vX.Y.Z`, so the step puts a small `git` wrapper first on `PATH`: it retries `git push` and `git fetch` up to five times, 5, 10, 15 and 20 seconds apart, and runs every other git command once, as well as semantic-release's `git fetch --unshallow`, which fails on the job's full clone by design before semantic-release falls back to a plain fetch. When the push still fails, semantic-release fails before it publishes. With `release-environment`, the job runs in that GitHub environment, and `after-release` is a command run after semantic-release when it released, that is when a new `v*` tag points at the commit, with that version as `RELEASE_VERSION` (a production deploy, say). It gets the job's OIDC token. With `release-secrets`, a newline- or space-separated list of secret names, semantic-release and `after-release` get those secrets as environment variables (signing keys, say); without it they get none. With `attest`, a path or glob (a newline-separated list for several), the job attests the build provenance of those files after a release, through GitHub artifact attestations: the certificate names `ai-ecoverse/slicc-shared-web/.github/workflows/pipeline.yml` at the pipeline's tag, and its build configuration names the caller's `.github/workflows/ci.yml`, so a verifier checks both. The release job asks for `attestations: write` whether or not `attest` is set, so the caller grants it.
|
|
98
99
|
|
|
99
100
|
**Review** is the check that stands for the reviews. On a pull request that gets a review it passes when both reviewers' `findings.json` say `approved`; when the repo can't read `AWS_BEARER_TOKEN_BEDROCK`, the reviewers don't start and it fails, naming the secret. On one that doesn't (a Renovate pull request outside `review-renovate`) it passes when `integration` did. In the merge queue it always passes, since the pull request was reviewed already. Require it next to `ci / integration`, as `ci / review`.
|
|
100
101
|
|
|
@@ -134,6 +135,8 @@ The commands in `lint`, `test`, `deploy`, `review-browser` and `after-release` r
|
|
|
134
135
|
| `require-tests` | `true` | `integration` fails when no test ran |
|
|
135
136
|
| `release-environment` | none | the GitHub environment the release job runs in |
|
|
136
137
|
| `after-release` | none | a command run after semantic-release, with `RELEASE_VERSION` |
|
|
138
|
+
| `release-secrets` | none | newline- or space-separated secret names (any case) that semantic-release and `after-release` get |
|
|
139
|
+
| `attest` | none | files whose build provenance the release attests, as `actions/attest-build-provenance`'s `subject-path` |
|
|
137
140
|
|
|
138
141
|
| Secret | Used by |
|
|
139
142
|
|---|---|
|
|
@@ -266,7 +269,7 @@ SLICC_UNIT_ALL=1 git commit
|
|
|
266
269
|
|
|
267
270
|
## Integration-test harness
|
|
268
271
|
|
|
269
|
-
`harness/` drives Chromium over raw CDP on `--remote-debugging-pipe`, as its only client, from `node --test`. On CI (`CI` set, as GitHub Actions does) Chrome runs headed, since headless Chrome behaves slightly differently; the pipeline starts Xvfb when the runner has no display. On a developer machine (no `CI`) it runs headless, so a test run doesn't open windows. `SLICC_HEADLESS=1` or `0`, or `launch({ headless })`, overrides either way. On Linux, a headed Chrome on CI (or with no `DISPLAY`) gets an Xvfb display of its own, started with `-displayfd` so it picks a free number and stopped with the browser: browsers launched side by side, as `node --test` runs files with `--test-concurrency`, never share a screen, so none takes another's window focus (four on one display broke `:focus-visible` checks in slicc-spectrum#572). This needs `Xvfb` on `PATH`; without it, Chrome uses `DISPLAY`, and on a Linux desktop without `CI` it always does. Every page, service worker, shared worker and dedicated worker, nested ones included, starts paused, gets coverage (and the CPU profiler, when profiling is on) switched on in the same tick, and only then runs. Each test gets its own browser context and leaves `artifacts/<suite>/<test>/` behind: a screenshot per tab and a `console.log` of every target. Lines logged before the first test, such as an extension service worker's at startup, go into the first test's `console.log`. The global teardown merges the raw coverage into `coverage/` (console table, lcov, V8 HTML) and writes `artifacts/hotspots.md`.
|
|
272
|
+
`harness/` drives Chromium over raw CDP on `--remote-debugging-pipe`, as its only client, from `node --test`. On CI (`CI` set, as GitHub Actions does) Chrome runs headed, since headless Chrome behaves slightly differently; the pipeline starts Xvfb when the runner has no display. On a developer machine (no `CI`) it runs headless, so a test run doesn't open windows. `SLICC_HEADLESS=1` or `0`, or `launch({ headless })`, overrides either way. On Linux, a headed Chrome on CI (or with no `DISPLAY`) gets an Xvfb display of its own, started with `-displayfd` so it picks a free number and stopped with the browser: browsers launched side by side, as `node --test` runs files with `--test-concurrency`, never share a screen, so none takes another's window focus (four on one display broke `:focus-visible` checks in slicc-spectrum#572). This needs `Xvfb` on `PATH`; without it, Chrome uses `DISPLAY`, and on a Linux desktop without `CI` it always does. Every page, service worker, shared worker and dedicated worker, nested ones included, starts paused, gets coverage (and the CPU profiler, when profiling is on) switched on in the same tick, and only then runs. With nothing to collect (`coverage: []` and profiling off) only pages start paused: service and shared workers are left out of the auto-attach and attached once they exist, so they never wait for the harness. A held start that Chrome repeats when it stops and restarts a service worker during an update left the updated worker installed and the next navigation unanswered whenever the harness was slow to run it (slicc-bios#844, #836, #789). Each test gets its own browser context and leaves `artifacts/<suite>/<test>/` behind: a screenshot per tab and a `console.log` of every target. Lines logged before the first test, such as an extension service worker's at startup, go into the first test's `console.log`. The global teardown merges the raw coverage into `coverage/` (console table, lcov, V8 HTML) and writes `artifacts/hotspots.md`.
|
|
270
273
|
|
|
271
274
|
CPU profiling is off by default. V8's sampler interrupts each page and worker thread every 100 µs with a signal, and the renderer SIGSEGVs in slicc-bios#114 all fault inside a signal handler walking the interrupted thread's frames, which points at it. Turn it on with `profile: true` or `SLICC_PROFILE=1` to get one CPU profile per target and snapshot in the test's artifact directory, and the 15 frames with the most self time in the repo's own scripts in `hotspots.md`. Without it, `hotspots.md` says that profiling is off.
|
|
272
275
|
|
|
@@ -300,7 +303,7 @@ test('boots', async (t) => {
|
|
|
300
303
|
| `roots` | `[urlPrefix, directory]` pairs the local server serves, first match wins | `[['/', 'src/']]` |
|
|
301
304
|
| `aliases` | Extra `[urlPrefix, directory]` pairs used only to map coverage and profiles back to files, for scripts that something else serves, such as a service worker | none |
|
|
302
305
|
| `isolated` | Send COOP, COEP and CORP on every response, so pages are cross-origin isolated | `false` |
|
|
303
|
-
| `coverage` | URL prefixes whose `.js`/`.mjs` scripts count for coverage. `node_modules/` never does. A `.map` next to a file is used. `[]` collects nothing: without profiling, no target gets the debugger, the profiler, exit breakpoints or a `beforeunload` pause, and workers
|
|
306
|
+
| `coverage` | URL prefixes whose `.js`/`.mjs` scripts count for coverage. `node_modules/` never does. A `.map` next to a file is used. `[]` collects nothing: without profiling, no target gets the debugger, the profiler, exit breakpoints or a `beforeunload` pause, and no worker, service and shared workers included, waits for the harness to start | `['/']` |
|
|
304
307
|
| `exits` | `{ urlPath: [regex, ...] }`: a breakpoint on the first line matching each pattern in that worker script, where the harness takes the worker's coverage and profile before it closes itself | none |
|
|
305
308
|
| `intercept` | Remote URL prefixes answered from a disk cache in `node_modules/.cache/`. Registry documents (anything on a `registry.*` host but a `/-/….tgz` tarball: packuments, abbreviated or full, and dist-tags) are fetched fresh once per test process and only served from the disk cache when the registry can't be reached (a `4xx` is passed on) | none |
|
|
306
309
|
| `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 |
|
package/harness/chrome.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
unpacked,
|
|
20
20
|
} from './extensions.mjs';
|
|
21
21
|
import { page } from './page.mjs';
|
|
22
|
-
import { breakpoints, recorder } from './recorder.mjs';
|
|
22
|
+
import { autoAttach, breakpoints, recorder, unpaused } from './recorder.mjs';
|
|
23
23
|
import { serve } from './server.mjs';
|
|
24
24
|
import { artifacts, bounded, ignore, sleep, slug, TIMED_OUT } from './util.mjs';
|
|
25
25
|
|
|
@@ -373,11 +373,9 @@ export async function launch({
|
|
|
373
373
|
});
|
|
374
374
|
const remote = await cdn(cdp, intercept);
|
|
375
375
|
await cdp.send('Target.setDiscoverTargets', { discover: true });
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
flatten: true,
|
|
380
|
-
});
|
|
376
|
+
const attaching = autoAttach({ coverage, profiling: profile });
|
|
377
|
+
if (attaching.filter) cdp.on((event) => unpaused(cdp, event));
|
|
378
|
+
await cdp.send('Target.setAutoAttach', attaching);
|
|
381
379
|
const harnessExtension = await (async () => {
|
|
382
380
|
const own = builtin ? await installBuiltin(cdp) : null;
|
|
383
381
|
await install(cdp, found);
|
package/harness/recorder.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { bounded, ignore, raw, samples, sleep, TIMED_OUT } from './util.mjs';
|
|
|
10
10
|
const Util = mcrUtil.Util ?? mcrUtil.default;
|
|
11
11
|
|
|
12
12
|
const profiled = new Set(['page', 'worker', 'service_worker', 'shared_worker']);
|
|
13
|
+
const unheld = ['service_worker', 'shared_worker'];
|
|
13
14
|
const sampling = [['Profiler.setSamplingInterval', { interval: 100 }], ['Profiler.start']];
|
|
14
15
|
const unloading = 'sliccHarnessUnload';
|
|
15
16
|
const unload = `addEventListener('beforeunload', function ${unloading}() { debugger; })`;
|
|
@@ -176,6 +177,19 @@ export function ownership(parents) {
|
|
|
176
177
|
};
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
export function autoAttach({ coverage = ['/'], profiling } = {}) {
|
|
181
|
+
const attach = { autoAttach: true, waitForDebuggerOnStart: true, flatten: true };
|
|
182
|
+
if (coverage.length > 0 || profiling) return attach;
|
|
183
|
+
const skipped = [...unheld, 'browser', 'tab'].map((type) => ({ type, exclude: true }));
|
|
184
|
+
return { ...attach, filter: [...skipped, {}] };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function unpaused(cdp, { method, params }) {
|
|
188
|
+
if (method !== 'Target.targetCreated' || !unheld.includes(params.targetInfo.type)) return null;
|
|
189
|
+
const { targetId } = params.targetInfo;
|
|
190
|
+
return cdp.send('Target.attachToTarget', { targetId, flatten: true }).catch(ignore);
|
|
191
|
+
}
|
|
192
|
+
|
|
179
193
|
export function retain(scripts, result) {
|
|
180
194
|
for (const script of result) {
|
|
181
195
|
const prev = scripts.get(script.url);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.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",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@ai-ecoverse/slicc-browsers": "1.18.5",
|
|
70
|
-
"@ai-ecoverse/slicc-cdp": "1.
|
|
70
|
+
"@ai-ecoverse/slicc-cdp": "1.31.1",
|
|
71
71
|
"@biomejs/biome": "2.5.15",
|
|
72
72
|
"lefthook": "2.2.2",
|
|
73
73
|
"monocart-coverage-reports": "2.13.2",
|