@roomi-fields/grillhouse 0.31.0 → 0.33.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 (149) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +40 -0
  3. package/bin/grillhouse.mjs +6 -4
  4. package/cadre/templates/projet/.github/workflows/ci.yml +136 -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/contrat.d.ts +15 -0
  10. package/dist/temporal/circuit/deroule.js +37 -14
  11. package/dist/temporal/circuit/deroule.js.map +1 -1
  12. package/dist/temporal/deroules.d.ts +1 -0
  13. package/dist/temporal/deroules.js +3 -1
  14. package/dist/temporal/deroules.js.map +1 -1
  15. package/dist/temporal/file/activites.d.ts +1 -0
  16. package/dist/temporal/file/activites.js +5 -2
  17. package/dist/temporal/file/activites.js.map +1 -1
  18. package/dist/temporal/file/contrat.d.ts +50 -33
  19. package/dist/temporal/file/contrat.js +2 -2
  20. package/dist/temporal/file/contrat.js.map +1 -1
  21. package/dist/temporal/file/deroule.d.ts +3 -1
  22. package/dist/temporal/file/deroule.js +128 -26
  23. package/dist/temporal/file/deroule.js.map +1 -1
  24. package/dist/temporal/installation.d.ts +3 -2
  25. package/dist/temporal/installation.js +7 -4
  26. package/dist/temporal/installation.js.map +1 -1
  27. package/dist/temporal/nuits/activites.d.ts +10 -0
  28. package/dist/temporal/nuits/activites.js +114 -0
  29. package/dist/temporal/nuits/activites.js.map +1 -0
  30. package/dist/temporal/nuits/appel.d.ts +23 -0
  31. package/dist/temporal/nuits/appel.js +40 -0
  32. package/dist/temporal/nuits/appel.js.map +1 -0
  33. package/dist/temporal/nuits/choix.d.ts +14 -0
  34. package/dist/temporal/nuits/choix.js +119 -0
  35. package/dist/temporal/nuits/choix.js.map +1 -0
  36. package/dist/temporal/nuits/client.d.ts +28 -0
  37. package/dist/temporal/nuits/client.js +83 -0
  38. package/dist/temporal/nuits/client.js.map +1 -0
  39. package/dist/temporal/nuits/commande.d.ts +2 -0
  40. package/dist/temporal/nuits/commande.js +107 -0
  41. package/dist/temporal/nuits/commande.js.map +1 -0
  42. package/dist/temporal/nuits/contrat.d.ts +98 -0
  43. package/dist/temporal/nuits/contrat.js +30 -0
  44. package/dist/temporal/nuits/contrat.js.map +1 -0
  45. package/dist/temporal/nuits/deroule.d.ts +5 -0
  46. package/dist/temporal/nuits/deroule.js +100 -0
  47. package/dist/temporal/nuits/deroule.js.map +1 -0
  48. package/dist/temporal/tickets/activites.d.ts +1 -0
  49. package/dist/temporal/tickets/activites.js +5 -0
  50. package/dist/temporal/tickets/activites.js.map +1 -1
  51. package/dist/temporal/tickets/contrat.d.ts +10 -0
  52. package/dist/temporal/tickets/deroule.js +8 -1
  53. package/dist/temporal/tickets/deroule.js.map +1 -1
  54. package/dist/temporal/travailleur.js +4 -1
  55. package/dist/temporal/travailleur.js.map +1 -1
  56. package/docs/ARCHITECTURE.md +257 -54
  57. package/docs/CADRE.md +41 -1
  58. package/docs/INTERFACE.md +54 -7
  59. package/hooks/hooks.json +4 -0
  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 +99 -48
  64. package/scripts/aiguillage.mjs +3 -0
  65. package/scripts/attente-au-tour.mjs +99 -0
  66. package/scripts/avancement.mjs +8 -18
  67. package/scripts/base-des-workflows.mjs +57 -0
  68. package/scripts/ci-des-branches.mjs +91 -0
  69. package/scripts/circuit.mjs +99 -5
  70. package/scripts/composants-affectes.mjs +24 -7
  71. package/scripts/composition-des-langages.mjs +3 -0
  72. package/scripts/copies-finies.mjs +8 -1
  73. package/scripts/crochets.mjs +4 -0
  74. package/scripts/dernier-vert.mjs +30 -4
  75. package/scripts/effets.mjs +9 -0
  76. package/scripts/enveloppe/enveloppe.mjs +3 -1
  77. package/scripts/enveloppe/lancer.sh +1 -1
  78. package/scripts/enveloppe/travail-de-la-copie.mjs +219 -59
  79. package/scripts/etapes.mjs +19 -2
  80. package/scripts/faits-du-circuit.mjs +43 -20
  81. package/scripts/fichier-du-poste.mjs +87 -0
  82. package/scripts/grillhouse-maj.mjs +15 -1
  83. package/scripts/integration/file.mjs +215 -275
  84. package/scripts/integration/integrer.mjs +82 -41
  85. package/scripts/integration/rejeu.mjs +13 -64
  86. package/scripts/jointure.d.ts +30 -2
  87. package/scripts/journal-des-etats.d.mts +41 -0
  88. package/scripts/journal-des-etats.mjs +273 -0
  89. package/scripts/journal.mjs +119 -0
  90. package/scripts/langages/cargo/commandes.mjs +81 -19
  91. package/scripts/langages/cargo/exemples.mjs +2 -2
  92. package/scripts/langages/cargo/index.mjs +14 -5
  93. package/scripts/langages/cargo/tailles-des-tests.mjs +19 -11
  94. package/scripts/langages/python/commandes.mjs +11 -7
  95. package/scripts/langages/python/exemples.mjs +1 -1
  96. package/scripts/langages/python/index.mjs +11 -2
  97. package/scripts/langages/python/tailles-des-tests.mjs +19 -11
  98. package/scripts/langages/typescript/code-mort.mjs +41 -24
  99. package/scripts/langages/typescript/consommateurs.mjs +28 -17
  100. package/scripts/langages/typescript/exemples.mjs +2 -0
  101. package/scripts/langages/typescript/frontieres.mjs +46 -0
  102. package/scripts/langages/typescript/index.mjs +24 -3
  103. package/scripts/langages/typescript/migrations/0.33.0-binaire-de-jour.mjs +34 -0
  104. package/scripts/langages/typescript/migrations/0.33.0-tests-du-poste.mjs +31 -0
  105. package/scripts/langages/typescript/resumes.mjs +17 -7
  106. package/scripts/langages/typescript/tailles-des-tests.mjs +251 -22
  107. package/scripts/langages/typescript/tests-de-nuit.mjs +101 -9
  108. package/scripts/langages/typescript/tests-du-poste.mjs +172 -0
  109. package/scripts/langages/typescript/tranches.mjs +273 -0
  110. package/scripts/langages/typescript/verifier.mjs +154 -23
  111. package/scripts/langages/typescript/vitest-config/base.mjs +3 -0
  112. package/scripts/langages/typescript/vitest-config/cibles.mjs +78 -7
  113. package/scripts/langages/typescript/vitest-config/lances.mjs +4 -4
  114. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +9 -0
  115. package/scripts/langages/typescript/vitest.nuit.config.mjs +3 -2
  116. package/scripts/langages.d.mts +20 -0
  117. package/scripts/lint-des-scripts.mjs +23 -6
  118. package/scripts/matiere-de-test.d.ts +11 -0
  119. package/scripts/migrations/0.33.0-cache-distant.mjs +36 -0
  120. package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +31 -0
  121. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +31 -0
  122. package/scripts/migrations/0.33.0-node-26.mjs +58 -0
  123. package/scripts/migrations.mjs +8 -0
  124. package/scripts/newday.mjs +18 -0
  125. package/scripts/nuit.sh +40 -13
  126. package/scripts/places-de-la-machine.mjs +6 -0
  127. package/scripts/registre.d.mts +90 -0
  128. package/scripts/registre.mjs +28 -3
  129. package/scripts/reprise.mjs +12 -8
  130. package/scripts/services-du-noyau.mjs +4 -0
  131. package/scripts/session-start.sh +28 -32
  132. package/scripts/sous-commandes.mjs +31 -10
  133. package/scripts/superviseur.mjs +127 -75
  134. package/scripts/tableau.mjs +222 -17
  135. package/scripts/taches-du-graphe.mjs +39 -6
  136. package/scripts/ticket-du-circuit.mjs +37 -7
  137. package/scripts/transitions.mjs +60 -8
  138. package/scripts/verrou-de-machine.mjs +1 -2
  139. package/scripts/workflows-du-cadre.mjs +75 -0
  140. package/skills/developpeur/SKILL.md +1 -1
  141. package/skills/explorateur/SKILL.md +1 -1
  142. package/skills/grill/SKILL.md +10 -62
  143. package/skills/grill/references/paquets.md +60 -0
  144. package/skills/pitmaster/SKILL.md +21 -31
  145. package/skills/questionneur/SKILL.md +1 -1
  146. package/skills/relecteur/SKILL.md +1 -1
  147. package/skills/testwriter/SKILL.md +7 -1
  148. package/skills/release/SKILL.md +0 -134
  149. package/skills/release/scripts/update-version.cjs +0 -92
@@ -6,6 +6,8 @@
6
6
  // npx grillhouse verifier [<argument of Turborepo>…] (npm run verifier -- --force)
7
7
  // npx grillhouse verifier --tout [<argument>…] every test, played for real
8
8
  // npx grillhouse verifier --gardes [<argument>…] the guards alone (the reviewer)
9
+ // npx grillhouse verifier --sans-tests [<argument>…] every control but the tests
10
+ // npx grillhouse verifier --tranche i/n [<argument>…] the tests of the tranche i of n
9
11
  //
10
12
  // - A pass measures itself against the last green (scripts/dernier-vert.mjs), as
11
13
  // `vitest --changed` and `jest --onlyChanged` do: the tree of the last pass green on every
@@ -80,6 +82,18 @@
80
82
  // run of Turborepo gets it in TMPDIR, TMP and TEMP, the root's `globalPassThroughEnv` passing
81
83
  // TMPDIR on to every task (scripts/langages/typescript/turbo-des-paquets.mjs), and the pass
82
84
  // removes it at its end, green, red or interrupted (SIGINT, SIGTERM, SIGHUP).
85
+ // - `--sans-tests` plays every task of the pass but the tests: the guards, the typing, the format
86
+ // check and the lint (`turbo run grillhouse:gardes gardes typecheck format:check lint …`), with no
87
+ // measure; `--tranche i/n` plays the tasks of tests alone (`turbo run test:unit …`), with the
88
+ // builds they depend on, each package of Vitest playing the i-th of n parts of its test files
89
+ // (./tranches.mjs): the n tranches and `--sans-tests` together play the complete pass, each task
90
+ // once, as the CI plays it, one job each. A tranche is measured as the pass is (against the last
91
+ // green or its `--base`; complete with `--tout`), carries itself in the variable
92
+ // `GRILLHOUSE_TESTS`, which the hash of the tests counts (two tranches never replay one another
93
+ // from the cache), plays for real, since it writes its reports (./tranches.mjs, under
94
+ // `.vitest-reports/`, its former ones removed first), and never keeps its tree as the last green,
95
+ // green or not; neither does `--sans-tests`. A tranche not of the form `i/n` (1 ≤ i ≤ n), or given
96
+ // with `--gardes` or `--sans-tests`, is refused before any work, code 1.
83
97
  // - The run plays without the paths of a targeted run's tests: the variable `GRILLHOUSE_TESTS`
84
98
  // (scripts/langages/typescript/vitest-config/cibles.mjs) carries only `rejouer`, for a complete
85
99
  // pass.
@@ -95,6 +109,8 @@ import {
95
109
  CHANGEMENTS,
96
110
  garderLeTotal,
97
111
  garderLeVert,
112
+ LA_FORME,
113
+ lireLaTranche,
98
114
  mesure,
99
115
  nommerLAvancement,
100
116
  ouvrirAvancement,
@@ -106,6 +122,7 @@ import {
106
122
  testsCibles,
107
123
  } from '../../services-du-noyau.mjs';
108
124
  import { paquets, TYPAGE } from '../../paquets.mjs';
125
+ import { fichiersDeLaTranche, RAPPORTS } from './tranches.mjs';
109
126
  import { controlesDuDepot, planifier } from './turbo-des-paquets.mjs';
110
127
  import { garderLesResumes } from './verdict.mjs';
111
128
 
@@ -136,6 +153,12 @@ export function verifier({
136
153
  dire = l => process.stdout.write(`${l}\n`),
137
154
  coeurs = availableParallelism(),
138
155
  }) {
156
+ // A malformed request is refused before any work.
157
+ const { erreur } = lireLesDemandes(demandes);
158
+ if (erreur) {
159
+ dire(erreur);
160
+ return 1;
161
+ }
139
162
  // The base of the pass, in the temporary directory of <env>: every task writes in it (TMPDIR,
140
163
  // which Turborepo passes on), and it goes at the end of the pass.
141
164
  const base = ouvrirBase('verification', { dans: env.TMPDIR || tmpdir() });
@@ -200,27 +223,128 @@ function depotAvecTests(racine) {
200
223
  const filtre = args => args.some(a => a.startsWith('--filter=') || a === '--filter' || a === '-F');
201
224
 
202
225
  // A pass green on every package keeps its tree as the last green (`garder`): not when it is
203
- // restricted by a filter, measured against nothing, or run after a red module (PASSE_ROUGE).
204
- export function poserLeVert({ code, etat, args, env, garder }) {
205
- if (code === 0 && etat && !filtre(args) && !env[PASSE_ROUGE]) {
226
+ // restricted by a filter or to a part of its tasks (<partielle>: a tranche, `--sans-tests`),
227
+ // measured against nothing, or run after a red module (PASSE_ROUGE).
228
+ export function poserLeVert({ code, etat, args, env, garder, partielle = false }) {
229
+ if (code === 0 && etat && !partielle && !filtre(args) && !env[PASSE_ROUGE]) {
206
230
  garder(etat);
207
231
  }
208
232
  }
209
233
 
210
- function passe({ racine, demandes, env, dire, coeurs }) {
234
+ // The options of the pass in <demandes>: `{ gardesSeules, sansTests, tranche, tout, base, args,
235
+ // erreur }`. `--base <commit>` (or `--base=<commit>`) belongs to the verification alone: it never
236
+ // reaches the tasks, `base` is '' when it has no value (alone, or followed by another option), and
237
+ // undefined when it is not given or when the guards alone, or the pass without its tests, ask for
238
+ // no measure. `--tranche i/n` (or `--tranche=i/n`) neither: `tranche` is `{ index, count }`;
239
+ // `erreur`, the line that refuses a tranche not of the form i/n, or given with `--gardes` or
240
+ // `--sans-tests`.
241
+ export function lireLesDemandes(demandes) {
211
242
  const gardesSeules = demandes.includes('--gardes');
243
+ const sansTests = demandes.includes('--sans-tests');
212
244
  const tout = demandes.includes('--tout') || demandes.includes('--force');
213
- const args = demandes.filter(a => a !== '--gardes' && a !== '--tout');
214
- // The measure against the last green: the guards alone need none.
215
- const m = gardesSeules ? null : mesure(racine, { tout, dans: env.TMPDIR });
245
+ let base;
246
+ let texte;
247
+ const args = [];
248
+ for (let i = 0; i < demandes.length; i++) {
249
+ const a = demandes[i];
250
+ if (a === '--gardes' || a === '--tout' || a === '--sans-tests') {
251
+ continue;
252
+ }
253
+ if (a === '--tranche') {
254
+ const suite = demandes[i + 1];
255
+ texte = suite !== undefined && !suite.startsWith('-') ? suite : '';
256
+ i += texte ? 1 : 0;
257
+ } else if (a.startsWith('--tranche=')) {
258
+ texte = a.slice('--tranche='.length);
259
+ } else if (a === '--base') {
260
+ const suite = demandes[i + 1];
261
+ if (suite !== undefined && !suite.startsWith('-')) {
262
+ base = suite;
263
+ i++;
264
+ } else {
265
+ base = '';
266
+ }
267
+ } else if (a.startsWith('--base=')) {
268
+ base = a.slice('--base='.length);
269
+ } else {
270
+ args.push(a);
271
+ }
272
+ }
273
+ const tranche = texte === undefined ? undefined : (lireLaTranche(texte) ?? undefined);
274
+ let erreur;
275
+ if (texte !== undefined && !tranche) {
276
+ erreur = `⛔ --tranche attend la forme ${LA_FORME}, deux entiers avec 1 ≤ i ≤ n (par exemple --tranche 1/3) : « ${texte} » ne l'a pas.`;
277
+ } else if (tranche && (gardesSeules || sansTests)) {
278
+ erreur = `⛔ --tranche joue les seuls tests : elle ne se combine ni avec --gardes ni avec --sans-tests.`;
279
+ }
280
+ const mesure = !gardesSeules && !sansTests;
281
+ return {
282
+ gardesSeules,
283
+ sansTests,
284
+ tranche,
285
+ tout,
286
+ base: mesure ? base : undefined,
287
+ args,
288
+ ...(erreur ? { erreur } : {}),
289
+ };
290
+ }
291
+
292
+ /**
293
+ * The tasks of Turborepo a pass plays, from its options (`lireLesDemandes`), <controles> the tasks
294
+ * of the format check and the lint of the repository (`controlesDuDepot`): a tranche, the tests
295
+ * alone; `--gardes`, the guards and the controls; `--sans-tests`, every task but the tests; else
296
+ * every task.
297
+ * @param {{ gardesSeules?: boolean, sansTests?: boolean, tranche?: object }} demandes
298
+ * @param {string[]} controles
299
+ * @returns {string[]}
300
+ */
301
+ export function tachesDeLaPasse({ gardesSeules, sansTests, tranche }, controles) {
302
+ if (tranche) {
303
+ return [SCRIPT_DES_TESTS];
304
+ }
305
+ if (gardesSeules) {
306
+ return [...GARDES, ...controles];
307
+ }
308
+ if (sansTests) {
309
+ return [...GARDES, TYPAGE, ...controles];
310
+ }
311
+ return [...TACHES, ...controles];
312
+ }
313
+
314
+ /**
315
+ * The content of the variable of the tests (`GRILLHOUSE_TESTS`) for the tranche <tranche> of a pass
316
+ * in <racine>: the tranche and the directory of its reports, and the moment of the pass, which no
317
+ * cached run holds.
318
+ * @param {{ index: number, count: number }} tranche
319
+ * @param {string} racine
320
+ */
321
+ export function testsDeLaTranche(tranche, racine) {
322
+ return {
323
+ ...testsCibles({ arguments: [], force: true }),
324
+ tranche: `${tranche.index}/${tranche.count}`,
325
+ rapports: path.join(racine, RAPPORTS),
326
+ };
327
+ }
328
+
329
+ function passe({ racine, demandes, env, dire, coeurs }) {
330
+ const lu = lireLesDemandes(demandes);
331
+ const { gardesSeules, sansTests, tranche, tout, base, args } = lu;
332
+ // The measure against the last green, or the base given: a pass without tests needs none.
333
+ const m = gardesSeules || sansTests ? null : mesure(racine, { tout, base, dans: env.TMPDIR });
216
334
  if (m) {
217
335
  dire(m.ligne);
218
336
  }
219
337
  const taches = new Set();
220
338
  try {
339
+ // A tranche writes its reports anew.
340
+ if (tranche) {
341
+ for (const f of fichiersDeLaTranche(path.join(racine, RAPPORTS), tranche)) {
342
+ rmSync(f, { force: true });
343
+ }
344
+ }
221
345
  const code = jouerLaPasse({
222
346
  racine,
223
- gardesSeules,
347
+ demandes: lu,
224
348
  args,
225
349
  tout,
226
350
  ajouts: m?.env ?? {},
@@ -233,36 +357,43 @@ function passe({ racine, demandes, env, dire, coeurs }) {
233
357
  writeFileSync(env[ROUGES], [...taches].map(t => `${t}\t${rejeu(t)}\n`).join(''));
234
358
  }
235
359
  // A pass green on every package keeps its tree as the last green.
236
- poserLeVert({ code, etat: m?.etat, args, env, garder: garderLeVert });
360
+ poserLeVert({
361
+ code,
362
+ etat: m?.etat,
363
+ args,
364
+ env,
365
+ garder: garderLeVert,
366
+ partielle: Boolean(tranche) || sansTests,
367
+ });
237
368
  return code;
238
369
  } finally {
239
370
  m?.retirer();
240
371
  }
241
372
  }
242
373
 
243
- function jouerLaPasse({ racine, gardesSeules, args, tout, ajouts, env, dire, coeurs, taches }) {
374
+ function jouerLaPasse({ racine, demandes, args, tout, ajouts, env, dire, coeurs, taches }) {
375
+ const { gardesSeules, sansTests, tranche } = demandes;
244
376
  const { [TESTS_CIBLES]: _, [CHANGEMENTS]: __, ...propre } = env;
245
377
  // The environment of the run: measured against the last green; the moment of a complete pass,
246
- // which moves the hash of every task of tests, so that each plays for real.
247
- const e = gardesSeules
248
- ? propre
249
- : {
250
- ...propre,
251
- ...ajouts,
252
- ...(tout
253
- ? { [TESTS_CIBLES]: JSON.stringify(testsCibles({ arguments: [], force: true })) }
254
- : {}),
255
- };
378
+ // which moves the hash of every task of tests, so that each plays for real; a tranche, with it.
379
+ const cibles = tranche
380
+ ? testsDeLaTranche(tranche, racine)
381
+ : tout
382
+ ? testsCibles({ arguments: [], force: true })
383
+ : undefined;
384
+ const e =
385
+ gardesSeules || sansTests
386
+ ? propre
387
+ : { ...propre, ...ajouts, ...(cibles ? { [TESTS_CIBLES]: JSON.stringify(cibles) } : {}) };
256
388
  const borne = args.some(a => CONCURRENCE.test(a)) ? [] : [`--concurrency=${concurrence(coeurs)}`];
257
389
  const a = [
258
- ...(gardesSeules ? GARDES : TACHES),
259
- ...controlesDuDepot(racine),
390
+ ...tachesDeLaPasse(demandes, controlesDuDepot(racine)),
260
391
  '--continue=dependencies-successful',
261
392
  ...borne,
262
393
  ...args,
263
394
  ];
264
395
  // The plan of the run, before it: the progress knows all its tasks.
265
- if (!gardesSeules && depotAvecTests(racine)) {
396
+ if (!gardesSeules && !sansTests && depotAvecTests(racine)) {
266
397
  planifier(env[AVANCEMENT], { racine, args: a, env: e });
267
398
  }
268
399
  // The run of Turborepo, and its summary.
@@ -75,6 +75,9 @@ import {
75
75
  import { ciblage, HORS_DU_JOUR } from './cibles.mjs';
76
76
  import { rapportAvancement } from './avancement.reporter.mjs';
77
77
  import { rapportJson } from './resultats.mjs';
78
+ // The mark of a measure of time, published as `./vitest-config/mesure` and imported by the tests of
79
+ // other packages: the import attaches it to the configuration that decides what such a mark does.
80
+ import './mesure.mjs';
78
81
 
79
82
  const ici = f => fileURLToPath(new URL(f, import.meta.url));
80
83
 
@@ -38,9 +38,15 @@
38
38
  // Vitest's `passWithNoTests: false`.
39
39
  // - The night's configuration (scripts/langages/typescript/vitest.nuit.config.mjs) plays what the
40
40
  // day leaves out, through the plugin `nuit`: the night tests, the benches and the witnesses; the
41
- // variable `GRILLHOUSE_TESTS_DE_NUIT` (NUIT_VARIABLE) chooses `nuit`, the night tests alone, or
42
- // `mesures`, the benches and the witnesses alone, one file at a time (`fileParallelism: false`),
43
- // as scripts/langages/typescript/tests-de-nuit.mjs plays them.
41
+ // variable `GRILLHOUSE_TESTS_DE_NUIT` (NUIT_VARIABLE) chooses `nuit`, the night tests alone,
42
+ // `hors-poste`, the night tests but those that bear the tag `@poste` at their head (the night of
43
+ // a shared machine), or `mesures`, the benches and the witnesses alone, one file at a time
44
+ // (`fileParallelism: false`), as scripts/langages/typescript/tests-de-nuit.mjs plays them; the
45
+ // variable `GRILLHOUSE_TRANCHE_DE_NUIT` (NUIT_TRANCHE) gives the run its tranche, as a tranche of
46
+ // the day (`trancher`, ../tranches.mjs).
47
+ // - A tranche of a pass (`tranche`, `i/n`, and `rapports` in the value, `npm run verifier --
48
+ // --tranche i/n`) plays its part of the files alone, writes its blob report and the files of its
49
+ // part (`trancher`, ../tranches.mjs).
44
50
  // - The changes since the last green (`GRILLHOUSE_CHANGEMENTS`, ./changements.mjs) restrict the
45
51
  // files played to those Vitest relates to them, the files named themselves kept, or leave every
46
52
  // test when a change lies out of Vitest's graph.
@@ -48,6 +54,7 @@
48
54
  import { globSync, readdirSync, readFileSync, statSync } from 'node:fs';
49
55
  import path from 'node:path';
50
56
  import { CHANGEMENTS, TESTS_CIBLES } from '../../../services-du-noyau.mjs';
57
+ import { trancher } from '../tranches.mjs';
51
58
  import { lireChangements, restreindre } from './changements.mjs';
52
59
 
53
60
  // The name of the variable is the core's (`TESTS_CIBLES`); this module reads it under its own name.
@@ -60,6 +67,11 @@ export const BUDGET = '**/*.budget.{test,spec}.?(c|m)[jt]s?(x)';
60
67
  export const HORS_DU_JOUR = [NUIT, BUDGET];
61
68
  /** The variable that chooses the tests of a run of the night's configuration: `nuit` or `mesures`. */
62
69
  export const NUIT_VARIABLE = 'GRILLHOUSE_TESTS_DE_NUIT';
70
+ /**
71
+ * The variable that carries the tranche of a run of the night's configuration, JSON: `tranche`,
72
+ * `i/n`, and `rapports`, the directory of its reports (`trancher`, ../tranches.mjs).
73
+ */
74
+ export const NUIT_TRANCHE = 'GRILLHOUSE_TRANCHE_DE_NUIT';
63
75
  // Whether the file at <fichier> bears the name of <motif>, a globstar then a name: by the name of
64
76
  // the file, since a globstar passes no directory whose name starts with a dot, and a ticket's copy
65
77
  // lives under `.claude/worktrees/`.
@@ -71,6 +83,28 @@ export const estUnTestDeNuit = fichier => parSonNom(fichier, NUIT);
71
83
  export const estUnBanc = fichier => parSonNom(fichier, BUDGET);
72
84
  /** Whether the file at <fichier> is a night test or a time budget bench, by its name. */
73
85
  export const deNuitOuBanc = fichier => HORS_DU_JOUR.some(p => parSonNom(fichier, p));
86
+ // The tag of a night test that depends on the poste (its envelope, its tools, its session): a line
87
+ // `// @poste` of the comment at the head of the file, before its first line of code, its reason
88
+ // after it (`// @poste: l'enveloppe bwrap`), as Bazel's tags (`manual`, `exclusive`) and pytest's
89
+ // markers live with the test.
90
+ const ETIQUETTE_DU_POSTE = /^\/\/\s*@poste\b/;
91
+ /**
92
+ * Whether the text <texte> of a test file bears the tag `@poste` in the comment at its head: the
93
+ * night of a shared machine (`hors-poste`) leaves it out, the night of the poste plays it.
94
+ * @param {string} texte the text of the file
95
+ */
96
+ export function porteLEtiquetteDuPoste(texte) {
97
+ for (const ligne of texte.split('\n')) {
98
+ const l = ligne.trim();
99
+ if (ETIQUETTE_DU_POSTE.test(l)) {
100
+ return true;
101
+ }
102
+ if (l !== '' && !l.startsWith('//') && !l.startsWith('#!')) {
103
+ return false;
104
+ }
105
+ }
106
+ return false;
107
+ }
74
108
  // Vitest's default `include` (its configDefaults).
75
109
  const INCLUDE = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];
76
110
  // The mark of a time witness: the import of `mesurerAuRepos`, on a line of its own, from the
@@ -165,7 +199,11 @@ export const ciblage = (env = process.env, dire = l => process.stdout.write(`${l
165
199
  // The files a targeted run names themselves, absolute.
166
200
  let nommes = [];
167
201
  if (texte) {
168
- nommes = await cibler(config, test, JSON.parse(texte), new Set(temoins));
202
+ const valeur = JSON.parse(texte);
203
+ nommes = await cibler(config, test, valeur, new Set(temoins));
204
+ if (valeur.tranche) {
205
+ await trancher(config, test, valeur);
206
+ }
169
207
  }
170
208
  // The witnesses out of the day, but those named themselves (in the include then).
171
209
  const joues = new Set(Array.isArray(test.include) ? test.include : []);
@@ -244,26 +282,59 @@ async function cibler(config, test, valeur, temoins) {
244
282
  return nommes;
245
283
  }
246
284
 
285
+ /**
286
+ * The night tests under <dir> that bear the tag `@poste` (`porteLEtiquetteDuPoste`), node_modules,
287
+ * dist, .git, .turbo and .claude left out; each path relative to <dir>, sorted.
288
+ * @param {string} dir the directory searched
289
+ */
290
+ export function testsDuPoste(dir) {
291
+ return [
292
+ ...new Set(
293
+ globSync([NUIT], { cwd: dir, exclude: d => HORS_TEMOINS.has(path.basename(d)) }).map(f =>
294
+ f.split(path.sep).join('/')
295
+ )
296
+ ),
297
+ ]
298
+ .filter(f => porteLEtiquetteDuPoste(lireTexte(path.join(dir, f))))
299
+ .sort();
300
+ }
301
+
247
302
  /**
248
303
  * The plugin of the night's configuration: the night tests, the benches and the time witnesses
249
- * under its directory, or, as <env> chooses in NUIT_VARIABLE, the night tests alone (`nuit`) or
250
- * the measures alone, one file at a time (`mesures`), the benches and the witnesses.
304
+ * under its directory, or, as <env> chooses in NUIT_VARIABLE, the night tests alone (`nuit`), the
305
+ * night tests but those tagged `@poste` (`hors-poste`, the night of a shared machine: a CI), or the
306
+ * measures alone, one file at a time (`mesures`), the benches and the witnesses; with
307
+ * NUIT_TRANCHE, the tranche it carries of these files.
251
308
  * @param {NodeJS.ProcessEnv} [env] the environment that holds the choice
252
309
  */
253
310
  export const nuit = (env = process.env) => ({
254
311
  name: 'grillhouse:nuit',
255
- config(config) {
312
+ async config(config) {
256
313
  const choix = env[NUIT_VARIABLE];
314
+ const tranche = env[NUIT_TRANCHE];
257
315
  delete env[NUIT_VARIABLE];
316
+ delete env[NUIT_TRANCHE];
258
317
  const test = (config.test ??= {});
259
318
  const temoins = temoinsDe(config, { ...test, include: INCLUDE });
260
319
  if (choix === 'nuit') {
261
320
  test.include = [NUIT];
321
+ } else if (choix === 'hors-poste') {
322
+ test.include = [NUIT];
323
+ const duPoste = testsDuPoste(path.resolve(config.root ?? process.cwd(), test.dir ?? ''));
324
+ if (duPoste.length) {
325
+ test.exclude = [
326
+ ...(test.exclude ?? ['**/node_modules/**']),
327
+ ...duPoste.map(r => r.replace(SPECIAUX, '\\$&')),
328
+ ];
329
+ }
262
330
  } else if (choix === 'mesures') {
263
331
  test.include = [BUDGET, ...temoins];
264
332
  test.fileParallelism = false;
265
333
  } else {
266
334
  test.include = [...HORS_DU_JOUR, ...temoins];
267
335
  }
336
+ if (tranche) {
337
+ await trancher(config, test, JSON.parse(tranche));
338
+ }
268
339
  },
269
340
  });
@@ -167,7 +167,7 @@ function sansCommentaires(texte) {
167
167
 
168
168
  // The code of <texte>: without its comments, whose words name no path read, nor its imports, whose
169
169
  // strings are in Vitest's graph.
170
- const code = texte => sansCommentaires(texte).replace(IMPORT, '');
170
+ export const code = texte => sansCommentaires(texte).replace(IMPORT, '');
171
171
 
172
172
  // The strings of the code <texte> (without its comments), read character by character: a quoted
173
173
  // string, or a template without a substitution, each once.
@@ -193,9 +193,9 @@ function chainesDe(texte) {
193
193
  return out;
194
194
  }
195
195
 
196
- // The strings of the code <texte>, then the strings of each call of `join` or `resolve` written
197
- // together, each once.
198
- function chaines(texte) {
196
+ /** The strings of the code <texte>, then the strings of each call of `join` or `resolve` written
197
+ * together, each once. */
198
+ export function chaines(texte) {
199
199
  const jointes = [...texte.matchAll(APPEL)]
200
200
  .map(a => chainesDe(a[1]).filter(Boolean))
201
201
  .filter(l => l.length > 1)
@@ -27,3 +27,12 @@ process.env.GRILLHOUSE_MESURE_D_ESSAI ||= JSON.stringify({
27
27
  });
28
28
  process.env.GRILLHOUSE_TEMPORAIRE_LIBRE ||= '0';
29
29
  process.env.GRILLHOUSE_COPIE_LIBRE ||= '0';
30
+ // The cache of a test's Turborepo is local alone: the remote cache of the CI or of the poste
31
+ // (scripts/fichier-du-poste.mjs) would serve a repository of trial the tasks another test or run
32
+ // wrote there. `TURBO_CACHE` says local alone; `TURBO_TOKEN`, named empty, keeps the file of the
33
+ // poste unread (`avecLeFichierDuPoste` leaves an environment that names one of its variables).
34
+ for (const nom of ['TURBO_API', 'TURBO_TEAM', 'TURBO_TEAMID', 'TURBO_REMOTE_CACHE_SIGNATURE_KEY']) {
35
+ delete process.env[nom];
36
+ }
37
+ process.env.TURBO_TOKEN = '';
38
+ process.env.TURBO_CACHE = 'local:rw';
@@ -8,8 +8,9 @@
8
8
  // its copy (`vitest run --root <copy> --config <this file>`), after a green full pass (`npm run
9
9
  // verifier -- --force`) and before the project's night script: its include names the night tests
10
10
  // and the benches, and its plugin adds the witnesses under the root, or chooses the night tests
11
- // alone or the measures alone, one file at a time (`nuit` of ./vitest-config/cibles.mjs, the
12
- // variable GRILLHOUSE_TESTS_DE_NUIT). It reads no day configuration of the project, whether the
11
+ // alone, the night tests but those tagged `@poste` (the night of a shared machine, a CI), or the
12
+ // measures alone, one file at a time (`nuit` of ./vitest-config/cibles.mjs, the variable
13
+ // GRILLHOUSE_TESTS_DE_NUIT). It reads no day configuration of the project, whether the
13
14
  // project has one at its root or one per package; it takes from the base configuration the common
14
15
  // environment (git's settings) and the measure of time: the setup file that notes the CPU pressure
15
16
  // of each test and the duration reporter, which gives 75, « à repasser », to a measure that fails
@@ -0,0 +1,20 @@
1
+ // The types of ./langages.mjs the frame reads (src/temporal/installation.ts, its tests).
2
+ import type { Composition, Langage } from './jointure.js';
3
+
4
+ /** The frame's languages, each its module, from this directory. */
5
+ export const LANGAGES: Record<string, string>;
6
+
7
+ /** The module of the language <nom> of the frame's list, loaded once per process. */
8
+ export function langage(nom: string): Langage;
9
+
10
+ /** The languages the project at <racine> declares, each once, in the order of its table; empty
11
+ * without document, table or language. */
12
+ export function langagesDeclares(racine: string): string[];
13
+
14
+ /** The modules of the languages the project at <racine> declares, in the order of its table;
15
+ * throws when it declares none, or a language out of the frame's list. */
16
+ export function langagesDe(racine: string): Langage[];
17
+
18
+ /** The join of the modules that serve the project at <racine>: the module itself when the project
19
+ * declares one, else their composition. */
20
+ export function langageDe(racine: string): Composition;
@@ -6,7 +6,7 @@
6
6
  import { spawnSync } from 'node:child_process';
7
7
  import path from 'node:path';
8
8
  import { fileURLToPath, pathToFileURL } from 'node:url';
9
- import { trancher } from './dette.mjs';
9
+ import { MODE, trancher } from './dette.mjs';
10
10
 
11
11
  const DOSSIER = 'packages/grillhouse/scripts';
12
12
  // The executable of ESLint in the repository's node_modules, from this file (packages/grillhouse/scripts).
@@ -43,16 +43,33 @@ export async function verifier(racine) {
43
43
  return constats;
44
44
  }
45
45
 
46
+ // The report of the check at <racine>: `lignes`, what the command writes on stderr (each refusal
47
+ // prefixed with `⛔`, then the debt's lines), and `code`, its exit code (1 on a refusal). The
48
+ // functional core of the command: it runs ESLint and reads the project's debt, and writes nothing to
49
+ // the standard streams; the command below is its shell. The refusals reach SARIF through `trancher`
50
+ // under the results directory <env> names (scripts/resultats.mjs); without it none is written, and
51
+ // the debt's mode is <env>'s `GRILLHOUSE_DETTE`.
52
+ export async function rapport(racine, env = process.env) {
53
+ const { refus, lignes } = trancher(
54
+ racine,
55
+ 'lint-des-scripts',
56
+ await verifier(racine),
57
+ env[MODE] || undefined,
58
+ env
59
+ );
60
+ return {
61
+ lignes: [...refus.map(r => `⛔ ${r.message}`), ...lignes],
62
+ code: refus.length ? 1 : 0,
63
+ };
64
+ }
65
+
46
66
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
47
67
  // The root of the repository: the first argument (the script `lint` of the package passes it),
48
68
  // the working directory otherwise.
49
69
  const racine = path.resolve(process.argv[2] ?? process.cwd());
50
- const { refus, lignes } = trancher(racine, 'lint-des-scripts', await verifier(racine));
51
- for (const r of refus) {
52
- process.stderr.write(`⛔ ${r.message}\n`);
53
- }
70
+ const { lignes, code } = await rapport(racine);
54
71
  for (const l of lignes) {
55
72
  process.stderr.write(`${l}\n`);
56
73
  }
57
- process.exitCode = refus.length ? 1 : 0;
74
+ process.exitCode = code;
58
75
  }
@@ -0,0 +1,11 @@
1
+ // The types of the shared test material the package's typed tests read
2
+ // (`@roomi-fields/grillhouse-matiere/test-fixtures`, which publishes its source, not a built
3
+ // declaration): tsconfig.json maps the entry here, so the typing of this package stays on its own
4
+ // files. Only the names these tests import are declared.
5
+
6
+ /** Writes at <repo> the docs/ARCHITECTURE.md of <paquets>: a list of languages (a package each,
7
+ * `paquet-<n>`), or a record of package name to language. */
8
+ export function declarerLesLangages(
9
+ repo: string,
10
+ paquets?: string[] | Record<string, string>
11
+ ): void;
@@ -0,0 +1,36 @@
1
+ // From 0.33.0 the remote cache of Turborepo is shared between the CI and the poste
2
+ // (grillhouse-44b.12.6): the template's CI takes its server from the repository's variables and
3
+ // secrets, and the commands of the frame on the poste read it from
4
+ // ~/.config/grillhouse/turbo-cache.env, read alone (scripts/fichier-du-poste.mjs).
5
+ //
6
+ // - The migration changes no file: without a server, the CI and the poste keep their local cache,
7
+ // and a marked workflow of the frame reaches the project by the update.
8
+ // - What stays to the project (`restes`), once: a project whose root's turbo.json does not sign
9
+ // the artifacts (`remoteCache.signature`) is told how to plug a server. One that signs them has
10
+ // plugged it already.
11
+ import { existsSync, readFileSync } from 'node:fs';
12
+ import path from 'node:path';
13
+
14
+ export const version = '0.33.0';
15
+ export const nom = 'cache distant';
16
+
17
+ /** Changes nothing: plugging a server is the project's gesture (`restes`). */
18
+ export function migrer() {
19
+ return [];
20
+ }
21
+
22
+ // Whether the root's turbo.json (or turbo.jsonc) of <projet> signs the artifacts of its remote cache.
23
+ const signe = projet =>
24
+ ['turbo.json', 'turbo.jsonc']
25
+ .map(f => path.join(projet, f))
26
+ .some(f => existsSync(f) && /"signature"\s*:\s*true/.test(readFileSync(f, 'utf8')));
27
+
28
+ /** How to plug a server of remote cache, for a project whose turbo.json does not sign. */
29
+ export function restes(projet) {
30
+ if (signe(projet)) {
31
+ return [];
32
+ }
33
+ return [
34
+ 'turbo.json : le cache distant de Turborepo se partage entre la CI et le poste, s\'il y a un serveur (facultatif ; sans lui rien ne change). Pour le brancher : les variables TURBO_API et TURBO_TEAM et les secrets TURBO_TOKEN et TURBO_REMOTE_CACHE_SIGNATURE_KEY du dépôt sur GitHub (la CI du cadre les lit : un push vers main ou agent/** écrit, tout autre run lit), `"remoteCache": { "signature": true }` dans le turbo.json racine, et, sur le poste, les quatre mêmes variables dans ~/.config/grillhouse/turbo-cache.env (droits 600), que chaque projet du poste lit seul, sans jamais écrire.',
35
+ ];
36
+ }
@@ -0,0 +1,31 @@
1
+ // From 0.33.0 the queue enters a lot on main only once the CI of its branch `agent/<ticket>`
2
+ // judged it green (grillhouse-44b.12.5): the CI of the project runs on a push to `agent/**`.
3
+ //
4
+ // - The workflows of `.github/workflows/` that run on a push to the branch main is pushed to, and
5
+ // list the branches of their push, gain `agent/**` (scripts/ci-des-branches.mjs).
6
+ // - A project whose CI already runs on a push to `agent/**` is left, nothing said: a second pass
7
+ // changes nothing.
8
+ // - A project without such a workflow is left; `restes` says the gesture, which the update
9
+ // reports without failing, as the opening of a session names it under « Manque ».
10
+ import {
11
+ ajouterLesBranchesDeTicket,
12
+ BRANCHES_DE_TICKET,
13
+ ecouteLesBranchesDeTicket,
14
+ GESTE,
15
+ } from '../ci-des-branches.mjs';
16
+
17
+ export const version = '0.33.0';
18
+ export const nom = 'ci des branches de ticket';
19
+
20
+ /** Adds `agent/**` to the push of the CI of the lots; returns what it did. */
21
+ export function migrer(projet) {
22
+ return ajouterLesBranchesDeTicket(projet).map(
23
+ f =>
24
+ `${f} : '${BRANCHES_DE_TICKET}' ajoutée aux branches de son push, que la file pousse et dont la CI juge chaque lot`
25
+ );
26
+ }
27
+
28
+ /** What stays to the project: the gesture, while no workflow runs on a push to `agent/**`. */
29
+ export function restes(projet) {
30
+ return ecouteLesBranchesDeTicket(projet) ? [] : [GESTE];
31
+ }
@@ -0,0 +1,31 @@
1
+ // From 0.33.0 the frame carries the CI of a project (grillhouse-44b.12.7): the template's
2
+ // `.github/workflows/ci.yml` (the verification in tranches, for a lot) and `nuit.yml` (the night
3
+ // tests out of the poste), each bearing the frame's mark on its first line, which the update keeps
4
+ // (scripts/workflows-du-cadre.mjs).
5
+ //
6
+ // - The migration changes no file: a project's CI is its own until it adopts the frame's, and the
7
+ // update starts no CI on a repository.
8
+ // - What stays to the project (`restes`), once: a project that holds no workflow of the frame is
9
+ // told how to adopt them. One that holds one has nothing to do.
10
+ import path from 'node:path';
11
+ import { CADRE } from '../cadre.mjs';
12
+ import { aLaCiDuCadre, GABARIT_DES_WORKFLOWS, WORKFLOWS } from '../workflows-du-cadre.mjs';
13
+
14
+ export const version = '0.33.0';
15
+ export const nom = 'ci du cadre';
16
+
17
+ /** Changes nothing: the adoption of the frame's CI is the project's gesture (`restes`). */
18
+ export function migrer() {
19
+ return [];
20
+ }
21
+
22
+ /** The adoption of the frame's CI, for a project that holds none of its workflows. */
23
+ export function restes(projet) {
24
+ if (aLaCiDuCadre(projet)) {
25
+ return [];
26
+ }
27
+ const modele = path.relative(projet, path.join(CADRE, GABARIT_DES_WORKFLOWS, 'ci.yml'));
28
+ return [
29
+ `${WORKFLOWS} : le cadre porte la CI d'un projet (ci.yml, le lot en tranches ; nuit.yml, les tests de nuit hors du poste). Pour l'adopter, copier \`${modele}\` dans \`${WORKFLOWS}/\` (un ci.yml du projet cède sa place, ses étapes propres versées ailleurs), puis \`npx grillhouse maj\`, qui écrit nuit.yml et tient les deux à jour. Leur machine : la variable RUNNER du dépôt sur GitHub, facultative (ubuntu-latest sans elle).`,
30
+ ];
31
+ }