@roomi-fields/grillhouse 0.45.1 → 0.47.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 (114) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +52 -0
  3. package/cadre/templates/c/package.json +19 -0
  4. package/cadre/templates/projet/.github/workflows/ci.yml +34 -49
  5. package/cadre/templates/projet/.github/workflows/machine-vierge.yml +101 -0
  6. package/cadre/templates/projet/CLAUDE.md +28 -5
  7. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  8. package/charte.md +61 -23
  9. package/dist/temporal/circuit/appel.d.ts +7 -0
  10. package/dist/temporal/circuit/appel.js +17 -0
  11. package/dist/temporal/circuit/appel.js.map +1 -1
  12. package/dist/temporal/circuit/client.d.ts +28 -5
  13. package/dist/temporal/circuit/client.js +56 -13
  14. package/dist/temporal/circuit/client.js.map +1 -1
  15. package/dist/temporal/circuit/commande.js +16 -4
  16. package/dist/temporal/circuit/commande.js.map +1 -1
  17. package/dist/temporal/circuit/contrat.d.ts +22 -2
  18. package/dist/temporal/circuit/contrat.js +76 -0
  19. package/dist/temporal/circuit/contrat.js.map +1 -1
  20. package/dist/temporal/circuit/deroule.js +68 -11
  21. package/dist/temporal/circuit/deroule.js.map +1 -1
  22. package/dist/temporal/file/activites.d.ts +2 -0
  23. package/dist/temporal/file/activites.js +7 -0
  24. package/dist/temporal/file/activites.js.map +1 -1
  25. package/dist/temporal/file/contrat.d.ts +28 -18
  26. package/dist/temporal/file/contrat.js +8 -5
  27. package/dist/temporal/file/contrat.js.map +1 -1
  28. package/dist/temporal/file/deroule.d.ts +1 -1
  29. package/dist/temporal/file/deroule.js +91 -42
  30. package/dist/temporal/file/deroule.js.map +1 -1
  31. package/dist/temporal/tickets/activites.d.ts +1 -0
  32. package/dist/temporal/tickets/activites.js +37 -11
  33. package/dist/temporal/tickets/activites.js.map +1 -1
  34. package/dist/temporal/tickets/contrat.d.ts +14 -0
  35. package/dist/temporal/tickets/deroule.js +16 -3
  36. package/dist/temporal/tickets/deroule.js.map +1 -1
  37. package/docs/ARCHITECTURE.md +309 -128
  38. package/docs/INTERFACE.md +42 -22
  39. package/hooks/register.tsx +30 -0
  40. package/package.json +1 -1
  41. package/scripts/activites.mjs +60 -21
  42. package/scripts/arbres-juges.mjs +59 -0
  43. package/scripts/attente-a-l-arret.mjs +29 -52
  44. package/scripts/attente-au-tour.mjs +8 -26
  45. package/scripts/avancement.mjs +2 -38
  46. package/scripts/branche-de-nuit.mjs +14 -45
  47. package/scripts/ci-de-main.mjs +273 -0
  48. package/scripts/circuit.mjs +204 -64
  49. package/scripts/circuits-cles.d.mts +9 -0
  50. package/scripts/circuits-cles.mjs +38 -0
  51. package/scripts/coeurs-dedies.mjs +4 -3
  52. package/scripts/dernier-vert.mjs +78 -10
  53. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -2
  54. package/scripts/etapes.mjs +7 -2
  55. package/scripts/faits-du-circuit.mjs +63 -28
  56. package/scripts/fichiers-nommes.mjs +55 -0
  57. package/scripts/file-des-tickets.d.mts +17 -0
  58. package/scripts/file-des-tickets.mjs +39 -0
  59. package/scripts/grillhouse-maj.mjs +20 -1
  60. package/scripts/integration/file.mjs +137 -592
  61. package/scripts/integration/integrer.mjs +10 -7
  62. package/scripts/langages/c/binaires.json +4 -0
  63. package/scripts/langages/c/binaires.mjs +83 -0
  64. package/scripts/langages/c/clang-format.mjs +62 -0
  65. package/scripts/langages/c/clang-tidy.mjs +93 -0
  66. package/scripts/langages/c/clang.mjs +42 -0
  67. package/scripts/langages/c/commandes.mjs +530 -0
  68. package/scripts/langages/c/composants.mjs +209 -0
  69. package/scripts/langages/c/exemples.mjs +250 -0
  70. package/scripts/langages/c/index-interfaces.mjs +77 -0
  71. package/scripts/langages/c/index.mjs +120 -0
  72. package/scripts/langages/c/lot.mjs +41 -0
  73. package/scripts/langages/c/mise-a-jour.mjs +70 -0
  74. package/scripts/langages/c/squelette.mjs +61 -0
  75. package/scripts/langages/c/verdict.mjs +99 -0
  76. package/scripts/langages/cargo/clippy.mjs +16 -9
  77. package/scripts/langages/cargo/commandes.mjs +7 -2
  78. package/scripts/langages/cargo/sccache.mjs +19 -6
  79. package/scripts/langages/typescript/tests.mjs +31 -5
  80. package/scripts/langages/typescript/turbo-des-paquets.mjs +67 -8
  81. package/scripts/langages/typescript/vitest-config/changements.mjs +32 -3
  82. package/scripts/langages/typescript/vitest-config/lances.mjs +16 -0
  83. package/scripts/langages-des-paquets.mjs +30 -2
  84. package/scripts/langages.mjs +1 -0
  85. package/scripts/limite-d-usage.mjs +88 -0
  86. package/scripts/mesure/avancement.mjs +1 -1
  87. package/scripts/migrations/0.47.0-ci-de-main.mjs +48 -0
  88. package/scripts/migrations.mjs +2 -2
  89. package/scripts/outils-cles.d.mts +13 -5
  90. package/scripts/outils-cles.mjs +157 -17
  91. package/scripts/passe-de-la-machine.mjs +26 -2
  92. package/scripts/places-de-la-machine.mjs +52 -6
  93. package/scripts/plafond-de-la-machine.d.mts +10 -2
  94. package/scripts/plafond-de-la-machine.mjs +39 -13
  95. package/scripts/reponses-du-circuit.d.mts +16 -0
  96. package/scripts/reponses-du-circuit.mjs +39 -3
  97. package/scripts/resultats.mjs +32 -11
  98. package/scripts/seances.mjs +211 -59
  99. package/scripts/session-start.sh +2 -11
  100. package/scripts/sortie.mjs +1 -1
  101. package/scripts/sous-commandes.mjs +5 -2
  102. package/scripts/superviseur.mjs +305 -295
  103. package/scripts/tableau.mjs +73 -45
  104. package/scripts/transitions.d.mts +22 -1
  105. package/scripts/transitions.mjs +111 -13
  106. package/scripts/workflows-du-cadre.mjs +21 -1
  107. package/skills/explorateur/SKILL.md +34 -13
  108. package/skills/grill/SKILL.md +6 -5
  109. package/skills/pitmaster/SKILL.md +33 -27
  110. package/skills/redacteur/references/documents-d-un-composant.md +1 -1
  111. package/skills/relecteur/SKILL.md +6 -0
  112. package/skills/testwriter/SKILL.md +4 -0
  113. package/scripts/ci-des-branches.mjs +0 -93
  114. package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +0 -31
@@ -0,0 +1,41 @@
1
+ // The changes of a project of C read by git: the elements of a lot (`elementsDuLot`).
2
+ //
3
+ // - The lot between two commits (`git diff --name-only --no-renames <avant> <apres>`): every file
4
+ // it changes in `fichiers`; the module reads no element of a source of C, so each `.c` and `.h`
5
+ // is named in `horsDuService`, which the reviewer surveys himself.
6
+ import { spawnSync } from 'node:child_process';
7
+
8
+ const lignesDeGit = (racine, args) => {
9
+ const r = spawnSync('git', ['-C', racine, ...args, '-z'], {
10
+ encoding: 'utf8',
11
+ maxBuffer: 256 * 1024 * 1024,
12
+ });
13
+ if (r.status !== 0) {
14
+ throw new Error(`⛔ git ${args.join(' ')} : ${r.stderr.trim()}`);
15
+ }
16
+ return r.stdout.split('\0').filter(Boolean);
17
+ };
18
+
19
+ /** The elements of the lot of <racine> between <avant> and <apres>. */
20
+ export function elementsDuLot(racine, { avant, apres }) {
21
+ try {
22
+ const fichiers = [
23
+ ...new Set(lignesDeGit(racine, ['diff', '--name-only', '--no-renames', avant, apres])),
24
+ ].sort();
25
+ return {
26
+ etat: 'fait',
27
+ raison: null,
28
+ elements: [],
29
+ horsDuService: fichiers.filter(f => /\.[ch]$/.test(f)),
30
+ fichiers,
31
+ };
32
+ } catch (e) {
33
+ return {
34
+ etat: 'impossible',
35
+ raison: `erreur : ${String(e.message).split('\n')[0]}`,
36
+ elements: [],
37
+ horsDuService: [],
38
+ fichiers: [],
39
+ };
40
+ }
41
+ }
@@ -0,0 +1,70 @@
1
+ // What the module c brings to the update of a project (`grillhouse maj`,
2
+ // scripts/grillhouse-maj.mjs), the demand `miseAJour` of the join (scripts/jointure.d.ts).
3
+ //
4
+ // - The template: `templates/c/` of the frame's files. Its package.json gives the frame's
5
+ // scripts, which run the frame's commands, and Turborepo, which plays the tasks of the projects.
6
+ // - `turbo.json`, which a project lacks, from the frame's template of its form (`TURBO`).
7
+ // - The root scripts `test`, `test:forcer` and `verifier` a project lacks become the template's;
8
+ // a project's own script stays.
9
+ // - The generator: the index of the interfaces (./index-interfaces.mjs), run where the project
10
+ // holds it, as the module python's.
11
+ // - The installation of uv and the clang tools (./binaires.json) by the commands of ./binaires.mjs,
12
+ // which the core runs; cmake and ctest are the poste's, required of it (`executables`).
13
+ import path from 'node:path';
14
+ import { fileURLToPath } from 'node:url';
15
+ import { poserLeGabaritAbsent } from '../../services-du-noyau.mjs';
16
+ import { SORTIE } from './index-interfaces.mjs';
17
+
18
+ const BINAIRES = path.join(path.dirname(fileURLToPath(import.meta.url)), 'binaires.mjs');
19
+ const GABARIT = 'templates/c';
20
+ const SCRIPTS_DES_TESTS = ['test', 'test:forcer', 'verifier'];
21
+ // The frame's templates of `turbo.json`, one per form of repository.
22
+ const TURBO = {
23
+ fichier: 'turbo.json',
24
+ avecEspaces: 'templates/turbo/paquets.json',
25
+ sansEspaces: 'templates/turbo/sans-paquets.json',
26
+ };
27
+
28
+ /** @type {import('../../jointure.js').MiseAJour['appliquer']} */
29
+ function appliquer(projet, { p, modele, source }) {
30
+ const turbo = poserLeGabaritAbsent(projet, source, p, TURBO);
31
+ p.scripts ??= {};
32
+ const scripts = [];
33
+ for (const nom of SCRIPTS_DES_TESTS) {
34
+ const script = modele.scripts?.[nom];
35
+ if (typeof script !== 'string' || typeof p.scripts[nom] === 'string') {
36
+ continue;
37
+ }
38
+ p.scripts[nom] = script;
39
+ scripts.push(nom);
40
+ }
41
+ return {
42
+ bilan: { scripts: scripts.length > 0 ? scripts : null, turbo },
43
+ lignes: [
44
+ ...(turbo
45
+ ? [
46
+ `turbo.json écrit depuis le gabarit du cadre ${turbo} ; il est au projet, la mise à jour n'y touche plus.`,
47
+ ]
48
+ : []),
49
+ ...(scripts.length > 0
50
+ ? [
51
+ `Scripts des tests : ${scripts.map(n => `${n} (\`${p.scripts[n]}\`)`).join(', ')} écrits ; les agents lancent \`npm test\`, l'intégration et la nuit \`npm run verifier\`.`,
52
+ ]
53
+ : []),
54
+ ],
55
+ aFaire: [],
56
+ installer: false,
57
+ sansVerifier: null,
58
+ };
59
+ }
60
+
61
+ /** The share of the module c in the update. */
62
+ export const miseAJour = {
63
+ gabarit: GABARIT,
64
+ appliquer,
65
+ generateurs: [{ commande: 'index-interfaces', args: [], sortie: SORTIE }],
66
+ installation: {
67
+ liste: { script: BINAIRES, args: ['liste'] },
68
+ installer: (nom, version) => ({ script: BINAIRES, args: ['installer', `${nom}@${version}`] }),
69
+ },
70
+ };
@@ -0,0 +1,61 @@
1
+ // The skeleton of a new package of the module c, the demand `squelette` of the join
2
+ // (scripts/jointure.d.ts), which `grillhouse paquet` writes (scripts/paquet.mjs), as `cmake`
3
+ // projects and `cargo new --lib` write one: no behaviour, no test.
4
+ //
5
+ // - Its name: the folder's, the name of its `project()`; its files of source are
6
+ // `src/<nom>.h` and `src/<nom>.c`, the name with `-` and `.` read `_`.
7
+ // - Its CMakeLists.txt: C99 strict (`CMAKE_C_STANDARD 99`, required, extensions off), the warnings
8
+ // `-Wall -Wextra -Wpedantic -Werror`, a static library of its one source, `enable_testing()` and
9
+ // `add_subdirectory(tests)`.
10
+ // - Its `tests/CMakeLists.txt`, written once: it takes every `tests/test_*.c` present
11
+ // (`file(GLOB … CONFIGURE_DEPENDS)`), one executable and one CTest test each, named as the file
12
+ // without its extension; the testwriter adds a file, never edits it.
13
+ // - The workspace and the lock: none, CMake has neither; the entry of the package in the
14
+ // `workspaces` of the root package.json is the core's (scripts/paquet-npm.mjs).
15
+ import path from 'node:path';
16
+
17
+ /** @type {import('../../jointure.js').Langage['squelette']} */
18
+ export function squelette(_racine, { chemin }) {
19
+ const nom = path.posix.basename(chemin);
20
+ const fichier = nom.replace(/[-.]/g, '_');
21
+ const garde = `${fichier.toUpperCase()}_H`;
22
+ const cmake = [
23
+ 'cmake_minimum_required(VERSION 3.16)',
24
+ `project(${nom} C)`,
25
+ '',
26
+ 'set(CMAKE_C_STANDARD 99)',
27
+ 'set(CMAKE_C_STANDARD_REQUIRED ON)',
28
+ 'set(CMAKE_C_EXTENSIONS OFF)',
29
+ 'add_compile_options(-Wall -Wextra -Wpedantic -Werror)',
30
+ '',
31
+ `add_library(${nom} STATIC src/${fichier}.c)`,
32
+ `target_include_directories(${nom} PUBLIC src)`,
33
+ '',
34
+ 'enable_testing()',
35
+ 'add_subdirectory(tests)',
36
+ '',
37
+ ].join('\n');
38
+ const tests = [
39
+ '# Every test_*.c of this folder is one executable and one CTest test of the same name.',
40
+ 'file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/test_*.c")',
41
+ 'foreach(source IN LISTS TEST_SOURCES)',
42
+ ' get_filename_component(test_name "${source}" NAME_WE)',
43
+ ' add_executable(${test_name} "${source}")',
44
+ ` target_link_libraries(\${test_name} PRIVATE ${nom})`,
45
+ ' add_test(NAME ${test_name} COMMAND ${test_name})',
46
+ 'endforeach()',
47
+ '',
48
+ ].join('\n');
49
+ return {
50
+ fichiers: {
51
+ [`${chemin}/CMakeLists.txt`]: cmake,
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`,
54
+ [`${chemin}/tests/CMakeLists.txt`]: tests,
55
+ [`${chemin}/.clang-format`]: 'BasedOnStyle: LLVM\nColumnLimit: 100\n',
56
+ [`${chemin}/.clang-tidy`]: "Checks: '-*,bugprone-*,cert-*,clang-analyzer-*,misc-*'\nWarningsAsErrors: '*'\n",
57
+ },
58
+ espace: null,
59
+ verrouiller: [],
60
+ };
61
+ }
@@ -0,0 +1,99 @@
1
+ // The verdict of a run of the module c, the demand `verdict` of the join (scripts/jointure.d.ts):
2
+ // what ./commandes.mjs left in the results directory of a pass (`GRILLHOUSE_RESULTATS`,
3
+ // scripts/resultats.mjs).
4
+ //
5
+ // - The tasks are those of the summary of the task runner (`tachesDuVerdict`,
6
+ // scripts/taches-du-graphe.mjs), a package the cache replayed included (`code` 0, no report); a
7
+ // task below that the summary lacks is added.
8
+ // - `<dossier>/c/<run>.json`, one per run: `{ taches, rapports }`, each task as the join types it
9
+ // (`code` null for a task planned that did not run; `tests` true for a run of CTest), and the
10
+ // folder of the package of each JUnit report by its file's name.
11
+ // - `<dossier>/ctest/<run>-<paquet>.xml`, the JUnit report CTest wrote (`--output-junit`), kept as
12
+ // it is: a `testcase` by CTest test, `test_<nom>` the test of the file `tests/test_<nom>.c` of
13
+ // the package; each file gives a report, each case a test, failed when it holds a `failure`,
14
+ // skipped when it holds `skipped`; its message the output of the test (`system-out`), else the
15
+ // failure's.
16
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
17
+ import path from 'node:path';
18
+ import { tachesDuVerdict } from '../../services-du-noyau.mjs';
19
+
20
+ export const TACHES = 'c';
21
+ export const JUNIT = 'ctest';
22
+
23
+ const fichiers = (dossier, extension) =>
24
+ existsSync(dossier)
25
+ ? readdirSync(dossier)
26
+ .filter(f => f.endsWith(extension))
27
+ .sort()
28
+ : [];
29
+ const lireJson = f => {
30
+ try {
31
+ return JSON.parse(readFileSync(f, 'utf8'));
32
+ } catch {
33
+ return null;
34
+ }
35
+ };
36
+
37
+ const ENTITES = { lt: '<', gt: '>', amp: '&', quot: '"', apos: "'" };
38
+ // The text <t> of XML, its entities read.
39
+ const texte = t =>
40
+ t.replace(/&(#x[0-9a-f]+|#\d+|\w+);/gi, (m, e) => {
41
+ if (e[0] === '#') {
42
+ return String.fromCodePoint(e[1] === 'x' ? parseInt(e.slice(2), 16) : Number(e.slice(1)));
43
+ }
44
+ return ENTITES[e] ?? m;
45
+ });
46
+ // The attribute <nom> of the opening tag <balise>, its text, or null.
47
+ const attribut = (balise, nom) => {
48
+ const m = new RegExp(`\\s${nom}="([^"]*)"`).exec(balise);
49
+ return m ? texte(m[1]) : null;
50
+ };
51
+
52
+ /**
53
+ * The cases of the JUnit report <xml> of CTest: `{ nom, etat, message }` each.
54
+ * @param {string} xml
55
+ */
56
+ export function casDuRapport(xml) {
57
+ const cas = [];
58
+ for (const c of xml.matchAll(/<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g)) {
59
+ const corps = c[2] ?? '';
60
+ const echec = /<(failure|error)\b([^>]*?)(?:\/>|>([\s\S]*?)<\/\1>)/.exec(corps);
61
+ const etat = echec ? 'failed' : /<skipped\b/.test(corps) ? 'skipped' : 'passed';
62
+ const sortie = /<system-out>([\s\S]*?)<\/system-out>/.exec(corps);
63
+ const message = echec
64
+ ? texte(sortie?.[1] ?? '').trim() || (attribut(echec[2], 'message') ?? '')
65
+ : '';
66
+ cas.push({ nom: attribut(c[1], 'name') ?? '', etat, message });
67
+ }
68
+ return cas;
69
+ }
70
+
71
+ // The reports of the JUnit report <xml> of the package at <dossier>, one per file of test.
72
+ function rapportsDe(xml, dossier) {
73
+ return casDuRapport(xml).map(({ nom, etat, message }) => ({
74
+ fichier: path.join(dossier, 'tests', `${nom}.c`),
75
+ etat: etat === 'failed' ? 'failed' : 'passed',
76
+ message: '',
77
+ tests: [{ titre: nom, nom, etat, message }],
78
+ }));
79
+ }
80
+
81
+ /**
82
+ * The verdict the results directory <dossier> holds: `{ rapports, taches }`.
83
+ * @param {string} dossier the results directory of a pass
84
+ */
85
+ export function verdict(dossier) {
86
+ const runs = fichiers(path.join(dossier, TACHES), '.json')
87
+ .map(f => lireJson(path.join(dossier, TACHES, f)))
88
+ .filter(Boolean);
89
+ const dossiers = Object.assign({}, ...runs.map(r => r.rapports ?? {}));
90
+ return {
91
+ rapports: fichiers(path.join(dossier, JUNIT), '.xml')
92
+ .filter(f => dossiers[f])
93
+ .flatMap(f => rapportsDe(readFileSync(path.join(dossier, JUNIT, f), 'utf8'), dossiers[f])),
94
+ taches: tachesDuVerdict(
95
+ dossier,
96
+ runs.flatMap(r => r.taches ?? [])
97
+ ),
98
+ };
99
+ }
@@ -85,15 +85,22 @@ export function commande(racine, { env = process.env } = {}) {
85
85
  process.stderr.write(`${absent}\n`);
86
86
  return 1;
87
87
  }
88
- demarrerLeServeur(racine, env);
89
- const r = spawnSync('cargo', ARGS, {
90
- cwd: racine,
91
- env: avecSccache(racine, env),
92
- encoding: 'utf8',
93
- maxBuffer: 256 * 1024 * 1024,
94
- });
95
- const constats = r.error ? [] : constatsDeClippy(r.stdout ?? '', racine);
96
- if (r.error || (r.status !== 0 && constats.length === 0)) {
88
+ const serveur = demarrerLeServeur(racine, env);
89
+ // A server that does not answer is a finding refused, cargo never run.
90
+ const r = serveur
91
+ ? null
92
+ : spawnSync('cargo', ARGS, {
93
+ cwd: racine,
94
+ env: avecSccache(racine, env),
95
+ encoding: 'utf8',
96
+ maxBuffer: 256 * 1024 * 1024,
97
+ });
98
+ const constats = serveur
99
+ ? [{ message: serveur.replace(/^⛔ /, '') }]
100
+ : r.error
101
+ ? []
102
+ : constatsDeClippy(r.stdout ?? '', racine);
103
+ if (r && (r.error || (r.status !== 0 && constats.length === 0))) {
97
104
  const fin = r.error?.message ?? (r.stderr ?? '').trim().split('\n').at(-1) ?? '';
98
105
  constats.push({ message: `cargo clippy rouge (code ${r.status ?? r.signal}) : ${fin}` });
99
106
  }
@@ -311,8 +311,13 @@ function passe(racine, env) {
311
311
  rmSync(junit, { force: true });
312
312
  }
313
313
  // The server of sccache, started under a short temporary directory (./sccache.mjs).
314
- if (COMPILATIONS.includes(args[0])) {
315
- demarrerLeServeur(racine, env);
314
+ // A server that does not answer stops the task before cargo, the line printed.
315
+ const serveur = COMPILATIONS.includes(args[0]) ? demarrerLeServeur(racine, env) : null;
316
+ if (serveur) {
317
+ process.stderr.write(`${serveur}\n`);
318
+ t.code = 1;
319
+ ecrire();
320
+ return t.code;
316
321
  }
317
322
  const banc = t.script === BUDGET;
318
323
  const avant = banc ? pression() : null;
@@ -159,18 +159,31 @@ export function sccacheAbsent(racine, env) {
159
159
  /**
160
160
  * Starts the server of sccache of the copy at <racine> under <env> (`avecSccache`), under the
161
161
  * machine's temporary directory (`COURT`), unless the project sets its own wrapper; a server
162
- * already running stays, and its refusal of a second one is no failure.
162
+ * already running stays, and its refusal of a second one is no failure. The server is judged
163
+ * reachable by what sccache answers: after the start, `sccache --show-stats` under the same
164
+ * environment interrogates it.
163
165
  * @param {string} racine
164
166
  * @param {NodeJS.ProcessEnv} env the environment before `avecSccache`
167
+ * @returns {string | null} the line that refuses the run, naming the start of the server and
168
+ * carrying the outputs of the start and of the interrogation; null when the server answers, or
169
+ * when the project sets its own wrapper
165
170
  */
166
171
  export function demarrerLeServeur(racine, env) {
167
172
  if (lanceurDuProjet(racine, env)) {
168
- return;
173
+ return null;
174
+ }
175
+ const sous = { env: { ...avecSccache(racine, env), TMPDIR: COURT }, encoding: 'utf8' };
176
+ const demarrage = spawnSync('sccache', ['--start-server'], sous);
177
+ const interrogation = spawnSync('sccache', ['--show-stats'], sous);
178
+ if (!interrogation.error && interrogation.status === 0) {
179
+ return null;
169
180
  }
170
- spawnSync('sccache', ['--start-server'], {
171
- env: { ...avecSccache(racine, env), TMPDIR: COURT },
172
- stdio: 'ignore',
173
- });
181
+ const dit = (nom, r) =>
182
+ `${nom} (code ${r.status ?? r.signal}) : ${[r.error?.message, r.stdout, r.stderr]
183
+ .filter(Boolean)
184
+ .join(' ')
185
+ .trim()}`;
186
+ return `⛔ démarrage du serveur sccache refusé : le serveur ne répond pas ; ${dit('--start-server', demarrage)} ; ${dit('--show-stats', interrogation)}`;
174
187
  }
175
188
 
176
189
  /**
@@ -23,7 +23,10 @@
23
23
  // counts them in the hash of every task of the run (its documentation, « Caching »: « including
24
24
  // dependencies of `build` that did not receive `--arg=value` »), where a variable of a task's
25
25
  // `env` enters that task's hash alone. So a run with paths is one Turborepo run of the tests with
26
- // what they depend on (`turbo run test:unit --filter=<name>`): the builds and the traces they
26
+ // what they depend on (`turbo run test:unit --filter=<name>`); a package named whole (the exact
27
+ // folder of a package) carries no path: it plays under the hash of the complete pass, and a run
28
+ // that mixes it with files of another package is two runs, the code the first that is not 0:
29
+ // the builds and the traces they
27
30
  // wait for play first, from the cache when nothing moved, whatever paths are named, and the hash
28
31
  // of the tests holds theirs, as Bazel's key of a target holds its transitive inputs; a change to
29
32
  // a package the tests import, or to what they read, plays them again. Every other run of
@@ -230,6 +233,9 @@ const lancer = () => {
230
233
  const refus = [];
231
234
  const noms = new Set();
232
235
  const absolus = [];
236
+ // The packages named whole (the exact folder of a package): they play under the hash of the
237
+ // complete pass, as Bazel's `//pkg/...` shares the cache of `//...`.
238
+ const entiers = new Set();
233
239
  for (const chemin of chemins) {
234
240
  const abs = path.resolve(racine, chemin);
235
241
  const p = liste.find(({ dossier }) =>
@@ -246,6 +252,10 @@ const lancer = () => {
246
252
  } else if (typeof p.pkg.scripts?.[SCRIPT_DES_TESTS] !== 'string') {
247
253
  refus.push(`⛔ ${chemin} : ${p.dossier} n'a pas de script ${SCRIPT_DES_TESTS}.`);
248
254
  } else {
255
+ if (abs === path.join(racine, p.dossier)) {
256
+ entiers.add(p.pkg.name);
257
+ continue;
258
+ }
249
259
  noms.add(p.pkg.name);
250
260
  // A directory ends with « / »: Vitest matches the start of a path, and packages/a is the start
251
261
  // of packages/ab.
@@ -259,10 +269,26 @@ const lancer = () => {
259
269
  }
260
270
  return 2;
261
271
  }
262
- return cibles(
263
- [...noms].sort().map(n => `--filter=${n}`),
264
- [...absolus, ...options]
265
- );
272
+ // The whole packages play with no path in the variable (only the options and the moment of
273
+ // `--force`); the files play in a run of their own. The code is the first that is not 0.
274
+ const codes = [];
275
+ if (entiers.size) {
276
+ codes.push(
277
+ cibles(
278
+ [...entiers].sort().map(n => `--filter=${n}`),
279
+ options
280
+ )
281
+ );
282
+ }
283
+ if (noms.size) {
284
+ codes.push(
285
+ cibles(
286
+ [...noms].sort().map(n => `--filter=${n}`),
287
+ [...absolus, ...options]
288
+ )
289
+ );
290
+ }
291
+ return codes.find(c => c !== 0) ?? 0;
266
292
  };
267
293
 
268
294
  try {
@@ -324,14 +324,30 @@ const POURQUOI = {
324
324
  };
325
325
  // The variables of the tools of the project at <racine> (`grillhouse.outils` of its package.json,
326
326
  // scripts/outils-cles.mjs), in the order it declares them: the paths of tools outside the
327
- // repository its tests demand, which the run passes to every task without hashing them. A key
328
- // that is no variable name is the guard of the tools' (`grillhouse outil`), not this one's.
327
+ // repository its tests demand, which the run passes to every task without hashing them; a tool
328
+ // declared hashed by content (`{ chemin, contenu: true }`) is not among them: its fingerprint is
329
+ // (`empreintesDOutils`). A key that is no variable name is the guard of the tools' (`grillhouse
330
+ // outil`), not this one's.
329
331
  function variablesDOutils(racine) {
332
+ return lesOutils(racine).filter(([, haché]) => !haché).map(([n]) => n);
333
+ }
334
+ // The variables `<VARIABLE>_EMPREINTE` of the tools of the project at <racine> declared hashed by
335
+ // content, in the order the key declares them: the root's `globalEnv` names them, Turborepo
336
+ // hashing the value of a variable it declares (the value scripts/outils-cles.mjs gives each pass).
337
+ function empreintesDOutils(racine) {
338
+ return lesOutils(racine)
339
+ .filter(([, haché]) => haché)
340
+ .map(([n]) => `${n}_EMPREINTE`);
341
+ }
342
+ // The tools of the project at <racine>, `[variable, hashed by content]` in the order of the key.
343
+ function lesOutils(racine) {
330
344
  try {
331
345
  const o = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8')).grillhouse
332
346
  ?.outils;
333
347
  return o && typeof o === 'object' && !Array.isArray(o)
334
- ? Object.keys(o).filter(n => /^[A-Za-z_][A-Za-z0-9_]*$/.test(n))
348
+ ? Object.entries(o)
349
+ .filter(([n]) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(n))
350
+ .map(([n, v]) => [n, v !== null && typeof v === 'object' && v.contenu === true])
335
351
  : [];
336
352
  } catch {
337
353
  return [];
@@ -654,16 +670,27 @@ function entreesBuild(racine, dossier, pkg, sm) {
654
670
  // example of Rust names them (rust.mdx § Caching behavior), none of TypeScript's. A crate: its
655
671
  // folder (Turborepo's default), then the Cargo.lock and the Cargo.toml of the root, the lock and
656
672
  // the manifest of its workspace. A project of Python: its folder, which holds its own uv.lock and
657
- // pyproject.toml, then the ones of the root when it has them (a workspace of uv).
673
+ // pyproject.toml, then the ones of the root when it has them (a workspace of uv). A package of C:
674
+ // its folder alone. An unknown language is a fault, named.
658
675
  function entreesDeBuildHorsJs(racine, langageNom) {
659
676
  const racineDe = f => `$TURBO_ROOT$/${f}`;
660
677
  if (langageNom === 'cargo') {
661
678
  return ['$TURBO_DEFAULT$', racineDe('Cargo.lock'), racineDe('Cargo.toml')];
662
679
  }
663
- return [
664
- '$TURBO_DEFAULT$',
665
- ...['pyproject.toml', 'uv.lock'].filter(f => existsSync(path.join(racine, f))).map(racineDe),
666
- ];
680
+ if (langageNom === 'python') {
681
+ return [
682
+ '$TURBO_DEFAULT$',
683
+ ...['pyproject.toml', 'uv.lock'].filter(f => existsSync(path.join(racine, f))).map(racineDe),
684
+ ];
685
+ }
686
+ // A package of C: its folder alone, which holds its CMakeLists.txt; it has no lock and no root
687
+ // manifest.
688
+ if (langageNom === 'c') {
689
+ return ['$TURBO_DEFAULT$'];
690
+ }
691
+ throw new Error(
692
+ `⛔ entrées de build : langage inconnu du générateur de turbo.json, ${langageNom}`
693
+ );
667
694
  }
668
695
 
669
696
  // The data and traces each package of the frame declares in its package.json:
@@ -913,6 +940,19 @@ function passagesManquants(racine) {
913
940
  return manques.length ? { f: r.f, attendu: [...actuel, ...manques], manques } : null;
914
941
  }
915
942
 
943
+ // The `globalEnv` the root's turbo.json at <racine> must hold, the fingerprint of each tool hashed
944
+ // by content it lacks added to the project's: { f, attendu, manques }; null when it holds them,
945
+ // without a root configuration, and when it is no JSON.
946
+ function empreintesManquantes(racine) {
947
+ const r = confRacine(racine);
948
+ if (!r) {
949
+ return null;
950
+ }
951
+ const actuel = Array.isArray(r.conf.globalEnv) ? r.conf.globalEnv : [];
952
+ const manques = empreintesDOutils(racine).filter(v => !actuel.includes(v));
953
+ return manques.length ? { f: r.f, attendu: [...actuel, ...manques], manques } : null;
954
+ }
955
+
916
956
  // The inputs of the root's turbo.json at <racine> that can reach the `.git` of a submodule its
917
957
  // .gitmodules declares (a pattern under `$TURBO_ROOT$/` of a task, or a global dependency, whose
918
958
  // fixed part is the submodule or holds it, then a glob) without its exclusion beside them:
@@ -1019,6 +1059,19 @@ export function ecrire(racine) {
1019
1059
  ecrits.push(passage.f);
1020
1060
  }
1021
1061
  }
1062
+ const empreintes = empreintesManquantes(racine);
1063
+ if (empreintes) {
1064
+ const abs = path.join(racine, empreintes.f);
1065
+ const texte = readFileSync(abs, 'utf8');
1066
+ const chemin = ['globalEnv'];
1067
+ writeFileSync(
1068
+ abs,
1069
+ applyEdits(texte, modify(texte, chemin, empreintes.attendu, MISE_EN_FORME))
1070
+ );
1071
+ if (!ecrits.includes(empreintes.f)) {
1072
+ ecrits.push(empreintes.f);
1073
+ }
1074
+ }
1022
1075
  const gits = gitsAbsents(racine);
1023
1076
  if (gits) {
1024
1077
  const abs = path.join(racine, gits.f);
@@ -1220,6 +1273,12 @@ export function verifier(racine) {
1220
1273
  `⛔ ${passage.f} : \`globalPassThroughEnv\` doit nommer ${v}, ${POURQUOI[v] ?? (variablesDeDonnees(racine).includes(v) ? "la donnée d'un paquet (`grillhouse.donnees`) que ses tests exigent" : "l'outil du projet (`grillhouse.outils`) que ses tests exigent")} ; \`${COMMANDE}\` l'ajoute.`
1221
1274
  );
1222
1275
  }
1276
+ const empreintes = empreintesManquantes(racine);
1277
+ for (const v of empreintes?.manques ?? []) {
1278
+ refus.push(
1279
+ `⛔ ${empreintes.f} : \`globalEnv\` doit nommer ${v}, l'empreinte du contenu d'un outil du projet déclaré haché (\`grillhouse.outils\`, \`contenu: true\`), dont Turborepo hache la valeur ; \`${COMMANDE}\` l'ajoute.`
1280
+ );
1281
+ }
1223
1282
  for (const { cle, attendu, present } of gardesEcartees(racine)?.ecarts ?? []) {
1224
1283
  const f = fichierRacine(racine);
1225
1284
  refus.push(
@@ -46,6 +46,11 @@
46
46
  // 7. a file of the package that no graph can hold, its extension not that of a module (`.js`,
47
47
  // `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`, `.jsx`, `.tsx`, `.json`): data, a template, a
48
48
  // script of the shell, a document, which a test reads without importing it.
49
+ // A file the measure classes without effect (`sansEffet`, scripts/dernier-vert.mjs: a document, or
50
+ // a file of code whose isolated transpilation, comments removed, is identical to the last
51
+ // green's) relates no test through the graph and triggers neither 6 nor 7, as Gradle's compile
52
+ // avoidance stops a build whose output is identical; 5, the tests that declare they read it
53
+ // (`@lit`) and, out of the mark `cible`, the tests that read it by its path keep their rule.
49
54
  // Vitest's own `forceRerunTriggers` (a configuration's, or its default) still apply, as with
50
55
  // `--changed`. Under the mark `cible`, 5 and 7 do not play the package whole, and no test is
51
56
  // related by the paths it reads (`testsQuiLancent`): the tests Vitest relates alone, the tests
@@ -70,7 +75,7 @@ import { existsSync, readFileSync, realpathSync } from 'node:fs';
70
75
  import { createRequire } from 'node:module';
71
76
  import path from 'node:path';
72
77
  import { fileURLToPath } from 'node:url';
73
- import { testsQuiDeclarent, testsQuiLancent } from './lances.mjs';
78
+ import { testsQuiDeclarent, testsQuiLancent, testsQuiNomment } from './lances.mjs';
74
79
 
75
80
  // This directory, the frame's base configuration.
76
81
  const BASE = path.dirname(fileURLToPath(import.meta.url));
@@ -107,6 +112,7 @@ export function lireChangements(chemin) {
107
112
  typeof c.racine !== 'string' ||
108
113
  !liste(c.fichiers) ||
109
114
  !liste(c.supprimes) ||
115
+ (c.sansEffet !== undefined && !liste(c.sansEffet)) ||
110
116
  (c.cible !== undefined && typeof c.cible !== 'boolean')
111
117
  ) {
112
118
  return null;
@@ -240,6 +246,15 @@ function paquetEntier(ch, dossier, test = {}) {
240
246
  return { raison, fichier: f };
241
247
  }
242
248
  }
249
+ // A file without effect on the output keeps rule 5 alone: a test that declares it reads the
250
+ // path reads its text, not its output.
251
+ if (!ch.cible) {
252
+ for (const f of ch.sansEffet ?? []) {
253
+ if (lit.some(l => f === l || f.startsWith(`${l}/`))) {
254
+ return { raison: 'un chemin que ses tests déclarent lire (grillhouse.lit)', fichier: f };
255
+ }
256
+ }
257
+ }
243
258
  return null;
244
259
  }
245
260
 
@@ -254,8 +269,22 @@ export function restreindre(test, dossier, ch, nommes, dire) {
254
269
  return;
255
270
  }
256
271
  const changes = ch.fichiers.map(f => path.join(ch.racine, f));
257
- const lanceurs = ch.cible ? [] : testsQuiLancent(dossier, ch.racine, changes);
258
- const declarants = testsQuiDeclarent(dossier, [...ch.fichiers, ...ch.supprimes]);
272
+ // A file without effect relates no test through the graph, yet the tests that read its text keep
273
+ // their rule.
274
+ const sansEffet = ch.sansEffet ?? [];
275
+ const lanceurs = ch.cible
276
+ ? []
277
+ : [
278
+ ...new Set([
279
+ ...testsQuiLancent(dossier, ch.racine, changes),
280
+ ...testsQuiNomment(
281
+ dossier,
282
+ ch.racine,
283
+ sansEffet.map(f => path.join(ch.racine, f))
284
+ ),
285
+ ]),
286
+ ];
287
+ const declarants = testsQuiDeclarent(dossier, [...ch.fichiers, ...ch.supprimes, ...sansEffet]);
259
288
  test.related = [...new Set([...changes, ...nommes, ...lanceurs, ...declarants])];
260
289
  test.passWithNoTests = true;
261
290
  dire(
@@ -465,6 +465,22 @@ export function testsQuiLancent(dossier, racine, changes) {
465
465
  });
466
466
  }
467
467
 
468
+ /**
469
+ * The test files of the package at <dossier>, in the repository at <racine>, that name one of the
470
+ * files <changes> (absolute) by its path (`nommesPar`): the tests that read its text, not those
471
+ * that import it or reach it through a file they read; sorted.
472
+ */
473
+ export function testsQuiNomment(dossier, racine, changes) {
474
+ const cibles = new Set(changes.map(f => reel(f) ?? f));
475
+ if (cibles.size === 0) {
476
+ return [];
477
+ }
478
+ const memo = new Map();
479
+ return testsDuPaquet(dossier).filter(t =>
480
+ [...nommesPar(t, dossier, racine, memo)].some(f => cibles.has(f))
481
+ );
482
+ }
483
+
468
484
  // The tag of a test that declares the files it reads: a line `// @lit <motif> …` of the comment at
469
485
  // the head of the file, before its first line of code, as the tag `@poste` (./cibles.mjs).
470
486
  const ETIQUETTE_DE_LECTURE = /^\/\/\s*@lit\b(.*)$/;