@roomi-fields/grillhouse 0.28.3 → 0.29.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.
Files changed (68) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/grillhouse.mjs +55 -14
  3. package/cadre/templates/projet/CLAUDE.md +1 -1
  4. package/cadre/templates/projet/README.md +11 -11
  5. package/cadre/templates/projet/_gitignore +2 -5
  6. package/charte.md +13 -4
  7. package/docs/ARCHITECTURE.md +260 -29
  8. package/docs/INTERFACE.md +51 -12
  9. package/package.json +1 -1
  10. package/scripts/aiguillage.mjs +324 -0
  11. package/scripts/avancement.mjs +33 -50
  12. package/scripts/circuit.mjs +558 -146
  13. package/scripts/composition-des-langages.mjs +16 -1
  14. package/scripts/conformite.mjs +16 -0
  15. package/scripts/copies-finies.mjs +171 -30
  16. package/scripts/demon.mjs +134 -21
  17. package/scripts/enveloppe/lancer.sh +13 -14
  18. package/scripts/enveloppe/travail-de-la-copie.mjs +94 -11
  19. package/scripts/etapes.mjs +1 -1
  20. package/scripts/fusion-du-changelog.mjs +0 -1
  21. package/scripts/grillhouse-maj.mjs +16 -7
  22. package/scripts/integration/file.mjs +3 -3
  23. package/scripts/integration/integrer.mjs +3 -3
  24. package/scripts/jointure.d.ts +39 -17
  25. package/scripts/langages/cargo/commandes.mjs +152 -25
  26. package/scripts/langages/cargo/composants.mjs +90 -2
  27. package/scripts/langages/cargo/exemples.mjs +68 -1
  28. package/scripts/langages/cargo/index.mjs +17 -8
  29. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
  30. package/scripts/langages/cargo/sccache.mjs +54 -2
  31. package/scripts/langages/cargo/squelette.mjs +72 -3
  32. package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
  33. package/scripts/langages/cargo/tests-de-head.mjs +159 -0
  34. package/scripts/langages/python/commandes.mjs +44 -7
  35. package/scripts/langages/python/composants.mjs +33 -3
  36. package/scripts/langages/python/exemples.mjs +19 -0
  37. package/scripts/langages/python/index.mjs +4 -0
  38. package/scripts/langages/python/squelette.mjs +119 -17
  39. package/scripts/langages/typescript/exemples.mjs +16 -0
  40. package/scripts/langages/typescript/index.mjs +6 -3
  41. package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
  42. package/scripts/langages/typescript/squelette.mjs +18 -2
  43. package/scripts/langages/typescript/tests-de-nuit.mjs +41 -21
  44. package/scripts/langages/typescript/verifier.mjs +82 -288
  45. package/scripts/langages/typescript/vitest-config/base.mjs +8 -9
  46. package/scripts/langages/typescript/vitest-config/cibles.mjs +92 -53
  47. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +11 -5
  48. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +4 -2
  49. package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
  50. package/scripts/langages/typescript/vitest.nuit.config.mjs +18 -13
  51. package/scripts/lecture-unique.mjs +51 -0
  52. package/scripts/mesure/pression.mjs +9 -7
  53. package/scripts/nuit.sh +19 -12
  54. package/scripts/outil.mjs +72 -0
  55. package/scripts/paquet.mjs +39 -10
  56. package/scripts/resultats.mjs +22 -5
  57. package/scripts/services-du-noyau.mjs +8 -9
  58. package/scripts/session-start.sh +10 -1
  59. package/scripts/sortie.mjs +20 -1
  60. package/scripts/sources.mjs +3 -3
  61. package/scripts/sous-commandes.mjs +1 -0
  62. package/scripts/superviseur.mjs +369 -14
  63. package/scripts/tableau.mjs +219 -58
  64. package/scripts/verrou-de-machine.mjs +303 -58
  65. package/skills/developpeur/SKILL.md +11 -3
  66. package/skills/pitmaster/SKILL.md +58 -23
  67. package/skills/relecteur/SKILL.md +18 -6
  68. package/skills/testwriter/SKILL.md +11 -15
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // `npm run verifier`: the full pass, what the integration, the queue, the continuous integration
3
- // and the night play. Its verdict is green (0), red (1) or « à repasser » (75).
3
+ // and the night play. Its verdict is green (0) or red (1); « à repasser » (75) only when the wait
4
+ // for the lock of the machine, or for room in the temporary directory, reaches its bound.
4
5
  //
5
6
  // npx grillhouse verifier [<argument of Turborepo>…] (npm run verifier -- --force)
6
7
  // npx grillhouse verifier --tout [<argument>…] every test, played for real
@@ -35,19 +36,13 @@
35
36
  // side, is half the cores of the machine, one at least (`concurrence`): each task of tests is
36
37
  // itself parallel (Vitest's workers), as make's `-j` and Bazel's `--local_cpu_resources` bound a
37
38
  // build by the machine; a `--concurrency` among the arguments replaces it.
38
- // - The time witnesses play alone, as Bazel plays a test tagged `exclusive`: the pass above leaves
39
- // them out, then a pass of their own plays them, one task at a time, one file at a time, nothing
40
- // beside them: `turbo run test:unit --filter=<package>… --continue=dependencies-successful
41
- // --concurrency=1 --summarize`, for each package that holds one (a test file that imports
42
- // `mesurerAuRepos`, `fichiersTemoins` of scripts/langages/typescript/vitest-config/cibles.mjs, which receives the
43
- // choice in the variable of the tests, `GRILLHOUSE_TESTS`: `temoins: 'hors'`, then `'seuls'`).
44
- // A repository without a witness plays no such pass. So a witness is measured under no load of
45
- // its own pass: a load it meets comes from elsewhere on the machine.
46
- // - A pass restricted by filters of Turborepo among the arguments (`--filter`, `-F`: the circuit's
47
- // final pass after a review sent back, `--filter=...[<avant>...<après>] --filter=//`,
48
- // scripts/circuit.mjs) plays the witnesses of the packages those filters choose alone
49
- // (`turbo ls <filtres> --output=json`): the pass of the witnesses carries no filter of its own
50
- // beside theirs, which Turborepo would join to them.
39
+ // - The pass plays no measure of time (grillhouse-bd7): the time budget benches and the time
40
+ // witnesses (a test file that imports `mesurerAuRepos`) are out of the day, as the night tests
41
+ // are, and the night plays them (scripts/langages/typescript/vitest-config/cibles.mjs,
42
+ // scripts/langages/typescript/tests-de-nuit.mjs), as Bazel leaves a test tagged `manual` out of
43
+ // its patterns and the benchmarks of Chromium and rustc-perf leave the CI of each commit for a
44
+ // machine at rest. The day waits for no rest: a delay past is a red (the duration reporter
45
+ // classifies a delay of a day test as a real red), and so is a task at 75.
51
46
  // - `--gardes` plays the two tasks of guards alone, `turbo run grillhouse:gardes gardes …`, with the
52
47
  // same verdict: what the reviewer plays on the ticket's copy, the tests aside.
53
48
  // - The verdict reads the exit code of each task in the summary of each run
@@ -55,74 +50,54 @@
55
50
  // would hide a 1). The summary each run writes is removed, and `.turbo/runs` with it when the
56
51
  // run created it; while the pass names a results directory (`GRILLHOUSE_RESULTATS`,
57
52
  // scripts/resultats.mjs), it goes there instead, where the circuit reads it.
58
- // - A task at 0 is green. A task at any other code than 0 and 75, a task at 75 that other tasks
59
- // wait for, a summary that does not read while Turborepo failed: red, code 1, each task named, a
60
- // task of the witnesses' pass with « (témoins de temps) ».
61
- // - A task at 75 (« à repasser »: every failure of its tests depended on a duration and one took
62
- // place under load, scripts/langages/typescript/vitest-config/duree.reporter.mjs) is played again alone, once the CPU
63
- // pressure is back under the threshold (scripts/mesure/pression.mjs; one line per 30 s at
64
- // most while it waits, with the pressure), one task after the other, in the choice of its run
65
- // (a task of the witnesses' pass plays its witnesses alone again):
66
- // `turbo run <task> --filter=<package>`, the arguments given after it, with what it depends on,
67
- // which passed in the pass and replays from the cache: its hash holds theirs, as in the pass.
68
- // Green at rest, it is green; at any code other
69
- // than 0 and 75, red; at 75 again (the load came back during the run), it waits and plays again.
70
- // - The wait is bounded: 15 min after the pass. The bound reached, the verdict is 75, « à
71
- // repasser »: neither green nor red; whoever launched the pass presents it again later
72
- // (scripts/integration/integrer.mjs, scripts/integration/file.mjs, scripts/nuit.sh).
53
+ // - A task at 0 is green. A task at any other code, 75 included, and a summary that does not read
54
+ // while Turborepo failed: red, code 1, each task named.
73
55
  // - The progress of the pass (scripts/avancement.mjs): the directory its caller names in
74
56
  // GRILLHOUSE_AVANCEMENT (the circuit's), else one of its own, which it names beside the lock of
75
- // the machine while it plays (its repository, its command), as a measure out of a ticket the
76
- // board shows, and removes at its end, its total kept. Before its first run of Turborepo, the
77
- // plan of each run that plays tests (`turbo run … --dry=json`) names their tasks and counts done
78
- // the files of those Turborepo replays from its cache.
57
+ // the machine it holds while it plays (`nommerLAvancement`), as the board shows its holder, and
58
+ // removes at its end, its total kept. Before its run of Turborepo, the plan of
59
+ // the run (`turbo run … --dry=json`) names its tasks of tests and counts done the files of those
60
+ // Turborepo replays from its cache.
79
61
  // - The red tasks: while the variable `GRILLHOUSE_ROUGES` (`ROUGES`) names a file, the pass writes
80
62
  // there, one Turborepo task id per line (`<package>#<task>`, `//#<task>` for the root), then a
81
63
  // tab and the command that replays it alone (`npx turbo run <task> --filter=<package>`), each task
82
- // red on its own exit code, a task red at rest included, once each; a task à repasser (75) is
83
- // none of them, nor a task that did not play (its prerequisite red is). Green or à repasser, the
84
- // file is empty. The night reads it for its bisect commands (scripts/nuit.sh), with no second
64
+ // red on its own exit code, once each; a task that did not play is none of them (its
65
+ // prerequisite red is). Green, the file is empty. The night reads it for its bisect commands (scripts/nuit.sh), with no second
85
66
  // reading of the summaries.
86
67
  // - The pass has a base of its own (scripts/mesure/base-de-passe.mjs), in the temporary
87
68
  // directory of its environment, which it sweeps first of the bases a killed pass left: every
88
69
  // run of Turborepo gets it in TMPDIR, TMP and TEMP, the root's `globalPassThroughEnv` passing
89
70
  // TMPDIR on to every task (scripts/langages/typescript/turbo-des-paquets.mjs), and the pass
90
71
  // removes it at its end, green, red or interrupted (SIGINT, SIGTERM, SIGHUP).
91
- // - Every run plays without the paths of a targeted run's tests: the variable `GRILLHOUSE_TESTS`
92
- // (scripts/langages/typescript/vitest-config/cibles.mjs) carries only the choice of the witnesses (and `rejouer` for
93
- // a complete pass).
72
+ // - The run plays without the paths of a targeted run's tests: the variable `GRILLHOUSE_TESTS`
73
+ // (scripts/langages/typescript/vitest-config/cibles.mjs) carries only `rejouer`, for a complete
74
+ // pass.
94
75
  import { spawnSync } from 'node:child_process';
95
76
  import { existsSync, readdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from 'node:fs';
96
77
  import { availableParallelism, tmpdir } from 'node:os';
97
78
  import path from 'node:path';
98
79
  import { pathToFileURL } from 'node:url';
99
80
  import {
100
- A_REPASSER,
101
- attendreLeRepos,
102
81
  AttenteDeLaMachine,
103
82
  AVANCEMENT,
104
83
  avecLaMachine,
105
- BORNE_ATTENTE_MS,
106
84
  CHANGEMENTS,
107
- ecrireLaMesure,
108
85
  garderLeTotal,
109
86
  garderLeVert,
110
- lirePression,
111
87
  mesure,
88
+ nommerLAvancement,
112
89
  ouvrirAvancement,
113
90
  ouvrirBase,
114
- paquetsDeLEnveloppe,
115
91
  retirerALInterruption,
116
92
  } from '../../services-du-noyau.mjs';
117
93
  import { paquets, TYPAGE } from '../../paquets.mjs';
118
94
  import { planifier } from './turbo-des-paquets.mjs';
119
95
  import { SCRIPT_DES_TESTS } from './script-des-tests.mjs';
120
96
  import { garderLesResumes } from './verdict.mjs';
121
- import { fichiersTemoins, VARIABLE as TESTS_CIBLES } from './vitest-config/cibles.mjs';
97
+ import { VARIABLE as TESTS_CIBLES } from './vitest-config/cibles.mjs';
122
98
 
123
99
  const GARDES = ['grillhouse:gardes', 'gardes'];
124
100
  const TACHES = [...GARDES, TYPAGE, SCRIPT_DES_TESTS];
125
- const TEMOINS = ' (témoins de temps)';
126
101
  const CONCURRENCE = /^--concurrency(?:=|$)/;
127
102
  // The variable that names the file of the red tasks, which the night reads.
128
103
  const ROUGES = 'GRILLHOUSE_ROUGES';
@@ -135,71 +110,16 @@ const rejeu = id => {
135
110
 
136
111
  const lister = dossier => (existsSync(dossier) ? readdirSync(dossier) : []);
137
112
 
138
- // The filters of Turborepo among <args> (`--filter=<f>`, `--filter <f>`, `-F <f>`) and the other
139
- // arguments: `{ filtres, autres }`, the filters each written `--filter=<f>`.
140
- function separerLesFiltres(args) {
141
- const filtres = [];
142
- const autres = [];
143
- for (let i = 0; i < args.length; i++) {
144
- if (args[i].startsWith('--filter=')) filtres.push(args[i]);
145
- else if ((args[i] === '--filter' || args[i] === '-F') && i + 1 < args.length)
146
- filtres.push(`--filter=${args[++i]}`);
147
- else autres.push(args[i]);
148
- }
149
- return { filtres, autres };
150
- }
151
-
152
- // The names of the packages of <racine> the filters <filtres> choose, as Turborepo lists them.
153
- function paquetsChoisis(racine, filtres, env) {
154
- const r = spawnSync('turbo', ['ls', ...filtres, '--output=json'], {
155
- cwd: racine,
156
- env,
157
- encoding: 'utf8',
158
- maxBuffer: 64 * 1024 * 1024,
159
- });
160
- try {
161
- return new Set(JSON.parse(r.stdout).packages.items.map(p => p.name));
162
- } catch {
163
- return null;
164
- }
165
- }
166
-
167
113
  // The tasks a pass plays side by side on a machine of <coeurs> cores: half of them, one at least.
168
114
  const concurrence = (coeurs = availableParallelism()) => Math.max(1, Math.floor(coeurs / 2));
169
115
 
170
- // <args> without a `--concurrency` (`--concurrency=<n>` or `--concurrency <n>`).
171
- function sansConcurrence(args) {
172
- const out = [];
173
- for (let i = 0; i < args.length; i++) {
174
- if (args[i] === '--concurrency') i++;
175
- else if (!CONCURRENCE.test(args[i])) out.push(args[i]);
176
- }
177
- return out;
178
- }
179
-
180
- // The filters of the packages of <racine> that hold a time witness, `--filter=<name>` each; in a
181
- // repository without packages, none when its root holds one. Null without a witness.
182
- function filtresDesTemoins(racine) {
183
- const liste = paquets(racine);
184
- if (liste.length === 0) return fichiersTemoins(racine).length ? [] : null;
185
- const noms = liste
186
- .filter(p => !p.hors && p.pkg.scripts?.[SCRIPT_DES_TESTS])
187
- .filter(p => fichiersTemoins(path.resolve(racine, p.dossier)).length > 0)
188
- .map(p => p.pkg.name);
189
- return noms.length ? noms.map(n => `--filter=${n}`) : null;
190
- }
191
-
192
116
  // The full pass in <racine>, its arguments <args> (`--gardes` among them: the guards alone), under
193
- // <env> and the lock of the machine; its verdict, 0, 1 or 75 (the stop of the wait for the lock
194
- // included). `dire` writes a line; `borneMs` and
195
- // `pasMs` are the bound of the wait and the gap between two readings of the pressure; `coeurs`,
196
- // the cores of the machine.
117
+ // <env> and the lock of the machine; its verdict, 0 or 1, or 75 when the wait for the lock, or for
118
+ // room in the temporary directory, reaches its bound. `dire` writes a line; `coeurs`, the cores of the machine.
197
119
  export function verifier({
198
120
  racine = process.cwd(),
199
121
  args: demandes = [],
200
122
  env = process.env,
201
- borneMs = BORNE_ATTENTE_MS,
202
- pasMs = 2_000,
203
123
  dire = l => process.stdout.write(`${l}\n`),
204
124
  coeurs = availableParallelism(),
205
125
  }) {
@@ -211,29 +131,16 @@ export function verifier({
211
131
  return avecLaMachine(
212
132
  envMachine => {
213
133
  // The progress of the pass: the directory its caller names (the circuit's), else its own,
214
- // named beside the lock of the machine while it plays.
134
+ // named beside the lock of the machine, which it holds, while it plays.
215
135
  const propre = !envMachine[AVANCEMENT];
216
136
  const dossier =
217
137
  envMachine[AVANCEMENT] || ouvrirAvancement({ racine, genre: 'verification' });
218
- const effacer =
219
- propre && !paquetsDeLEnveloppe(envMachine)
220
- ? ecrireLaMesure({
221
- env: envMachine,
222
- depot: nomDuDepot(racine),
223
- commande: [
224
- 'npm run verifier',
225
- ...(demandes.length ? ['--', ...demandes] : []),
226
- ].join(' '),
227
- dossier,
228
- })
229
- : () => {};
138
+ const effacer = propre ? nommerLAvancement({ env: envMachine, dossier }) : () => {};
230
139
  try {
231
140
  return passe({
232
141
  racine,
233
142
  demandes,
234
143
  env: { ...envMachine, [AVANCEMENT]: dossier, ...base.env },
235
- borneMs,
236
- pasMs,
237
144
  dire,
238
145
  coeurs,
239
146
  });
@@ -257,19 +164,6 @@ export function verifier({
257
164
  }
258
165
  }
259
166
 
260
- // The name of the repository at <racine>: the folder of its main tree, its copies included; the
261
- // folder of <racine> out of git.
262
- function nomDuDepot(racine) {
263
- const r = spawnSync(
264
- 'git',
265
- ['-C', racine, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
266
- {
267
- encoding: 'utf8',
268
- }
269
- );
270
- return path.basename(r.status === 0 ? path.dirname(r.stdout.trim()) : path.resolve(racine));
271
- }
272
-
273
167
  // Whether a package of <racine>, or its root, plays tests (a script `test:unit`).
274
168
  function depotAvecTests(racine) {
275
169
  const liste = paquets(racine);
@@ -287,11 +181,13 @@ function depotAvecTests(racine) {
287
181
  return liste.some(p => !p.hors && p.pkg.scripts?.[SCRIPT_DES_TESTS]);
288
182
  }
289
183
 
290
- function passe({ racine, demandes, env, borneMs, pasMs, dire, coeurs }) {
184
+ // Whether <args> hold a filter of Turborepo (`--filter=<f>`, `--filter <f>`, `-F <f>`).
185
+ const filtre = args => args.some(a => a.startsWith('--filter=') || a === '--filter' || a === '-F');
186
+
187
+ function passe({ racine, demandes, env, dire, coeurs }) {
291
188
  const gardesSeules = demandes.includes('--gardes');
292
189
  const tout = demandes.includes('--tout') || demandes.includes('--force');
293
190
  const args = demandes.filter(a => a !== '--gardes' && a !== '--tout');
294
- const { filtres: filtresDeLaPasse } = separerLesFiltres(args);
295
191
  // The measure against the last green: the guards alone need none.
296
192
  const m = gardesSeules ? null : mesure(racine, { tout, dans: env.TMPDIR });
297
193
  if (m) dire(m.ligne);
@@ -304,8 +200,6 @@ function passe({ racine, demandes, env, borneMs, pasMs, dire, coeurs }) {
304
200
  tout,
305
201
  ajouts: m?.env ?? {},
306
202
  env,
307
- borneMs,
308
- pasMs,
309
203
  dire,
310
204
  coeurs,
311
205
  taches,
@@ -313,178 +207,78 @@ function passe({ racine, demandes, env, borneMs, pasMs, dire, coeurs }) {
313
207
  if (env[ROUGES])
314
208
  writeFileSync(env[ROUGES], [...taches].map(t => `${t}\t${rejeu(t)}\n`).join(''));
315
209
  // A pass green on every package keeps its tree as the last green.
316
- if (code === 0 && m?.etat && filtresDeLaPasse.length === 0) garderLeVert(m.etat);
210
+ if (code === 0 && m?.etat && !filtre(args)) garderLeVert(m.etat);
317
211
  return code;
318
212
  } finally {
319
213
  m?.retirer();
320
214
  }
321
215
  }
322
216
 
323
- function jouerLaPasse({
324
- racine,
325
- gardesSeules,
326
- args,
327
- tout,
328
- ajouts,
329
- env,
330
- borneMs,
331
- pasMs,
332
- dire,
333
- coeurs,
334
- taches,
335
- }) {
217
+ function jouerLaPasse({ racine, gardesSeules, args, tout, ajouts, env, dire, coeurs, taches }) {
336
218
  const { [TESTS_CIBLES]: _, [CHANGEMENTS]: __, ...propre } = env;
337
- // The moment of a complete pass, which moves the hash of every task of tests: each plays for
338
- // real.
339
- const rejouer = tout ? { rejouer: new Date().toISOString() } : {};
340
- // The environment of a run whose tests leave the witnesses out (`hors`) or play them alone
341
- // (`seuls`), measured against the last green.
342
- const choix = temoins => ({
343
- ...propre,
344
- ...ajouts,
345
- [TESTS_CIBLES]: JSON.stringify({ arguments: [], temoins, ...rejouer }),
346
- });
347
- const turbo = (a, e) =>
348
- spawnSync('turbo', ['run', ...a], { cwd: racine, env: e, stdio: 'inherit' });
349
- // Each red named, then the verdict 1.
350
- const rouge = liste => {
351
- for (const r of liste) dire(`⛔ ${r}`);
352
- dire('⛔ rouge.');
353
- return 1;
354
- };
355
-
356
- // One run of Turborepo, and its summary.
357
- const runs = path.join(racine, '.turbo', 'runs');
358
- const jouer = (a, e, libelle) => {
359
- const existait = existsSync(runs);
360
- const avant = new Set(lister(runs));
361
- const r = turbo([...a, '--summarize'], e);
362
- const nouveaux = lister(runs).filter(f => !avant.has(f) && f.endsWith('.json'));
363
- let resume = null;
364
- if (nouveaux.length === 1) {
365
- try {
366
- resume = JSON.parse(readFileSync(path.join(runs, nouveaux[0]), 'utf8'));
367
- } catch {
368
- resume = null;
369
- }
370
- }
371
- garderLesResumes(racine, avant, e);
372
- if (!existait && existsSync(runs) && lister(runs).length === 0) rmdirSync(runs);
373
- return { r, resume, env: e, libelle };
374
- };
375
-
219
+ // The environment of the run: measured against the last green; the moment of a complete pass,
220
+ // which moves the hash of every task of tests, so that each plays for real.
221
+ const e = gardesSeules
222
+ ? propre
223
+ : {
224
+ ...propre,
225
+ ...ajouts,
226
+ ...(tout
227
+ ? { [TESTS_CIBLES]: JSON.stringify({ arguments: [], rejouer: new Date().toISOString() }) }
228
+ : {}),
229
+ };
376
230
  const borne = args.some(a => CONCURRENCE.test(a)) ? [] : [`--concurrency=${concurrence(coeurs)}`];
377
- const lancements = [
378
- {
379
- a: [
380
- ...(gardesSeules ? GARDES : TACHES),
381
- '--continue=dependencies-successful',
382
- ...borne,
383
- ...args,
384
- ],
385
- e: gardesSeules ? propre : choix('hors'),
386
- libelle: '',
387
- },
231
+ const a = [
232
+ ...(gardesSeules ? GARDES : TACHES),
233
+ '--continue=dependencies-successful',
234
+ ...borne,
235
+ ...args,
388
236
  ];
389
- // The time witnesses, alone: in a pass restricted by filters, those of the packages they choose.
390
- const { filtres: filtresDeLaPasse, autres } = separerLesFiltres(args);
391
- let filtres = gardesSeules ? null : filtresDesTemoins(racine);
392
- if (filtres?.length && filtresDeLaPasse.length) {
393
- const choisis = paquetsChoisis(racine, filtresDeLaPasse, propre);
394
- if (choisis) filtres = filtres.filter(f => choisis.has(f.slice('--filter='.length)));
395
- if (filtres.length === 0) filtres = null;
396
- }
397
- if (filtres) {
398
- lancements.push({
399
- a: [
400
- SCRIPT_DES_TESTS,
401
- ...filtres,
402
- '--continue=dependencies-successful',
403
- '--concurrency=1',
404
- ...sansConcurrence(filtres.length || !filtresDeLaPasse.length ? autres : args),
405
- ],
406
- e: choix('seuls'),
407
- libelle: TEMOINS,
408
- });
409
- }
410
- // The plan of each run that plays tests, before the first: the progress knows all its tasks.
237
+ // The plan of the run, before it: the progress knows all its tasks.
411
238
  if (!gardesSeules && depotAvecTests(racine)) {
412
- for (const { a, e } of lancements) planifier(env[AVANCEMENT], { racine, args: a, env: e });
239
+ planifier(env[AVANCEMENT], { racine, args: a, env: e });
413
240
  }
414
- const passes = [];
415
- for (const { a, e, libelle } of lancements) {
416
- if (libelle) {
417
- const ou = filtres.map(f => f.slice('--filter='.length)).join(', ') || 'la racine';
418
- dire(`⏱ témoins de temps : ${ou} ; ils jouent seuls, une tâche après l'autre.`);
241
+ // The run of Turborepo, and its summary.
242
+ const runs = path.join(racine, '.turbo', 'runs');
243
+ const existait = existsSync(runs);
244
+ const avant = new Set(lister(runs));
245
+ const r = spawnSync('turbo', ['run', ...a, '--summarize'], {
246
+ cwd: racine,
247
+ env: e,
248
+ stdio: 'inherit',
249
+ });
250
+ const nouveaux = lister(runs).filter(f => !avant.has(f) && f.endsWith('.json'));
251
+ let resume = null;
252
+ if (nouveaux.length === 1) {
253
+ try {
254
+ resume = JSON.parse(readFileSync(path.join(runs, nouveaux[0]), 'utf8'));
255
+ } catch {
256
+ resume = null;
419
257
  }
420
- passes.push(jouer(a, e, libelle));
421
258
  }
422
- if (passes.every(p => p.r.status === 0)) return 0;
259
+ garderLesResumes(racine, avant, e);
260
+ if (!existait && existsSync(runs) && lister(runs).length === 0) rmdirSync(runs);
261
+ if (r.status === 0) return 0;
423
262
 
424
- // The verdict of each task.
263
+ // The verdict of each task: any code but 0 is a red, named.
425
264
  const rouges = [];
426
- const aRepasser = [];
427
- for (const { r, resume, env: e, libelle } of passes) {
428
- if (r.status === 0) continue;
429
- if (!Array.isArray(resume?.tasks)) {
430
- rouges.push(
431
- `rouge${libelle} : Turborepo sort en ${r.status ?? r.signal}, et le résumé de la passe ne se lit pas.`
432
- );
433
- continue;
434
- }
435
- let echecs = 0;
265
+ if (!Array.isArray(resume?.tasks)) {
266
+ rouges.push(
267
+ `rouge : Turborepo sort en ${r.status ?? r.signal}, et le résumé de la passe ne se lit pas.`
268
+ );
269
+ } else {
436
270
  for (const t of resume.tasks) {
437
271
  const code = t.execution?.exitCode;
438
272
  if (code === 0) continue;
439
- echecs++;
440
- const nom = `${t.taskId}${libelle}`;
441
- if (code === A_REPASSER && (t.dependents ?? []).length === 0)
442
- aRepasser.push({ ...t, nom, env: e });
443
- else if (code === A_REPASSER)
444
- rouges.push(`${nom} à repasser, mais ${t.dependents.join(', ')} l'attendent`);
445
- else {
446
- rouges.push(`${nom} (code ${code ?? 'absent'})`);
447
- if (typeof code === 'number') taches.add(t.taskId);
448
- }
449
- }
450
- if (echecs === 0)
451
- rouges.push(`Turborepo sort en ${r.status ?? r.signal}${libelle} sans tâche en échec`);
452
- }
453
- if (rouges.length > 0) return rouge(rouges);
454
-
455
- // The tasks à repasser, each played again at rest in the choice of its run, until the bound.
456
- const limite = Date.now() + borneMs;
457
- const lire = () => lirePression(env.GRILLHOUSE_PRESSION_CPU || undefined);
458
- let restants = aRepasser;
459
- dire(
460
- `⏱ à repasser : ${restants.map(t => t.nom).join(', ')} ; chaque tâche se rejoue seule, au repos.`
461
- );
462
- while (restants.length > 0) {
463
- const suivants = [];
464
- for (const [i, t] of restants.entries()) {
465
- if (Date.now() >= limite || !attendreLeRepos({ lire, limite, pasMs, dire })) {
466
- const ouverts = [...suivants, ...restants.slice(i)].map(x => x.nom).join(', ');
467
- const borneTexte =
468
- borneMs >= 60_000 ? `${Math.round(borneMs / 60_000)} min` : `${borneMs / 1000} s`;
469
- dire(`⏱ pas de repos en ${borneTexte} : ${ouverts} ni vert ni rouge.`);
470
- // A task red at rest makes the pass red, whatever remains to play.
471
- if (rouges.length > 0) return rouge(rouges);
472
- dire(`⏱ à repasser (code ${A_REPASSER}).`);
473
- return A_REPASSER;
474
- }
475
- dire(`↻ ${t.nom} : relance au repos.`);
476
- const r = turbo([t.task, `--filter=${t.package}`, ...args], t.env);
477
- if (r.status === 0) dire(`✓ ${t.nom} vert au repos.`);
478
- else if (r.status === A_REPASSER) suivants.push(t);
479
- else {
480
- rouges.push(`${t.nom} rouge au repos (code ${r.status ?? r.signal})`);
481
- taches.add(t.taskId);
482
- }
273
+ rouges.push(`${t.taskId} (code ${code ?? 'absent'})`);
274
+ if (typeof code === 'number') taches.add(t.taskId);
483
275
  }
484
- restants = suivants;
276
+ if (rouges.length === 0)
277
+ rouges.push(`Turborepo sort en ${r.status ?? r.signal} sans tâche en échec`);
485
278
  }
486
- if (rouges.length > 0) return rouge(rouges);
487
- return 0;
279
+ for (const l of rouges) dire(`⛔ ${l}`);
280
+ dire('⛔ rouge.');
281
+ return 1;
488
282
  }
489
283
 
490
284
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
@@ -11,12 +11,13 @@
11
11
  // writes (scripts/grillhouse-maj.mjs). Grillhouse's package imports it by its own name.
12
12
  //
13
13
  // - The exclusions of the day: a night test (`*.nuit.test.*`, `*.nuit.spec.*`) is too long for the
14
- // day, and the measures of a time budget bench (`*.budget.test.*`, `*.budget.spec.*`) move with
15
- // the load of the day: `npm test`, `npm run verifier` and the integration leave both out, and
16
- // the night plays them (scripts/nuit.sh, scripts/langages/typescript/vitest.nuit.config.mjs); a targeted run that
14
+ // day, and every measure of time, a time budget bench (`*.budget.test.*`, `*.budget.spec.*`) or
15
+ // a time witness (a test file that imports `mesurerAuRepos`), moves with the load of the day:
16
+ // `npm test`, `npm run verifier` and the integration leave them out, and the night plays them
17
+ // (scripts/nuit.sh, scripts/langages/typescript/vitest.nuit.config.mjs); a targeted run that
17
18
  // names the file of one itself plays it, under the measure of time below (./cibles.mjs, where
18
- // the patterns live). `mergeConfig` adds the exclusions of a configuration that extends this one
19
- // to these.
19
+ // the patterns live, and whose plugin leaves the witnesses out). `mergeConfig` adds the
20
+ // exclusions of a configuration that extends this one to these.
20
21
  // - A run that plays no test fails, as Vitest's default has it (`passWithNoTests` unset): a
21
22
  // targeted run (`npm test -- <paths>`, scripts/langages/typescript/tests.mjs) plays each path in its package only,
22
23
  // and a path that names no test is a mistake, never a green.
@@ -30,19 +31,17 @@
30
31
  // (GIT_CONFIG_COUNT/KEY/VALUE, git-config(1)), the automatic maintenance and garbage collection
31
32
  // off (maintenance.auto=false, gc.auto=0). This file is the one address of these settings; the
32
33
  // night configuration takes them from here.
33
- // - A time witness is measured with the CPU at rest: a setup file notes the CPU pressure at the
34
+ // - A measure of time is taken with the CPU at rest: a setup file notes the CPU pressure at the
34
35
  // start and at the end of each test (./mesure.setup.mjs), and the duration reporter, beside
35
36
  // Vitest's default one, gives the exit code 75, « à repasser », when every failure depends on a
36
37
  // duration and one took place under load (./duree.reporter.mjs; the signal and its threshold,
37
- // ./pression.mjs). A test that measures time marks itself (`mesurerAuRepos`,
38
+ // scripts/mesure/pression.mjs); a delay past in a day test is a red. A test that measures time marks itself (`mesurerAuRepos`,
38
39
  // `@roomi-fields/grillhouse/vitest-config/mesure`). `mergeConfig` adds the reporters and the setup files of
39
40
  // a configuration that extends this one to these; a reporter named on the command line
40
41
  // (`--reporter`) replaces them, and Vitest's code then stands.
41
42
  // - The machine of a test file is its own: a setup file gives it a lock of the heavy measure of
42
43
  // its own, so that a `npm run verifier` a test plays in a repository of trial neither waits for
43
44
  // the lock of the machine nor holds it (./machine.setup.mjs, scripts/verrou-de-machine.mjs).
44
- // - The time witnesses play alone in `npm run verifier`: the plugin below leaves them out of its
45
- // pass, then plays them in a pass of their own (./cibles.mjs, scripts/langages/typescript/verifier.mjs).
46
45
  // - While a run names its results directory (`GRILLHOUSE_RESULTATS`, ./resultats.mjs), the JSON
47
46
  // reporter writes Vitest's report there too, which the circuit reads (scripts/resultats.mjs); a
48
47
  // setup file gives each test file's processes a results directory of their own, so that a run a