@roomi-fields/grillhouse 0.47.1 → 0.48.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 (101) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +48 -0
  3. package/cadre/templates/projet/.github/workflows/ci.yml +18 -38
  4. package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -0
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +5 -0
  6. package/cadre/templates/projet/CLAUDE.md +23 -6
  7. package/charte.md +9 -2
  8. package/dist/temporal/circuit/commande.js +5 -3
  9. package/dist/temporal/circuit/commande.js.map +1 -1
  10. package/dist/temporal/commande.js +2 -13
  11. package/dist/temporal/commande.js.map +1 -1
  12. package/dist/temporal/deroules.d.ts +1 -1
  13. package/dist/temporal/deroules.js +2 -2
  14. package/dist/temporal/deroules.js.map +1 -1
  15. package/dist/temporal/file/activites.d.ts +1 -4
  16. package/dist/temporal/file/activites.js +13 -14
  17. package/dist/temporal/file/activites.js.map +1 -1
  18. package/dist/temporal/file/contrat.d.ts +20 -91
  19. package/dist/temporal/file/contrat.js +7 -3
  20. package/dist/temporal/file/contrat.js.map +1 -1
  21. package/dist/temporal/file/deroule.d.ts +1 -9
  22. package/dist/temporal/file/deroule.js +54 -163
  23. package/dist/temporal/file/deroule.js.map +1 -1
  24. package/dist/temporal/installation.d.ts +26 -1
  25. package/dist/temporal/installation.js +111 -2
  26. package/dist/temporal/installation.js.map +1 -1
  27. package/dist/temporal/nuits/activites.d.ts +11 -2
  28. package/dist/temporal/nuits/activites.js +16 -5
  29. package/dist/temporal/nuits/activites.js.map +1 -1
  30. package/dist/temporal/nuits/choix.d.ts +15 -0
  31. package/dist/temporal/nuits/choix.js +20 -0
  32. package/dist/temporal/nuits/choix.js.map +1 -1
  33. package/dist/temporal/nuits/contrat.d.ts +16 -3
  34. package/dist/temporal/nuits/deroule.js +9 -2
  35. package/dist/temporal/nuits/deroule.js.map +1 -1
  36. package/dist/temporal/places/client.d.ts +13 -2
  37. package/dist/temporal/places/client.js +17 -2
  38. package/dist/temporal/places/client.js.map +1 -1
  39. package/dist/temporal/places/contrat.d.ts +41 -4
  40. package/dist/temporal/places/contrat.js +8 -0
  41. package/dist/temporal/places/contrat.js.map +1 -1
  42. package/dist/temporal/places/deroule.js +46 -6
  43. package/dist/temporal/places/deroule.js.map +1 -1
  44. package/docs/ARCHITECTURE.md +166 -41
  45. package/docs/INTERFACE.md +13 -3
  46. package/package.json +1 -1
  47. package/scripts/activites.mjs +48 -10
  48. package/scripts/aiguillage.mjs +1 -0
  49. package/scripts/attente-a-l-arret.mjs +2 -5
  50. package/scripts/attente-au-tour.mjs +2 -5
  51. package/scripts/branche-de-nuit.mjs +32 -44
  52. package/scripts/ci-de-main.mjs +215 -16
  53. package/scripts/circuit.mjs +45 -33
  54. package/scripts/composition-des-langages.mjs +2 -0
  55. package/scripts/crochets.mjs +2 -2
  56. package/scripts/effets.mjs +2 -1
  57. package/scripts/enveloppe/enveloppe.mjs +61 -6
  58. package/scripts/enveloppe/travail-de-la-copie.mjs +2 -0
  59. package/scripts/etapes.mjs +11 -1
  60. package/scripts/etat-du-depot.mjs +23 -0
  61. package/scripts/faits-du-circuit.mjs +12 -23
  62. package/scripts/fermeture-de-la-machine.d.mts +27 -0
  63. package/scripts/fermeture-de-la-machine.mjs +108 -0
  64. package/scripts/greffons.mjs +1 -1
  65. package/scripts/integration/file.mjs +16 -13
  66. package/scripts/integration/integrer.mjs +2 -0
  67. package/scripts/jointure.d.ts +5 -0
  68. package/scripts/langages/c/index.mjs +2 -0
  69. package/scripts/langages/c/squelette.mjs +1 -1
  70. package/scripts/langages/cargo/index.mjs +2 -0
  71. package/scripts/langages/python/index.mjs +2 -0
  72. package/scripts/langages/typescript/index.mjs +3 -0
  73. package/scripts/langages/typescript/module-absent.mjs +24 -0
  74. package/scripts/langages/typescript/turbo-des-paquets.mjs +19 -1
  75. package/scripts/langages/typescript/vitest-config/lances.mjs +3 -1
  76. package/scripts/langages.mjs +25 -3
  77. package/scripts/machine.mjs +103 -0
  78. package/scripts/matieres-cles.mjs +17 -0
  79. package/scripts/matieres-lues.mjs +104 -0
  80. package/scripts/migrations/0.48.0-ci-declenchee-par-la-file.mjs +32 -0
  81. package/scripts/migrations/0.48.0-poussee-retiree.mjs +31 -0
  82. package/scripts/migrations.mjs +4 -0
  83. package/scripts/nuit.sh +16 -44
  84. package/scripts/passe-de-la-machine.mjs +9 -7
  85. package/scripts/places-de-la-machine.mjs +74 -11
  86. package/scripts/places-du-serveur.mjs +29 -8
  87. package/scripts/poussee-retiree.mjs +18 -0
  88. package/scripts/registre.d.mts +2 -2
  89. package/scripts/regles-des-places.d.mts +36 -5
  90. package/scripts/regles-des-places.mjs +56 -9
  91. package/scripts/reponses-du-circuit.d.mts +2 -0
  92. package/scripts/reponses-du-circuit.mjs +26 -0
  93. package/scripts/resultats.mjs +40 -0
  94. package/scripts/sous-commandes.mjs +15 -2
  95. package/scripts/superviseur.mjs +64 -57
  96. package/scripts/tableau.mjs +132 -67
  97. package/scripts/transitions.d.mts +8 -0
  98. package/scripts/transitions.mjs +21 -3
  99. package/skills/pitmaster/SKILL.md +6 -3
  100. package/skills/relecteur/SKILL.md +3 -1
  101. package/scripts/poussee-cles.mjs +0 -46
@@ -11,6 +11,9 @@ import path from 'node:path';
11
11
 
12
12
  export const SHA = /^[0-9a-f]{40,64}$/;
13
13
 
14
+ // The journal every bd command writes: the tree judged takes its version of the commit.
15
+ export const JOURNAL = '.beads/interactions.jsonl';
16
+
14
17
  export const git = (racine, args, env = process.env) =>
15
18
  spawnSync('git', ['-C', racine, ...args], {
16
19
  encoding: 'utf8',
@@ -51,6 +54,17 @@ function sousModuleModifie(racine) {
51
54
  return r.stdout.split('\0').some(e => /^[12] \S+ S/.test(e));
52
55
  }
53
56
 
57
+ // The files where the tree judged of the folder at <racine> differs from the tree of its HEAD
58
+ // (the journal of bd left out, it takes its version of the commit); [] when none or git fails.
59
+ export function ecartsDuDossier(racine) {
60
+ const etat = etatDuDepot(racine);
61
+ if (!etat.arbre) {
62
+ return [];
63
+ }
64
+ const r = git(etat.racine, ['diff-tree', '-r', '--name-only', '-z', etat.commit, etat.arbre]);
65
+ return r.status === 0 ? r.stdout.split('\0').filter(Boolean) : [];
66
+ }
67
+
54
68
  // The state of the repository at <racine> as it stands: `{ racine, commit, arbre, branche, main }`,
55
69
  // its top (its real path), HEAD, the tree of its working tree, the branch of HEAD (null when
56
70
  // detached) and main (brancheDeMain); `{ raison }` when no last green can count.
@@ -80,6 +94,15 @@ export function etatDuDepot(racine) {
80
94
  if (git(top, ['add', '-A'], env).status !== 0) {
81
95
  return { raison: 'git échoue' };
82
96
  }
97
+ // The journal of bd takes its version of the commit (removed when the commit lacks it).
98
+ const dansLeCommit = sortie(top, ['ls-tree', 'HEAD', '--', JOURNAL]);
99
+ const entree = dansLeCommit?.match(/^(\d+) blob ([0-9a-f]+)\t/);
100
+ const retablir = entree
101
+ ? git(top, ['update-index', '--add', '--cacheinfo', `${entree[1]},${entree[2]},${JOURNAL}`], env)
102
+ : git(top, ['update-index', '--force-remove', JOURNAL], env);
103
+ if (retablir.status !== 0) {
104
+ return { raison: 'git échoue' };
105
+ }
83
106
  const arbre = sortie(top, ['write-tree'], env);
84
107
  if (!arbre) {
85
108
  return { raison: 'git échoue' };
@@ -50,10 +50,8 @@
50
50
  // an effect not written has its outcome, said on the error output or the failure of its
51
51
  // activity;
52
52
  // - the acts of the queue of a project (scripts/integration/file.mjs, grillhouse-4nr.8): `situer`,
53
- // where the lot of a ticket stands (`situerLeLot`); `brancher`, the branch made the candidate its
54
- // CI judges and pushed (`preparerLaBranche`); `passages`, one reading of the CI of a commit, its
55
- // expected workflows together (`lireLesPassagesDeLaCI`); `conclure`, the CI concluded at the
56
- // ticket (`conclureLaCI`); `avancer`,
53
+ // where the lot of a ticket stands (`situerLeLot`); `brancher`, the branch made the candidate the
54
+ // final pass judges (`preparerLaBranche`); `avancer`,
57
55
  // main moved onto the candidate (`avancerMain`); each of `brancher` and `avancer` telling the
58
56
  // ticket of a branch out of the queue or kept (`direLIssue`); `fermer`, the ticket closed and main
59
57
  // pushed (`fermerLEntree`); `effet-de-la-file`, one effect they gave back, under the key of its
@@ -91,6 +89,7 @@ import {
91
89
  } from './integration/file.mjs';
92
90
  import {
93
91
  ghDans,
92
+ declencherLaCiDeMain,
94
93
  lireLaCiDeMain,
95
94
  lotsDepuisLeVert,
96
95
  ouvrirLeDefautDeMain,
@@ -477,9 +476,16 @@ Object.assign(ACTES, {
477
476
  // The CI of main read once, in the main tree: the defect ticket of a red passage opened for the
478
477
  // owner (`ouvrirLeDefautDeMain`, one per passage), the lots entered since the last green named by
479
478
  // git. `{ etat }`: `verte`, `rouge` or `non-lue`.
480
- async 'surveiller-la-ci-de-main'({ racine }) {
479
+ // It starts the CI first when the delay and the tip ask for it (`declencherLaCiDeMain`, <apresEntree>
480
+ // after an entry): a start GitHub refuses leaves its fault, the queue goes on.
481
+ async 'surveiller-la-ci-de-main'({ racine, apresEntree }) {
481
482
  const o = laFile(racine);
482
- const lecture = lireLaCiDeMain({ racine, gh: ghDans(racine) });
483
+ const gh = ghDans(racine);
484
+ const lancement = declencherLaCiDeMain({ racine, gh }, { apresEntree: apresEntree === true });
485
+ if (lancement.faute) {
486
+ o.dire(`⚠ ${lancement.faute}`);
487
+ }
488
+ const lecture = lireLaCiDeMain({ racine, gh });
483
489
  if (lecture.etat === 'rouge') {
484
490
  const pointe = o.principale ?? 'main';
485
491
  const lots = lotsDepuisLeVert(racine, { vert: lecture.vert, pointe });
@@ -490,23 +496,6 @@ Object.assign(ACTES, {
490
496
  }
491
497
  return { etat: lecture.etat };
492
498
  },
493
- // The acts of the former path of the queue (the CI of a ticket's branch, the readings of the
494
- // workflows of main), kept for the executions in flight whose history replays them, retired
495
- // by grillhouse-3uv.131 once they are drained: they read nothing and judge nothing, the lot
496
- // having been prepared as the queue's former path did, and the final pass of its circuit
497
- // having judged it.
498
- async passages() {
499
- return { etat: 'verte', passage: 'ancien-chemin' };
500
- },
501
- async 'inscrire-flux-de-main'() {
502
- return null;
503
- },
504
- async 'relire-flux-de-main'() {
505
- return { dues: 0, effets: [] };
506
- },
507
- async conclure() {
508
- return { avancer: true, effets: [] };
509
- },
510
499
  // One effect an act of the queue gave back, under the key of its activity, with the outcome of
511
500
  // the queue when it is not written (`ecrireLEffet`).
512
501
  async 'effet-de-la-file'({ racine, effet, cle, derniere }) {
@@ -0,0 +1,27 @@
1
+ // The types of the closure of the machine (./fermeture-de-la-machine.mjs), which the workflow of
2
+ // the places (src/temporal/places/) imports.
3
+
4
+ /** What the command of closure does on the reservation in place. */
5
+ export function decisionDeFermeture(
6
+ reservation: { auteur?: 'nuit' | 'superviseur' } | null | undefined
7
+ ): 'fermer' | 'deja-fermee' | 'nuit-tient';
8
+
9
+ /** What the command of reopening does on the reservation in place. */
10
+ export function decisionDeReouverture(
11
+ reservation: { auteur?: 'nuit' | 'superviseur' } | null | undefined
12
+ ): 'rouvrir' | 'deja-ouverte' | 'nuit-tient';
13
+
14
+ /** What still runs by project and by ticket, or « la machine est vide ». */
15
+ export function direCeQuiTourne(o: {
16
+ prises: readonly { ticket?: string | null; racine?: string | null }[];
17
+ parts: readonly { ticket?: string | null; projet?: string | null; etat?: string }[];
18
+ }): string[];
19
+
20
+ /** The lines a command says once it has played. */
21
+ export function direLaFermeture(o: {
22
+ issue: string;
23
+ reservation: { depuis: number } | null;
24
+ prises: readonly { ticket?: string | null; racine?: string | null }[];
25
+ parts: readonly { ticket?: string | null; projet?: string | null; etat?: string }[];
26
+ maintenant: number;
27
+ }): string[];
@@ -0,0 +1,108 @@
1
+ // The closure of the machine by the supervisor, as `kubectl cordon` and `drain` close a node to new
2
+ // work: the decision of each command on the reservation of the machine in place, and the lines it
3
+ // says, what still runs by project and by ticket (sessions: the places of the workflow of the
4
+ // machine; passes: their parts), « la machine est vide » when nothing plays, and how long the
5
+ // closure has lasted. Pure: the workflow of the places (src/temporal/places/deroule.ts) bundles
6
+ // the decisions, so this module imports only a rule that imports nothing. The commands themselves
7
+ // are scripts/machine.mjs.
8
+ import { duree } from './regles-des-places.mjs';
9
+
10
+ /**
11
+ * What the command of closure does on the reservation <reservation> of the machine (null without):
12
+ * `'fermer'` when none stands, `'deja-fermee'` under the supervisor's own closure, `'nuit-tient'`
13
+ * when the night holds the machine (an absent author is the night's): no second reservation.
14
+ * @param {{ auteur?: 'nuit' | 'superviseur' } | null | undefined} reservation
15
+ * @returns {'fermer' | 'deja-fermee' | 'nuit-tient'}
16
+ */
17
+ export function decisionDeFermeture(reservation) {
18
+ if (!reservation) {
19
+ return 'fermer';
20
+ }
21
+ return reservation.auteur === 'superviseur' ? 'deja-fermee' : 'nuit-tient';
22
+ }
23
+
24
+ /**
25
+ * What the command of reopening does on the reservation <reservation>: `'rouvrir'` the supervisor's
26
+ * closure, `'deja-ouverte'` when none stands, `'nuit-tient'` for a night's, which it never lifts.
27
+ * @param {{ auteur?: 'nuit' | 'superviseur' } | null | undefined} reservation
28
+ * @returns {'rouvrir' | 'deja-ouverte' | 'nuit-tient'}
29
+ */
30
+ export function decisionDeReouverture(reservation) {
31
+ if (!reservation) {
32
+ return 'deja-ouverte';
33
+ }
34
+ return reservation.auteur === 'superviseur' ? 'rouvrir' : 'nuit-tient';
35
+ }
36
+
37
+ // The folder name of a root of project, « alpha » for « /depots/alpha ».
38
+ const nomDuProjet = racine => (racine ? (racine.split('/').filter(Boolean).at(-1) ?? racine) : '?');
39
+
40
+ const pluriel = (n, mot) => `${n} ${mot}${n > 1 ? 's' : ''}`;
41
+
42
+ /**
43
+ * What still runs, one line by project: its sessions (`prises`, the places of the workflow of the
44
+ * machine) and its passes (`parts` that hold their part; a pass that waits does not run), each with
45
+ * its tickets. Only « la machine est vide » when nothing runs.
46
+ * @param {{ prises: { ticket?: string | null, racine?: string | null }[],
47
+ * parts: { ticket?: string | null, projet?: string | null, etat?: string }[] }} o
48
+ * @returns {string[]}
49
+ */
50
+ export function direCeQuiTourne({ prises, parts }) {
51
+ /** @type {Map<string, { seances: string[], passes: string[] }>} */
52
+ const projets = new Map();
53
+ const de = nom => {
54
+ if (!projets.has(nom)) {
55
+ projets.set(nom, { seances: [], passes: [] });
56
+ }
57
+ return projets.get(nom);
58
+ };
59
+ for (const p of prises) {
60
+ de(nomDuProjet(p.racine)).seances.push(p.ticket ?? 'sans ticket');
61
+ }
62
+ for (const p of parts.filter(x => x.etat !== 'attend')) {
63
+ de(nomDuProjet(p.projet)).passes.push(p.ticket ?? 'sans ticket');
64
+ }
65
+ if (!projets.size) {
66
+ return ['la machine est vide'];
67
+ }
68
+ return [...projets.entries()]
69
+ .sort(([a], [b]) => a.localeCompare(b, 'en'))
70
+ .map(([nom, { seances, passes }]) =>
71
+ [
72
+ nom,
73
+ ...(seances.length ? [`${pluriel(seances.length, 'séance')} (${seances.join(', ')})`] : []),
74
+ ...(passes.length ? [`${pluriel(passes.length, 'passe')} (${passes.join(', ')})`] : []),
75
+ ].join(' · ')
76
+ );
77
+ }
78
+
79
+ /**
80
+ * The lines a command says once it has played: its <issue> (`fermee`, `deja-fermee`, `nuit-tient`
81
+ * for the closure; `rouverte`, `deja-ouverte`, `nuit-tient` for the reopening), then, for a closure
82
+ * or a night that holds the machine, what still runs. <reservation> is the one in place after the
83
+ * command (its start gives how long the closure has lasted), <maintenant> the time in ms.
84
+ * @param {{ issue: string, reservation: { depuis: number } | null,
85
+ * prises: Parameters<typeof direCeQuiTourne>[0]['prises'],
86
+ * parts: Parameters<typeof direCeQuiTourne>[0]['parts'], maintenant: number }} o
87
+ * @returns {string[]}
88
+ */
89
+ export function direLaFermeture({ issue, reservation, prises, parts, maintenant }) {
90
+ const tourne = direCeQuiTourne({ prises, parts });
91
+ switch (issue) {
92
+ case 'fermee':
93
+ return ['machine fermée par le superviseur : aucune place neuve, aucun circuit neuf', ...tourne];
94
+ case 'deja-fermee':
95
+ return [
96
+ `machine déjà fermée par le superviseur, depuis ${reservation ? duree(maintenant - reservation.depuis) : '?'}`,
97
+ ...tourne,
98
+ ];
99
+ case 'nuit-tient':
100
+ return ['la nuit tient la machine : elle garde sa réservation, aucune autre n’est prise', ...tourne];
101
+ case 'rouverte':
102
+ return ['machine rouverte : les circuits reprennent d’eux-mêmes à l’étape suivante'];
103
+ case 'deja-ouverte':
104
+ return ['machine déjà ouverte : rien à faire'];
105
+ default:
106
+ throw new Error(`issue inconnue : ${issue}`);
107
+ }
108
+ }
@@ -302,7 +302,7 @@ export function greffonsAbsents(projet) {
302
302
  const GREFFON_DU_CADRE = 'grillhouse';
303
303
  const NOM_DU_PAQUET = '@roomi-fields/grillhouse';
304
304
  const X_Y_Z = /^\d+\.\d+\.\d+$/;
305
- function versionDuPaquet() {
305
+ export function versionDuPaquet() {
306
306
  try {
307
307
  const p = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
308
308
  return p.name === NOM_DU_PAQUET && typeof p.version === 'string' ? p.version : null;
@@ -47,9 +47,9 @@
47
47
  // ticket that fixes it.
48
48
  // At its entry on main (`fermerLEntree`), the branch's ticket closes « intégré : <commit> », loses
49
49
  // `en-file`, and the branch is deleted; a branch git does not delete (its copy still in place) is
50
- // written to the ticket, which closes all the same. Then main is pushed to origin, on the branch
51
- // `grillhouse.poussee.commit` of main's package.json (`main` without the key), which the pre-push
52
- // hook lets go as the tree is judged; a refused push is written to the ticket and does not stop the
50
+ // written to the ticket, which closes all the same. Then main is pushed to origin, to the branch
51
+ // main, which the pre-push hook lets go as the tree is judged (a main whose package.json carries the
52
+ // retired key `grillhouse.poussee` is refused by its name, nothing pushed); a refused push is written to the ticket and does not stop the
53
53
  // queue. The working directory of its circuit (`.claude/worktrees/<ticket>.travail`,
54
54
  // scripts/circuit.mjs), which lives as long as the ticket, is removed then (`retirerLeTravail`).
55
55
  // Every comment and change of the queue at a ticket is written under the author `file`, which bd
@@ -69,8 +69,9 @@ import { arbreEstJuge, garderLArbreJuge } from '../arbres-juges.mjs';
69
69
  import { A_REPASSER } from '../codes-de-sortie.mjs';
70
70
  import { BASE_DU_LOT } from '../dernier-vert.mjs';
71
71
  import { avecLesDonnees, donneesDe } from '../donnees-cles.mjs';
72
+ import { matieresDeclareesDe } from '../matieres-cles.mjs';
72
73
  import { avecLesOutils, empreintesDe, outilsDe } from '../outils-cles.mjs';
73
- import { lireCommit } from '../poussee-cles.mjs';
74
+ import { pousseeRetiree } from '../poussee-retiree.mjs';
74
75
  import { ouvrirCopie } from './rejeu.mjs';
75
76
  import { lotSurMain } from './integrer.mjs';
76
77
  import { ACTEUR, emettre } from '../effets.mjs';
@@ -191,6 +192,7 @@ function remplacer(o, tip, tete) {
191
192
  let env;
192
193
  try {
193
194
  engendres = engendresDe(racine);
195
+ matieresDeclareesDe(racine);
194
196
  env = avecLesDonnees(
195
197
  donneesDe(racine),
196
198
  avecLesOutils(outilsDe(racine), process.env, empreintesDe(racine))
@@ -427,11 +429,12 @@ function livrerLesCapacites(o, ticket, labels) {
427
429
  * The ticket of <entree> (`{ ticket, branche, commit }`) entered on main at <commit>, with the
428
430
  * tools <o>: it closes « intégré : <commit> » and loses `en-file` (a ticket already closed is left
429
431
  * as it is), the branch is deleted, then main is pushed to origin on the branch
430
- * `grillhouse.poussee.commit` of main's package.json; the queue is then done with the ticket, and
432
+ * main, unless main's package.json carries the retired key `grillhouse.poussee` (refused by its
433
+ * name, nothing pushed); the queue is then done with the ticket, and
431
434
  * removes the working directory of its circuit (`retirerLeTravail`). Each of its gestures replays
432
435
  * without harm (a ticket closed is left closed, a branch gone stays gone, a commit pushed is pushed
433
436
  * again as it is), and never reopens the ticket; its comments are effects (`commenterAu`), which
434
- * the workflow of the queue writes once each. `{ poussee, raison }`: the branch pushed to, or null
437
+ * the workflow of the queue writes once each. `{ poussee, raison }`: `main` once pushed, or null
435
438
  * and why, in one line (`enUneLigne`), its comment at the ticket whole.
436
439
  */
437
440
  export function fermerLEntree(o, entree) {
@@ -459,26 +462,26 @@ export function fermerLEntree(o, entree) {
459
462
  }
460
463
  retirerLeTravail(o, entree.ticket);
461
464
  const paquet = git('show', `refs/heads/${o.principale}:package.json`);
462
- const { commit, faute } = lireCommit(paquet.status === 0 ? JSON.parse(paquet.stdout) : null);
463
- if (faute) {
464
- const raison = `Poussée non faite : grillhouse.poussee.commit vaut ${faute}, pas un nom de branche.`;
465
+ const retiree = pousseeRetiree(paquet.status === 0 ? JSON.parse(paquet.stdout) : null);
466
+ if (retiree) {
467
+ const raison = `Poussée non faite : ${retiree}`;
465
468
  commenter(raison);
466
469
  return { poussee: null, raison: enUneLigne(raison), ...ferme };
467
470
  }
468
471
  const sansInvite = { encoding: 'utf8', env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } };
469
472
  const pousse = spawnSync(
470
473
  'git',
471
- ['-C', racine, 'push', 'origin', `${entree.commit}:refs/heads/${commit}`],
474
+ ['-C', racine, 'push', 'origin', `${entree.commit}:refs/heads/main`],
472
475
  sansInvite
473
476
  );
474
477
  if (pousse.status !== 0) {
475
- const raison = `La poussée de ${court} vers origin/${commit} (grillhouse.poussee.commit) est refusée :\n${pousse.stderr.trim()}`;
478
+ const raison = `La poussée de ${court} vers origin/main est refusée :\n${pousse.stderr.trim()}`;
476
479
  commenter(raison);
477
480
  o.dire(`⚠ poussée de ${court} refusée`);
478
481
  return { poussee: null, raison: enUneLigne(raison), ...ferme };
479
482
  }
480
- o.dire(`✓ poussée : ${court} est sur origin/${commit}`);
481
- return { poussee: commit, raison: null, ...ferme };
483
+ o.dire(`✓ poussée : ${court} est sur origin/main`);
484
+ return { poussee: 'main', raison: null, ...ferme };
482
485
  }
483
486
 
484
487
  /**
@@ -99,6 +99,7 @@ import { langageDe } from '../langages.mjs';
99
99
  import { prefixe } from '../prefixe-des-tickets.mjs';
100
100
  import { commitsDelivering, gitLog } from '../un-commit-par-ticket.mjs';
101
101
  import { avecLesDonnees, donneesDe } from '../donnees-cles.mjs';
102
+ import { matieresDeclareesDe } from '../matieres-cles.mjs';
102
103
  import { avecLesOutils, empreintesDe, outilsDe } from '../outils-cles.mjs';
103
104
  import { lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
104
105
  import { ouvrirCopie, RETIRER_COPIE } from './rejeu.mjs';
@@ -382,6 +383,7 @@ function main(argv) {
382
383
  outils = outilsDe(racine);
383
384
  empreintes = empreintesDe(racine);
384
385
  donnees = donneesDe(racine);
386
+ matieresDeclareesDe(racine);
385
387
  } catch (e) {
386
388
  return refuser(`Une clé grillhouse du package.json est refusée :\n${e.message}`);
387
389
  }
@@ -250,6 +250,11 @@ export interface Composition {
250
250
  * whatever the task that bears it — the build task, or the test task with no report
251
251
  * (grillhouse-lv9). Every module answers it; a language with no compilation step answers false. */
252
252
  echecDeCompilation(texte: string): boolean;
253
+ /** The absolute path of the module the load failure `message` of the test file `fichier` names
254
+ * as absent, null when it names none: the proof of the red reads a test that imports a module
255
+ * the ticket creates as red, as a test target that does not compile. A language whose compiler
256
+ * bears it (`echecDeCompilation`) answers null. */
257
+ moduleAbsent(message: string, fichier: string): string | null;
253
258
  estUnTest(chemin: string, racine: string): ClasseDeTest;
254
259
  /** Whether the test file `chemin` (from `racine`) is out of the day, one that only the night
255
260
  * plays (a night test, a time budget bench, a time witness), by the module's own definitions;
@@ -97,6 +97,8 @@ export default {
97
97
  commandes,
98
98
  verdict,
99
99
  echecDeCompilation,
100
+ // A test that includes an absent header does not compile: `echecDeCompilation` bears it.
101
+ moduleAbsent: () => null,
100
102
  estUnTest,
101
103
  // No night test in C yet.
102
104
  horsDuJour: () => false,
@@ -50,7 +50,7 @@ export function squelette(_racine, { chemin }) {
50
50
  fichiers: {
51
51
  [`${chemin}/CMakeLists.txt`]: cmake,
52
52
  [`${chemin}/src/${fichier}.h`]: `#ifndef ${garde}\n#define ${garde}\n\n#endif\n`,
53
- [`${chemin}/src/${fichier}.c`]: `#include "${fichier}.h"\n\n/* A translation unit holds one declaration (ISO C): the first function of the package replaces it. */\ntypedef int ${fichier}_sans_code;\n`,
53
+ [`${chemin}/src/${fichier}.c`]: `#include "${fichier}.h"\n\n/* A translation unit holds one declaration (ISO C): the package's first function replaces it. */\ntypedef int ${fichier}_sans_code;\n`,
54
54
  [`${chemin}/tests/CMakeLists.txt`]: tests,
55
55
  [`${chemin}/.clang-format`]: 'BasedOnStyle: LLVM\nColumnLimit: 100\n',
56
56
  [`${chemin}/.clang-tidy`]: "Checks: '-*,bugprone-*,cert-*,clang-analyzer-*,misc-*'\nWarningsAsErrors: '*'\n",
@@ -139,6 +139,8 @@ export default {
139
139
  commandes,
140
140
  verdict,
141
141
  echecDeCompilation,
142
+ // A test that imports an absent module does not compile: `echecDeCompilation` bears it.
143
+ moduleAbsent: () => null,
142
144
  estUnTest,
143
145
  horsDuJour: fichierHorsDuJour,
144
146
  manifestes,
@@ -110,6 +110,8 @@ export default {
110
110
  verdict,
111
111
  // Python has no compilation step: no test task bears a compilation failure (jointure.d.ts).
112
112
  echecDeCompilation: () => false,
113
+ // No load failure of pytest is read as an absent module.
114
+ moduleAbsent: () => null,
113
115
  estUnTest,
114
116
  // A night test, `*_nuit_test.py` (`estDeNuit`).
115
117
  horsDuJour: chemin => estDeNuit(path.basename(chemin)),
@@ -61,6 +61,7 @@ import { garderLesResumes, lireLesResumes, resumesDuLancement } from './resume-d
61
61
  import { miseAJour } from './mise-a-jour.mjs';
62
62
  import { squelette } from './squelette.mjs';
63
63
  import { estHorsDuJour } from './vitest-config/cibles.mjs';
64
+ import { moduleAbsent } from './module-absent.mjs';
64
65
  import * as configVitest from './migrations/0.23.0-config-vitest.mjs';
65
66
  import * as nomsDeclaresInutilises from './migrations/0.24.4-noms-declares-inutilises.mjs';
66
67
  import * as lignesMalFormees from './migrations/0.24.6-lignes-mal-formees.mjs';
@@ -271,6 +272,8 @@ export default {
271
272
  verdict,
272
273
  // A build failure is already a red `build` task here; no test task bears a compilation failure.
273
274
  echecDeCompilation: () => false,
275
+ // The module a test file imports and Vitest did not find (./module-absent.mjs).
276
+ moduleAbsent,
274
277
  estUnTest,
275
278
  // A night test, a bench or a time witness (./vitest-config/cibles.mjs, `estHorsDuJour`).
276
279
  horsDuJour: (chemin, racine) => estHorsDuJour(path.resolve(racine, chemin)),
@@ -0,0 +1,24 @@
1
+ // The module a test file imports that Vitest did not find, read from the message of its load
2
+ // failure: the path the import names, resolved from the test file. A test written before its code
3
+ // imports the module the ticket creates; that load failure is its red, as a test target that does
4
+ // not compile is in a compiled language (`echecDeCompilation` of cargo and c). An import of a
5
+ // package (a bare name) is no module of the project: null.
6
+ import path from 'node:path';
7
+
8
+ const DE_VITEST = /Failed to load url (\S+) \(resolved id: [^)]*\)/;
9
+ const DE_NODE = /Cannot find module '([^']+)'/;
10
+
11
+ /**
12
+ * The absolute path of the module the load failure <message> of the test file <fichier> names as
13
+ * absent, or null when the message names none or names a package.
14
+ * @param {string} message
15
+ * @param {string} fichier
16
+ * @returns {string | null}
17
+ */
18
+ export function moduleAbsent(message, fichier) {
19
+ const nomme = (DE_VITEST.exec(message) ?? DE_NODE.exec(message))?.[1];
20
+ if (!nomme || !(nomme.startsWith('.') || path.isAbsolute(nomme))) {
21
+ return null;
22
+ }
23
+ return path.resolve(path.dirname(fichier), nomme);
24
+ }
@@ -67,6 +67,10 @@
67
67
  // root's task sets none, since `$TURBO_EXTENDS$` then extends an empty list; then
68
68
  // `$TURBO_ROOT$/<dir>/**` each) and waits, beside the root's `dependsOn`, for each trace whose
69
69
  // output one of them overlaps (`<producer>#trace:<name>`); the producer declares nothing for it.
70
+ // The patterns its test files declare they read (`// @lit <motif>` at their head,
71
+ // ./vitest-config/lances.mjs) are hashed with them (`$TURBO_ROOT$/<motif>` each, those `lit`
72
+ // already covers left out), a package without `lit` included: one declaration, read by the
73
+ // choice of the tests of a pass and by Turborepo's cache.
70
74
  // - `traces`: each trace the package produces, its command the package's script of the same name,
71
75
  // `trace:<name>`. Its task waits for `build` and `^build`, and for the traces its `lit` overlaps;
72
76
  // it hashes the package's files and its `lit`, its output left out, and Turborepo caches its
@@ -174,6 +178,7 @@ import {
174
178
  VARIABLE_TRAVAILLEURS as TRAVAILLEURS,
175
179
  } from '../../services-du-noyau.mjs';
176
180
  import { matieres } from './consommateurs.mjs';
181
+ import { lecturesDeclarees, testsDuPaquet } from './vitest-config/lances.mjs';
177
182
  import { parcourir } from './parcours.mjs';
178
183
  import { paquets, TYPAGE } from '../../paquets.mjs';
179
184
  import { ecrireSarif, RESULTATS } from '../../resultats.mjs';
@@ -717,6 +722,17 @@ function declarations(liste) {
717
722
  });
718
723
  }
719
724
 
725
+ // The patterns the test files of the package at <dossier> (absolute) declare they read (`// @lit`
726
+ // at their head, ./vitest-config/lances.mjs), each a glob from the root, those the paths <lit> of
727
+ // the package already cover left out; sorted.
728
+ function lecturesDesTests(dossier, lit) {
729
+ return [
730
+ ...new Set(testsDuPaquet(dossier).flatMap(t => lecturesDeclarees(readFileSync(t, 'utf8')))),
731
+ ]
732
+ .filter(m => !lit.some(l => m === l || m.startsWith(`${l}/`)))
733
+ .sort();
734
+ }
735
+
720
736
  // The text of a package's turbo.json, whose tasks are <taches>.
721
737
  const texte = taches =>
722
738
  `// Généré par \`${COMMANDE}\` depuis les package.json, le turbo.json racine et docs/agents/hors-cadre.txt ; ne pas éditer.\n${JSON.stringify(
@@ -821,12 +837,14 @@ export function attendus(racine) {
821
837
  }
822
838
  }
823
839
  const decl = decls.get(dossier);
824
- if (decl.lit.length) {
840
+ const declares = lecturesDesTests(path.join(racine, dossier), decl.lit);
841
+ if (decl.lit.length || declares.length) {
825
842
  taches[TESTS] = {
826
843
  dependsOn: [...deplier(deRacine.get(TESTS)?.dependsOn ?? []), ...jointes(decl.lit)],
827
844
  inputs: [
828
845
  base(TESTS),
829
846
  ...decl.lit.map(l => `$TURBO_ROOT$/${l}/**`),
847
+ ...declares.map(m => `$TURBO_ROOT$/${m}`),
830
848
  ...gitsExclus(decl.lit, sm),
831
849
  ],
832
850
  };
@@ -39,7 +39,9 @@
39
39
  // target of Bazel declares its `data`: a line `// @lit <motif> …` of the comment at its head,
40
40
  // each pattern a glob from the top of the repository (`// @lit packages/grillhouse/scripts/**`).
41
41
  // ./changements.mjs adds it to the tests of every pass, targeted or not, whose changes, files
42
- // changed, added or removed, one of its patterns covers.
42
+ // changed, added or removed, one of its patterns covers; the generator of the packages'
43
+ // turbo.json (../turbo-des-paquets.mjs) writes each pattern in the inputs of the package's test
44
+ // task, so that Turborepo's cache follows the same declaration.
43
45
  // - What a test names without the frame reading it (`nonDeclares`): a string of the test's code or
44
46
  // of its material that ends the path of a module of its package (`'verrou.mjs'`,
45
47
  // `'verrous/verrou.mjs'`), out of a directory of tests, the module out of what the test reads and
@@ -30,6 +30,7 @@ import { spawnSync } from 'node:child_process';
30
30
  import { createRequire } from 'node:module';
31
31
  import path from 'node:path';
32
32
  import { composer } from './composition-des-langages.mjs';
33
+ import { matieresDeclarees, sousUneMatiere } from './matieres-lues.mjs';
33
34
  import {
34
35
  ARCHITECTURE,
35
36
  COLONNE,
@@ -98,10 +99,31 @@ export function langagesDe(racine) {
98
99
  return noms.map(charger);
99
100
  }
100
101
 
102
+ // The class of a file under a folder of test material the project declares
103
+ // (`grillhouse.matieres`, ./matieres-cles.mjs): shared test material, never played.
104
+ const MATIERE_DECLAREE = Object.freeze({ joue: false, test: false, matiere: true });
105
+
106
+ // <langage> with the answer of `estUnTest` completed after its modules: the first answer not null
107
+ // of a module stays the file's; a file under a declared folder, in any language, is test material;
108
+ // any other file keeps the answer of its module.
109
+ const avecLesMatieres = langage =>
110
+ Object.assign(Object.create(langage), {
111
+ estUnTest: (chemin, racine) =>
112
+ langage.estUnTest(chemin, racine) ??
113
+ (sousUneMatiere(
114
+ matieresDeclarees(racine, d => langage.composants(d)),
115
+ racine,
116
+ chemin
117
+ )
118
+ ? MATIERE_DECLAREE
119
+ : null),
120
+ });
121
+
101
122
  const composes = new Map();
102
123
  /**
103
- * The join of the modules that serve the project at <racine> (`langagesDe`): the module itself
104
- * when the project declares one, else their composition, built once per list of languages.
124
+ * The join of the modules that serve the project at <racine> (`langagesDe`): their composition
125
+ * (the module itself when the project declares one), the folders of test material the project
126
+ * declares (`grillhouse.matieres`) added to `estUnTest`, built once per list of languages.
105
127
  * @param {string} racine the root of the project
106
128
  * @returns {import('./jointure.js').Composition}
107
129
  */
@@ -109,7 +131,7 @@ export function langageDe(racine) {
109
131
  const modules = langagesDe(racine);
110
132
  const cle = modules.map(m => m.nom).join('+');
111
133
  if (!composes.has(cle)) {
112
- composes.set(cle, composer(modules));
134
+ composes.set(cle, avecLesMatieres(composer(modules)));
113
135
  }
114
136
  return composes.get(cle);
115
137
  }