@ai-ecoverse/slicc-shared-web 2.7.3 → 2.7.5
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 -6
- package/bin/slicc-install-hooks.sh +19 -10
- package/harness/display.mjs +13 -2
- package/harness/shard.cjs +12 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ The caller cancels superseded runs on pull requests only, so a push to `main` ne
|
|
|
69
69
|
|
|
70
70
|
**Deploy** runs on pull requests only, never in the merge queue, with `id-token: write` for an OIDC-authenticated deploy. The merge queue's tests therefore run without `STAGING_URL`: a test that needs it skips when it's empty. It runs the `deploy` command with every secret the caller passes as an environment variable, except the pipeline's own `AWS_BEARER_TOKEN_BEDROCK`, `SLICC_ISSUES_TOKEN` and `github_token`. The command writes `url=<staging URL>` to `$GITHUB_OUTPUT`; the tests and the reviewers get it as `STAGING_URL`. With `deploy-secrets`, a newline- or space-separated list of secret names, only those of them are exported.
|
|
71
71
|
|
|
72
|
-
**Integration tests** install Chrome for Testing with `slicc-cdp install-browser` (with `--with-deps` where the runner has root or passwordless sudo) (`--version` from the `chrome` input, stable without it), then
|
|
72
|
+
**Integration tests** install Chrome for Testing with `slicc-cdp install-browser` (with `--with-deps` where the runner has root or passwordless sudo) (`--version` from the `chrome` input, stable without it), then each runs its share of the files matching `test-glob`. `lint` plans the split once for all `shards`, so the shards can't disagree: it takes the JUnit reports of the latest completed merge queue run of the same workflow (else the latest completed pull request run), and hands each file to the shard with the least time so far, longest first; a file without a timing counts as the average, and without any timings every file counts the same. Each shard runs the repo's own `test` command unchanged: `harness/shard.cjs`, preloaded through `NODE_OPTIONS`, makes the outermost `node --test` run only the shard's files that its own patterns match, writes `junit/<shard>.xml` next to the usual spec output, and then takes itself out of the environment, so a `node --test` that a test starts runs as it would without it. Files a `node --test` call would run that are not in `test-glob` (unit tests, say, whether in the same call or another) run on shard 0 only, so nothing is dropped; when `test-glob` matches nothing, shard 0 runs the command unchanged and the others run nothing. Each call keeps its own JUnit report (`junit/<shard>-<pid>.xml` for all but the last). Each shard uploads `coverage/`, `artifacts/` and `junit/` as `integration-<shard>`. `integration` passes only when every shard did and their JUnit reports add up to at least one test that ran, not skipped, and no failure or error (the placeholder an empty shard runs doesn't count), and every file matching `test-glob` was handed to `node --test` on exactly one shard (`shard.cjs` lists the files it hands over next to its JUnit report, as `junit/<shard>-<pid>.files`, since a test registered through a helper is attributed to the helper); a file that ran on no shard or on two is named as an error, and it prints `integration: PASS <n> tests (<k> skipped) in <m> JUnit reports` or `integration: FAIL <why>`; a repo without node tests sets `require-tests: false`. Setting `NODE_OPTIONS` in `test` would replace the pipeline's own, which carry the shard preload and the JUnit reporter, so extra node flags (a bigger heap, say) go in `node-options`. `integration` is therefore the one check to require for the tests, under the caller's job name (`ci / integration`). A suite whose last step reads every test's artifacts, as this repo's `verify.mjs` does, sets `shards: 1`.
|
|
73
73
|
|
|
74
74
|
**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:
|
|
75
75
|
|
|
@@ -92,7 +92,7 @@ Each reviewer answers with `findings.json`, held to one JSON schema:
|
|
|
92
92
|
}
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
**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;
|
|
95
|
+
**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
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 no secrets.
|
|
98
98
|
|
|
@@ -121,7 +121,7 @@ The commands in `lint`, `test`, `deploy`, `review-browser` and `after-release` r
|
|
|
121
121
|
| `lint` | `npm run lint` | |
|
|
122
122
|
| `chrome` | stable | a Chrome for Testing version for `slicc-cdp install-browser` |
|
|
123
123
|
| `test` | `npm test` | runs on Xvfb display `:99` when the runner has no `DISPLAY`; Xvfb is installed where the runner has root or sudo, and the step fails naming the runner when it has neither Xvfb nor root |
|
|
124
|
-
| `test-glob` | `test/integration/**/*.test.mjs` | the files to split
|
|
124
|
+
| `test-glob` | `test/integration/**/*.test.mjs` | the files to split |
|
|
125
125
|
| `shards` | `4` | below 1 counts as 1 |
|
|
126
126
|
| `deploy` | none | a command that deploys to staging |
|
|
127
127
|
| `deploy-secrets` | all | newline- or space-separated secret names (any case) that `deploy` gets |
|
|
@@ -233,12 +233,12 @@ Without it, every worktree of a repo shares `.git/hooks/` with the main clone, a
|
|
|
233
233
|
|
|
234
234
|
and the PR commits the `.githooks/` directory that the first `npm install` writes.
|
|
235
235
|
|
|
236
|
-
- **What it does:** sets one shared, relative `core.hooksPath` of `.githooks` (`<dir>/.githooks` for a package in a subdirectory of the repo),
|
|
236
|
+
- **What it does:** sets one shared, relative `core.hooksPath` of `.githooks` (`<dir>/.githooks` for a package in a subdirectory of the repo), writes a hook into this worktree's gitignored `node_modules/.git-hooks/` for every git hook in the config `lefthook dump` prints, `extends` included, and a shim into `.githooks/` for each one that has none yet. Each hook runs `lefthook run --no-auto-install <hook>` with the lefthook binary from its own `node_modules/`, found relative to the hook, so lefthook never tries to sync hooks into `core.hooksPath`. It sets no git config from the command line or the environment, so the AI git wrapper lets it run. It never overwrites an existing shim. Git resolves a relative `core.hooksPath` against the top of the worktree a commit runs in, so each worktree runs its own committed shim, and the shim runs that worktree's own `node_modules/.git-hooks/<hook>`. No `extensions.worktreeConfig`, no per-worktree config, and `core.bare` stays where it is, so worktrees of a bare repo work too. Running it again changes nothing.
|
|
237
237
|
- **Hooks are never shared:** whatever another worktree installs later, removing a worktree removes only its own hooks, and a moved checkout keeps working. Lefthook's own `postinstall` refuses the custom `core.hooksPath`, writes nothing and doesn't fail the install, and git never reads `.git/hooks/` once `core.hooksPath` is set, so `allowScripts` needs no entry for lefthook.
|
|
238
238
|
- **A worktree that never ran `npm install`** fails every commit with `pre-commit: run npm install`, since its shim finds no `node_modules/.git-hooks/pre-commit`.
|
|
239
239
|
- **A checkout without the committed `.githooks/`** (a branch cut before the rollout PR) has no shim, so its commits run no hooks until it merges or rebases onto the rollout.
|
|
240
|
-
- **A hook type added to `lefthook.yml` later** needs `npm install` again in each worktree, and its new shim committed
|
|
241
|
-
- **
|
|
240
|
+
- **A hook type added to `lefthook.yml` later** needs `npm install` again in each worktree, and its new shim committed.
|
|
241
|
+
- **Don't unset `core.hooksPath`** when `lefthook install` suggests it: that sends every worktree back to the shared `.git/hooks/`.
|
|
242
242
|
- **Clones set up by the previous version** (2.1.1, 1.29.3), which set an absolute per-worktree `core.hooksPath` into a `worktree-hooks/` directory: it unsets that in the current worktree's `config.worktree`. It leaves `extensions.worktreeConfig` and the moved `core.bare` alone.
|
|
243
243
|
- **Outside a git checkout** (a packed tarball, say) it does nothing and exits 0.
|
|
244
244
|
|
|
@@ -8,16 +8,25 @@ if [ -f "$own" ]; then
|
|
|
8
8
|
esac
|
|
9
9
|
fi
|
|
10
10
|
git config core.hooksPath "$(git rev-parse --show-prefix).githooks"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
config="$(lefthook dump)"
|
|
12
|
+
githooks=" applypatch-msg pre-applypatch post-applypatch pre-commit pre-merge-commit prepare-commit-msg commit-msg post-commit pre-rebase post-checkout post-merge pre-push pre-receive update proc-receive post-receive post-update reference-transaction push-to-checkout pre-auto-gc post-rewrite sendemail-validate fsmonitor-watchman p4-changelist p4-prepare-changelist p4-post-changelist p4-pre-submit post-index-change "
|
|
13
|
+
mkdir -p node_modules/.git-hooks .githooks
|
|
14
|
+
for name in $(printf '%s\n' "$config" | sed -n 's/^\([a-z][a-z0-9-]*\):.*/\1/p'); do
|
|
15
|
+
case "$githooks" in *" $name "*) ;; *) continue ;; esac
|
|
16
|
+
hook="node_modules/.git-hooks/$name"
|
|
17
|
+
sed "s/@HOOK@/$name/g" >"$hook" <<'HOOK'
|
|
18
|
+
#!/bin/sh
|
|
19
|
+
if [ "${LEFTHOOK_VERBOSE:-}" = 1 ] || [ "${LEFTHOOK_VERBOSE:-}" = true ]; then set -x; fi
|
|
20
|
+
modules="$(cd "${0%/*}/.." && pwd -P)"
|
|
21
|
+
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
|
22
|
+
cpu="$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')"
|
|
23
|
+
lefthook="$modules/lefthook-$os-$cpu/bin/lefthook"
|
|
24
|
+
[ -x "$lefthook" ] || lefthook="$modules/.bin/lefthook"
|
|
25
|
+
[ -x "$lefthook" ] || { echo "@HOOK@: run npm install" >&2; exit 1; }
|
|
26
|
+
exec "$lefthook" run --no-auto-install "@HOOK@" "$@"
|
|
27
|
+
HOOK
|
|
28
|
+
chmod +x "$hook"
|
|
29
|
+
[ ! -e ".githooks/$name" ] || continue
|
|
21
30
|
cat >".githooks/$name" <<'SHIM'
|
|
22
31
|
#!/bin/sh
|
|
23
32
|
hook="${0%/*}/../node_modules/.git-hooks/${0##*/}"
|
package/harness/display.mjs
CHANGED
|
@@ -32,10 +32,11 @@ function stopper(xvfb) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
async function start(env) {
|
|
36
|
+
const wanted = 1000 + Math.floor(Math.random() * 50000);
|
|
36
37
|
const xvfb = spawn(
|
|
37
38
|
'Xvfb',
|
|
38
|
-
['-displayfd', '3', '-screen', '0', '1920x1080x24', '-nolisten', 'tcp'],
|
|
39
|
+
[`:${wanted}`, '-displayfd', '3', '-screen', '0', '1920x1080x24', '-nolisten', 'tcp'],
|
|
39
40
|
{ detached: true, stdio: ['ignore', 'ignore', 'pipe', 'pipe'] }
|
|
40
41
|
);
|
|
41
42
|
const close = stopper(xvfb);
|
|
@@ -65,6 +66,16 @@ export async function ownDisplay(env = inherited) {
|
|
|
65
66
|
return { env: { ...env, DISPLAY: `:${display}` }, child: xvfb, close };
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
export async function ownDisplay(env = inherited) {
|
|
70
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
71
|
+
try {
|
|
72
|
+
return await start(env);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (attempt >= 5) throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
68
79
|
export async function screenFor(headed, env = inherited) {
|
|
69
80
|
if (!wantsOwnDisplay({ headed, env })) return { env, child: null, close: async () => {} };
|
|
70
81
|
return ownDisplay(env);
|
package/harness/shard.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const { existsSync, globSync, renameSync, statSync } = require('node:fs');
|
|
2
|
+
const { existsSync, globSync, renameSync, statSync, writeFileSync } = require('node:fs');
|
|
3
3
|
const { isAbsolute, join, matchesGlob, normalize, relative } = require('node:path');
|
|
4
4
|
|
|
5
5
|
const env = process.env;
|
|
@@ -56,6 +56,16 @@ function keepReport() {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function record(files) {
|
|
60
|
+
const junit = env.SLICC_TEST_JUNIT;
|
|
61
|
+
if (junit) {
|
|
62
|
+
writeFileSync(
|
|
63
|
+
junit.replace(/(\.xml)?$/, `-${process.pid}.files`),
|
|
64
|
+
files.map((file) => `${file}\n`).join('')
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
59
69
|
function select(patterns) {
|
|
60
70
|
const matches = (file) => patterns.length === 0 || patterns.some((p) => inside(file, p));
|
|
61
71
|
const mine = lines(list).filter(matches);
|
|
@@ -69,6 +79,7 @@ function select(patterns) {
|
|
|
69
79
|
if (list !== undefined && process.execArgv.includes('--test') && !env.NODE_TEST_CONTEXT) {
|
|
70
80
|
keepReport();
|
|
71
81
|
const chosen = select(process.argv.slice(1));
|
|
82
|
+
record(chosen ?? expand(process.argv.slice(1)));
|
|
72
83
|
env.NODE_OPTIONS = env.SLICC_TEST_NODE_OPTIONS ?? '';
|
|
73
84
|
for (const name of [
|
|
74
85
|
'SLICC_TEST_NODE_OPTIONS',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.5",
|
|
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",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"release": "semantic-release"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@ai-ecoverse/slicc-browsers": "1.
|
|
69
|
+
"@ai-ecoverse/slicc-browsers": "1.16.2",
|
|
70
70
|
"@ai-ecoverse/slicc-cdp": "1.30.23",
|
|
71
71
|
"@biomejs/biome": "2.5.15",
|
|
72
72
|
"lefthook": "2.2.2",
|