@roomi-fields/grillhouse 0.33.1 → 0.34.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 (129) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +81 -0
  3. package/cadre/templates/projet/CLAUDE.md +9 -3
  4. package/charte.md +23 -6
  5. package/dist/temporal/acte.d.ts +7 -0
  6. package/dist/temporal/acte.js +19 -2
  7. package/dist/temporal/acte.js.map +1 -1
  8. package/dist/temporal/circuit/activites.d.ts +3 -1
  9. package/dist/temporal/circuit/activites.js +25 -1
  10. package/dist/temporal/circuit/activites.js.map +1 -1
  11. package/dist/temporal/circuit/appel.d.ts +19 -0
  12. package/dist/temporal/circuit/appel.js +93 -0
  13. package/dist/temporal/circuit/appel.js.map +1 -0
  14. package/dist/temporal/circuit/client.d.ts +7 -0
  15. package/dist/temporal/circuit/client.js +20 -0
  16. package/dist/temporal/circuit/client.js.map +1 -1
  17. package/dist/temporal/circuit/commande.js +27 -87
  18. package/dist/temporal/circuit/commande.js.map +1 -1
  19. package/dist/temporal/circuit/contrat.d.ts +19 -0
  20. package/dist/temporal/circuit/contrat.js +2 -0
  21. package/dist/temporal/circuit/contrat.js.map +1 -1
  22. package/dist/temporal/circuit/deroule.js +86 -11
  23. package/dist/temporal/circuit/deroule.js.map +1 -1
  24. package/dist/temporal/file/activites.d.ts +3 -0
  25. package/dist/temporal/file/activites.js +9 -0
  26. package/dist/temporal/file/activites.js.map +1 -1
  27. package/dist/temporal/file/contrat.d.ts +58 -0
  28. package/dist/temporal/file/deroule.d.ts +8 -1
  29. package/dist/temporal/file/deroule.js +100 -2
  30. package/dist/temporal/file/deroule.js.map +1 -1
  31. package/dist/temporal/nuits/contrat.d.ts +2 -0
  32. package/dist/temporal/nuits/deroule.js +3 -0
  33. package/dist/temporal/nuits/deroule.js.map +1 -1
  34. package/dist/temporal/places/activites.d.ts +8 -0
  35. package/dist/temporal/places/activites.js +12 -1
  36. package/dist/temporal/places/activites.js.map +1 -1
  37. package/dist/temporal/places/client.d.ts +8 -1
  38. package/dist/temporal/places/client.js +25 -2
  39. package/dist/temporal/places/client.js.map +1 -1
  40. package/dist/temporal/places/contrat.d.ts +35 -3
  41. package/dist/temporal/places/contrat.js +5 -4
  42. package/dist/temporal/places/contrat.js.map +1 -1
  43. package/dist/temporal/places/deroule.js +55 -9
  44. package/dist/temporal/places/deroule.js.map +1 -1
  45. package/dist/temporal/tickets/activites.d.ts +3 -0
  46. package/dist/temporal/tickets/activites.js +73 -4
  47. package/dist/temporal/tickets/activites.js.map +1 -1
  48. package/dist/temporal/tickets/contrat.d.ts +31 -0
  49. package/dist/temporal/tickets/deroule.js +61 -10
  50. package/dist/temporal/tickets/deroule.js.map +1 -1
  51. package/docs/ARCHITECTURE.md +225 -57
  52. package/docs/CADRE.md +6 -1
  53. package/docs/INTERFACE.md +24 -8
  54. package/hooks/crochet.mjs +17 -2
  55. package/hooks/hooks.json +24 -0
  56. package/package.json +1 -1
  57. package/scripts/activites.mjs +77 -14
  58. package/scripts/aiguillage.mjs +2 -0
  59. package/scripts/attente-a-l-arret.mjs +141 -0
  60. package/scripts/attente-au-tour.mjs +32 -16
  61. package/scripts/avancement.mjs +5 -3
  62. package/scripts/branche-de-nuit.mjs +63 -3
  63. package/scripts/ci-des-branches.mjs +4 -2
  64. package/scripts/circuit.mjs +57 -4
  65. package/scripts/circuits-du-serveur.mjs +34 -1
  66. package/scripts/commandes-composees.mjs +11 -4
  67. package/scripts/copies-finies.mjs +43 -29
  68. package/scripts/crochets.mjs +1 -1
  69. package/scripts/dette.mjs +55 -4
  70. package/scripts/disque-des-copies.d.mts +28 -0
  71. package/scripts/disque-des-copies.mjs +155 -0
  72. package/scripts/droits.mjs +2 -0
  73. package/scripts/etapes.mjs +6 -4
  74. package/scripts/faits-du-circuit.mjs +24 -0
  75. package/scripts/file-des-tickets.d.mts +16 -0
  76. package/scripts/file-des-tickets.mjs +65 -7
  77. package/scripts/gardes-du-cadre.mjs +4 -2
  78. package/scripts/integration/file.mjs +308 -10
  79. package/scripts/jointure.d.ts +41 -2
  80. package/scripts/langages/cargo/commandes.mjs +81 -12
  81. package/scripts/langages/cargo/composants.mjs +12 -4
  82. package/scripts/langages/cargo/executables-de-tests.mjs +118 -0
  83. package/scripts/langages/cargo/exemples.mjs +17 -3
  84. package/scripts/langages/cargo/index.mjs +8 -3
  85. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +2 -2
  86. package/scripts/langages/cargo/migrations/0.34.0-executables-de-tests.mjs +35 -0
  87. package/scripts/langages/cargo/squelette.mjs +8 -3
  88. package/scripts/langages/cargo/tailles-des-tests.mjs +68 -6
  89. package/scripts/langages/cargo/tests-de-head.mjs +12 -9
  90. package/scripts/langages/cargo/verdict.mjs +40 -14
  91. package/scripts/langages/python/commandes.mjs +14 -2
  92. package/scripts/langages/python/index.mjs +12 -4
  93. package/scripts/langages/python/verdict.mjs +8 -1
  94. package/scripts/langages/typescript/index.mjs +9 -2
  95. package/scripts/langages/typescript/resume-du-lanceur.mjs +92 -0
  96. package/scripts/langages/typescript/tests.mjs +1 -1
  97. package/scripts/langages/typescript/verdict.mjs +4 -60
  98. package/scripts/langages/typescript/verifier.mjs +1 -1
  99. package/scripts/langages/typescript/vitest-config/changements.mjs +12 -7
  100. package/scripts/langages/typescript/vitest-config/lances.mjs +45 -0
  101. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +1 -0
  102. package/scripts/messages-non-lus.mjs +166 -0
  103. package/scripts/mesure-de-la-machine.mjs +7 -4
  104. package/scripts/migrations-des-gardes.mjs +179 -0
  105. package/scripts/places-de-la-machine.mjs +44 -40
  106. package/scripts/places-du-serveur.mjs +82 -14
  107. package/scripts/plafond-de-la-machine.d.mts +18 -0
  108. package/scripts/plafond-de-la-machine.mjs +45 -0
  109. package/scripts/recommencer.d.mts +4 -0
  110. package/scripts/recommencer.mjs +29 -0
  111. package/scripts/regles-des-places.d.mts +35 -0
  112. package/scripts/regles-des-places.mjs +82 -1
  113. package/scripts/resultats.mjs +38 -4
  114. package/scripts/retirer-les-copies-finies.mjs +11 -7
  115. package/scripts/seances.mjs +1 -1
  116. package/scripts/services-du-noyau.mjs +1 -0
  117. package/scripts/sous-commandes.mjs +2 -0
  118. package/scripts/superviseur.mjs +235 -56
  119. package/scripts/tableau.mjs +468 -267
  120. package/scripts/taches-du-graphe.mjs +49 -8
  121. package/scripts/ticket-du-circuit.mjs +25 -0
  122. package/scripts/transitions.d.mts +27 -1
  123. package/scripts/transitions.mjs +96 -4
  124. package/scripts/verrou-de-machine.mjs +41 -17
  125. package/skills/explorateur/SKILL.md +8 -2
  126. package/skills/pitmaster/SKILL.md +18 -15
  127. package/skills/pitmaster/references/tour.md +3 -1
  128. package/skills/questionneur/SKILL.md +5 -1
  129. package/skills/testwriter/SKILL.md +32 -6
@@ -71,7 +71,7 @@
71
71
  // Every comment and change of the queue at a ticket is written under the author `file`, which bd
72
72
  // reads in BEADS_ACTOR, as the circuit writes its own lines under `circuit`.
73
73
  import { spawnSync } from 'node:child_process';
74
- import { existsSync, rmSync } from 'node:fs';
74
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
75
75
  import { createRequire } from 'node:module';
76
76
  import path from 'node:path';
77
77
  import { couvertPar, engendresDe, regenerer, touchesPar } from '../engendres.mjs';
@@ -153,8 +153,9 @@ function motifDeGitHub(motif) {
153
153
  // Whether the `on.push` of a workflow <push> runs on a push to <branche>, as GitHub reads its
154
154
  // filters: none runs on every branch; `branches` in its order, a `!` pattern taking out what the
155
155
  // ones before took in, the last match deciding; `branches-ignore` takes out what it matches;
156
- // `tags` or `tags-ignore` alone run on no branch. A filter on the paths, or a form the queue does
157
- // not judge, counts as one that runs.
156
+ // `tags` or `tags-ignore` alone run on no branch. GitHub asks both filters: a branch the branch
157
+ // filter leaves out never runs, whatever the paths; a filter on the paths leaves a branch it takes
158
+ // in counted as one that runs, as does a form the queue does not judge.
158
159
  function pousseeSurLaBranche(push, branche) {
159
160
  if (push === null || push === undefined) {
160
161
  return true;
@@ -162,9 +163,6 @@ function pousseeSurLaBranche(push, branche) {
162
163
  if (typeof push !== 'object' || Array.isArray(push)) {
163
164
  return true;
164
165
  }
165
- if (push.paths || push['paths-ignore']) {
166
- return true;
167
- }
168
166
  const { branches, 'branches-ignore': ignorees } = push;
169
167
  if (branches && ignorees) {
170
168
  return true;
@@ -226,9 +224,27 @@ const VERTE = 'verte';
226
224
  const SANS_CI = 'sans-ci';
227
225
  const NON_LUE = 'non-lue';
228
226
 
229
- // The workflows of the commit <sha> of the repository <racine> that run on a push to <branche>:
230
- // their paths.
231
- function fluxDuCommit(racine, sha, branche) {
227
+ // The name GitHub gives the workflow of the file <texte>: its `name` key, its path <chemin> without
228
+ // one (or when the file is not given or its YAML not read).
229
+ function nomDuFlux(chemin, texte) {
230
+ if (texte === null) {
231
+ return chemin;
232
+ }
233
+ try {
234
+ const require = createRequire(import.meta.url);
235
+ const nom = require('yaml').parse(texte)?.name;
236
+ return typeof nom === 'string' && nom !== '' ? nom : chemin;
237
+ } catch {
238
+ return chemin;
239
+ }
240
+ }
241
+
242
+ /**
243
+ * The workflows of the commit <sha> of the repository <racine> that run on a push to <branche>,
244
+ * in the order of the files of their directory: `{ chemin, nom }`, the path and the name GitHub
245
+ * gives the workflow (`workflowName` of `gh run list`).
246
+ */
247
+ export function fluxDuCommit(racine, sha, branche) {
232
248
  const git = (...a) => spawnSync('git', ['-C', racine, ...a], { encoding: 'utf8' });
233
249
  const l = git('ls-tree', '--name-only', `${sha}:${DOSSIER_DES_FLUX}`);
234
250
  const noms = l.status === 0 ? l.stdout.split('\n').filter(n => EXTENSIONS_DES_FLUX.test(n)) : [];
@@ -237,7 +253,198 @@ function fluxDuCommit(racine, sha, branche) {
237
253
  const f = git('show', `${sha}:${chemin}`);
238
254
  return { chemin, texte: f.status === 0 ? f.stdout : null };
239
255
  });
240
- return fluxDeLaBranche(fichiers, branche);
256
+ const attendus = new Set(fluxDeLaBranche(fichiers, branche));
257
+ return fichiers
258
+ .filter(({ chemin }) => attendus.has(chemin))
259
+ .map(({ chemin, texte }) => ({ chemin, nom: nomDuFlux(chemin, texte) }));
260
+ }
261
+
262
+ /**
263
+ * The workflows of the commit <sha> that run on a push to <main> and not on a push to the branch of
264
+ * the ticket <brancheDuTicket>: `{ chemin, nom }`, in the order of the files. The one the CI of the
265
+ * branch already judged is any workflow of the second set, found by its path.
266
+ * @param {string} racine
267
+ * @param {string} sha
268
+ * @param {string} main
269
+ * @param {string} brancheDuTicket
270
+ * @returns {{ chemin: string, nom: string }[]}
271
+ */
272
+ export function fluxDeMainAbsentsDeLaBranche(racine, sha, main, brancheDuTicket) {
273
+ const jugés = new Set(fluxDuCommit(racine, sha, brancheDuTicket).map(f => f.chemin));
274
+ return fluxDuCommit(racine, sha, main).filter(f => !jugés.has(f.chemin));
275
+ }
276
+
277
+ // The file of the readings due of the workflows of main, in the main tree <racine>.
278
+ const lecturesDues = racine => path.join(racine, '.claude', 'worktrees', 'flux-de-main-dus.json');
279
+
280
+ /** The readings due of the workflows of main of <racine>: `{ ticket, commit, branche, flux, poussee }`. */
281
+ export function lecturesDuesDe(racine) {
282
+ try {
283
+ const lu = JSON.parse(readFileSync(lecturesDues(racine), 'utf8'));
284
+ return Array.isArray(lu) ? lu : [];
285
+ } catch {
286
+ return [];
287
+ }
288
+ }
289
+
290
+ // The readings due <dues> written whole, atomically.
291
+ function ecrireLesLecturesDues(racine, dues) {
292
+ const f = lecturesDues(racine);
293
+ mkdirSync(path.dirname(f), { recursive: true });
294
+ const provisoire = `${f}.${process.pid}`;
295
+ writeFileSync(provisoire, `${JSON.stringify(dues, null, 2)}\n`);
296
+ renameSync(provisoire, f);
297
+ }
298
+
299
+ /**
300
+ * After the push of the commit <sha> of the ticket <ticket> to <branche> (main) at <poussee> ms, the
301
+ * reading of its workflows of main recorded as due, with the tools <o>: nothing is read, nothing
302
+ * waited for; none is due when every workflow of main is one the CI of <brancheDuTicket> judged.
303
+ * A reading of the same ticket and commit is replaced.
304
+ */
305
+ export function inscrireLesFluxDeMain(o, { ticket, sha, branche, brancheDuTicket, poussee }) {
306
+ const flux = fluxDeMainAbsentsDeLaBranche(o.racine, sha, branche, brancheDuTicket);
307
+ if (flux.length === 0) {
308
+ return;
309
+ }
310
+ const autres = lecturesDuesDe(o.racine).filter(l => !(l.ticket === ticket && l.commit === sha));
311
+ ecrireLesLecturesDues(o.racine, [...autres, { ticket, commit: sha, branche, flux, poussee }]);
312
+ }
313
+
314
+ // The conclusion of the run <id> read by <gh>: `{ fini, conclusion }`, or `{ raison }`.
315
+ function lireUnPassage(gh, id) {
316
+ const v = gh(['run', 'view', id, '--json', 'status,conclusion,jobs'], {
317
+ timeout: 60_000,
318
+ killSignal: 'SIGKILL',
319
+ });
320
+ if (v.error) {
321
+ return { raison: `gh ne se lance pas (${v.error.code ?? v.error.message}).` };
322
+ }
323
+ if (v.status !== 0) {
324
+ return { raison: `gh run view refuse :\n${`${v.stderr}${v.stdout}`.trim()}` };
325
+ }
326
+ try {
327
+ const vue = JSON.parse(v.stdout || '{}');
328
+ return { fini: vue?.status === 'completed', conclusion: vue?.conclusion ?? null };
329
+ } catch {
330
+ return { raison: `gh run view rend une sortie illisible :\n${v.stdout.trim()}` };
331
+ }
332
+ }
333
+
334
+ // The runs of the commit <sha> on <branche> read by <gh>: the list, or `{ raison }`.
335
+ function lirePassagesDe(gh, sha, branche) {
336
+ const r = gh([
337
+ 'run',
338
+ 'list',
339
+ '--commit',
340
+ sha,
341
+ '--branch',
342
+ branche,
343
+ '--json',
344
+ 'databaseId,status,conclusion,workflowName',
345
+ ]);
346
+ if (r.error) {
347
+ return { raison: `gh ne se lance pas (${r.error.code ?? r.error.message}).` };
348
+ }
349
+ if (r.status !== 0) {
350
+ return { raison: `gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}` };
351
+ }
352
+ try {
353
+ const l = JSON.parse(r.stdout || '[]');
354
+ return { passages: Array.isArray(l) ? l : [] };
355
+ } catch {
356
+ return { raison: `gh run list rend une sortie illisible :\n${r.stdout.trim()}` };
357
+ }
358
+ }
359
+
360
+ /** The label a ticket reopened by a red workflow of main bears, which the wait of the supervisor reads. */
361
+ export const FLUX_ROUGE = 'flux-rouge';
362
+ /** The title of the comment that gives the address of the red run, whose second paragraph is that address. */
363
+ export const TITRE_DU_FLUX_ROUGE = '## Flux de main rouge';
364
+
365
+ /**
366
+ * Each reading due of the workflows of main read once, without waiting, with the tools <o> at
367
+ * <maintenant> ms and the bounds <ci> (`rechercheMs`, `attenteMs`, from the push of main). A workflow
368
+ * red (any conclusion but `success`) reopens the ticket of the commit pushed under the label
369
+ * `flux-rouge`, a comment giving the address of the run, and closes the reading; green, it says
370
+ * nothing; with no run past the search bound, a run unfinished past the wait bound, or `gh`
371
+ * failing, a comment names the workflow and why, nothing is reopened. A reading with a workflow
372
+ * still to come stays due. `{ dues }`: the readings still due.
373
+ */
374
+ export function relireLesLecturesDues(o, { maintenant, ci }) {
375
+ const toutes = lecturesDuesDe(o.racine);
376
+ if (toutes.length === 0) {
377
+ return { dues: 0 };
378
+ }
379
+ const restantes = [];
380
+ for (const l of toutes) {
381
+ const court = l.commit.slice(0, 7);
382
+ const ecoule = maintenant - l.poussee;
383
+ const nonJuge = (nom, pourquoi) => {
384
+ commenterAu(
385
+ o,
386
+ l.ticket,
387
+ `## Flux de main non jugé\n\nLe flux ${nom} de ${court} sur ${l.branche} n'a pas été jugé : ${pourquoi}\n\nLa file ne le tient pas pour rouge : le superviseur le lit à la main.`
388
+ );
389
+ o.dire(`⚠ flux ${nom} de ${court} non jugé : ${pourquoi}`);
390
+ };
391
+ const lus = lirePassagesDe(o.gh, l.commit, l.branche);
392
+ if (lus.raison) {
393
+ for (const f of l.flux) {
394
+ nonJuge(f.nom, lus.raison);
395
+ }
396
+ continue;
397
+ }
398
+ const encore = [];
399
+ let rouge = null;
400
+ for (const f of l.flux) {
401
+ const p = lus.passages
402
+ .filter(x => x?.databaseId && x.workflowName === f.nom)
403
+ .reduce((m, x) => (m === null || x.databaseId > m.databaseId ? x : m), null);
404
+ if (p === null) {
405
+ if (ecoule > ci.rechercheMs) {
406
+ nonJuge(f.nom, `aucun passage trouvé en ${Math.round(ci.rechercheMs / 60_000)} min.`);
407
+ } else {
408
+ encore.push(f);
409
+ }
410
+ continue;
411
+ }
412
+ const id = String(p.databaseId);
413
+ const v = lireUnPassage(o.gh, id);
414
+ if (v.raison) {
415
+ nonJuge(f.nom, v.raison);
416
+ } else if (!v.fini) {
417
+ if (ecoule > ci.attenteMs) {
418
+ nonJuge(
419
+ f.nom,
420
+ `le passage ${id} n'est pas fini après ${Math.round(ci.attenteMs / 60_000)} min.`
421
+ );
422
+ } else {
423
+ encore.push(f);
424
+ }
425
+ } else if (v.conclusion !== 'success') {
426
+ rouge = { nom: f.nom, id };
427
+ break;
428
+ }
429
+ }
430
+ if (rouge) {
431
+ const url =
432
+ o.gh(['run', 'view', rouge.id, '--json', 'url', '--jq', '.url']).stdout?.trim() || rouge.id;
433
+ commenterAu(
434
+ o,
435
+ l.ticket,
436
+ `${TITRE_DU_FLUX_ROUGE}\n\n${rouge.nom} : ${url} (commit ${court})\n\nLe flux ${rouge.nom} de ${court} est rouge sur ${l.branche}, après l'entrée du lot : le ticket est rouvert, le superviseur juge la cause.`
437
+ );
438
+ o.bd('update', l.ticket, '--status', 'open', '--add-label', FLUX_ROUGE);
439
+ o.dire(`✗ flux ${rouge.nom} de ${court} rouge sur ${l.branche} : ${l.ticket} rouvert`);
440
+ continue;
441
+ }
442
+ if (encore.length > 0) {
443
+ restantes.push({ ...l, flux: encore });
444
+ }
445
+ }
446
+ ecrireLesLecturesDues(o.racine, restantes);
447
+ return { dues: restantes.length };
241
448
  }
242
449
 
243
450
  // The GitHub CLI run in the main tree <racine>.
@@ -290,6 +497,7 @@ export function lireUneFoisLaCI(o, { sha, branche, passage = null }) {
290
497
  let id = passage;
291
498
  if (id === null) {
292
499
  if (fluxDuCommit(o.racine, sha, branche).length === 0) {
500
+ // (the reading of before the CI of every workflow, kept for the replay of `lireLaCI`)
293
501
  return { etat: SANS_CI };
294
502
  }
295
503
  const r = gh([
@@ -346,6 +554,96 @@ export function lireUneFoisLaCI(o, { sha, branche, passage = null }) {
346
554
  return { etat: 'en-cours', passage: id };
347
555
  }
348
556
 
557
+ /**
558
+ * One reading of the CI of the commit <sha> pushed to <branche>, every expected workflow
559
+ * (`fluxDuCommit`) read together, with the tools <o>: `{ etat: 'sans-ci' }`; `{ etat: 'non-lue',
560
+ * raison }` (gh absent, refusing, or its output unreadable); `{ etat: 'rouge', passage, flux }`, the
561
+ * first workflow in the order of the files whose run is not a success, whatever the others still
562
+ * do; `{ etat: 'verte', passage }`, every workflow green, `passage` the first workflow's; or `{
563
+ * etat: 'en-cours', flux: [{ nom, passage, fini }] }`, each workflow with its run (null while it
564
+ * is looked for). A run joins its workflow by its name (`workflowName`); one of no expected name
565
+ * does not count, the latest run (the greatest id) of a name decides, and workflows of one name count
566
+ * for one, which `gh run list` does not tell apart. Each run is read at its current attempt (`gh
567
+ * run view <id>` without `--attempt`). Nothing is kept from one reading to the next; nothing is
568
+ * written to the ticket: `conclureLaCI` does.
569
+ */
570
+ export function lireLesPassagesDeLaCI(o, { sha, branche }) {
571
+ const { gh } = o;
572
+ const attendus = [...new Set(fluxDuCommit(o.racine, sha, branche).map(f => f.nom))];
573
+ if (attendus.length === 0) {
574
+ return { etat: SANS_CI };
575
+ }
576
+ const r = gh([
577
+ 'run',
578
+ 'list',
579
+ '--commit',
580
+ sha,
581
+ '--branch',
582
+ branche,
583
+ '--json',
584
+ 'databaseId,status,conclusion,workflowName',
585
+ ]);
586
+ if (r.error) {
587
+ return { etat: NON_LUE, raison: `gh ne se lance pas (${r.error.code ?? r.error.message}).` };
588
+ }
589
+ if (r.status !== 0) {
590
+ return { etat: NON_LUE, raison: `gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}` };
591
+ }
592
+ let passages;
593
+ try {
594
+ passages = JSON.parse(r.stdout || '[]');
595
+ } catch {
596
+ return {
597
+ etat: NON_LUE,
598
+ raison: `gh run list rend une sortie illisible :\n${r.stdout.trim()}`,
599
+ };
600
+ }
601
+ const recent = nom =>
602
+ (Array.isArray(passages) ? passages : [])
603
+ .filter(x => x?.databaseId && x.workflowName === nom)
604
+ .reduce((m, x) => (m === null || x.databaseId > m.databaseId ? x : m), null);
605
+ const lus = [];
606
+ for (const nom of attendus) {
607
+ const p = recent(nom);
608
+ if (p === null) {
609
+ lus.push({ nom, passage: null, fini: false });
610
+ continue;
611
+ }
612
+ const id = String(p.databaseId);
613
+ const v = gh(['run', 'view', id, '--json', 'status,conclusion,jobs'], {
614
+ timeout: 60_000,
615
+ killSignal: 'SIGKILL',
616
+ });
617
+ if (v.error) {
618
+ return { etat: NON_LUE, raison: `gh ne se lance pas (${v.error.code ?? v.error.message}).` };
619
+ }
620
+ if (v.status !== 0) {
621
+ return { etat: NON_LUE, raison: `gh run view refuse :\n${`${v.stderr}${v.stdout}`.trim()}` };
622
+ }
623
+ let vue;
624
+ try {
625
+ vue = JSON.parse(v.stdout || '{}');
626
+ } catch {
627
+ return {
628
+ etat: NON_LUE,
629
+ raison: `gh run view rend une sortie illisible :\n${v.stdout.trim()}`,
630
+ };
631
+ }
632
+ const fini = vue?.status === 'completed';
633
+ if (!fini) {
634
+ ecrireLesEtapes(o.avancement, vue);
635
+ }
636
+ if (fini && vue.conclusion !== 'success') {
637
+ return { etat: 'rouge', passage: id, flux: nom };
638
+ }
639
+ lus.push({ nom, passage: id, fini });
640
+ }
641
+ if (lus.every(f => f.fini)) {
642
+ return { etat: VERTE, passage: lus[0].passage };
643
+ }
644
+ return { etat: 'en-cours', flux: lus };
645
+ }
646
+
349
647
  /**
350
648
  * The working directory of the circuit of <ticket> in the main tree of <o> removed, once the queue
351
649
  * is done with the ticket closed: as the workspace of a pipeline, it lives as long as the ticket.
@@ -256,6 +256,20 @@ export interface Composition {
256
256
  * its class (day, night, bench), which the proof of the red writes, plays and removes; null for
257
257
  * a file that has none. */
258
258
  soeurDAvant?(chemin: string, racine: string): string | null;
259
+ /** Optional, for the module that drives the task runner (typescript), which the core serves to
260
+ * the others: the names of the summaries of a run present in `racine` before a run. */
261
+ resumesDuLancement?(racine: string): Set<string>;
262
+ /** Optional, typescript's alone: moves the summaries a run in `racine` wrote (absent from
263
+ * `avant`) into the results directory `env` names, or removes them without one; gives each
264
+ * task of those summaries with its exit code, null for a task that did not run. */
265
+ garderLesResumes?(
266
+ racine: string,
267
+ avant: Set<string>,
268
+ env?: NodeJS.ProcessEnv
269
+ ): { tache: string; code: number | null }[];
270
+ /** Optional, typescript's alone: the tasks of the summaries under the results directory
271
+ * `dossier`, in their order, each with its cache status; `code` null for a task that did not run. */
272
+ lireLesResumes?(dossier: string): TacheDuResume[];
259
273
  /** Whether HEAD's version of the test file `chemin` (from `racine`) plays in a tree of its own,
260
274
  * the copy's with that file alone replaced, under the file's own name, which the proof of the
261
275
  * red builds, plays and removes (cargo, python); false for a file the tool cannot play so
@@ -263,7 +277,8 @@ export interface Composition {
263
277
  * beside it (typescript: `soeurDAvant`) or does not play. */
264
278
  arbreDAvant(chemin: string, racine: string): boolean;
265
279
  /** The environment a tree of HEAD's version of `chemin` plays under (cargo: the target
266
- * directory of the copy's compilations); empty for none. */
280
+ * directory of the copy's compilations; python: the copy's folder of uv environments, which the
281
+ * tree reuses, `GRILLHOUSE_VENV_DE_LA_COPIE`); empty for none. */
267
282
  envDArbre(chemin: string, racine: string): Record<string, string>;
268
283
  /** The names of the tests of HEAD's version of the test file `chemin` (from `racine`), as the
269
284
  * verdict names them, read without playing them, for a file whose tree the proof does not play
@@ -293,6 +308,10 @@ export interface Langage extends Composition {
293
308
  /** The manifest of a package of this language, in its folder (`package.json`, `Cargo.toml`):
294
309
  * the guard of the languages asks it of a package the architecture declares of this language. */
295
310
  manifeste: string;
311
+ /** The expected size of a copy of a project of this language before any of its copies is
312
+ * measured, in bytes: the room a circuit's start wants on the disk of the copies, the charter's
313
+ * margin besides (scripts/disque-des-copies.mjs), its dependencies and its builds included. */
314
+ tailleDUneCopie: number;
296
315
  /** The name the text of a manifest of this language gives its package (the `name` of a
297
316
  * `package.json`, of the `[package]` of a `Cargo.toml`, of the `[project]` of a
298
317
  * `pyproject.toml`); null for none. */
@@ -489,7 +508,8 @@ export const TRACE: string;
489
508
  export function nomDuPaquet(racine: string, dossier: string): string | null;
490
509
  /** Runs the tasks `taches` of the packages `noms` (all when empty) with the task runner `outil`,
491
510
  * each task whose dependencies succeed played to its end: the runner's exit code. `tests` is the
492
- * content of the variable `TESTS_CIBLES` of the run; the variable of `env` never passes on. */
511
+ * content of the variable `TESTS_CIBLES` of the run; the variable of `env` never passes on. A
512
+ * red run names, through `dire`, each task whose code is not 0. */
493
513
  export function lancerLesTaches(o: {
494
514
  outil: string;
495
515
  racine: string;
@@ -497,7 +517,26 @@ export function lancerLesTaches(o: {
497
517
  noms?: Iterable<string>;
498
518
  tests?: { arguments: string[]; rejouer?: string };
499
519
  env?: NodeJS.ProcessEnv;
520
+ dire?: (ligne: string) => void;
500
521
  }): number;
522
+ /** A task of the summary of the task runner, or one a module wrote: `code` null for a task that did not run. */
523
+ export interface TacheDuResume {
524
+ tache: string;
525
+ paquet: string;
526
+ dossier: string;
527
+ script: string;
528
+ tests: boolean;
529
+ code: number | null;
530
+ cache: string | null;
531
+ journal: string | null;
532
+ }
533
+ /** The tasks of the verdict of a language without a reading of the summary of its own (cargo,
534
+ * python): those of the summary under `dossier`, read by the module that drives the runner
535
+ * (`lireLesResumes`), then each of `ecrites` whose id they lack. */
536
+ export function tachesDuVerdict<T extends { tache: string }>(
537
+ dossier: string,
538
+ ecrites: T[]
539
+ ): (TacheDuResume | T)[];
501
540
  /** The content of the variable `TESTS_CIBLES` for a targeted run: the paths and options it names, and
502
541
  * the moment of the run when `force` (the task plays for real); undefined when there is nothing to
503
542
  * carry. */
@@ -8,10 +8,10 @@
8
8
  // npx grillhouse verifier [--tout | --gardes] verifier
9
9
  // node commandes.mjs typer typer
10
10
  // npx grillhouse tests-de-nuit tests-de-nuit
11
- // npx grillhouse tailles-des-tests | clippy | frontieres | index-interfaces
11
+ // npx grillhouse tailles-des-tests | executables-de-tests | clippy | frontieres | index-interfaces
12
12
  // each guard, its own script
13
13
  //
14
- // - Each guard of structure of the module (./tailles-des-tests.mjs, ./clippy.mjs,
14
+ // - Each guard of structure of the module (./tailles-des-tests.mjs, ./executables-de-tests.mjs, ./clippy.mjs,
15
15
  // ./frontieres.mjs, ./index-interfaces.mjs) is a command by its name too, its own script, as the module typescript's: the line of a red
16
16
  // guard (`grillhouse <garde>`, scripts/gardes-du-cadre.mjs) names a command that exists.
17
17
  // - `tester` plays the tests of the crates as tasks of Turborepo, the way of the module
@@ -47,7 +47,9 @@
47
47
  // `<target>/grillhouse/<crate>-build.log`, the task's `journal` from the root, then to the error
48
48
  // stream. The folder of a crate plays it whole; the source of a test target
49
49
  // (`<crate>/tests/<nom>.rs`) builds and plays that target alone (`--test <nom>`), without the
50
- // doctests; the paths of the variable `GRILLHOUSE_TESTS` that lie in the crate replace the folder.
50
+ // doctests; a module of a target `tests/<dossier>/main.rs` (`tests/it/foo.rs`, the crate's one
51
+ // executable) builds that target and plays its tests alone, by the filterset of nextest
52
+ // (`-E 'binary_id(<crate>::it) & test(/^foo::/)'`), as Cargo filters its own testsuite; the paths of the variable `GRILLHOUSE_TESTS` that lie in the crate replace the folder.
51
53
  // A path out of every crate, or in a crate without tests, is refused, named, and nothing plays
52
54
  // (code 2). `--force` changes nothing here: cargo keeps no result of a test to replay. Another
53
55
  // option goes to nextest.
@@ -227,6 +229,7 @@ const COMPILATIONS = ['test', 'nextest', 'check', 'build'];
227
229
  * this one, and its arguments as a guard. */
228
230
  export const GARDES = [
229
231
  { nom: 'tailles-des-tests', args: [] },
232
+ { nom: 'executables-de-tests', args: [] },
230
233
  { nom: 'clippy', args: [] },
231
234
  { nom: 'frontieres', args: [] },
232
235
  { nom: 'index-interfaces', args: ['--verifier'] },
@@ -457,7 +460,7 @@ function jouerLesTests(racine, p, choix, options, temporaire = () => ({}), tranc
457
460
  const bancs = [];
458
461
  // The test executables the builds of the run report, removed once its tests played.
459
462
  const executables = [];
460
- for (const { c, cibles: nommees, jour } of choix) {
463
+ for (const { c, cibles: nommees, jour, modules = new Map() } of choix) {
461
464
  // Targets named beside the day of the crate (`jour`, a unit test of `src/` named): the day
462
465
  // builds whole, and plays besides the targets named.
463
466
  const cibles = jour && nommees.length === 0 ? [] : nommees;
@@ -492,7 +495,7 @@ function jouerLesTests(racine, p, choix, options, temporaire = () => ({}), tranc
492
495
  ? duC.length
493
496
  ? [...duC, ...nommes]
494
497
  : []
495
- : nommes;
498
+ : [...nommes, ...filtreDesModules(nom, autres, modules)];
496
499
  const args = [...nextest, '-p', nom, ...selection, ...options];
497
500
  prevues.push([
498
501
  p.prevoir(nom, d, 'nextest', true, args),
@@ -500,7 +503,13 @@ function jouerLesTests(racine, p, choix, options, temporaire = () => ({}), tranc
500
503
  ]);
501
504
  }
502
505
  if (desBancs.length && indivisible) {
503
- const args = [...nextestDuBanc, '-p', nom, ...desBancs.flatMap(n => ['--test', n])];
506
+ const args = [
507
+ ...nextestDuBanc,
508
+ '-p',
509
+ nom,
510
+ ...desBancs.flatMap(n => ['--test', n]),
511
+ ...filtreDesModules(nom, desBancs, modules),
512
+ ];
504
513
  bancs.push({
505
514
  nom,
506
515
  d,
@@ -562,6 +571,46 @@ function duJour(c) {
562
571
  // The refusal of a night test named in a targeted run: the night alone plays it.
563
572
  const REFUS_DE_NUIT = 'un test de nuit se joue la nuit seulement (npx grillhouse nuit le joue)';
564
573
 
574
+ // The target `tests/<dossier>/main.rs` of the crate <crate> whose module is the file <abs> (out
575
+ // of `tests/common/` and of the target's root), and the module's path in the executable
576
+ // (`tests/it/foo.rs` and `tests/it/foo/mod.rs` → `foo`, `tests/it/foo/sous.rs` → `foo::sous`):
577
+ // `{ cible, module }`, null for any other file.
578
+ function moduleDeCible(crate, abs) {
579
+ const parts = path.relative(crate.composant.dossier, abs).split(path.sep);
580
+ if (parts.length < 3 || parts[0] !== 'tests' || parts[1] === 'common' || !abs.endsWith('.rs')) {
581
+ return null;
582
+ }
583
+ const racine = path.join(crate.composant.dossier, 'tests', parts[1], 'main.rs');
584
+ const cible = crate.cibles.find(t => t.kind.includes('test') && t.src === racine);
585
+ const module = parts.slice(2);
586
+ module[module.length - 1] = module[module.length - 1].replace(/\.rs$/, '');
587
+ if (module.at(-1) === 'mod') {
588
+ module.pop();
589
+ }
590
+ return cible && module.length ? { cible, module: module.join('::') } : null;
591
+ }
592
+
593
+ // The filterset of nextest that plays, of the targets <noms> of the crate <nom>, the modules
594
+ // <modules> holds (`Map` target → its modules, or null for the whole target), as Cargo's own
595
+ // testsuite filters one executable by module path: `binary_id(<crate>::<cible>) &
596
+ // test(/^<module>::/)`; none when every target plays whole.
597
+ function filtreDesModules(nom, noms, modules) {
598
+ if (noms.every(n => (modules.get(n) ?? null) === null)) {
599
+ return [];
600
+ }
601
+ const echapper = s => s.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
602
+ const parCible = noms.map(n => {
603
+ const binaire = `binary_id(${nom}::${n})`;
604
+ const deN = modules.get(n) ?? null;
605
+ if (deN === null) {
606
+ return binaire;
607
+ }
608
+ const tests = deN.map(m => `test(/^${echapper(m)}::/)`).join(' | ');
609
+ return `(${binaire} & (${tests}))`;
610
+ });
611
+ return ['-E', parCible.join(' | ')];
612
+ }
613
+
565
614
  // The crates the paths <chemins> choose in <racine>: `{ choix }`, or `{ refus }` naming each path
566
615
  // refused.
567
616
  function choisir(racine, tous, chemins) {
@@ -585,7 +634,9 @@ function choisir(racine, tous, chemins) {
585
634
  refus.push(`${chemin} : ${c.nom} n'a aucun test, ni dossier tests/, ni tests.rs sous src/`);
586
635
  continue;
587
636
  }
588
- const cible = crate.cibles.find(t => t.kind.includes('test') && t.src === abs);
637
+ const propre = crate.cibles.find(t => t.kind.includes('test') && t.src === abs);
638
+ const duModule = propre ? null : moduleDeCible(crate, abs);
639
+ const cible = propre ?? duModule?.cible;
589
640
  // A night test plays at night alone (`tests-de-nuit`): a targeted run refuses it, named.
590
641
  if (cible && horsDuJour(cible) === 'nuit') {
591
642
  refus.push(`${chemin} : ${REFUS_DE_NUIT}`);
@@ -593,14 +644,24 @@ function choisir(racine, tous, chemins) {
593
644
  }
594
645
  const deja = parDossier.get(c.dossier);
595
646
  // A file with no target of its own (a unit test of `src/`) asks for the day of its crate; a
596
- // target named stays named, whatever the order of the paths.
597
- const entree = deja ?? { c: crate, cibles: [], jour: false };
647
+ // target named stays named, whatever the order of the paths; a module of a target
648
+ // `tests/<dossier>/main.rs` names its target, its tests alone (`modules`), unless the target
649
+ // is named whole.
650
+ const entree = deja ?? { c: crate, cibles: [], jour: false, modules: new Map() };
598
651
  parDossier.set(c.dossier, entree);
599
652
  if (!cible) {
600
653
  entree.jour = true;
601
- } else {
654
+ continue;
655
+ }
656
+ if (!entree.cibles.includes(cible.name)) {
602
657
  entree.cibles.push(cible.name);
603
658
  }
659
+ const avant = entree.modules.get(cible.name);
660
+ if (!duModule || avant === null) {
661
+ entree.modules.set(cible.name, null);
662
+ } else {
663
+ entree.modules.set(cible.name, [...(avant ?? []), duModule.module]);
664
+ }
604
665
  }
605
666
  if (refus.length) {
606
667
  return { refus };
@@ -661,8 +722,16 @@ function verifier(racine, args, env) {
661
722
  env,
662
723
  })
663
724
  : 0;
664
- p.jouer(p.prevoir(RACINE, racine, 'deny', false, ['deny', 'check']));
665
- return code === 0 ? p.code() : 1;
725
+ const deny = p.jouer(p.prevoir(RACINE, racine, 'deny', false, ['deny', 'check']));
726
+ const verdict = code === 0 ? p.code() : 1;
727
+ // A red pass names its task out of the graph, as `lancerLesTaches` names those of the graph.
728
+ if (verdict !== 0) {
729
+ if (deny !== 0) {
730
+ process.stderr.write(`⛔ ${RACINE}#deny (code ${deny})\n`);
731
+ }
732
+ process.stderr.write('⛔ rouge.\n');
733
+ }
734
+ return verdict;
666
735
  }
667
736
 
668
737
  // The scripts of guards of the project, in the order they play, as the module typescript's
@@ -316,8 +316,10 @@ export function envDArbre(_chemin, racine) {
316
316
  /**
317
317
  * The names of the tests of HEAD's version of the test file <chemin> (from the root <racine>),
318
318
  * read without playing them, for a file whose tree the proof does not play: a unit test file of
319
- * `src/` (`tests.rs`, a file of a folder `tests/` under `src/`, out of `src/bin/`) and a target
320
- * `tests/<dossier>/main.rs` (./tests-de-head.mjs), and a target `tests/<nom>.rs`, whose tree the
319
+ * `src/` (`tests.rs`, a file of a folder `tests/` under `src/`, out of `src/bin/`) and each file
320
+ * of a target `tests/<dossier>/main.rs`, its root and its modules (`tests/it/foo.rs`, the names
321
+ * `foo::…`), each its own tests as the verdict gives them (./tests-de-head.mjs,
322
+ * ./verdict.mjs), and a target `tests/<nom>.rs`, whose tree the
321
323
  * proof plays unless it no longer compiles (grillhouse-3e2.2): its names as nextest gives them,
322
324
  * without the target, its out-of-line modules read (`mod common;`, `common::<fn>`). <lire> gives
323
325
  * HEAD's text of a file from the root. Null for any other file, or one HEAD does not hold.
@@ -336,8 +338,14 @@ export function testsDeHead(chemin, racine, lire) {
336
338
  return null;
337
339
  }
338
340
  const parts = path.relative(c.dossier, abs).split(path.sep);
339
- if (parts.length === 3 && parts[0] === 'tests' && parts[2] === 'main.rs') {
340
- return nomsDeHead(chemin, null, lire);
341
+ // A file of a target `tests/<dossier>/main.rs`, out of the helpers of `tests/common/`.
342
+ if (parts.length >= 3 && parts[0] === 'tests' && parts[1] !== 'common') {
343
+ const module = parts.slice(2);
344
+ module[module.length - 1] = module[module.length - 1].replace(/\.rs$/, '');
345
+ if (module.at(-1) === 'mod' || (module.length === 1 && module[0] === 'main')) {
346
+ module.pop();
347
+ }
348
+ return nomsDeHead(chemin, module, lire);
341
349
  }
342
350
  if (arbreDAvant(chemin, racine)) {
343
351
  return nomsDeHead(chemin, null, lire);