@roomi-fields/grillhouse 0.32.0 → 0.33.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.
Files changed (131) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +32 -0
  3. package/bin/grillhouse.mjs +6 -4
  4. package/cadre/templates/projet/.github/workflows/ci.yml +169 -16
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +111 -0
  6. package/cadre/templates/projet/deployment/docs/01-INSTALL.md +4 -4
  7. package/cadre/templates/projet/package.json +2 -2
  8. package/charte.md +8 -5
  9. package/dist/temporal/circuit/client.d.ts +10 -3
  10. package/dist/temporal/circuit/client.js +8 -4
  11. package/dist/temporal/circuit/client.js.map +1 -1
  12. package/dist/temporal/circuit/contrat.d.ts +25 -0
  13. package/dist/temporal/circuit/contrat.js +31 -0
  14. package/dist/temporal/circuit/contrat.js.map +1 -1
  15. package/dist/temporal/circuit/deroule.js +67 -38
  16. package/dist/temporal/circuit/deroule.js.map +1 -1
  17. package/dist/temporal/commande.js +13 -3
  18. package/dist/temporal/commande.js.map +1 -1
  19. package/dist/temporal/deroules.d.ts +1 -0
  20. package/dist/temporal/deroules.js +3 -1
  21. package/dist/temporal/deroules.js.map +1 -1
  22. package/dist/temporal/file/activites.d.ts +1 -0
  23. package/dist/temporal/file/activites.js +5 -2
  24. package/dist/temporal/file/activites.js.map +1 -1
  25. package/dist/temporal/file/contrat.d.ts +50 -33
  26. package/dist/temporal/file/contrat.js +2 -2
  27. package/dist/temporal/file/contrat.js.map +1 -1
  28. package/dist/temporal/file/deroule.d.ts +3 -1
  29. package/dist/temporal/file/deroule.js +128 -26
  30. package/dist/temporal/file/deroule.js.map +1 -1
  31. package/dist/temporal/installation.d.ts +15 -1
  32. package/dist/temporal/installation.js +57 -15
  33. package/dist/temporal/installation.js.map +1 -1
  34. package/dist/temporal/nuits/activites.d.ts +10 -0
  35. package/dist/temporal/nuits/activites.js +114 -0
  36. package/dist/temporal/nuits/activites.js.map +1 -0
  37. package/dist/temporal/nuits/appel.d.ts +23 -0
  38. package/dist/temporal/nuits/appel.js +40 -0
  39. package/dist/temporal/nuits/appel.js.map +1 -0
  40. package/dist/temporal/nuits/choix.d.ts +14 -0
  41. package/dist/temporal/nuits/choix.js +119 -0
  42. package/dist/temporal/nuits/choix.js.map +1 -0
  43. package/dist/temporal/nuits/client.d.ts +28 -0
  44. package/dist/temporal/nuits/client.js +83 -0
  45. package/dist/temporal/nuits/client.js.map +1 -0
  46. package/dist/temporal/nuits/commande.d.ts +2 -0
  47. package/dist/temporal/nuits/commande.js +107 -0
  48. package/dist/temporal/nuits/commande.js.map +1 -0
  49. package/dist/temporal/nuits/contrat.d.ts +98 -0
  50. package/dist/temporal/nuits/contrat.js +30 -0
  51. package/dist/temporal/nuits/contrat.js.map +1 -0
  52. package/dist/temporal/nuits/deroule.d.ts +5 -0
  53. package/dist/temporal/nuits/deroule.js +100 -0
  54. package/dist/temporal/nuits/deroule.js.map +1 -0
  55. package/dist/temporal/travailleur.js +4 -1
  56. package/dist/temporal/travailleur.js.map +1 -1
  57. package/docs/ARCHITECTURE.md +214 -49
  58. package/docs/CADRE.md +31 -1
  59. package/docs/INTERFACE.md +47 -7
  60. package/hooks/register.tsx +11 -3
  61. package/package.json +4 -1
  62. package/scripts/abi-des-dependances.mjs +105 -0
  63. package/scripts/activites.mjs +113 -42
  64. package/scripts/aiguillage.mjs +1 -0
  65. package/scripts/avancement.mjs +8 -18
  66. package/scripts/ci-des-branches.mjs +91 -0
  67. package/scripts/circuit.mjs +79 -4
  68. package/scripts/circuits-du-serveur.mjs +4 -3
  69. package/scripts/composants-affectes.mjs +24 -7
  70. package/scripts/composition-des-langages.mjs +3 -0
  71. package/scripts/crochets.mjs +4 -0
  72. package/scripts/dernier-vert.mjs +31 -10
  73. package/scripts/enveloppe/enveloppe.mjs +3 -1
  74. package/scripts/enveloppe/lancer.sh +1 -1
  75. package/scripts/enveloppe/travail-de-la-copie.mjs +219 -59
  76. package/scripts/etapes.mjs +18 -1
  77. package/scripts/faits-du-circuit.mjs +43 -20
  78. package/scripts/fichier-du-poste.mjs +87 -0
  79. package/scripts/grillhouse-maj.mjs +15 -1
  80. package/scripts/integration/file.mjs +215 -275
  81. package/scripts/integration/integrer.mjs +82 -41
  82. package/scripts/integration/rejeu.mjs +13 -64
  83. package/scripts/jointure.d.ts +26 -2
  84. package/scripts/langages/cargo/commandes.mjs +81 -19
  85. package/scripts/langages/cargo/exemples.mjs +2 -2
  86. package/scripts/langages/cargo/index.mjs +11 -5
  87. package/scripts/langages/cargo/tailles-des-tests.mjs +19 -11
  88. package/scripts/langages/python/commandes.mjs +11 -7
  89. package/scripts/langages/python/exemples.mjs +1 -1
  90. package/scripts/langages/python/index.mjs +9 -2
  91. package/scripts/langages/python/tailles-des-tests.mjs +19 -11
  92. package/scripts/langages/typescript/code-mort.mjs +41 -24
  93. package/scripts/langages/typescript/consommateurs.mjs +28 -17
  94. package/scripts/langages/typescript/exemples.mjs +2 -0
  95. package/scripts/langages/typescript/index.mjs +22 -3
  96. package/scripts/langages/typescript/migrations/0.33.0-binaire-de-jour.mjs +34 -0
  97. package/scripts/langages/typescript/migrations/0.33.0-tests-du-poste.mjs +31 -0
  98. package/scripts/langages/typescript/resumes.mjs +17 -7
  99. package/scripts/langages/typescript/tailles-des-tests.mjs +251 -22
  100. package/scripts/langages/typescript/tests-de-nuit.mjs +101 -9
  101. package/scripts/langages/typescript/tests-du-poste.mjs +172 -0
  102. package/scripts/langages/typescript/tests.mjs +8 -2
  103. package/scripts/langages/typescript/tranches.mjs +273 -0
  104. package/scripts/langages/typescript/verifier.mjs +140 -31
  105. package/scripts/langages/typescript/vitest-config/changements.mjs +23 -11
  106. package/scripts/langages/typescript/vitest-config/cibles.mjs +78 -7
  107. package/scripts/langages/typescript/vitest-config/lances.mjs +4 -4
  108. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +9 -0
  109. package/scripts/langages/typescript/vitest.nuit.config.mjs +3 -2
  110. package/scripts/lint-des-scripts.mjs +23 -6
  111. package/scripts/migrations/0.33.0-cache-distant.mjs +36 -0
  112. package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +31 -0
  113. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +31 -0
  114. package/scripts/migrations/0.33.0-node-26.mjs +58 -0
  115. package/scripts/migrations.mjs +8 -0
  116. package/scripts/newday.mjs +18 -0
  117. package/scripts/nuit.sh +35 -17
  118. package/scripts/registre.d.mts +90 -0
  119. package/scripts/registre.mjs +28 -3
  120. package/scripts/reprise.mjs +12 -8
  121. package/scripts/services-du-noyau.mjs +5 -1
  122. package/scripts/session-start.sh +40 -32
  123. package/scripts/sous-commandes.mjs +29 -10
  124. package/scripts/superviseur.mjs +72 -27
  125. package/scripts/tableau.mjs +129 -20
  126. package/scripts/taches-du-graphe.mjs +39 -6
  127. package/scripts/transitions.mjs +42 -3
  128. package/scripts/verrou-de-machine.mjs +1 -2
  129. package/scripts/workflows-du-cadre.mjs +75 -0
  130. package/skills/grill/SKILL.md +8 -6
  131. package/skills/pitmaster/SKILL.md +15 -9
@@ -36,15 +36,33 @@
36
36
  // inscribed in the project's debt (`grillhouse-dette.json`, ./dette.mjs) passes: the large tests
37
37
  // of the day that exist when the rule arrives are inscribed there by the update
38
38
  // (./migrations/0.25.0-tailles-des-tests.mjs), the count never rises, and a new one is refused.
39
+ // - A test of the day validates the code by importing it: one that starts the frame's command
40
+ // (`lanceLeCadre`) is a finding, `{ fichier, regle: 'binaire-de-jour', message }`, out of the zone
41
+ // of the end-to-end tests: a directory `e2e/` at any depth (as Playwright's and Angular's `e2e/`,
42
+ // Cypress's `cypress/e2e/`), or a package of PAQUETS_DE_BOUT_EN_BOUT (`grillhouse-essais`, as a
43
+ // project `<app>-e2e` of Nx). The reading sees a process call (APPEL; git's left out) whose first
44
+ // argument is `'grillhouse'` (or `'npx'` then `'grillhouse'`), or that writes a string naming the
45
+ // command (`node_modules/.bin/grillhouse`, `bin/grillhouse.mjs`, a line `npx grillhouse <x>`) or
46
+ // a file of `bin/` or `scripts/` of the frame's package (`cadreDe`, resolved from the file's
47
+ // directory, its package, the root): a script of the frame is the code of its subcommand. A name
48
+ // counts when its initializer is a path naming it so (`const BIN = path.resolve(…)`), or another
49
+ // such name, in the test or its material. A path built at run time (`path.join(SCRIPTS, nom)`),
50
+ // a launcher passed through a helper without the name in the call, and the code of a `node -e`
51
+ // (a template with a substitution) escape the reading. The cases that exist when the rule
52
+ // arrives are inscribed by the update (./migrations/0.33.0-binaire-de-jour.mjs).
39
53
  // - The guard writes on its error stream the count of each size, the night's included.
40
54
  import { spawnSync } from 'node:child_process';
41
- import { globSync, readFileSync } from 'node:fs';
55
+ import { existsSync, globSync, readFileSync, realpathSync, statSync } from 'node:fs';
56
+ import { createRequire } from 'node:module';
42
57
  import path from 'node:path';
43
58
  import { pathToFileURL } from 'node:url';
44
59
  import { trancher } from '../../dette.mjs';
60
+ import { paquets } from '../../paquets.mjs';
45
61
  import { matieres } from './composants.mjs';
46
62
  import { deNuitOuBanc } from './vitest-config/cibles.mjs';
47
63
  import {
64
+ chaines,
65
+ code,
48
66
  IMPORT,
49
67
  lireLeDisque,
50
68
  MATIERE,
@@ -54,6 +72,7 @@ import {
54
72
 
55
73
  export const GARDE = 'tailles-des-tests';
56
74
  export const GRAND_DE_JOUR = 'grand-de-jour';
75
+ export const BINAIRE_DE_JOUR = 'binaire-de-jour';
57
76
 
58
77
  // The import of a way to start a process.
59
78
  const PROCESSUS = /['"](?:node:)?child_process['"]|['"]execa['"]|['"]zx['"]/;
@@ -149,20 +168,211 @@ export function lesMatieres(racine) {
149
168
  });
150
169
  }
151
170
 
171
+ /** The package of the frame, whose command a test of the day does not start. */
172
+ export const PAQUET_DU_CADRE = '@roomi-fields/grillhouse';
173
+ /** The packages of end-to-end tests by design: they start the frame's scripts and import none. */
174
+ export const PAQUETS_DE_BOUT_EN_BOUT = ['@roomi-fields/grillhouse-essais'];
175
+ // The directory of the end-to-end tests, at any depth (`tests/e2e/`), as Playwright's and
176
+ // Angular's `e2e/` and Cypress's `cypress/e2e/`.
177
+ const ZONE_E2E = /(?:^|\/)e2e\//;
178
+ // A string that names the frame's command: its link, its file, or a command line.
179
+ const COMMANDE_DU_CADRE =
180
+ /(?:^|[\s/'"])(?:\.bin\/grillhouse|bin\/grillhouse\.mjs)(?=$|[\s'"])|^(?:npx\s+(?:-\S+\s+)*)?grillhouse\s+[a-z]/;
181
+ // A literal first argument of a call: `'grillhouse'`, or `'npx'` whose arguments name it.
182
+ const PREMIER_GRILLHOUSE = /^['"`]grillhouse['"`]$/;
183
+ const PREMIER_NPX = /^['"`]npx['"`]$/;
184
+ // A path a string may write, resolved from the directory of its file.
185
+ const CHEMIN = /^[\w@.][\w@./-]*$/;
186
+ // An initializer that writes a path or a command: a string, an array, a join or a resolution of
187
+ // paths, a URL, another name (alone, or a choice between names); a value computed from it (a
188
+ // process's result, a file's text, a function, a trial project) is none.
189
+ const VALEUR_DE_CHEMIN =
190
+ /^\s*(?:['"`[]|(?:path\.)?(?:join|resolve)\(|fileURLToPath\(|new\s+URL\(|[\w$.]+\s*(?:$|\?|\|\|))/;
191
+ // A template that substitutes a value: the code of `node -e`, a shell line built at run time.
192
+ const GABARIT = /`(?:[^`\\]|\\.)*\$\{(?:[^`\\]|\\.)*`/g;
193
+ // A declaration of a name and the start of its initializer.
194
+ const DECLARATION = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=(?!=)/g;
195
+
196
+ /**
197
+ * The directory of the frame's package for the repository at <racine>: the package of its
198
+ * workspace of that name (in Grillhouse, `packages/grillhouse`), else the one Node resolves from
199
+ * it, by its real path; null when the repository does not install it.
200
+ */
201
+ export function cadreDe(racine) {
202
+ const ici = paquets(racine).find(p => p.pkg?.name === PAQUET_DU_CADRE);
203
+ if (ici) {
204
+ return path.join(racine, ici.dossier);
205
+ }
206
+ try {
207
+ const pkg = createRequire(path.join(racine, 'package.json')).resolve(
208
+ `${PAQUET_DU_CADRE}/package.json`
209
+ );
210
+ return path.dirname(realpathSync(pkg));
211
+ } catch {
212
+ return null;
213
+ }
214
+ }
215
+
216
+ // The initializer of the declaration whose `=` ends at <debut> of <texte>: to its `;` or its end of
217
+ // line at depth 0.
218
+ function initialiseur(texte, debut) {
219
+ let profondeur = 0;
220
+ const fin = Math.min(texte.length, debut + 2000);
221
+ for (let i = debut; i < fin; i++) {
222
+ const c = texte[i];
223
+ if (c === '(' || c === '[' || c === '{') {
224
+ profondeur++;
225
+ } else if (c === ')' || c === ']' || c === '}') {
226
+ if (--profondeur < 0) {
227
+ return texte.slice(debut, i);
228
+ }
229
+ } else if ((c === ';' || c === '\n') && profondeur === 0) {
230
+ return texte.slice(debut, i);
231
+ }
232
+ }
233
+ return texte.slice(debut, fin);
234
+ }
235
+
236
+ // The directory of the package that holds <f> under <racine>: the nearest holding a package.json
237
+ // <lire> reads, else <racine>.
238
+ function paquetDe(f, lire, racine) {
239
+ for (
240
+ let d = path.dirname(f);
241
+ d.startsWith(racine) && d !== path.dirname(d);
242
+ d = path.dirname(d)
243
+ ) {
244
+ if (lire(path.join(d, 'package.json')) !== null) {
245
+ return d;
246
+ }
247
+ if (d === racine) {
248
+ break;
249
+ }
250
+ }
251
+ return racine;
252
+ }
253
+
254
+ // Whether the string <s> names the frame's command, or a file under `bin/` or `scripts/` of the
255
+ // frame's package at <cadre>, resolved from one of <bases>.
256
+ function nommeLeCadre(s, bases, cadre) {
257
+ if (COMMANDE_DU_CADRE.test(s)) {
258
+ return true;
259
+ }
260
+ if (!cadre || !CHEMIN.test(s)) {
261
+ return false;
262
+ }
263
+ return bases.some(b => {
264
+ const c = path.resolve(b, s);
265
+ const cle = `${cadre}\0${c}`;
266
+ if (!duCadre.has(cle)) {
267
+ duCadre.set(cle, fichierDuCadre(c, cadre));
268
+ }
269
+ return duCadre.get(cle);
270
+ });
271
+ }
272
+ // Whether the path <c> is a file under `bin/` or `scripts/` of the frame's package at <cadre>,
273
+ // each path read once per process.
274
+ const duCadre = new Map();
275
+ function fichierDuCadre(c, cadre) {
276
+ try {
277
+ if (!existsSync(c) || !statSync(c).isFile()) {
278
+ return false;
279
+ }
280
+ const r = path.relative(cadre, realpathSync(c)).split(path.sep);
281
+ return r[0] === 'bin' || r[0] === 'scripts';
282
+ } catch {
283
+ return false;
284
+ }
285
+ }
286
+
287
+ /**
288
+ * Whether the texts <sources> (`[{ f, texte }]`: a test file and its test material) start the
289
+ * frame's command: a process call whose first argument is `'grillhouse'` (or `'npx'` then
290
+ * `'grillhouse'`), or that writes a string naming it (its link, `bin/grillhouse.mjs`, a line
291
+ * `npx grillhouse <x>`, a file of `bin/` or `scripts/` of the frame's package at <cadre>), or a name
292
+ * whose initializer does, in one of the texts. <lire> reads a file, <racine> is the repository.
293
+ */
294
+ export function lanceLeCadre(sources, lire, racine, cadre = null) {
295
+ const lus = sources.map(({ f, texte }) => ({
296
+ f,
297
+ code: code(texte),
298
+ bases: [path.dirname(f), paquetDe(f, lire, racine), racine],
299
+ }));
300
+ // The names whose initializer is a path or a command naming the frame, or a name already
301
+ // marked, to a fixed point.
302
+ const marques = new Set();
303
+ const declarations = lus.flatMap(({ code: c, bases }) =>
304
+ [...c.matchAll(DECLARATION)]
305
+ .map(m => ({ nom: m[1], init: initialiseur(c, m.index + m[0].length), bases }))
306
+ .filter(d => VALEUR_DE_CHEMIN.test(d.init))
307
+ );
308
+ const reference = (texte, nom) =>
309
+ new RegExp(`(?<![\\w$.])${nom.replaceAll('$', '\\$')}(?![\\w$])`).test(texte);
310
+ const nomme = (texte, bases) =>
311
+ chaines(texte).some(s => nommeLeCadre(s, bases, cadre)) ||
312
+ [...marques].some(n => reference(texte, n));
313
+ for (let change = true; change;) {
314
+ change = false;
315
+ for (const d of declarations) {
316
+ if (!marques.has(d.nom) && nomme(d.init, d.bases)) {
317
+ marques.add(d.nom);
318
+ change = true;
319
+ }
320
+ }
321
+ }
322
+ return lus.some(({ code: c, bases }) =>
323
+ [...c.matchAll(APPEL)].some(m => {
324
+ const premier = m[1].trim();
325
+ if (GIT.test(premier)) {
326
+ return false;
327
+ }
328
+ const appel = appelComplet(c, m.index + m[0].indexOf('(')).replace(GABARIT, '``');
329
+ return (
330
+ PREMIER_GRILLHOUSE.test(premier) ||
331
+ (PREMIER_NPX.test(premier) && chaines(appel).includes('grillhouse')) ||
332
+ nomme(appel, bases)
333
+ );
334
+ })
335
+ );
336
+ }
337
+
338
+ // Whether the test <fichier> (from the top of <racine>) lies in the zone of the end-to-end tests:
339
+ // under a directory `e2e/`, or in a package of PAQUETS_DE_BOUT_EN_BOUT.
340
+ function dansLaZone(fichier, racine) {
341
+ if (ZONE_E2E.test(fichier)) {
342
+ return true;
343
+ }
344
+ const d = paquetDe(path.join(racine, fichier), lireLeDisque, racine);
345
+ try {
346
+ return PAQUETS_DE_BOUT_EN_BOUT.includes(
347
+ JSON.parse(readFileSync(path.join(d, 'package.json'), 'utf8')).name
348
+ );
349
+ } catch {
350
+ return false;
351
+ }
352
+ }
353
+
152
354
  /**
153
355
  * The size of the test file <fichier> (absolute), read by <lire> (a path → its text, null when it
154
356
  * does not read), in the repository at <racine>, whose packages of the shared test material are
155
- * <lesMatieres> (`[{ nom, dir, entree }]`, absolute paths): `{ taille, modules }`, `taille` one of
156
- * `petit`, `moyen`, `grand`, `modules` the modules of the repository it imports (the test material
157
- * followed, not counted).
357
+ * <lesMatieres> (`[{ nom, dir, entree }]`, absolute paths), the frame's package at <cadre> (null
358
+ * when not installed): `{ taille, modules, lance }`, `taille` one of `petit`, `moyen`, `grand`,
359
+ * `modules` the modules of the repository it imports (the test material followed, not counted),
360
+ * `lance` whether it starts the frame's command (`lanceLeCadre`).
158
361
  */
159
- export function classer(fichier, lire, racine = path.parse(fichier).root, lesMatieres = []) {
362
+ export function classer(
363
+ fichier,
364
+ lire,
365
+ racine = path.parse(fichier).root,
366
+ lesMatieres = [],
367
+ cadre = null
368
+ ) {
160
369
  const dansUneMatiere = f =>
161
370
  lesMatieres.some(m => {
162
371
  const r = path.relative(m.dir, f);
163
372
  return r !== '' && !r.startsWith('..') && !path.isAbsolute(r);
164
373
  });
165
374
  const textes = [];
375
+ const sources = [];
166
376
  const modules = new Set();
167
377
  const vus = new Set();
168
378
  // <f> followed; with <noms>, the names a test imports of it, its re-exports of a whole module
@@ -178,6 +388,7 @@ export function classer(fichier, lire, racine = path.parse(fichier).root, lesMat
178
388
  const texte = lire(f) ?? '';
179
389
  if (!lus.has(f)) {
180
390
  textes.push(texte);
391
+ sources.push({ f, texte });
181
392
  }
182
393
  lus.add(f);
183
394
  // The server counts when the part of the file the test takes starts it: the whole file for
@@ -227,7 +438,11 @@ export function classer(fichier, lire, racine = path.parse(fichier).root, lesMat
227
438
  : processus || modules.size > 1
228
439
  ? 'moyen'
229
440
  : 'petit';
230
- return { taille, modules: [...modules] };
441
+ return {
442
+ taille,
443
+ modules: [...modules],
444
+ lance: processus && lanceLeCadre(sources, lire, racine, cadre),
445
+ };
231
446
  }
232
447
 
233
448
  // The directories a listing out of git leaves out.
@@ -249,28 +464,42 @@ export function testsDuDepot(racine) {
249
464
  return [...new Set(fichiers.filter(f => TEST.test(f)))].sort();
250
465
  }
251
466
 
252
- /** Each test file of the repository at <racine> and its size: `[{ fichier, taille, nuit }]`. */
467
+ /**
468
+ * Each test file of the repository at <racine> and its size: `[{ fichier, taille, nuit, lance }]`,
469
+ * `lance` whether it starts the frame's command.
470
+ */
253
471
  export function tailles(racine) {
254
472
  const m = lesMatieres(racine);
255
- return testsDuDepot(racine).map(fichier => ({
256
- fichier,
257
- taille: classer(path.join(racine, fichier), lireLeDisque, racine, m).taille,
258
- nuit: deNuitOuBanc(fichier),
259
- }));
473
+ const cadre = cadreDe(racine);
474
+ return testsDuDepot(racine).map(fichier => {
475
+ const { taille, lance } = classer(path.join(racine, fichier), lireLeDisque, racine, m, cadre);
476
+ return { fichier, taille, nuit: deNuitOuBanc(fichier), lance };
477
+ });
260
478
  }
261
479
 
262
480
  /**
263
- * The findings of the repository at <racine>: one `{ fichier, regle, message }` per large test of
264
- * the day, in the debt's form (./dette.mjs).
481
+ * The findings of the repository at <racine>, in the debt's form (./dette.mjs): one
482
+ * `{ fichier, regle, message }` per large test of the day (`grand-de-jour`), and per test of the
483
+ * day out of the zone of the end-to-end tests that starts the frame's command (`binaire-de-jour`).
265
484
  */
266
485
  export function verifier(racine) {
267
- return tailles(racine)
268
- .filter(t => t.taille === 'grand' && !t.nuit)
269
- .map(({ fichier }) => ({
270
- fichier,
271
- regle: GRAND_DE_JOUR,
272
- message: `${fichier} : un grand test (il monte un dépôt ou un projet d'essai et y lance le produit ou le cadre) est un test de nuit, jamais joué au fil du travail ; il se renomme en *.nuit.test.*, ou il se réduit à la plus petite taille qui prouve son critère.`,
273
- }));
486
+ const toutes = tailles(racine);
487
+ return [
488
+ ...toutes
489
+ .filter(t => t.taille === 'grand' && !t.nuit)
490
+ .map(({ fichier }) => ({
491
+ fichier,
492
+ regle: GRAND_DE_JOUR,
493
+ message: `${fichier} : un grand test (il monte un dépôt ou un projet d'essai et y lance le produit ou le cadre) est un test de nuit, jamais joué au fil du travail ; il se renomme en *.nuit.test.*, ou il se réduit à la plus petite taille qui prouve son critère.`,
494
+ })),
495
+ ...toutes
496
+ .filter(t => t.lance && !t.nuit && !dansLaZone(t.fichier, racine))
497
+ .map(({ fichier }) => ({
498
+ fichier,
499
+ regle: BINAIRE_DE_JOUR,
500
+ message: `${fichier} : un test de jour valide le code en l'important ; il lance ici la commande grillhouse (son binaire, ou un script de bin/ ou scripts/ du cadre). Il importe la fonction qu'il prouve, ou, s'il est un vrai test de bout-en-bout, il va sous un dossier e2e/.`,
501
+ })),
502
+ ];
274
503
  }
275
504
 
276
505
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
@@ -286,7 +515,7 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
286
515
  process.stderr.write(`${l}\n`);
287
516
  }
288
517
  process.stderr.write(
289
- `ℹ️ ${GARDE} : ${toutes.length} fichier(s) de tests, ${compte('petit')} petit(s), ${compte('moyen')} moyen(s), ${compte('grand')} grand(s) ; ${nuit} de nuit ou de banc.\n`
518
+ `ℹ️ ${GARDE} : ${toutes.length} fichier(s) de tests, ${compte('petit')} petit(s), ${compte('moyen')} moyen(s), ${compte('grand')} grand(s) ; ${nuit} de nuit ou de banc ; ${toutes.filter(x => x.lance).length} lance(nt) la commande grillhouse.\n`
290
519
  );
291
520
  process.exitCode = refus.length ? 1 : 0;
292
521
  }
@@ -3,7 +3,9 @@
3
3
  // (scripts/jointure.d.ts), which the night (scripts/nuit.sh) runs in its copy after the full pass,
4
4
  // through its mounts.
5
5
  //
6
- // node tests-de-nuit.mjs from the root of the copy
6
+ // node tests-de-nuit.mjs from the root of the copy: the night of the poste
7
+ // node tests-de-nuit.mjs --hors-du-poste the night of a shared machine (a CI runner)
8
+ // node tests-de-nuit.mjs --hors-du-poste --tranche i/n its tranche i of n
7
9
  //
8
10
  // - The files `*.nuit.test.*` and `*.nuit.spec.*` of the copy, outside node_modules, dist and
9
11
  // .git, the night tests, then its measures of time, the time budget benches (`*.budget.test.*`,
@@ -16,22 +18,74 @@
16
18
  // time (GRILLHOUSE_TESTS_DE_NUIT=mesures), as Bazel plays a test tagged `exclusive` after the
17
19
  // others, nothing beside it, and as the module cargo plays its benches after its night tests
18
20
  // (grillhouse-bd7). Each run plays when the copy holds its files.
21
+ // - With `--hors-du-poste`, the night of a shared machine: the night tests alone, but those that
22
+ // bear the tag `@poste` (`porteLEtiquetteDuPoste` of ./vitest-config/cibles.mjs, which the guard
23
+ // ./tests-du-poste.mjs asks of a night test that depends on the poste), in one run
24
+ // (GRILLHOUSE_TESTS_DE_NUIT=hors-poste), and no measure of time: a shared machine does not measure
25
+ // a time (the frame's charter, « Une mesure de temps joue la nuit »). It keeps no last green, as
26
+ // the night of the poste alone does (scripts/nuit.sh).
27
+ // - With `--tranche i/n` (or `--tranche=i/n`) beside `--hors-du-poste`, the i-th of n parts of
28
+ // those files, Vitest's split (`--shard`), as a tranche of the verification
29
+ // (`npm run verifier -- --tranche i/n`, ./tranches.mjs): it writes its blob report and the files
30
+ // of its part under `.vitest-reports/` (the reports of an earlier run of the same tranche
31
+ // removed), which `grillhouse fusion-des-tranches` controls and merges once the n tranches played:
32
+ // the n tranches together play each night test out of the poste once. The variable
33
+ // GRILLHOUSE_TRANCHE_DE_NUIT carries it to the night's configuration.
34
+ // - A tranche not of the form `i/n` (1 ≤ i ≤ n), a tranche without `--hors-du-poste` (the night of
35
+ // the poste plays whole), and any other argument are refused before any work, exit 2.
19
36
  // - The exit code: 0 when every run is green; 75, « à repasser », when every red run is at 75
20
37
  // (every failure depended on a duration, one under load, ./vitest-config/duree.reporter.mjs);
21
38
  // else the code of the first red run.
22
39
  // - They play once the temporary directory has room, as every heavy pass
23
40
  // (`attendreDeLaPlace` of scripts/verrou-de-machine.mjs): a wait that reaches its bound ends at 75.
24
41
  import { spawnSync } from 'node:child_process';
25
- import { readdirSync } from 'node:fs';
42
+ import { readdirSync, rmSync } from 'node:fs';
26
43
  import path from 'node:path';
27
44
  import { fileURLToPath, pathToFileURL } from 'node:url';
28
- import { A_REPASSER, attendreDeLaPlace } from '../../services-du-noyau.mjs';
45
+ import {
46
+ A_REPASSER,
47
+ attendreDeLaPlace,
48
+ LA_FORME,
49
+ lireLaTranche,
50
+ } from '../../services-du-noyau.mjs';
29
51
  import {
30
52
  estUnBanc,
31
53
  estUnTestDeNuit,
32
54
  fichiersTemoins,
55
+ NUIT_TRANCHE,
33
56
  NUIT_VARIABLE,
34
57
  } from './vitest-config/cibles.mjs';
58
+ import { fichiersDeLaTranche, RAPPORTS } from './tranches.mjs';
59
+
60
+ /**
61
+ * The options of the arguments <args>: `{ horsDuPoste, tranche, erreur }`, `tranche`
62
+ * `{ index, count }` or undefined, `erreur` the line that refuses them, or undefined.
63
+ * @param {string[]} args
64
+ */
65
+ export function lireLesArguments(args) {
66
+ let horsDuPoste = false;
67
+ let texte;
68
+ for (let i = 0; i < args.length; i++) {
69
+ const a = args[i];
70
+ if (a === '--hors-du-poste') {
71
+ horsDuPoste = true;
72
+ } else if (a === '--tranche') {
73
+ texte = args[++i] ?? '';
74
+ } else if (a.startsWith('--tranche=')) {
75
+ texte = a.slice('--tranche='.length);
76
+ } else {
77
+ return { horsDuPoste, erreur: `⛔ tests-de-nuit : argument inconnu « ${a} » (usage : tests-de-nuit [--hors-du-poste [--tranche ${LA_FORME}]]).` };
78
+ }
79
+ }
80
+ const tranche = texte === undefined ? undefined : (lireLaTranche(texte) ?? undefined);
81
+ if (texte !== undefined && !tranche) {
82
+ return { horsDuPoste, erreur: `⛔ --tranche attend la forme ${LA_FORME}, deux entiers avec 1 ≤ i ≤ n (par exemple --tranche 1/3) : « ${texte} » ne l'a pas.` };
83
+ }
84
+ if (tranche && !horsDuPoste) {
85
+ return { horsDuPoste, erreur: '⛔ --tranche découpe la nuit d\'une machine partagée : elle se donne avec --hors-du-poste ; la nuit du poste se joue entière.' };
86
+ }
87
+ return { horsDuPoste, tranche };
88
+ }
35
89
 
36
90
  const CONFIGURATION = fileURLToPath(new URL('./vitest.nuit.config.mjs', import.meta.url));
37
91
  const HORS = new Set(['node_modules', 'dist', '.git']);
@@ -51,15 +105,33 @@ function enTient(dossier, est) {
51
105
  }
52
106
 
53
107
  /**
54
- * Plays the night tests, then the measures of time, of the copy at <racine>: 0, 75 or the code of
55
- * the first red run of Vitest; 0 when there is none.
108
+ * The runs of Vitest the night plays in the copy at <racine>, each a value of
109
+ * GRILLHOUSE_TESTS_DE_NUIT, in their order: `nuit` when it holds night tests, then `mesures` when it
110
+ * holds a bench or a time witness; with <horsDuPoste>, `hors-poste` alone when it holds night tests.
56
111
  * @param {string} racine the root of the copy
112
+ * @param {{ horsDuPoste?: boolean }} [options] the night of a shared machine
113
+ * @returns {string[]}
57
114
  */
58
- export function testsDeNuit(racine) {
59
- const runs = [
115
+ export function runsDeLaNuit(racine, { horsDuPoste = false } = {}) {
116
+ if (horsDuPoste) {
117
+ return enTient(racine, estUnTestDeNuit) ? ['hors-poste'] : [];
118
+ }
119
+ return [
60
120
  enTient(racine, estUnTestDeNuit) && 'nuit',
61
121
  (enTient(racine, estUnBanc) || fichiersTemoins(racine).length > 0) && 'mesures',
62
122
  ].filter(Boolean);
123
+ }
124
+
125
+ /**
126
+ * Plays the night tests, then the measures of time, of the copy at <racine>: 0, 75 or the code of
127
+ * the first red run of Vitest; 0 when there is none. With <horsDuPoste>, the night tests alone, but
128
+ * those tagged `@poste`, and no measure.
129
+ * @param {string} racine the root of the copy
130
+ * With <tranche>, the night tests of its part alone, its reports written under RAPPORTS.
131
+ * @param {{ horsDuPoste?: boolean, tranche?: { index: number, count: number } }} [options] the night of a shared machine, its tranche
132
+ */
133
+ export function testsDeNuit(racine, options = {}) {
134
+ const runs = runsDeLaNuit(racine, options);
63
135
  if (runs.length === 0) {
64
136
  return 0;
65
137
  }
@@ -72,11 +144,25 @@ export function testsDeNuit(racine) {
72
144
  process.stdout.write(`${e.message}\n`);
73
145
  return e.code;
74
146
  }
147
+ const { tranche } = options;
148
+ const rapports = path.join(racine, RAPPORTS);
149
+ if (tranche) {
150
+ for (const f of fichiersDeLaTranche(rapports, tranche)) {
151
+ rmSync(f, { force: true });
152
+ }
153
+ }
154
+ const enTranche = tranche
155
+ ? { [NUIT_TRANCHE]: JSON.stringify({ tranche: `${tranche.index}/${tranche.count}`, rapports }) }
156
+ : {};
75
157
  const codes = runs.map(choix => {
76
158
  const r = spawnSync(
77
159
  'npx',
78
160
  ['--no-install', 'vitest', 'run', '--root', racine, '--config', CONFIGURATION],
79
- { cwd: racine, stdio: 'inherit', env: { ...process.env, [NUIT_VARIABLE]: choix } }
161
+ {
162
+ cwd: racine,
163
+ stdio: 'inherit',
164
+ env: { ...process.env, [NUIT_VARIABLE]: choix, ...enTranche },
165
+ }
80
166
  );
81
167
  return r.status ?? 1;
82
168
  });
@@ -88,5 +174,11 @@ export function testsDeNuit(racine) {
88
174
  }
89
175
 
90
176
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
91
- process.exitCode = testsDeNuit(process.cwd());
177
+ const { horsDuPoste, tranche, erreur } = lireLesArguments(process.argv.slice(2));
178
+ if (erreur) {
179
+ process.stderr.write(`${erreur}\n`);
180
+ process.exitCode = 2;
181
+ } else {
182
+ process.exitCode = testsDeNuit(process.cwd(), { horsDuPoste, tranche });
183
+ }
92
184
  }