@roomi-fields/grillhouse 0.25.5 → 0.27.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/.claude-plugin/plugin.json +1 -1
- package/agents/testwriter.md +1 -1
- package/bin/grillhouse.mjs +20 -3
- package/cadre/templates/cargo/package.json +3 -0
- package/cadre/templates/projet/.gitattributes +1 -0
- package/cadre/templates/projet/CLAUDE.md +13 -0
- package/cadre/templates/projet/docs/ARCHITECTURE.md +15 -0
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/python/package.json +18 -0
- package/charte.md +32 -1
- package/docs/ARCHITECTURE.md +146 -40
- package/docs/CADRE.md +7 -6
- package/docs/INTERFACE.md +108 -32
- package/hooks/register.tsx +57 -16
- package/package.json +9 -3
- package/scripts/circuit.mjs +165 -27
- package/scripts/commande-du-langage.mjs +2 -2
- package/scripts/commandes-composees.mjs +156 -0
- package/scripts/composition-des-langages.mjs +306 -0
- package/scripts/conformite.mjs +1 -3
- package/scripts/copies-finies.mjs +167 -28
- package/scripts/crochets.mjs +9 -3
- package/scripts/dernier-vert.mjs +15 -2
- package/scripts/engendres.mjs +170 -0
- package/scripts/enveloppe/enveloppe.mjs +59 -17
- package/scripts/enveloppe/lancer.sh +15 -22
- package/scripts/enveloppe/travail-de-la-copie.mjs +262 -0
- package/scripts/etapes.mjs +1 -1
- package/scripts/fusion-du-changelog.mjs +120 -0
- package/scripts/gardes-du-cadre.mjs +7 -4
- package/scripts/grillhouse-maj.mjs +171 -99
- package/scripts/index-interfaces.mjs +78 -0
- package/scripts/init.mjs +5 -5
- package/scripts/integration/file.mjs +270 -117
- package/scripts/integration/integrer.mjs +50 -62
- package/scripts/jointure.d.ts +48 -14
- package/scripts/langages/cargo/binaires.json +2 -1
- package/scripts/langages/cargo/binaires.mjs +29 -6
- package/scripts/langages/cargo/clippy.mjs +12 -2
- package/scripts/langages/cargo/commandes.mjs +60 -7
- package/scripts/langages/cargo/composants.mjs +229 -8
- package/scripts/langages/cargo/exemples.mjs +1 -15
- package/scripts/langages/cargo/index-interfaces.mjs +20 -3
- package/scripts/langages/cargo/index.mjs +25 -17
- package/scripts/langages/cargo/mise-a-jour.mjs +2 -1
- package/scripts/langages/cargo/sccache.mjs +172 -0
- package/scripts/langages/cargo/verdict.mjs +50 -10
- package/scripts/langages/python/binaires.json +3 -0
- package/scripts/langages/python/binaires.mjs +59 -0
- package/scripts/langages/python/commandes.mjs +411 -0
- package/scripts/langages/python/composants.mjs +272 -0
- package/scripts/langages/python/exemples.mjs +260 -0
- package/scripts/langages/python/index-interfaces.mjs +77 -0
- package/scripts/langages/python/index.mjs +94 -0
- package/scripts/langages/python/lot.mjs +76 -0
- package/scripts/langages/python/mise-a-jour.mjs +54 -0
- package/scripts/langages/python/tailles-des-tests.mjs +102 -0
- package/scripts/langages/python/verdict.mjs +85 -0
- package/scripts/langages/typescript/exemples.mjs +1 -20
- package/scripts/langages/typescript/index-interfaces.mjs +10 -3
- package/scripts/langages/typescript/index.mjs +15 -17
- package/scripts/langages/typescript/regle-des-tests.mjs +37 -0
- package/scripts/langages-des-paquets.mjs +171 -0
- package/scripts/langages.mjs +60 -41
- package/scripts/migrations/0.27.0-langages-dans-l-architecture.mjs +182 -0
- package/scripts/migrations.mjs +2 -0
- package/scripts/nuit.sh +15 -1
- package/scripts/outils-cles.mjs +188 -0
- package/scripts/resultats.mjs +22 -6
- package/scripts/session-start.sh +34 -9
- package/scripts/sources.mjs +2 -1
- package/scripts/sous-commandes.mjs +21 -3
- package/scripts/tableau-des-composants.mjs +138 -0
- package/scripts/verrou-de-machine.mjs +14 -13
- package/scripts/verrous/verrou.mjs +53 -16
- package/skills/developpeur/SKILL.md +4 -0
- package/skills/explorateur/SKILL.md +3 -1
- package/skills/grill/SKILL.md +9 -1
- package/skills/pitmaster/SKILL.md +12 -3
- package/skills/pitmaster/references/consigne-agent.md +3 -3
- package/skills/redacteur/references/documents-d-un-composant.md +12 -0
- package/skills/relecteur/SKILL.md +6 -2
- package/skills/testwriter/SKILL.md +29 -6
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// tester, verifier and preparer refuse a workspace whose Cargo.lock git does not track.
|
|
17
17
|
// - A crate at the root, its workspace `members = ["."]`, with its tests, as OSC Bridge: `seul`;
|
|
18
18
|
// a crate at the root holding a second crate, `crates/aide`, none with tests: `imbrique`.
|
|
19
|
-
// - A directory without Cargo.toml: `vide
|
|
19
|
+
// - A directory without Cargo.toml: `vide`.
|
|
20
20
|
// - Two results directories of a run: every task and test green (`vert`); `ws-core` at 75,
|
|
21
21
|
// `ws-app` red with a test of `integ` failed, `ws-outil` not played (`defaut`).
|
|
22
22
|
// - `depots`: the repositories, for the tests of the module beside the suite.
|
|
@@ -202,8 +202,6 @@ export default {
|
|
|
202
202
|
const aJour = espace(dans);
|
|
203
203
|
const vide = mkdtempSync(path.join(dans, 'vide-'));
|
|
204
204
|
writeFileSync(path.join(vide, 'README.md'), 'aucun crate\n');
|
|
205
|
-
const typescript = mkdtempSync(path.join(dans, 'typescript-'));
|
|
206
|
-
writeFileSync(path.join(typescript, 'tsconfig.json'), '{}\n');
|
|
207
205
|
const seul = aLaRacine(dans, 'seul', [], {
|
|
208
206
|
'src/main.rs': 'fn main() {}\n',
|
|
209
207
|
'src/lib.rs': 'pub fn un() -> i32 {\n 1\n}\n',
|
|
@@ -260,7 +258,6 @@ export default {
|
|
|
260
258
|
avantLeLot,
|
|
261
259
|
enRetard,
|
|
262
260
|
vide,
|
|
263
|
-
typescript,
|
|
264
261
|
},
|
|
265
262
|
composants: {
|
|
266
263
|
valide: vide,
|
|
@@ -379,17 +376,6 @@ export default {
|
|
|
379
376
|
invalide: aJour,
|
|
380
377
|
attendu: ['ws-app (ws-app) : joue des tests', 'ws-core (ws-core) : joue des tests'],
|
|
381
378
|
},
|
|
382
|
-
trouve: {
|
|
383
|
-
valide: [
|
|
384
|
-
{ nom: 'vide', racine: vide },
|
|
385
|
-
{ nom: 'typescript', racine: typescript },
|
|
386
|
-
],
|
|
387
|
-
invalide: [
|
|
388
|
-
{ nom: 'espace', racine: aJour },
|
|
389
|
-
{ nom: 'crate à la racine', racine: seul },
|
|
390
|
-
],
|
|
391
|
-
attendu: ['espace : trouvé', 'crate à la racine : trouvé'],
|
|
392
|
-
},
|
|
393
379
|
};
|
|
394
380
|
},
|
|
395
381
|
};
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
// node index-interfaces.mjs writes docs/agents/index-des-interfaces.md
|
|
8
8
|
// node index-interfaces.mjs --verifier refuses (exit 1) when that file is out of date, its
|
|
9
9
|
// finding in SARIF too (../../resultats.mjs)
|
|
10
|
+
// node index-interfaces.mjs --publie <composant>
|
|
11
|
+
// prints nothing: a crate's interface names no consumer,
|
|
12
|
+
// which the module typescript's prints from
|
|
10
13
|
//
|
|
11
14
|
// - An interface is found at `<crate>/docs/INTERFACE.md` for each member of the workspace
|
|
12
15
|
// (./composants.mjs), and at `docs/INTERFACE.md`; in their paths' order.
|
|
@@ -78,14 +81,24 @@ function entrees({ rel, composant }, contenu) {
|
|
|
78
81
|
return [`## ${tetiere}`, '', `${premierePhrase(paragraphe)} (\`${rel}\`)`, ''];
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
/**
|
|
85
|
+
* The entries of the index of each interface of the workspace at <racine>, `{ rel, lignes }`, in
|
|
86
|
+
* the order of `interfaces`: what the module gives the core's index of a project of several
|
|
87
|
+
* languages (`entreesDeLIndex` of the join).
|
|
88
|
+
* @param {string} racine the root of the workspace
|
|
89
|
+
*/
|
|
90
|
+
export const entreesDeLIndex = racine =>
|
|
91
|
+
interfaces(racine).map(i => ({
|
|
92
|
+
rel: i.rel,
|
|
93
|
+
lignes: entrees(i, readFileSync(path.join(racine, i.rel), 'utf8')),
|
|
94
|
+
}));
|
|
95
|
+
|
|
81
96
|
/**
|
|
82
97
|
* The index of the interfaces of the workspace at <racine>, as its file holds it.
|
|
83
98
|
* @param {string} racine the root of the workspace
|
|
84
99
|
*/
|
|
85
100
|
export function index(racine) {
|
|
86
|
-
const corps =
|
|
87
|
-
entrees(i, readFileSync(path.join(racine, i.rel), 'utf8'))
|
|
88
|
-
);
|
|
101
|
+
const corps = entreesDeLIndex(racine).flatMap(e => e.lignes);
|
|
89
102
|
return [
|
|
90
103
|
'# Index des interfaces',
|
|
91
104
|
'',
|
|
@@ -120,6 +133,10 @@ export function enRetard(racine) {
|
|
|
120
133
|
* @param {{ env?: NodeJS.ProcessEnv }} [o] the environment (the results directory)
|
|
121
134
|
*/
|
|
122
135
|
export function commande(racine, args, { env = process.env } = {}) {
|
|
136
|
+
// A crate's interface declares no consumers: what its providers publish is nothing to print.
|
|
137
|
+
if (args.includes('--publie')) {
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
123
140
|
if (!args.includes('--verifier')) {
|
|
124
141
|
mkdirSync(path.dirname(path.join(racine, SORTIE)), { recursive: true });
|
|
125
142
|
writeFileSync(path.join(racine, SORTIE), index(racine));
|
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
// The core loads it by scripts/langages.mjs, and this module imports of the core its published
|
|
5
5
|
// entries alone.
|
|
6
6
|
//
|
|
7
|
-
// -
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
7
|
+
// - The manifest of its package, which the guard of the languages asks of a package the
|
|
8
|
+
// architecture declares cargo (`manifeste`): a Cargo.toml. Its one tool of npm is what its scripts import, smol-toml, the
|
|
9
|
+
// reader of a Cargo.toml (`outils`, an optional peer of the package, which the update adds to a
|
|
10
|
+
// project of cargo alone): cargo and its subcommands live on the machine, and the update
|
|
11
|
+
// installs the binaries the module runs, nextest, cargo-deny and sccache, at their versions
|
|
11
12
|
// (`binaires`, ./binaires.json). What cargo writes in a project: `target` (`ignorer`).
|
|
12
13
|
// - Where cargo writes, which the envelope opens to a session (`sorties`), and the rules that
|
|
13
14
|
// refuse a role that writes the test runner run directly (`droits`).
|
|
14
15
|
// - The components, a file's, the shared test material, the components that play tests, the
|
|
15
|
-
// readers of a crate
|
|
16
|
+
// readers of a crate, the rule of a test file and what the testwriter writes of the manifests
|
|
17
|
+
// (./composants.mjs).
|
|
16
18
|
// - The crates touched since a commit and their dependents (./touches.mjs).
|
|
17
19
|
// - The elements of a lot, one per crate (./elements-du-lot.mjs).
|
|
18
20
|
// - The commands `tester`, `verifier`, `typer` and `preparer` (./commandes.mjs), each described,
|
|
@@ -23,10 +25,12 @@
|
|
|
23
25
|
// - The generated file, the index of the interfaces (./index-interfaces.mjs), its command and its
|
|
24
26
|
// check; the guards of structure, in the order they play: clippy (./clippy.mjs), the boundaries
|
|
25
27
|
// between crates (./frontieres.mjs), the index of the interfaces up to date, each a command by
|
|
26
|
-
// its name too (./commandes.mjs), which the line of a red guard names
|
|
28
|
+
// its name too (./commandes.mjs), which the line of a red guard names; the entries of the index
|
|
29
|
+
// of each interface (`entreesDeLIndex`), which the core assembles in a project of several
|
|
30
|
+
// languages. No migration yet.
|
|
27
31
|
// - Its share of the update (./mise-a-jour.mjs, `miseAJour`): the template of a project of cargo
|
|
28
32
|
// (`templates/cargo/`) and its test scripts.
|
|
29
|
-
import {
|
|
33
|
+
import { readFileSync } from 'node:fs';
|
|
30
34
|
import path from 'node:path';
|
|
31
35
|
import { fileURLToPath } from 'node:url';
|
|
32
36
|
import { commandes, GARDES } from './commandes.mjs';
|
|
@@ -36,34 +40,35 @@ import {
|
|
|
36
40
|
estUnTest,
|
|
37
41
|
joueDesTests,
|
|
38
42
|
lecteurs,
|
|
43
|
+
manifestes,
|
|
39
44
|
matieres,
|
|
40
45
|
} from './composants.mjs';
|
|
41
46
|
import { elementsDuLot } from './elements-du-lot.mjs';
|
|
42
|
-
import { enRetard, SORTIE } from './index-interfaces.mjs';
|
|
47
|
+
import { enRetard, entreesDeLIndex, SORTIE } from './index-interfaces.mjs';
|
|
43
48
|
import { miseAJour } from './mise-a-jour.mjs';
|
|
49
|
+
import { CACHE } from './sccache.mjs';
|
|
44
50
|
import { touches } from './touches.mjs';
|
|
45
51
|
import { verdict } from './verdict.mjs';
|
|
46
52
|
|
|
47
53
|
// The scripts of this module, beside this file.
|
|
48
54
|
const ici = nom => path.join(path.dirname(fileURLToPath(import.meta.url)), nom);
|
|
49
55
|
|
|
50
|
-
// Whether the repository at <racine> holds a Cargo.toml at its root.
|
|
51
|
-
const trouve = racine => existsSync(path.join(racine, 'Cargo.toml'));
|
|
52
|
-
|
|
53
56
|
export default {
|
|
54
57
|
nom: 'cargo',
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
outils: [],
|
|
58
|
-
// The binaries the module runs, nextest and cargo-deny
|
|
59
|
-
// grillhouse-pkl.1 measured
|
|
58
|
+
manifeste: 'Cargo.toml',
|
|
59
|
+
// The reader of TOML by which the lock judges a Cargo.toml (./composants.mjs, `manifestes`).
|
|
60
|
+
outils: ['smol-toml'],
|
|
61
|
+
// The binaries the module runs, each at an exact version: nextest and cargo-deny at the ones the
|
|
62
|
+
// probe of grillhouse-pkl.1 measured; sccache, the cache of compilation common to the copies
|
|
63
|
+
// (./sccache.mjs), at the last release of mozilla/sccache, v0.19.0 (2026-10-24).
|
|
60
64
|
binaires: JSON.parse(readFileSync(ici('binaires.json'), 'utf8')),
|
|
61
65
|
// What cargo writes in a project: its target directory.
|
|
62
66
|
ignorer: ['target'],
|
|
63
67
|
// Where cargo writes, in writing: the target directory of the workspace; in its home, the
|
|
64
68
|
// registry's index and sources, the git dependencies, cargo-deny's advisories, and the files of
|
|
65
69
|
// its locks and of the SQLite cache of its packages (`.package-cache`, `.package-cache-mutate`,
|
|
66
|
-
// `.global-cache`), files without a trailing
|
|
70
|
+
// `.global-cache`), files without a trailing `/`; the cache of sccache, common to the copies
|
|
71
|
+
// (./sccache.mjs), where a server of sccache the session starts writes. What it reads, read-only: its home, `~/.cargo`
|
|
67
72
|
// (its binaries, its `env`, which the shells source, and its configuration stay unwritten), and
|
|
68
73
|
// rustup's toolchains, `~/.rustup`. Measured on 2026-10-30: `cargo fetch --locked` of
|
|
69
74
|
// osc-bridge in bwrap with these mounts alone, green, the cache of its packages written.
|
|
@@ -76,6 +81,7 @@ export default {
|
|
|
76
81
|
'~/.cargo/.package-cache',
|
|
77
82
|
'~/.cargo/.package-cache-mutate',
|
|
78
83
|
'~/.cargo/.global-cache',
|
|
84
|
+
CACHE,
|
|
79
85
|
],
|
|
80
86
|
propres: [],
|
|
81
87
|
lues: ['~/.cargo/', '~/.rustup/'],
|
|
@@ -98,6 +104,7 @@ export default {
|
|
|
98
104
|
commandes,
|
|
99
105
|
verdict,
|
|
100
106
|
estUnTest,
|
|
107
|
+
manifestes,
|
|
101
108
|
fichiersEngendres: () => [
|
|
102
109
|
{
|
|
103
110
|
nom: "l'index des interfaces",
|
|
@@ -109,6 +116,7 @@ export default {
|
|
|
109
116
|
verifier: enRetard,
|
|
110
117
|
},
|
|
111
118
|
],
|
|
119
|
+
entreesDeLIndex,
|
|
112
120
|
gardes: () => GARDES.map(({ script, args }) => [script, ...args]),
|
|
113
121
|
migrations: [],
|
|
114
122
|
miseAJour,
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
// - The generator: the index of the interfaces (./index-interfaces.mjs), run where the project
|
|
22
22
|
// holds it, as the module typescript's.
|
|
23
23
|
// - The installation of its binaries (./binaires.json): the commands of ./binaires.mjs, which list
|
|
24
|
-
// what cargo installed and install one binary by cargo-binstall
|
|
24
|
+
// what cargo installed and install one binary by cargo-binstall, installed first when it lacks;
|
|
25
|
+
// the core runs them.
|
|
25
26
|
import { copyFileSync, existsSync, mkdirSync, readdirSync } from 'node:fs';
|
|
26
27
|
import path from 'node:path';
|
|
27
28
|
import { fileURLToPath } from 'node:url';
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// The cache of compilation of the module cargo: sccache (Mozilla), the wrapper of rustc
|
|
2
|
+
// (`RUSTC_WRAPPER=sccache`) that Firefox and the CI of Rust use, which the update installs
|
|
3
|
+
// (./binaires.json). Each copy keeps its own target directory, so that two compilations never wait
|
|
4
|
+
// on the lock cargo takes on a target directory; sccache shares their compilations, its cache one
|
|
5
|
+
// directory of the home (`SCCACHE_DIR`, ~/.cache/sccache, sccache's default on Linux, named so
|
|
6
|
+
// that the envelope opens the same, ./index.mjs `sorties`), common to every copy of the machine.
|
|
7
|
+
// Every command of the module that compiles (tests, verification, typing, clippy) runs cargo
|
|
8
|
+
// under this environment, in a copy as in an agent's envelope.
|
|
9
|
+
//
|
|
10
|
+
// - One server per copy and per namespace of processes: by default the server of sccache listens
|
|
11
|
+
// on 127.0.0.1:4226 (README of v0.19.0), one for the whole machine, and the envelope shares the
|
|
12
|
+
// network, so that a server born in one agent's envelope would serve another copy, and one born
|
|
13
|
+
// outside would compile for an agent out of his envelope. Each run names its server's socket
|
|
14
|
+
// (`SCCACHE_SERVER_UDS`), an abstract unix socket (the README's `\x00<name>` form), named after
|
|
15
|
+
// the copy and the namespace of processes it runs in (`/proc/self/ns/pid`), which each envelope
|
|
16
|
+
// creates (`--unshare-pid`): the two sides of an envelope, and two envelopes of one copy, never
|
|
17
|
+
// share a server, whatever the environment says. An abstract socket writes no file, so that
|
|
18
|
+
// neither the read-only copy nor the 108 bytes of a socket's path bind it, and it goes with its
|
|
19
|
+
// server, leaving no stale file. The disk cache stays common.
|
|
20
|
+
// - The server starts before each run of cargo that compiles, under the machine's `/tmp`
|
|
21
|
+
// (`demarrerLeServeur`): sccache 0.19.0 starts its server by binding a socket of a path under
|
|
22
|
+
// TMPDIR (`<TMPDIR>/sccacheXXXXXX/sock`, src/commands.rs, `run_server_process`), which fails
|
|
23
|
+
// past the 108 bytes of a socket's path (« path must be shorter than SUN_LEN »), and the
|
|
24
|
+
// temporary directory of a pass of tests under the working directory of a session passes them
|
|
25
|
+
// (grillhouse-qmk, OSC Bridge OB-p58). Cargo then finds the server running and starts none; it
|
|
26
|
+
// keeps its own temporary directory, the pass's.
|
|
27
|
+
// - A wrapper the project sets already is its own: the run keeps it, without sccache. It is read
|
|
28
|
+
// as cargo reads it: the environment (`RUSTC_WRAPPER`, `CARGO_BUILD_RUSTC_WRAPPER`), then
|
|
29
|
+
// `build.rustc-wrapper` of each `.cargo/config.toml` (or `.cargo/config`) from the project up to
|
|
30
|
+
// the root, then of `$CARGO_HOME` (`~/.cargo` by default).
|
|
31
|
+
// - A machine without sccache on the PATH of the command is refused before any run of cargo, in
|
|
32
|
+
// one line that names it and the command that installs it (`sccacheAbsent`), rather than on the
|
|
33
|
+
// error of cargo that cannot run its wrapper.
|
|
34
|
+
import { spawnSync } from 'node:child_process';
|
|
35
|
+
import { createHash } from 'node:crypto';
|
|
36
|
+
import { accessSync, constants, readFileSync, readlinkSync, realpathSync } from 'node:fs';
|
|
37
|
+
import { createRequire } from 'node:module';
|
|
38
|
+
import { homedir } from 'node:os';
|
|
39
|
+
import path from 'node:path';
|
|
40
|
+
|
|
41
|
+
// The loader of smol-toml, an optional peer of the package, a tool of this module.
|
|
42
|
+
const require = createRequire(import.meta.url);
|
|
43
|
+
|
|
44
|
+
/** The cache of sccache, from the home: what the envelope opens in writing. */
|
|
45
|
+
export const CACHE = '~/.cache/sccache/';
|
|
46
|
+
|
|
47
|
+
// The machine's temporary directory, short whatever the copy: the one the server of sccache starts
|
|
48
|
+
// under (`demarrerLeServeur`), an empty one proper to the session in an envelope.
|
|
49
|
+
const COURT = '/tmp';
|
|
50
|
+
|
|
51
|
+
// The directories of cargo's configuration for a run in <racine> under <env>, in cargo's order:
|
|
52
|
+
// `.cargo` of the project and of each parent up to the root, then `$CARGO_HOME`.
|
|
53
|
+
function dossiersDeConfiguration(racine, env) {
|
|
54
|
+
const dossiers = [];
|
|
55
|
+
for (let d = path.resolve(racine); ; d = path.dirname(d)) {
|
|
56
|
+
dossiers.push(path.join(d, '.cargo'));
|
|
57
|
+
if (path.dirname(d) === d) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const maison = env.CARGO_HOME || path.join(env.HOME || homedir(), '.cargo');
|
|
62
|
+
return [...dossiers, maison];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// The wrapper of rustc the project at <racine> sets, as cargo reads it (see the header), or null.
|
|
66
|
+
function lanceurDuProjet(racine, env) {
|
|
67
|
+
const parLEnvironnement = env.RUSTC_WRAPPER || env.CARGO_BUILD_RUSTC_WRAPPER;
|
|
68
|
+
if (parLEnvironnement) {
|
|
69
|
+
return parLEnvironnement;
|
|
70
|
+
}
|
|
71
|
+
const { parse } = require('smol-toml');
|
|
72
|
+
for (const dossier of dossiersDeConfiguration(racine, env)) {
|
|
73
|
+
for (const nom of ['config.toml', 'config']) {
|
|
74
|
+
try {
|
|
75
|
+
const w = parse(readFileSync(path.join(dossier, nom), 'utf8'))?.build?.['rustc-wrapper'];
|
|
76
|
+
if (w) {
|
|
77
|
+
return String(w);
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
// An absent or unreadable configuration sets no wrapper.
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The namespace of processes this process runs in, `pid:[<inode>]`. */
|
|
88
|
+
export const espaceDesProcessus = () => readlinkSync('/proc/self/ns/pid');
|
|
89
|
+
|
|
90
|
+
const reel = p => {
|
|
91
|
+
try {
|
|
92
|
+
return realpathSync(p);
|
|
93
|
+
} catch {
|
|
94
|
+
return path.resolve(p);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The socket of the server of sccache for the copy at <racine> in the namespace of processes
|
|
100
|
+
* <espace>: an abstract unix socket, named after both.
|
|
101
|
+
* @param {string} racine
|
|
102
|
+
* @param {string} [espace] this process's namespace by default
|
|
103
|
+
*/
|
|
104
|
+
export function socketDuServeur(racine, espace = espaceDesProcessus()) {
|
|
105
|
+
const empreinte = createHash('sha256')
|
|
106
|
+
.update(`${reel(racine)}\0${espace}`)
|
|
107
|
+
.digest('hex');
|
|
108
|
+
return `\\x00grillhouse-sccache-${empreinte.slice(0, 16)}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The line that refuses a run in <racine> whose PATH (<env>'s) holds no sccache, the command that
|
|
113
|
+
* installs it named; null when one is there, or when the project sets its own wrapper.
|
|
114
|
+
* @param {string} racine
|
|
115
|
+
* @param {NodeJS.ProcessEnv} env
|
|
116
|
+
* @returns {string | null}
|
|
117
|
+
*/
|
|
118
|
+
export function sccacheAbsent(racine, env) {
|
|
119
|
+
if (lanceurDuProjet(racine, env)) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const present = (env.PATH ?? '')
|
|
123
|
+
.split(path.delimiter)
|
|
124
|
+
.filter(Boolean)
|
|
125
|
+
.some(d => {
|
|
126
|
+
try {
|
|
127
|
+
accessSync(path.join(d, 'sccache'), constants.X_OK);
|
|
128
|
+
return true;
|
|
129
|
+
} catch {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return present
|
|
134
|
+
? null
|
|
135
|
+
: "⛔ sccache absent du PATH : cargo compile à travers lui (RUSTC_WRAPPER=sccache) ; `npx grillhouse maj` l'installe avec les autres binaires du module cargo.";
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Starts the server of sccache of the copy at <racine> under <env> (`avecSccache`), under the
|
|
140
|
+
* machine's temporary directory (`COURT`), unless the project sets its own wrapper; a server
|
|
141
|
+
* already running stays, and its refusal of a second one is no failure.
|
|
142
|
+
* @param {string} racine
|
|
143
|
+
* @param {NodeJS.ProcessEnv} env the environment before `avecSccache`
|
|
144
|
+
*/
|
|
145
|
+
export function demarrerLeServeur(racine, env) {
|
|
146
|
+
if (lanceurDuProjet(racine, env)) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
spawnSync('sccache', ['--start-server'], {
|
|
150
|
+
env: { ...avecSccache(racine, env), TMPDIR: COURT },
|
|
151
|
+
stdio: 'ignore',
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* <env> with rustc wrapped by sccache for the copy at <racine>, its cache the home's, its server
|
|
157
|
+
* the copy's; <env> as it is when the project sets its own wrapper.
|
|
158
|
+
* @param {string} racine
|
|
159
|
+
* @param {NodeJS.ProcessEnv} env
|
|
160
|
+
* @returns {NodeJS.ProcessEnv}
|
|
161
|
+
*/
|
|
162
|
+
export function avecSccache(racine, env) {
|
|
163
|
+
if (lanceurDuProjet(racine, env)) {
|
|
164
|
+
return env;
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
...env,
|
|
168
|
+
RUSTC_WRAPPER: 'sccache',
|
|
169
|
+
SCCACHE_DIR: path.join(env.HOME || homedir(), '.cache', 'sccache'),
|
|
170
|
+
SCCACHE_SERVER_UDS: socketDuServeur(racine),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
// `ws-core::integ`, `ws-core::bin/outil`), its target's source.
|
|
10
10
|
// - `<dossier>/nextest/<run>-<crate>.xml`, the JUnit report of each run of nextest: each
|
|
11
11
|
// `testsuite`, a test binary, gives a test file, each `testcase` a test, failed when it holds a
|
|
12
|
-
// `failure` or an `error`, skipped when it holds `skipped`; its message, the failure's.
|
|
12
|
+
// `failure` or an `error`, skipped when it holds `skipped`; its message, the failure's. A unit
|
|
13
|
+
// test of a module `tests` that lives in a file of its own (`server::tests::relais`, in
|
|
14
|
+
// `src/server/tests.rs` beside the library's root, grillhouse-agr) gives that file, so that the
|
|
15
|
+
// proof of the red finds the result of a new tests.rs.
|
|
13
16
|
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
14
17
|
import path from 'node:path';
|
|
15
18
|
|
|
@@ -46,26 +49,63 @@ const attribut = (balise, nom) => {
|
|
|
46
49
|
return m ? texte(m[1]) : null;
|
|
47
50
|
};
|
|
48
51
|
|
|
49
|
-
// The
|
|
52
|
+
// The file of the unit test <nom> (its module path, `server::tests::relais`) of the binary whose
|
|
53
|
+
// root is <racine>: the file of its module `tests` that exists, as rustc finds a module's file
|
|
54
|
+
// from its crate root's folder — `server/tests.rs` or `server/tests/mod.rs`, a module under it
|
|
55
|
+
// `server/tests/<m>.rs` or `server/tests/<m>/mod.rs`, the deepest first; <racine> for a test of
|
|
56
|
+
// no such file (an inline module).
|
|
57
|
+
function fichierDuTest(racine, nom) {
|
|
58
|
+
const parts = nom.split('::').slice(0, -1);
|
|
59
|
+
const k = parts.indexOf('tests');
|
|
60
|
+
if (k < 0) {
|
|
61
|
+
return racine;
|
|
62
|
+
}
|
|
63
|
+
const dossier = path.join(path.dirname(racine), ...parts.slice(0, k), 'tests');
|
|
64
|
+
const sous = parts.slice(k + 1);
|
|
65
|
+
for (let j = sous.length; j >= 0; j--) {
|
|
66
|
+
const d = path.join(dossier, ...sous.slice(0, j));
|
|
67
|
+
const candidats = [`${d}.rs`, path.join(d, 'mod.rs')];
|
|
68
|
+
const trouve = candidats.find(f => existsSync(f));
|
|
69
|
+
if (trouve) {
|
|
70
|
+
return trouve;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return racine;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// The test files of the JUnit report <xml>, each binary's file read in <cibles>, each unit test
|
|
77
|
+
// under its own file (`fichierDuTest`).
|
|
50
78
|
function rapportsDe(xml, cibles) {
|
|
51
79
|
const out = [];
|
|
52
80
|
for (const s of xml.matchAll(/<testsuite\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testsuite>)/g)) {
|
|
53
81
|
const nom = attribut(s[1], 'name') ?? '';
|
|
54
|
-
const
|
|
82
|
+
const racine = cibles[nom] ?? nom;
|
|
83
|
+
const parFichier = new Map([[racine, []]]);
|
|
55
84
|
for (const c of (s[2] ?? '').matchAll(/<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g)) {
|
|
56
85
|
const corps = c[2] ?? '';
|
|
57
86
|
const echec = /<(failure|error)\b([^>]*?)(?:\/>|>([\s\S]*?)<\/\1>)/.exec(corps);
|
|
58
87
|
const etat = echec ? 'failed' : /<skipped\b/.test(corps) ? 'skipped' : 'passed';
|
|
59
88
|
const message = echec ? (attribut(echec[2], 'message') ?? texte(echec[3] ?? '')) : '';
|
|
60
89
|
const titre = attribut(c[1], 'name') ?? '';
|
|
61
|
-
|
|
90
|
+
const test = { titre, nom: titre, etat, message };
|
|
91
|
+
const fichier = cibles[nom] ? fichierDuTest(racine, titre) : racine;
|
|
92
|
+
if (!parFichier.has(fichier)) {
|
|
93
|
+
parFichier.set(fichier, []);
|
|
94
|
+
}
|
|
95
|
+
parFichier.get(fichier).push(test);
|
|
96
|
+
}
|
|
97
|
+
for (const [fichier, deCeFichier] of parFichier) {
|
|
98
|
+
// The binary's root without a test of its own reports nothing, but for an empty binary.
|
|
99
|
+
if (deCeFichier.length === 0 && parFichier.size > 1) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
out.push({
|
|
103
|
+
fichier,
|
|
104
|
+
etat: deCeFichier.some(t => t.etat === 'failed') ? 'failed' : 'passed',
|
|
105
|
+
message: '',
|
|
106
|
+
tests: deCeFichier,
|
|
107
|
+
});
|
|
62
108
|
}
|
|
63
|
-
out.push({
|
|
64
|
-
fichier: cibles[nom] ?? nom,
|
|
65
|
-
etat: tests.some(t => t.etat === 'failed') ? 'failed' : 'passed',
|
|
66
|
-
message: '',
|
|
67
|
-
tests,
|
|
68
|
-
});
|
|
69
109
|
}
|
|
70
110
|
return out;
|
|
71
111
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The installation of uv, the binary of the module python (./binaires.json), by the commands its
|
|
3
|
+
// share of the update describes (`miseAJour.installation`, scripts/jointure.d.ts), which the core
|
|
4
|
+
// runs.
|
|
5
|
+
//
|
|
6
|
+
// node binaires.mjs liste the binaries installed, JSON on the standard output
|
|
7
|
+
// node binaires.mjs installer <nom>@<version> installs one binary at its version
|
|
8
|
+
//
|
|
9
|
+
// - `liste`: `{ "uv": <version> }` from `uv --version` (`uv 0.10.4 (…)`); `{}` when uv is absent
|
|
10
|
+
// or fails, so that the update installs it.
|
|
11
|
+
// - `installer`: the standalone installer of Astral at the version, as uv's documentation gives it
|
|
12
|
+
// (`curl -LsSf https://astral.sh/uv/<version>/install.sh | sh`), its output this process's
|
|
13
|
+
// error stream, its code this process's, the profiles of the shell left as they are
|
|
14
|
+
// (UV_NO_MODIFY_PATH); a failure names on the error stream the command to type.
|
|
15
|
+
import { spawnSync } from 'node:child_process';
|
|
16
|
+
import { pathToFileURL } from 'node:url';
|
|
17
|
+
|
|
18
|
+
/** The binaries installed: `{ uv: <version> }`, `{}` without uv. */
|
|
19
|
+
export function installes() {
|
|
20
|
+
const r = spawnSync('uv', ['--version'], { encoding: 'utf8' });
|
|
21
|
+
const m = r.status === 0 ? /^uv (\S+)/.exec(r.stdout ?? '') : null;
|
|
22
|
+
return m ? { uv: m[1] } : {};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The command of the shell that installs uv at <version>. */
|
|
26
|
+
export const commandeDInstallation = version =>
|
|
27
|
+
`curl -LsSf https://astral.sh/uv/${version}/install.sh | sh`;
|
|
28
|
+
|
|
29
|
+
/** Installs <cible> (`uv@<version>`): the exit code of the installer. */
|
|
30
|
+
export function installer(cible) {
|
|
31
|
+
const [nom, version] = cible.split('@');
|
|
32
|
+
if (nom !== 'uv' || !version) {
|
|
33
|
+
process.stderr.write(`⛔ binaire inconnu du module python : ${cible} (uv@<version>)\n`);
|
|
34
|
+
return 2;
|
|
35
|
+
}
|
|
36
|
+
const commande = commandeDInstallation(version);
|
|
37
|
+
const r = spawnSync('sh', ['-c', commande], {
|
|
38
|
+
stdio: ['ignore', 2, 2],
|
|
39
|
+
env: { ...process.env, UV_NO_MODIFY_PATH: '1' },
|
|
40
|
+
});
|
|
41
|
+
const code = r.error ? 127 : (r.status ?? 1);
|
|
42
|
+
if (code !== 0) {
|
|
43
|
+
const cause = r.error ? r.error.message : `code ${code}`;
|
|
44
|
+
process.stderr.write(`⛔ \`${commande}\` échoue (${cause}) ; lance-la.\n`);
|
|
45
|
+
}
|
|
46
|
+
return code;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
50
|
+
const [nom, cible] = process.argv.slice(2);
|
|
51
|
+
if (nom === 'liste') {
|
|
52
|
+
process.stdout.write(`${JSON.stringify(installes())}\n`);
|
|
53
|
+
} else if (nom === 'installer' && cible) {
|
|
54
|
+
process.exitCode = installer(cible);
|
|
55
|
+
} else {
|
|
56
|
+
process.stderr.write('usage: binaires.mjs liste | installer <nom>@<version>\n');
|
|
57
|
+
process.exitCode = 2;
|
|
58
|
+
}
|
|
59
|
+
}
|