@roomi-fields/grillhouse 0.52.0 → 0.54.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 (155) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +96 -0
  3. package/agents/direct.md +1 -1
  4. package/cadre/templates/projet/docs/agents/issue-tracker.md +2 -2
  5. package/cadre/templates/projet/vitest.config.cjs +45 -0
  6. package/charte/superviseur.md +36 -37
  7. package/charte.md +13 -1
  8. package/dist/temporal/circuit/appel.d.ts +2 -0
  9. package/dist/temporal/circuit/appel.js +24 -2
  10. package/dist/temporal/circuit/appel.js.map +1 -1
  11. package/dist/temporal/circuit/client.d.ts +14 -5
  12. package/dist/temporal/circuit/client.js +41 -9
  13. package/dist/temporal/circuit/client.js.map +1 -1
  14. package/dist/temporal/circuit/commande.js +17 -6
  15. package/dist/temporal/circuit/commande.js.map +1 -1
  16. package/dist/temporal/circuit/contrat.d.ts +9 -0
  17. package/dist/temporal/circuit/contrat.js +6 -0
  18. package/dist/temporal/circuit/contrat.js.map +1 -1
  19. package/dist/temporal/circuit/deroule.js +29 -12
  20. package/dist/temporal/circuit/deroule.js.map +1 -1
  21. package/dist/temporal/client.d.ts +35 -1
  22. package/dist/temporal/client.js +144 -1
  23. package/dist/temporal/client.js.map +1 -1
  24. package/dist/temporal/commande.js +31 -13
  25. package/dist/temporal/commande.js.map +1 -1
  26. package/dist/temporal/etat.d.ts +3 -1
  27. package/dist/temporal/etat.js +31 -17
  28. package/dist/temporal/etat.js.map +1 -1
  29. package/dist/temporal/file/activites.js +1 -1
  30. package/dist/temporal/file/activites.js.map +1 -1
  31. package/dist/temporal/file/contrat.d.ts +4 -5
  32. package/dist/temporal/file/contrat.js +2 -2
  33. package/dist/temporal/file/contrat.js.map +1 -1
  34. package/dist/temporal/file/deroule.js +7 -5
  35. package/dist/temporal/file/deroule.js.map +1 -1
  36. package/dist/temporal/installation.d.ts +116 -53
  37. package/dist/temporal/installation.js +898 -241
  38. package/dist/temporal/installation.js.map +1 -1
  39. package/dist/temporal/nuits/deroule.js +3 -1
  40. package/dist/temporal/nuits/deroule.js.map +1 -1
  41. package/dist/temporal/places/deroule.js +2 -1
  42. package/dist/temporal/places/deroule.js.map +1 -1
  43. package/dist/temporal/sonde/deroule.js +2 -1
  44. package/dist/temporal/sonde/deroule.js.map +1 -1
  45. package/dist/temporal/tickets/deroule.js +4 -3
  46. package/dist/temporal/tickets/deroule.js.map +1 -1
  47. package/dist/temporal/travailleur.d.ts +7 -1
  48. package/dist/temporal/travailleur.js +49 -25
  49. package/dist/temporal/travailleur.js.map +1 -1
  50. package/docs/INTERFACE.md +37 -12
  51. package/docs/architecture/circuit.md +21 -18
  52. package/docs/architecture/entree.md +10 -11
  53. package/docs/architecture/greffon.md +45 -27
  54. package/docs/architecture/installation.md +92 -59
  55. package/docs/architecture/machine.md +2 -2
  56. package/docs/architecture/tests.md +15 -6
  57. package/docs/lexique.md +2 -2
  58. package/hooks/hooks.json +10 -0
  59. package/hooks/register.tsx +59 -39
  60. package/package.json +3 -2
  61. package/scripts/activites.mjs +5 -4
  62. package/scripts/aiguillage.mjs +5 -2
  63. package/scripts/bd-garde.mjs +69 -0
  64. package/scripts/ci-de-main.mjs +259 -56
  65. package/scripts/circuit.mjs +274 -47
  66. package/scripts/circuits-du-serveur.mjs +3 -2
  67. package/scripts/circuits-tenus.d.mts +7 -0
  68. package/scripts/circuits-tenus.mjs +17 -0
  69. package/scripts/commandes-composees.mjs +1 -1
  70. package/scripts/copie-de-montee.mjs +354 -0
  71. package/scripts/copies-du-depot.d.mts +13 -0
  72. package/scripts/copies-du-depot.mjs +66 -0
  73. package/scripts/copies-finies.mjs +6 -40
  74. package/scripts/crochets.mjs +16 -2
  75. package/scripts/direct.mjs +2 -2
  76. package/scripts/droits.mjs +13 -6
  77. package/scripts/engendres.mjs +5 -3
  78. package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
  79. package/scripts/etapes.mjs +11 -3
  80. package/scripts/faits-du-circuit.mjs +12 -5
  81. package/scripts/file-des-tickets.d.mts +13 -2
  82. package/scripts/file-des-tickets.mjs +71 -21
  83. package/scripts/greffons.mjs +42 -27
  84. package/scripts/grillhouse-maj.mjs +105 -85
  85. package/scripts/init.mjs +1 -1
  86. package/scripts/integration/file.mjs +5 -2
  87. package/scripts/integration/integrer.mjs +14 -4
  88. package/scripts/jointure.d.ts +16 -0
  89. package/scripts/langages/c/commandes.mjs +18 -8
  90. package/scripts/langages/cargo/commandes.mjs +88 -35
  91. package/scripts/langages/cargo/index.mjs +6 -3
  92. package/scripts/langages/cargo/sccache.mjs +15 -12
  93. package/scripts/langages/cargo/tailles-des-tests.mjs +115 -6
  94. package/scripts/langages/python/commandes.mjs +19 -9
  95. package/scripts/langages/python/squelette.mjs +2 -2
  96. package/scripts/langages/typescript/code-mort.mjs +36 -3
  97. package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
  98. package/scripts/langages/typescript/index.mjs +2 -0
  99. package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +370 -0
  100. package/scripts/langages/typescript/mise-a-jour.mjs +49 -12
  101. package/scripts/langages/typescript/parcours.mjs +5 -1
  102. package/scripts/langages/typescript/squelette.mjs +20 -17
  103. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
  104. package/scripts/langages/typescript/turbo-des-paquets.mjs +24 -37
  105. package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
  106. package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
  107. package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
  108. package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
  109. package/scripts/langages.d.mts +6 -0
  110. package/scripts/langages.mjs +6 -0
  111. package/scripts/lire.mjs +236 -0
  112. package/scripts/mesure/pression.mjs +5 -3
  113. package/scripts/migrations/cout-des-jetons-au-registre.mjs +136 -0
  114. package/scripts/migrations/lire-un-ticket.mjs +46 -0
  115. package/scripts/migrations.mjs +4 -0
  116. package/scripts/montee.mjs +588 -0
  117. package/scripts/nuit.sh +21 -12
  118. package/scripts/outil.mjs +5 -3
  119. package/scripts/paquet-npm.mjs +22 -0
  120. package/scripts/paquet.mjs +5 -5
  121. package/scripts/pre-compact.mjs +25 -0
  122. package/scripts/registre.d.mts +7 -1
  123. package/scripts/registre.mjs +114 -102
  124. package/scripts/reponses-du-circuit.d.mts +17 -2
  125. package/scripts/reponses-du-circuit.mjs +78 -20
  126. package/scripts/resultats.mjs +55 -17
  127. package/scripts/retirer-les-copies-finies.mjs +4 -7
  128. package/scripts/seances.mjs +28 -3
  129. package/scripts/services-du-noyau.mjs +7 -2
  130. package/scripts/session-start.sh +18 -11
  131. package/scripts/sortie.mjs +4 -7
  132. package/scripts/sous-commandes.mjs +2 -0
  133. package/scripts/suiveur.mjs +12 -4
  134. package/scripts/superviseur.mjs +135 -84
  135. package/scripts/tableau.mjs +651 -224
  136. package/scripts/tarifs.mjs +67 -0
  137. package/scripts/ticket-du-circuit.mjs +25 -4
  138. package/scripts/transitions.d.mts +6 -14
  139. package/scripts/transitions.mjs +126 -49
  140. package/scripts/verdict-de-la-nuit.mjs +2 -2
  141. package/scripts/verrou-de-fichier.d.mts +11 -0
  142. package/skills/direct/SKILL.md +21 -11
  143. package/skills/explorateur/SKILL.md +16 -6
  144. package/skills/grill/SKILL.md +9 -7
  145. package/skills/grill/references/paquets.md +4 -4
  146. package/skills/mesure/SKILL.md +4 -3
  147. package/skills/pitmaster/SKILL.md +56 -35
  148. package/skills/pitmaster/references/consigne-agent.md +1 -1
  149. package/skills/pitmaster/references/erreurs.md +4 -2
  150. package/skills/pitmaster/references/tour.md +11 -4
  151. package/skills/relecteur/SKILL.md +8 -1
  152. package/skills/testwriter/SKILL.md +1 -1
  153. package/types/index.d.ts +3 -1
  154. package/cadre/templates/projet/vitest.config.ts +0 -44
  155. package/scripts/base-des-workflows.mjs +0 -58
@@ -61,11 +61,20 @@
61
61
  // names the file of a bench plays it, as Bazel builds a target tagged `manual` when named; a path
62
62
  // that names a night test is refused, named, and nothing plays (code 2): the night alone plays
63
63
  // it; a folder named leaves them out, as the day does.
64
+ // - A time budget bench is built and played under cargo's profile `bench`, so that it measures
65
+ // optimized code: a build of its own (`cargo test --no-run --profile bench` on the benches of
66
+ // the crate alone, a task `build` with its log `<target>/grillhouse/<crate>-build-bench.log`),
67
+ // then `cargo nextest run --cargo-profile bench`; the other tests keep the profile `test`. A
68
+ // build of benches that fails leaves its benches not played; a build under the profile `test`
69
+ // that fails leaves the crate's build of benches and its benches not played. Every build of
70
+ // benches of a pass comes before the first bench played.
64
71
  // - A time budget bench plays alone, one test at a time (`--test-threads 1`), in a task `budget` of
65
- // its own after the other tests: in `tests-de-nuit` and in a path that names it. A red of the
66
- // task while the CPU pressure of the machine (`lirePression` of ./jointure) is at or above its
67
- // threshold at its start or at its end is « à repasser », 75, said in one line with the
68
- // pressure; at rest, a red.
72
+ // its own after the other tests: in `tests-de-nuit` and in a path that names it. Before it, the
73
+ // module waits for the rest of the machine (`attendreLeRepos` of ./jointure), one minute at
74
+ // most, or `GRILLHOUSE_ATTENTE_REPOS_MS` milliseconds; at the bound, or on a pressure that does
75
+ // not read, the bench plays all the same. A red of the task while the CPU pressure of the machine
76
+ // (`lirePression` of ./jointure) is at or above its threshold at its start or at its end is « à
77
+ // repasser », 75, said in one line with the pressure; at rest, a red.
69
78
  // - `verifier` plays the tests of the crates as the tasks of Turborepo (`turbo run test:unit
70
79
  // --filter=<crate>…`, each crate a package of the graph, the cache of the tasks selecting those
71
80
  // that play again; `--tout` plays them for real, the moment of the pass in the variable
@@ -123,6 +132,7 @@
123
132
  //
124
133
  // Mechanism: packages/grillhouse/docs/architecture/tests.md §3.3 (the modules of language), §3.4
125
134
  // (the guards); `GRILLHOUSE_TESTS` and `GRILLHOUSE_RESULTATS` are data of a pass (tests.md §4.2),
135
+ // `GRILLHOUSE_ATTENTE_REPOS_MS` and `GRILLHOUSE_PRESSION_CPU` data of the trials,
126
136
  // and the code applies no key of the project (installation.md §4.2) nor file of the post (§4.3).
127
137
  import { spawnSync } from 'node:child_process';
128
138
  import {
@@ -141,13 +151,16 @@ import path from 'node:path';
141
151
  import { fileURLToPath, pathToFileURL } from 'node:url';
142
152
  import { RESULTATS } from '../../resultats.mjs';
143
153
  import {
154
+ A_REPASSER,
144
155
  AttenteDeLaMachine,
156
+ attendreLeRepos,
145
157
  surUnePart,
146
158
  avecLaPasse,
147
159
  cheminsDeLaTache,
148
160
  construireDepuisLesArguments,
149
161
  constructionDuGraphe,
150
162
  ecrirePression,
163
+ gesteDuPackageJson,
151
164
  GRAPHE_JOUE,
152
165
  joueCeQuiNeSeDivisePas,
153
166
  lancerLesTaches,
@@ -188,7 +201,6 @@ export const NOMS = [
188
201
  ];
189
202
  // The task runner of the graph of the packages.
190
203
  const OUTIL = 'turbo';
191
- const A_REPASSER = 75;
192
204
  // The exit code of nextest when its filter keeps no test (NO_TESTS_RUN).
193
205
  const AUCUN_TEST = 4;
194
206
  // What the night out of the poste says of a filter that keeps no test: green.
@@ -196,6 +208,10 @@ const AUCUN_HORS_DU_POSTE = 'aucun test hors du poste';
196
208
  const RACINE = '//';
197
209
  // The task of the time budget benches of a crate.
198
210
  const BUDGET = 'budget';
211
+ // The longest wait for rest before a bench, and the variable that sets it, in ms (a datum of the
212
+ // trials, as GRILLHOUSE_PRESSION_CPU).
213
+ const ATTENTE_DU_BANC_MS = 60_000;
214
+ const VARIABLE_ATTENTE = 'GRILLHOUSE_ATTENTE_REPOS_MS';
199
215
  const VERROU = 'Cargo.lock';
200
216
  // The commands that play the exact versions of the repository, refused without its Cargo.lock.
201
217
  const VERROUILLEES = ['tests-du-paquet', 'verifier', 'tests-de-nuit'];
@@ -282,6 +298,20 @@ function passe(racine, env) {
282
298
  const compilation = avecSccache(racine, env);
283
299
  // The CPU pressure of the machine, the file <env> names or the kernel's.
284
300
  const pression = () => lirePression(env.GRILLHOUSE_PRESSION_CPU || undefined);
301
+ // Waits for the rest of the machine before a bench, so that the load of the builds of the pass,
302
+ // once fallen, leaves a red bench red; at the bound, the bench plays all the same.
303
+ const attendre = () => {
304
+ const posee = env[VARIABLE_ATTENTE];
305
+ const borne = posee ? Number(posee) : ATTENTE_DU_BANC_MS;
306
+ if (!Number.isFinite(borne) || borne < 0) {
307
+ throw new Error(`⛔ ${VARIABLE_ATTENTE} : « ${posee} » n'est pas un temps en millisecondes.`);
308
+ }
309
+ attendreLeRepos({
310
+ lire: pression,
311
+ limite: Date.now() + borne,
312
+ dire: l => process.stderr.write(`${l}\n`),
313
+ });
314
+ };
285
315
  const ecrire = () => {
286
316
  if (!dossier) {
287
317
  return;
@@ -334,6 +364,9 @@ function passe(racine, env) {
334
364
  return t.code;
335
365
  }
336
366
  const banc = t.script === BUDGET;
367
+ if (banc) {
368
+ attendre();
369
+ }
337
370
  const avant = banc ? pression() : null;
338
371
  let r;
339
372
  if (journal) {
@@ -457,8 +490,10 @@ export const partitionDeNextest = tranche =>
457
490
  // the test targets named, empty for the whole crate of the day (its night tests and its benches
458
491
  // left out). For a crate that plays tests:
459
492
  // the build of its test targets first, then nextest, then its doctests; a failed build leaves the
460
- // crate's other tasks not played. The benches named, each crate's in a task `budget`, are
461
- // planned with the rest and played by the function this one returns, after the other tests.
493
+ // crate's other tasks not played. The benches named, each crate's built under cargo's profile
494
+ // `bench` in a task `build` of its own and played in a task `budget`, are planned with the rest
495
+ // and played by the function this one returns, after the other tests: every build of benches
496
+ // first, then the benches whose build is green.
462
497
  // In a tranche <tranche>, nextest plays its part (`partitionDeNextest`); the doctests and the
463
498
  // benches, which nextest does not split, play in the first tranche alone. With <videVert>, a run
464
499
  // of nextest whose filter keeps no test is green, and said.
@@ -483,7 +518,7 @@ function jouerLesTests(
483
518
  const j = travailleurs === null ? [] : ['-j', String(travailleurs)];
484
519
  // A bench plays on one thread (`--test-threads 1`, which `-j` of nextest is the alias of): it
485
520
  // takes the arguments without `-j`.
486
- const nextestDuBanc = [...nextest];
521
+ const nextestDuBanc = ['nextest', 'run', '--cargo-profile', 'bench', ...nextest.slice(2)];
487
522
  nextest.push(...j, ...partitionDeNextest(tranche));
488
523
  const indivisible = joueCeQuiNeSeDivisePas(tranche);
489
524
  const parCrate = [];
@@ -505,18 +540,25 @@ function jouerLesTests(
505
540
  const deBanc = n => tests.some(t => t.name === n && horsDuJour(t) === 'banc');
506
541
  const desBancs = cibles.filter(deBanc);
507
542
  const autres = cibles.filter(n => !deBanc(n));
508
- const journal = path.join(m.target_directory, 'grillhouse', `${nom}-build.log`);
509
- const construction = [
510
- 'test',
511
- '--no-run',
512
- MESSAGES,
513
- ...j,
514
- '-p',
515
- nom,
516
- ...(avecLeJour ? [] : cibles.flatMap(n => ['--test', n])),
517
- ];
518
- prevues.push([p.prevoir(nom, d, 'build', false, construction), { journal, executables }]);
543
+ // The build of the targets `noms` (every test target without one) under the options
544
+ // `profil` of cargo, planned with its log `<crate>-<journal>.log`.
545
+ const construire = (journal, profil, noms) => {
546
+ const args = [
547
+ 'test',
548
+ '--no-run',
549
+ ...profil,
550
+ MESSAGES,
551
+ ...j,
552
+ '-p',
553
+ nom,
554
+ ...noms.flatMap(n => ['--test', n]),
555
+ ];
556
+ const sortie = path.join(m.target_directory, 'grillhouse', `${nom}-${journal}.log`);
557
+ return [p.prevoir(nom, d, 'build', false, args), { journal: sortie, executables }];
558
+ };
559
+ // A run that names benches alone builds nothing under the profile `test`.
519
560
  if (cibles.length === 0 || autres.length || avecLeJour) {
561
+ prevues.push(construire('build', [], avecLeJour ? [] : autres));
520
562
  const duC = duJour(c);
521
563
  const nommes = autres.flatMap(n => ['--test', n]);
522
564
  const selection = !cibles.length
@@ -552,6 +594,7 @@ function jouerLesTests(
552
594
  ...filtreDesModules(nom, desBancs, modules),
553
595
  ];
554
596
  bancs.push({
597
+ construction: construire('build-bench', ['--profile', 'bench'], desBancs),
555
598
  nom,
556
599
  d,
557
600
  temporaire: temporaire(nom),
@@ -567,11 +610,10 @@ function jouerLesTests(
567
610
  }
568
611
  parCrate.push([prevues, etat]);
569
612
  }
570
- const prevusBancs = bancs.map(b => [
571
- p.prevoir(b.nom, b.d, BUDGET, true, b.args),
572
- b.etat,
573
- b.temporaire,
574
- ]);
613
+ const prevusBancs = bancs.map(b => ({
614
+ ...b,
615
+ tache: p.prevoir(b.nom, b.d, BUDGET, true, b.args),
616
+ }));
575
617
  for (const [prevues, etat] of parCrate) {
576
618
  for (const [t, o] of prevues) {
577
619
  if (p.jouer(t, o) !== 0 && t.t.script === 'build') {
@@ -581,10 +623,12 @@ function jouerLesTests(
581
623
  }
582
624
  }
583
625
  return () => {
584
- for (const [t, etat, temporaire] of prevusBancs) {
585
- if (etat.construit) {
586
- p.jouer(t, { junit, temporaire });
587
- }
626
+ // A crate whose build under the profile `test` failed builds no bench.
627
+ const construits = prevusBancs.filter(
628
+ b => b.etat.construit && p.jouer(...b.construction) === 0
629
+ );
630
+ for (const { tache, temporaire } of construits) {
631
+ p.jouer(tache, { junit, temporaire });
588
632
  }
589
633
  // The copy keeps no test executable between two passes: cargo builds again the one it misses.
590
634
  for (const f of executables) {
@@ -734,7 +778,7 @@ function nomsDuGraphe(racine, crates) {
734
778
  for (const c of crates) {
735
779
  const nom = nomDuPaquet(racine, c.composant.dossier);
736
780
  if (nom === null) {
737
- absents.push(c.composant.nom);
781
+ absents.push(c.composant);
738
782
  } else {
739
783
  noms.add(nom);
740
784
  }
@@ -744,14 +788,20 @@ function nomsDuGraphe(racine, crates) {
744
788
 
745
789
  // Says, on the error stream, each crate of <absents> that is no package of the graph: its tests do
746
790
  // not play, as a package without a `package.json` is out of Turborepo's tasks.
747
- function direLesAbsents(absents) {
748
- for (const nom of absents) {
791
+ function direLesAbsents(racine, absents) {
792
+ for (const c of absents) {
749
793
  process.stderr.write(
750
- `⚠️ ${nom} : pas un paquet du graphe (package.json absent) ; ses tests ne se jouent pas : npx grillhouse maj\n`
794
+ `⚠️ ${c.nom} : pas un paquet du graphe (package.json absent) ; ses tests ne se jouent pas${suiteDuGeste(racine, c)}\n`
751
795
  );
752
796
  }
753
797
  }
754
798
 
799
+ // The gesture by hand for the component <c> that is no package of the graph, as the end of its line.
800
+ function suiteDuGeste(racine, c) {
801
+ const geste = gesteDuPackageJson(racine, c.dossier, c.paquet ?? c.nom);
802
+ return geste ? ` : ${geste}` : '.';
803
+ }
804
+
755
805
  // The pass of `verifier` in <racine>, under the lock of the machine (<env> carries its mark): the
756
806
  // tests of the crates as tasks of Turborepo (every one played for real with <args> `--tout`), then
757
807
  // cargo deny. It keeps no green.
@@ -764,7 +814,7 @@ function verifier(racine, args, env) {
764
814
  const { noms, absents } = env[GRAPHE_JOUE]
765
815
  ? { noms: new Set(), absents: [] }
766
816
  : nomsDuGraphe(racine, crates(racine));
767
- direLesAbsents(absents);
817
+ direLesAbsents(racine, absents);
768
818
  const code = noms.size
769
819
  ? lancerLesTaches({
770
820
  outil: OUTIL,
@@ -975,11 +1025,14 @@ function tester(racine, tous, args, env) {
975
1025
  const { noms, absents } = nomsDuGraphe(racine, choisis);
976
1026
  if (chemins.length && absents.length) {
977
1027
  process.stderr.write(
978
- `⛔ ${absents.join(', ')} : pas un paquet du graphe (package.json absent) : npx grillhouse maj\n`
1028
+ `⛔ ${absents.map(c => c.nom).join(', ')} : pas un paquet du graphe (package.json absent)\n`
979
1029
  );
1030
+ for (const c of absents) {
1031
+ process.stderr.write(`${c.nom}${suiteDuGeste(racine, c)}\n`);
1032
+ }
980
1033
  return 2;
981
1034
  }
982
- direLesAbsents(absents);
1035
+ direLesAbsents(racine, absents);
983
1036
  if (noms.size === 0) {
984
1037
  return 0;
985
1038
  }
@@ -61,7 +61,7 @@ import { miseAJour } from './mise-a-jour.mjs';
61
61
  import * as taillesDesTests from './migrations/0.28.4-tailles-des-tests.mjs';
62
62
  import * as executablesDeTests from './migrations/0.34.0-executables-de-tests.mjs';
63
63
  import { squelette } from './squelette.mjs';
64
- import { CACHE, CIBLES } from './sccache.mjs';
64
+ import { CACHE, CIBLES, DOSSIER_DU_LANCEUR } from './sccache.mjs';
65
65
  import { echecDeCompilation, verdict } from './verdict.mjs';
66
66
 
67
67
  // The scripts of this module, beside this file.
@@ -94,8 +94,10 @@ export default {
94
94
  // registry's index and sources, the git dependencies, cargo-deny's advisories, and the files of
95
95
  // its locks and of the SQLite cache of its packages (`.package-cache`, `.package-cache-mutate`,
96
96
  // `.global-cache`), files without a trailing `/`; the cache of sccache, common to the copies
97
- // (./sccache.mjs), where a server of sccache the session starts writes; the targets of the
98
- // workspaces rooted in the temporary directory, `~/.cache/grillhouse/cargo/` (./sccache.mjs). What it reads, read-only: its home, `~/.cargo`
97
+ // (./sccache.mjs), where a server of sccache the session starts writes; the directory of the
98
+ // wrapper of rustc, out of that cache, which a run of the session writes when it is missing
99
+ // (./sccache.mjs); the targets of the workspaces rooted in the temporary directory,
100
+ // `~/.cache/grillhouse/cargo/` (./sccache.mjs). What it reads, read-only: its home, `~/.cargo`
99
101
  // (its binaries, its `env`, which the shells source, and its configuration stay unwritten), and
100
102
  // rustup's toolchains, `~/.rustup`.
101
103
  sorties: {
@@ -108,6 +110,7 @@ export default {
108
110
  '~/.cargo/.package-cache-mutate',
109
111
  '~/.cargo/.global-cache',
110
112
  CACHE,
113
+ DOSSIER_DU_LANCEUR,
111
114
  CIBLES,
112
115
  ],
113
116
  propres: [],
@@ -43,7 +43,8 @@
43
43
  // temporary directory of a pass of tests under the working directory of a session passes them
44
44
  // (grillhouse-qmk, OSC Bridge OB-p58). Cargo then finds the server running and starts none; it
45
45
  // keeps its own temporary directory, the pass's. Its wrapper still runs the client under `/tmp`
46
- // (`lanceurCourt`): a client that must start the server itself, which cargo's long TMPDIR
46
+ // (`lanceurCourt`, a file of its own directory, ~/.cache/grillhouse/sccache-lanceur, out of
47
+ // `SCCACHE_DIR`, whose oldest files sccache removes past its size, whatever they are): a client that must start the server itself, which cargo's long TMPDIR
47
48
  // would break, binds its socket there (grillhouse-3uv.239, OSD-sf1.25.1). The two ends of the
48
49
  // start are so short whoever begins it, rather than one more rescue of the first.
49
50
  // - That wrapper changes nothing else of what rustc sees: it is run by bash, which hands on every
@@ -89,6 +90,10 @@ const require = createRequire(import.meta.url);
89
90
  /** The cache of sccache, from the home: what the envelope opens in writing. */
90
91
  export const CACHE = '~/.cache/grillhouse/sccache/';
91
92
 
93
+ /** The directory of the wrapper of rustc (`lanceurCourt`), from the home: what the envelope opens
94
+ * in writing, out of the cache sccache prunes. */
95
+ export const DOSSIER_DU_LANCEUR = '~/.cache/grillhouse/sccache-lanceur/';
96
+
92
97
  /** The targets of the workspaces rooted in the temporary directory, from the home: what the
93
98
  * envelope opens in writing (`cibleDeCompilation`). */
94
99
  export const CIBLES = '~/.cache/grillhouse/cargo/';
@@ -136,16 +141,15 @@ function lanceurDuProjet(racine, env) {
136
141
  // `-p`: bash reads no startup file of the caller (`BASH_ENV`) and imports none of its functions.
137
142
  const LANCEUR = '#!/bin/bash -p\nTMPDIR=/tmp exec sccache "$@"\n';
138
143
 
139
- // The wrapper of rustc of the run: a script of the cache directory <cache> that runs sccache under
144
+ // The wrapper of rustc of the run: a script of the directory <dossier> that runs sccache under
140
145
  // the machine's `COURT` temporary directory. Cargo hands its wrapper its own TMPDIR, which a
141
146
  // client that has to start the server (a server stopped by its idle time, killed, or born in
142
147
  // another envelope) binds a socket under, refused past 108 bytes of a path (« path must be
143
- // shorter than SUN_LEN », OSD-sf1.25.1); the compilations keep cargo's TMPDIR. Written once, then
144
- // read: a file cannot carry an executable bit in a package, so the script is made here. Its name
145
- // is its own, apart from `sccache-court`: the cache is common to every copy of the machine, and a
146
- // copy on the 0.50.2 writes there its script for `sh`.
147
- function lanceurCourt(cache) {
148
- const fichier = path.join(cache, 'sccache-court-bash');
148
+ // shorter than SUN_LEN », OSD-sf1.25.1); the compilations keep cargo's TMPDIR. <dossier> is out of
149
+ // `SCCACHE_DIR`, which sccache owns and prunes. Written when missing, then read: a file cannot
150
+ // carry an executable bit in a package, so the script is made here.
151
+ function lanceurCourt(dossier) {
152
+ const fichier = path.join(dossier, 'sccache-court-bash');
149
153
  try {
150
154
  if (readFileSync(fichier, 'utf8') === LANCEUR && (statSync(fichier).mode & 0o111) !== 0) {
151
155
  return fichier;
@@ -153,7 +157,7 @@ function lanceurCourt(cache) {
153
157
  } catch {
154
158
  // Absent: written below.
155
159
  }
156
- mkdirSync(cache, { recursive: true });
160
+ mkdirSync(dossier, { recursive: true });
157
161
  const temporaire = `${fichier}.${process.pid}`;
158
162
  writeFileSync(temporaire, LANCEUR, { mode: 0o755 });
159
163
  renameSync(temporaire, fichier);
@@ -304,12 +308,11 @@ export function avecSccache(racine, env) {
304
308
  if (lanceurDuProjet(racine, env)) {
305
309
  return { ...env, ...cible };
306
310
  }
307
- const cache = cacheDeCompilation('sccache', env);
308
311
  return {
309
312
  ...env,
310
313
  ...cible,
311
- RUSTC_WRAPPER: lanceurCourt(cache),
312
- SCCACHE_DIR: cache,
314
+ RUSTC_WRAPPER: lanceurCourt(cacheDeCompilation('sccache-lanceur', env)),
315
+ SCCACHE_DIR: cacheDeCompilation('sccache', env),
313
316
  SCCACHE_SERVER_UDS: socketDuServeur(racine, env.TMPDIR || tmpdir()),
314
317
  };
315
318
  }
@@ -19,8 +19,8 @@
19
19
  // files under `src/`; a crate of the product it uses is not read: what it starts is its own.
20
20
  // - large (`grand`): it starts a process (`std::process`, `tokio::process`, `assert_cmd`, `duct`,
21
21
  // `xshell`), mounts a trial repository (git's `init`, `clone` or `worktree add`, as an
22
- // argument or a command, or git2's `Repository::init` and `Repository::clone`) and starts
23
- // there something else than git (`Command::new` of a binary of the product, `cargo_bin`,
22
+ // argument of a call of git or in a command, or git2's `Repository::init` and
23
+ // `Repository::clone`) and starts there something else than git (`Command::new` of a binary of the product, `cargo_bin`,
24
24
  // `cmd!` of another program);
25
25
  // - medium (`moyen`): it starts a process;
26
26
  // - small (`petit`): it starts none.
@@ -46,10 +46,30 @@ export const GRAND_DE_JOUR = 'grand-de-jour';
46
46
 
47
47
  // The use of a way to start a process.
48
48
  const PROCESSUS = /\b(?:std|tokio|async_std)::process\b|\b(?:assert_cmd|duct|xshell)\b/;
49
- // A trial repository mounted: git's `init`, `clone` or `worktree add`, as an argument or a command;
50
- // git2's `Repository::init` or `Repository::clone`.
49
+ // A trial repository mounted without an argument of a call: git's `init`, `clone` or `worktree add`
50
+ // in a command, or git2's `Repository::init` or `Repository::clone`.
51
51
  const DEPOT_D_ESSAI =
52
- /"(?:init|clone)"|\bgit\s+(?:-C\s+\S+\s+)?(?:init|clone)\b|"worktree"\s*,\s*"add"|\bworktree\s+add\b|\bRepository::(?:init|clone)\w*\s*\(/;
52
+ /\bgit\s+(?:-[Cc]\s+\S+\s+)*(?:init|clone|worktree\s+add)\b|\bRepository::(?:init|clone)\w*\s*\(/;
53
+ // The same three as the arguments of a call of git (`appelsDeGit`), in one list or one by one.
54
+ const ARGUMENT_DE_DEPOT = /"(?:init|clone)"|"worktree"(?:\s*,|\s*\)\s*\.arg\s*\()\s*"add"/;
55
+ // A comment, a string (raw or not) or a character, whose brackets and semicolons are no code.
56
+ const HORS_DU_CODE =
57
+ /\/\/[^\n]*|\/\*[\s\S]*?\*\/|\br(#*)"[\s\S]*?"\1|"(?:\\[\s\S]|[^"\\])*"|'(?:\\[^']+|[^\\'\n])'/g;
58
+ // The command of git, `Command::new("git")`.
59
+ const COMMANDE_GIT = /\bCommand::new\s*\(\s*r?#*"git"/g;
60
+ // The name a statement binds to the expression that follows it, `let mut c: Command = `.
61
+ const NOM_LIE =
62
+ /\blet\s+(?:mut\s+)?([A-Za-z_]\w*)\s*(?::\s*[\w:<>]+\s*)?=\s*(?:[A-Za-z_]\w*(?:::|\.))*$/;
63
+ // The next method of a chain, up to its parenthesis.
64
+ const METHODE = /\s*(?:\?|\.\s*await\b)?\s*\.\s*([A-Za-z_]\w*)\s*(?:::\s*<[^()]*>\s*)?\(/y;
65
+ // The return type of a function that gives a command.
66
+ const REND_UNE_COMMANDE = /->[^{]*\bCommand\b/;
67
+ // A call of git by its parentheses: a function or a macro named after git (`git(`, `run_git(`), or
68
+ // whose program is git (`cmd!("git", …)`, `cmd("git", …)`).
69
+ const APPEL_DE_GIT =
70
+ /\b(?:[A-Za-z0-9]+_)*git(?:_[A-Za-z0-9]+)*!?\s*\(|\b\w+!?\s*\(\s*(?=(?:[A-Za-z_]\w*\s*,\s*)?r?#*"git"\s*,)/g;
71
+ // A function and its parameters, up to the brace of its body.
72
+ const FONCTION = /\bfn\s+([A-Za-z_]\w*)([^{;]*(?:;[^{;\]]*\][^{;]*)*)\{/g;
53
73
  // A call that starts a process, its program captured: `Command::new(<programme>`, assert_cmd's
54
74
  // `cargo_bin(<binaire>`, the macro `cmd!` of duct (`cmd!("git", …)`) and of xshell (`cmd!(sh,
55
75
  // "git …")`).
@@ -94,6 +114,93 @@ function fichierDuModule(f, nom, chemin, lire) {
94
114
  return ordre.find(c => lire(c) !== null) ?? null;
95
115
  }
96
116
 
117
+ // Where the code open at <debut> in <code> (its comments and strings blanked) ends: the bracket
118
+ // that closes it (`groupe`), the `;` that ends the statement (`instruction`), or the bracket that
119
+ // closes the block around (`bloc`).
120
+ function finDe(code, debut, portee = 'groupe') {
121
+ let ouverts = 0;
122
+ for (let i = debut; i < code.length; i++) {
123
+ if ('([{'.includes(code[i])) {
124
+ ouverts++;
125
+ } else if (')]}'.includes(code[i])) {
126
+ ouverts--;
127
+ if (ouverts < 0 || (ouverts === 0 && portee === 'groupe')) {
128
+ return i;
129
+ }
130
+ } else if (portee === 'instruction' && ouverts === 0 && code[i] === ';') {
131
+ return i;
132
+ }
133
+ }
134
+ return code.length;
135
+ }
136
+
137
+ // The `arg` and `args` of the method chain that follows <fin> in <texte> (<code>, its comments and
138
+ // strings blanked), each `.arg(…)`; empty for none.
139
+ function argumentsEnChaine(texte, code, fin) {
140
+ let args = '';
141
+ for (let i = fin; ;) {
142
+ METHODE.lastIndex = i;
143
+ const m = METHODE.exec(code);
144
+ if (!m) {
145
+ return args;
146
+ }
147
+ const ouvre = i + m[0].length - 1;
148
+ i = finDe(code, ouvre) + 1;
149
+ if (m[1] === 'arg' || m[1] === 'args') {
150
+ args += `.${m[1]}${texte.slice(ouvre, i)}`;
151
+ }
152
+ }
153
+ }
154
+
155
+ // The `arg` and `args` of the name <nom>, from <debut> to the end of its block or to the statement
156
+ // that binds it again, put end to end.
157
+ function argumentsDuNom(texte, code, nom, debut) {
158
+ const bloc = code.slice(debut, finDe(code, debut, 'bloc'));
159
+ const autre = bloc.search(new RegExp(`\\blet\\s+(?:mut\\s+)?${nom}\\b`));
160
+ const portee = autre < 0 ? bloc : bloc.slice(0, autre);
161
+ return [...portee.matchAll(new RegExp(`(?<![\\w.])${nom}\\b(?=\\s*\\.)`, 'g'))]
162
+ .map(a => argumentsEnChaine(texte, code, debut + a.index + nom.length))
163
+ .join('');
164
+ }
165
+
166
+ // The text of each call of git in <texte>: the parentheses of a call named after git or running it,
167
+ // and those of a call of a function of the text that passes its arguments to a command of git; and
168
+ // the `arg` and `args` of a command of git (`Command::new("git")`, a call named after git, or a
169
+ // call of a function of the text that returns such a command), chained on it or on the name it is
170
+ // bound to.
171
+ function appelsDeGit(texte) {
172
+ const code = texte.replace(HORS_DU_CODE, s => s.replace(/[^\n]/g, s.startsWith('/') ? ' ' : '_'));
173
+ const appels = [];
174
+ // The calls <motif> finds: their parentheses when <passe>, and the arguments of the command
175
+ // they give.
176
+ const suivre = (motif, passe) => {
177
+ for (const m of texte.matchAll(motif)) {
178
+ const ouvre = m.index + m[0].indexOf('(');
179
+ const fin = finDe(code, ouvre);
180
+ if (passe) {
181
+ appels.push(texte.slice(ouvre, fin));
182
+ }
183
+ appels.push(argumentsEnChaine(texte, code, fin + 1));
184
+ const lie = NOM_LIE.exec(code.slice(Math.max(0, m.index - 200), m.index));
185
+ if (lie) {
186
+ const suite = finDe(code, m.index, 'instruction') + 1;
187
+ appels.push(argumentsDuNom(texte, code, lie[1], suite));
188
+ }
189
+ }
190
+ };
191
+ suivre(COMMANDE_GIT, false);
192
+ suivre(APPEL_DE_GIT, true);
193
+ for (const m of code.matchAll(FONCTION)) {
194
+ const corps = texte.slice(m.index, finDe(code, m.index + m[0].length - 1));
195
+ const passe = /\b(?:str|String|OsStr)\b/.test(m[2]);
196
+ const rend = REND_UNE_COMMANDE.test(m[2]);
197
+ if ((passe || rend) && corps.search(COMMANDE_GIT) >= 0) {
198
+ suivre(new RegExp(`\\b${m[1]}\\s*\\(`, 'g'), passe);
199
+ }
200
+ }
201
+ return appels;
202
+ }
203
+
97
204
  /**
98
205
  * The size of the test file <fichier> (absolute), read by <lire> (a path → its text, null when it
99
206
  * does not read), the crates of the shared test material <matieres> (`[{ nom, fichiers }]`, `nom`
@@ -129,7 +236,9 @@ export function classer(fichier, lire = lireLeDisque, matieres = []) {
129
236
  const tout = textes.join('\n');
130
237
  const processus = PROCESSUS.test(tout);
131
238
  const autreQueGit = [...tout.matchAll(APPEL)].some(m => !GIT.test((m[1] ?? m[2] ?? m[3]).trim()));
132
- if (processus && autreQueGit && DEPOT_D_ESSAI.test(tout)) {
239
+ const depot = () =>
240
+ DEPOT_D_ESSAI.test(tout) || appelsDeGit(tout).some(a => ARGUMENT_DE_DEPOT.test(a));
241
+ if (processus && autreQueGit && depot()) {
133
242
  return 'grand';
134
243
  }
135
244
  return processus ? 'moyen' : 'petit';
@@ -81,7 +81,7 @@
81
81
  // - While the environment names a results directory (`GRILLHOUSE_RESULTATS`), the run writes
82
82
  // there what ./verdict.mjs reads: its tasks, each planned before it plays, and the JUnit report
83
83
  // of each run of pytest.
84
- // - uv absent from the PATH: one line that names it and `npx grillhouse maj`, which installs it.
84
+ // - uv absent from the PATH: one line that names it and `npx grillhouse binaires`, which installs it.
85
85
  // - The exit code: 0 when every task is green, 75 when the only reds are « à repasser », 1
86
86
  // otherwise; 2 for a path refused or a command unknown.
87
87
  import { spawnSync } from 'node:child_process';
@@ -91,6 +91,7 @@ import path from 'node:path';
91
91
  import { fileURLToPath, pathToFileURL } from 'node:url';
92
92
  import { RESULTATS } from '../../resultats.mjs';
93
93
  import {
94
+ A_REPASSER,
94
95
  AttenteDeLaMachine,
95
96
  surUnePart,
96
97
  avecLaPasse,
@@ -98,6 +99,7 @@ import {
98
99
  cheminsDeLaTache,
99
100
  construireDepuisLesArguments,
100
101
  constructionDuGraphe,
102
+ gesteDuPackageJson,
101
103
  GRAPHE_JOUE,
102
104
  joueCeQuiNeSeDivisePas,
103
105
  lancerLesTaches,
@@ -132,7 +134,6 @@ export const NOMS = [
132
134
  ];
133
135
  // The task runner of the graph of the packages.
134
136
  const OUTIL = 'turbo';
135
- const A_REPASSER = 75;
136
137
  const RACINE = '//';
137
138
  /** The night tests, which the day leaves out. */
138
139
  export const DE_NUIT = '*_nuit_test.py';
@@ -351,7 +352,7 @@ function nomsDuGraphe(racine, projets) {
351
352
  for (const c of projets) {
352
353
  const nom = nomDuPaquet(racine, c.dossier);
353
354
  if (nom === null) {
354
- absents.push(c.nom);
355
+ absents.push(c);
355
356
  } else {
356
357
  noms.add(nom);
357
358
  }
@@ -361,14 +362,20 @@ function nomsDuGraphe(racine, projets) {
361
362
 
362
363
  // Says, on the error stream, each project of <absents> that is no package of the graph: its tests
363
364
  // do not play, as a package without a `package.json` is out of Turborepo's tasks.
364
- function direLesAbsents(absents) {
365
- for (const nom of absents) {
365
+ function direLesAbsents(racine, absents) {
366
+ for (const c of absents) {
366
367
  process.stderr.write(
367
- `⚠️ ${nom} : pas un paquet du graphe (package.json absent) ; ses tests ne se jouent pas : npx grillhouse maj\n`
368
+ `⚠️ ${c.nom} : pas un paquet du graphe (package.json absent) ; ses tests ne se jouent pas${suiteDuGeste(racine, c)}\n`
368
369
  );
369
370
  }
370
371
  }
371
372
 
373
+ // The gesture by hand for the component <c> that is no package of the graph, as the end of its line.
374
+ function suiteDuGeste(racine, c) {
375
+ const geste = gesteDuPackageJson(racine, c.dossier, c.paquet ?? c.nom);
376
+ return geste ? ` : ${geste}` : '.';
377
+ }
378
+
372
379
  // The pass of `tester` in <racine>, its arguments <args>, under <env>: the tasks `test:unit` of the
373
380
  // projects the paths choose (every project that plays tests without a path) as Turborepo's, the
374
381
  // exit code its.
@@ -390,11 +397,14 @@ function tester(racine, args, env) {
390
397
  const { noms, absents } = nomsDuGraphe(racine, choisis);
391
398
  if (chemins.length && absents.length) {
392
399
  process.stderr.write(
393
- `⛔ ${absents.join(', ')} : pas un paquet du graphe (package.json absent) : npx grillhouse maj\n`
400
+ `⛔ ${absents.map(c => c.nom).join(', ')} : pas un paquet du graphe (package.json absent)\n`
394
401
  );
402
+ for (const c of absents) {
403
+ process.stderr.write(`${c.nom}${suiteDuGeste(racine, c)}\n`);
404
+ }
395
405
  return 2;
396
406
  }
397
- direLesAbsents(absents);
407
+ direLesAbsents(racine, absents);
398
408
  if (noms.size === 0) {
399
409
  return 0;
400
410
  }
@@ -454,7 +464,7 @@ function verifier(racine, args, env) {
454
464
  return 0;
455
465
  }
456
466
  const { noms, absents } = nomsDuGraphe(racine, composants(racine));
457
- direLesAbsents(absents);
467
+ direLesAbsents(racine, absents);
458
468
  if (noms.size === 0) {
459
469
  return 0;
460
470
  }
@@ -12,7 +12,7 @@
12
12
  // package's), as `cargo new` refuses a name Rust reserves: `import site` reaches the standard
13
13
  // module, never the package. The list is the interpreter's own, `sys.stdlib_module_names`, of
14
14
  // the Python the package requires, which uv provides; without uv, the refusal names `npx
15
- // grillhouse maj`, which installs it.
15
+ // grillhouse binaires`, which installs it.
16
16
  // - Its files: its pyproject.toml (PEP 621: its name, its version 0.1.0, the Python it requires, no
17
17
  // dependency; its group `test` of `[dependency-groups]`, PEP 735, pytest, which the module runs
18
18
  // by its path in the environment of the package (./commandes.mjs); the configuration of pytest,
@@ -87,7 +87,7 @@ function modulesStandard(racine) {
87
87
  );
88
88
  if (r.status !== 0) {
89
89
  throw new Error(
90
- `uv ne donne pas les modules de la bibliothèque standard de Python (${String(r.error?.message ?? r.stderr).trim()}) ; \`npx grillhouse maj\` installe uv, puis relance la commande.`
90
+ `uv ne donne pas les modules de la bibliothèque standard de Python (${String(r.error?.message ?? r.stderr).trim()}) ; \`npx grillhouse binaires\` installe uv, puis relance la commande.`
91
91
  );
92
92
  }
93
93
  return new Set(r.stdout.split('\n').filter(Boolean));