@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.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +52 -0
- package/cadre/templates/c/package.json +19 -0
- package/cadre/templates/projet/.github/workflows/ci.yml +34 -49
- package/cadre/templates/projet/.github/workflows/machine-vierge.yml +101 -0
- package/cadre/templates/projet/CLAUDE.md +28 -5
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/charte.md +61 -23
- package/dist/temporal/circuit/appel.d.ts +7 -0
- package/dist/temporal/circuit/appel.js +17 -0
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +28 -5
- package/dist/temporal/circuit/client.js +56 -13
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/commande.js +16 -4
- package/dist/temporal/circuit/commande.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +22 -2
- package/dist/temporal/circuit/contrat.js +76 -0
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +68 -11
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/file/activites.d.ts +2 -0
- package/dist/temporal/file/activites.js +7 -0
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +28 -18
- package/dist/temporal/file/contrat.js +8 -5
- package/dist/temporal/file/contrat.js.map +1 -1
- package/dist/temporal/file/deroule.d.ts +1 -1
- package/dist/temporal/file/deroule.js +91 -42
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/tickets/activites.d.ts +1 -0
- package/dist/temporal/tickets/activites.js +37 -11
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/dist/temporal/tickets/contrat.d.ts +14 -0
- package/dist/temporal/tickets/deroule.js +16 -3
- package/dist/temporal/tickets/deroule.js.map +1 -1
- package/docs/ARCHITECTURE.md +309 -128
- package/docs/INTERFACE.md +42 -22
- package/hooks/register.tsx +30 -0
- package/package.json +1 -1
- package/scripts/activites.mjs +60 -21
- package/scripts/arbres-juges.mjs +59 -0
- package/scripts/attente-a-l-arret.mjs +29 -52
- package/scripts/attente-au-tour.mjs +8 -26
- package/scripts/avancement.mjs +2 -38
- package/scripts/branche-de-nuit.mjs +14 -45
- package/scripts/ci-de-main.mjs +273 -0
- package/scripts/circuit.mjs +204 -64
- package/scripts/circuits-cles.d.mts +9 -0
- package/scripts/circuits-cles.mjs +38 -0
- package/scripts/coeurs-dedies.mjs +4 -3
- package/scripts/dernier-vert.mjs +78 -10
- package/scripts/enveloppe/travail-de-la-copie.mjs +5 -2
- package/scripts/etapes.mjs +7 -2
- package/scripts/faits-du-circuit.mjs +63 -28
- package/scripts/fichiers-nommes.mjs +55 -0
- package/scripts/file-des-tickets.d.mts +17 -0
- package/scripts/file-des-tickets.mjs +39 -0
- package/scripts/grillhouse-maj.mjs +20 -1
- package/scripts/integration/file.mjs +137 -592
- package/scripts/integration/integrer.mjs +10 -7
- package/scripts/langages/c/binaires.json +4 -0
- package/scripts/langages/c/binaires.mjs +83 -0
- package/scripts/langages/c/clang-format.mjs +62 -0
- package/scripts/langages/c/clang-tidy.mjs +93 -0
- package/scripts/langages/c/clang.mjs +42 -0
- package/scripts/langages/c/commandes.mjs +530 -0
- package/scripts/langages/c/composants.mjs +209 -0
- package/scripts/langages/c/exemples.mjs +250 -0
- package/scripts/langages/c/index-interfaces.mjs +77 -0
- package/scripts/langages/c/index.mjs +120 -0
- package/scripts/langages/c/lot.mjs +41 -0
- package/scripts/langages/c/mise-a-jour.mjs +70 -0
- package/scripts/langages/c/squelette.mjs +61 -0
- package/scripts/langages/c/verdict.mjs +99 -0
- package/scripts/langages/cargo/clippy.mjs +16 -9
- package/scripts/langages/cargo/commandes.mjs +7 -2
- package/scripts/langages/cargo/sccache.mjs +19 -6
- package/scripts/langages/typescript/tests.mjs +31 -5
- package/scripts/langages/typescript/turbo-des-paquets.mjs +67 -8
- package/scripts/langages/typescript/vitest-config/changements.mjs +32 -3
- package/scripts/langages/typescript/vitest-config/lances.mjs +16 -0
- package/scripts/langages-des-paquets.mjs +30 -2
- package/scripts/langages.mjs +1 -0
- package/scripts/limite-d-usage.mjs +88 -0
- package/scripts/mesure/avancement.mjs +1 -1
- package/scripts/migrations/0.47.0-ci-de-main.mjs +48 -0
- package/scripts/migrations.mjs +2 -2
- package/scripts/outils-cles.d.mts +13 -5
- package/scripts/outils-cles.mjs +157 -17
- package/scripts/passe-de-la-machine.mjs +26 -2
- package/scripts/places-de-la-machine.mjs +52 -6
- package/scripts/plafond-de-la-machine.d.mts +10 -2
- package/scripts/plafond-de-la-machine.mjs +39 -13
- package/scripts/reponses-du-circuit.d.mts +16 -0
- package/scripts/reponses-du-circuit.mjs +39 -3
- package/scripts/resultats.mjs +32 -11
- package/scripts/seances.mjs +211 -59
- package/scripts/session-start.sh +2 -11
- package/scripts/sortie.mjs +1 -1
- package/scripts/sous-commandes.mjs +5 -2
- package/scripts/superviseur.mjs +305 -295
- package/scripts/tableau.mjs +73 -45
- package/scripts/transitions.d.mts +22 -1
- package/scripts/transitions.mjs +111 -13
- package/scripts/workflows-du-cadre.mjs +21 -1
- package/skills/explorateur/SKILL.md +34 -13
- package/skills/grill/SKILL.md +6 -5
- package/skills/pitmaster/SKILL.md +33 -27
- package/skills/redacteur/references/documents-d-un-composant.md +1 -1
- package/skills/relecteur/SKILL.md +6 -0
- package/skills/testwriter/SKILL.md +4 -0
- package/scripts/ci-des-branches.mjs +0 -93
- package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +0 -31
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The commands of the module c, the demand `commandes` of the join (scripts/jointure.d.ts): each
|
|
3
|
+
// one this script with its name first, `{ script, args }`, described, never run, by `commandes`;
|
|
4
|
+
// run by `grillhouse <commande>` in the root of the project, its arguments after.
|
|
5
|
+
//
|
|
6
|
+
// npx grillhouse tests [--force] [<chemin>…] [--<option>…] tester
|
|
7
|
+
// npx grillhouse tests-du-paquet <chemin>… [--<option>…] tests-du-paquet
|
|
8
|
+
// npx grillhouse verifier [--tout | --gardes] verifier
|
|
9
|
+
// node commandes.mjs typer typer
|
|
10
|
+
// npx grillhouse index-interfaces the guard, its own script
|
|
11
|
+
//
|
|
12
|
+
// - A package is played by CMake and CTest, in `.build-cmake/<paquet>` at the root, outside the
|
|
13
|
+
// package's tree: `cmake -S <paquet> -B <construction>` configures, `cmake --build` compiles,
|
|
14
|
+
// `ctest --test-dir <construction>` plays; a step that fails ends the task of the package, its
|
|
15
|
+
// code the task's (a compiler error is the build's: red, no test plays).
|
|
16
|
+
// - `tester` and `verifier` play the tasks of the packages as Turborepo's, the way of the module
|
|
17
|
+
// python's (../python/commandes.mjs): `turbo run test:unit` (and `typecheck`) on the projects
|
|
18
|
+
// of the graph, each one a package with its own `package.json` (scripts/paquet-npm.mjs), a path
|
|
19
|
+
// written from the root choosing the project that holds it (a path out of every project is
|
|
20
|
+
// refused, named, code 2). `verifier --gardes` plays the guards of the root scripts alone.
|
|
21
|
+
// - `tests-du-paquet <chemin>…` is the body of the task `test:unit`: a path is a package (its
|
|
22
|
+
// folder: played whole) or one of its test files, `tests/test_*.c` (played alone, by `ctest -R`);
|
|
23
|
+
// any other path is refused, named, and nothing plays (code 2). Every `tests/test_*.c` is one
|
|
24
|
+
// CTest test, `test_<nom>`, which the skeleton's `tests/CMakeLists.txt` registers; the JUnit
|
|
25
|
+
// report CTest writes (`--output-junit`) is kept as it is (./verdict.mjs). A test file that
|
|
26
|
+
// CTest registers none of (a `tests/CMakeLists.txt` edited by hand) is red, « fichier de test
|
|
27
|
+
// non pris par CTest », named. A package played whole without a test file is compiled, and green.
|
|
28
|
+
// - `typer`: the configuration and the compilation of every package, or of the one named;
|
|
29
|
+
// `construire <chemin>` builds the one package named, as the script `build` of its package.json.
|
|
30
|
+
// - `cmake` and `ctest` absent from the PATH: one line that names the tool, code 1.
|
|
31
|
+
// - The tests play under a temporary directory of their pass (`ouvrirBase`), removed at the end,
|
|
32
|
+
// what the tests left there failing the pass (code 1), as the module python's.
|
|
33
|
+
// - While the environment names a results directory (`GRILLHOUSE_RESULTATS`), the run writes
|
|
34
|
+
// there what ./verdict.mjs reads: its tasks, each planned before it plays, and the JUnit report
|
|
35
|
+
// of each run of CTest.
|
|
36
|
+
// - The exit code: 0 when every task is green, 1 otherwise; 2 for a path refused or a command
|
|
37
|
+
// unknown.
|
|
38
|
+
import { spawnSync } from 'node:child_process';
|
|
39
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
40
|
+
import { constants, tmpdir } from 'node:os';
|
|
41
|
+
import path from 'node:path';
|
|
42
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
43
|
+
import { RESULTATS } from '../../resultats.mjs';
|
|
44
|
+
import {
|
|
45
|
+
AttenteDeLaMachine,
|
|
46
|
+
avecLaPasse,
|
|
47
|
+
cheminsDeLaTache,
|
|
48
|
+
construireDepuisLesArguments,
|
|
49
|
+
GRAPHE_JOUE,
|
|
50
|
+
joueCeQuiNeSeDivisePas,
|
|
51
|
+
lancerLesTaches,
|
|
52
|
+
ligneDesRestes,
|
|
53
|
+
nomDuPaquet,
|
|
54
|
+
ouvrirBase,
|
|
55
|
+
retirerALInterruption,
|
|
56
|
+
SCRIPT_DES_TESTS,
|
|
57
|
+
surUnePart,
|
|
58
|
+
testsCibles,
|
|
59
|
+
travailleursDeLaSeance,
|
|
60
|
+
trouverDansLePath,
|
|
61
|
+
} from '../../services-du-noyau.mjs';
|
|
62
|
+
import { TYPAGE } from '../../paquets.mjs';
|
|
63
|
+
import {
|
|
64
|
+
composantDans,
|
|
65
|
+
composants,
|
|
66
|
+
estUnFichierDeTest,
|
|
67
|
+
fichiersDeTest,
|
|
68
|
+
joueDesTests,
|
|
69
|
+
TESTS,
|
|
70
|
+
} from './composants.mjs';
|
|
71
|
+
import { casDuRapport, JUNIT, TACHES } from './verdict.mjs';
|
|
72
|
+
|
|
73
|
+
const ICI = fileURLToPath(import.meta.url);
|
|
74
|
+
export const NOMS = ['tester', 'tests-du-paquet', 'verifier', 'typer', 'construire'];
|
|
75
|
+
// The task runner of the graph of the packages.
|
|
76
|
+
const OUTIL = 'turbo';
|
|
77
|
+
const RACINE = '//';
|
|
78
|
+
/** The constructions of CMake, one directory per package, at the root. */
|
|
79
|
+
export const CONSTRUCTION = '.build-cmake';
|
|
80
|
+
const A_REPASSER = 75;
|
|
81
|
+
|
|
82
|
+
/** The guards of the module: each its name and its script beside this one. */
|
|
83
|
+
export const GARDES = [
|
|
84
|
+
{ nom: 'index-interfaces', args: ['--verifier'] },
|
|
85
|
+
{ nom: 'clang-format', args: [] },
|
|
86
|
+
{ nom: 'clang-tidy', args: [] },
|
|
87
|
+
].map(g => ({
|
|
88
|
+
...g,
|
|
89
|
+
script: path.join(path.dirname(ICI), `${g.nom}.mjs`),
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
/** The commands of the module, each this script and its name; then each guard, its script. */
|
|
93
|
+
export const commandes = () =>
|
|
94
|
+
Object.fromEntries([
|
|
95
|
+
...NOMS.map(n => [n, { script: ICI, args: [n] }]),
|
|
96
|
+
...GARDES.map(g => [g.nom, { script: g.script, args: [] }]),
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Whether <journal>, the output of a build, shows a failure of the compiler.
|
|
101
|
+
* @param {string} journal
|
|
102
|
+
*/
|
|
103
|
+
export const echecDeCompilation = journal => /(?:fatal )?error: |^CMake Error/m.test(journal);
|
|
104
|
+
|
|
105
|
+
// The run of the tasks of a command in <racine>: each planned, then played, written in the
|
|
106
|
+
// results directory <env> names.
|
|
107
|
+
function passe(racine, env) {
|
|
108
|
+
const dossier = env[RESULTATS] || null;
|
|
109
|
+
const id = `${Date.now()}-${process.pid}`;
|
|
110
|
+
const taches = [];
|
|
111
|
+
const rapports = {};
|
|
112
|
+
const ecrire = () => {
|
|
113
|
+
if (!dossier) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
mkdirSync(path.join(dossier, TACHES), { recursive: true });
|
|
117
|
+
writeFileSync(
|
|
118
|
+
path.join(dossier, TACHES, `${id}.json`),
|
|
119
|
+
`${JSON.stringify({ taches, rapports }, null, 2)}\n`
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
racine,
|
|
124
|
+
env,
|
|
125
|
+
prevoir(paquet, dossierDuPaquet, script, tests) {
|
|
126
|
+
const t = {
|
|
127
|
+
tache: `${paquet}#${script}`,
|
|
128
|
+
paquet,
|
|
129
|
+
dossier: path.relative(racine, dossierDuPaquet) || '.',
|
|
130
|
+
script,
|
|
131
|
+
tests,
|
|
132
|
+
code: null,
|
|
133
|
+
cache: null,
|
|
134
|
+
journal: null,
|
|
135
|
+
};
|
|
136
|
+
taches.push(t);
|
|
137
|
+
ecrire();
|
|
138
|
+
return t;
|
|
139
|
+
},
|
|
140
|
+
// The file of the JUnit report CTest writes for the package <nom> at <dossierDuPaquet>: in
|
|
141
|
+
// the results directory when there is one, else beside the construction.
|
|
142
|
+
junit(nom, dossierDuPaquet, construction) {
|
|
143
|
+
if (!dossier) {
|
|
144
|
+
return path.join(construction, 'ctest-junit.xml');
|
|
145
|
+
}
|
|
146
|
+
const f = `${id}-${nom}.xml`;
|
|
147
|
+
rapports[f] = dossierDuPaquet;
|
|
148
|
+
mkdirSync(path.join(dossier, JUNIT), { recursive: true });
|
|
149
|
+
return path.join(dossier, JUNIT, f);
|
|
150
|
+
},
|
|
151
|
+
// Ends the task <t> with <code>.
|
|
152
|
+
finir(t, code) {
|
|
153
|
+
t.code = code;
|
|
154
|
+
ecrire();
|
|
155
|
+
return code;
|
|
156
|
+
},
|
|
157
|
+
code() {
|
|
158
|
+
const rouges = taches.filter(t => t.code !== 0);
|
|
159
|
+
if (rouges.length === 0) {
|
|
160
|
+
return 0;
|
|
161
|
+
}
|
|
162
|
+
return rouges.every(t => t.code === A_REPASSER) ? A_REPASSER : 1;
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// The exit code of <r>, the result of a spawn.
|
|
168
|
+
const codeDe = r => (r.error ? 127 : (r.status ?? 128 + (constants.signals[r.signal] ?? 0)));
|
|
169
|
+
|
|
170
|
+
// The tools <noms> the PATH of <env> lacks, named on the error stream: true when one lacks.
|
|
171
|
+
function manque(noms, env) {
|
|
172
|
+
const absents = noms.filter(n => trouverDansLePath(n, env) === null);
|
|
173
|
+
for (const n of absents) {
|
|
174
|
+
process.stderr.write(`⛔ ${n} absent du PATH : le poste exige cmake et ctest (CMake).\n`);
|
|
175
|
+
}
|
|
176
|
+
return absents.length > 0;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// The environment of a tool: <env> whose PATH ends with the folder of the Node that runs this
|
|
180
|
+
// script, as npm gives the scripts it runs, so that a tool written for Node finds it.
|
|
181
|
+
export const pourLOutil = env => ({
|
|
182
|
+
...env,
|
|
183
|
+
PATH: [env.PATH, path.dirname(process.execPath)].filter(Boolean).join(path.delimiter),
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// Runs <programme> <args> in <cwd>: its code.
|
|
187
|
+
const jouer = (programme, args, cwd, env) =>
|
|
188
|
+
codeDe(spawnSync(programme, args, { cwd, env: pourLOutil(env), stdio: 'inherit' }));
|
|
189
|
+
|
|
190
|
+
// The configuration and the compilation of the package <c> in the run <p>, under <t>: the first
|
|
191
|
+
// code that is not 0, else 0.
|
|
192
|
+
function construire(p, c, t, env) {
|
|
193
|
+
const construction = path.join(p.racine, CONSTRUCTION, c.nom);
|
|
194
|
+
const travailleurs = travailleursDeLaSeance(env);
|
|
195
|
+
// The same configuration as the guard clang-tidy's (./clang-tidy.mjs): one directory, one flag.
|
|
196
|
+
const configure = jouer(
|
|
197
|
+
'cmake',
|
|
198
|
+
['-S', c.dossier, '-B', construction, '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON'],
|
|
199
|
+
p.racine,
|
|
200
|
+
env
|
|
201
|
+
);
|
|
202
|
+
if (configure !== 0) {
|
|
203
|
+
return configure;
|
|
204
|
+
}
|
|
205
|
+
return jouer(
|
|
206
|
+
'cmake',
|
|
207
|
+
[
|
|
208
|
+
'--build',
|
|
209
|
+
construction,
|
|
210
|
+
...(travailleurs === null ? [] : ['--parallel', String(travailleurs)]),
|
|
211
|
+
],
|
|
212
|
+
p.racine,
|
|
213
|
+
env
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// The names of the cases of the JUnit report at <fichier>; none when it is not there.
|
|
218
|
+
function casJoues(fichier) {
|
|
219
|
+
return existsSync(fichier) ? casDuRapport(readFileSync(fichier, 'utf8')).map(x => x.nom) : [];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Plays each `{ c, fichiers }` of <choix> in the run <p>, `fichiers` the test files named (their
|
|
223
|
+
// names without `.c`), null for the whole package: the task `ctest` of each.
|
|
224
|
+
function jouerLesTests(p, choix, env) {
|
|
225
|
+
for (const { c, fichiers } of choix) {
|
|
226
|
+
const t = p.prevoir(c.nom, c.dossier, 'ctest', true);
|
|
227
|
+
const sansTest = fichiers === null && fichiersDeTest(c.dossier).length === 0;
|
|
228
|
+
if (manque(sansTest ? ['cmake'] : ['cmake', 'ctest'], env)) {
|
|
229
|
+
p.finir(t, 127);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
let code = construire(p, c, t, env);
|
|
233
|
+
const voulus = fichiers ?? fichiersDeTest(c.dossier).map(f => path.basename(f, '.c'));
|
|
234
|
+
if (code === 0 && voulus.length > 0) {
|
|
235
|
+
const construction = path.join(p.racine, CONSTRUCTION, c.nom);
|
|
236
|
+
const junit = p.junit(c.nom, c.dossier, construction);
|
|
237
|
+
mkdirSync(path.dirname(junit), { recursive: true });
|
|
238
|
+
const args = [
|
|
239
|
+
'--test-dir',
|
|
240
|
+
construction,
|
|
241
|
+
'--output-junit',
|
|
242
|
+
junit,
|
|
243
|
+
'--no-tests=error',
|
|
244
|
+
'--output-on-failure',
|
|
245
|
+
...(fichiers === null ? [] : ['-R', `^(${fichiers.join('|')})$`]),
|
|
246
|
+
];
|
|
247
|
+
// CTest's own codes (8 for a failed test) are the task's failure, 1.
|
|
248
|
+
code = jouer('ctest', args, p.racine, env) === 0 ? 0 : 1;
|
|
249
|
+
const joues = new Set(casJoues(junit));
|
|
250
|
+
const sans = voulus.filter(n => !joues.has(n));
|
|
251
|
+
if (sans.length > 0) {
|
|
252
|
+
process.stderr.write(
|
|
253
|
+
`⛔ ${c.nom} : fichier de test non pris par CTest : ${sans.map(n => `${TESTS}/${n}.c`).join(', ')} (tests/CMakeLists.txt les enregistre).\n`
|
|
254
|
+
);
|
|
255
|
+
code = code === 0 ? 1 : code;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
p.finir(t, code);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// The packages the paths <chemins> choose in <racine>: `{ choix }`, each `{ c, fichiers }`, or
|
|
263
|
+
// `{ refus }`.
|
|
264
|
+
function choisir(racine, tous, chemins) {
|
|
265
|
+
const parDossier = new Map();
|
|
266
|
+
const refus = [];
|
|
267
|
+
for (const chemin of chemins) {
|
|
268
|
+
const c = composantDans(tous, racine, chemin);
|
|
269
|
+
if (!c) {
|
|
270
|
+
refus.push(`${chemin} : hors de tout paquet C (CMakeLists.txt avec project())`);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const parts = path.relative(c.dossier, path.resolve(racine, chemin)).split(path.sep);
|
|
274
|
+
const entier = parts.length === 1 && parts[0] === '';
|
|
275
|
+
const test = parts.length === 2 && parts[0] === TESTS && estUnFichierDeTest(parts[1]);
|
|
276
|
+
if (!entier && !test) {
|
|
277
|
+
refus.push(`${chemin} : ni un paquet C, ni un fichier de test (${TESTS}/test_*.c)`);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const deja = parDossier.get(c.dossier) ?? { c, fichiers: [] };
|
|
281
|
+
if (entier || deja.fichiers === null) {
|
|
282
|
+
deja.fichiers = null;
|
|
283
|
+
} else {
|
|
284
|
+
deja.fichiers.push(path.basename(parts[1], '.c'));
|
|
285
|
+
}
|
|
286
|
+
parDossier.set(c.dossier, deja);
|
|
287
|
+
}
|
|
288
|
+
return refus.length ? { refus } : { choix: [...parDossier.values()] };
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// The graph packages of the projects <projets>: `{ noms, absents }`.
|
|
292
|
+
function nomsDuGraphe(racine, projets) {
|
|
293
|
+
const noms = new Set();
|
|
294
|
+
const absents = [];
|
|
295
|
+
for (const c of projets) {
|
|
296
|
+
const nom = nomDuPaquet(racine, c.dossier);
|
|
297
|
+
if (nom === null) {
|
|
298
|
+
absents.push(c.nom);
|
|
299
|
+
} else {
|
|
300
|
+
noms.add(nom);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return { noms, absents };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Says each project of <absents> that is no package of the graph: its tests do not play.
|
|
307
|
+
function direLesAbsents(absents) {
|
|
308
|
+
for (const nom of absents) {
|
|
309
|
+
process.stderr.write(
|
|
310
|
+
`⚠️ ${nom} : pas un paquet du graphe (package.json absent) ; ses tests ne se jouent pas : npx grillhouse maj\n`
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// The pass of `tester` in <racine>, its arguments <args>, under <env>: the tasks `test:unit` of the
|
|
316
|
+
// projects the paths choose (every project that plays tests without a path) as Turborepo's.
|
|
317
|
+
function tester(racine, args, env) {
|
|
318
|
+
const tous = composants(racine);
|
|
319
|
+
const chemins = args.filter(a => !a.startsWith('-'));
|
|
320
|
+
const options = args.filter(a => a.startsWith('-') && a !== '--force');
|
|
321
|
+
let choisis = tous.filter(c => joueDesTests(racine, c));
|
|
322
|
+
if (chemins.length) {
|
|
323
|
+
const r = choisir(racine, tous, chemins);
|
|
324
|
+
if (r.refus) {
|
|
325
|
+
for (const l of r.refus) {
|
|
326
|
+
process.stderr.write(`⛔ ${l}\n`);
|
|
327
|
+
}
|
|
328
|
+
return 2;
|
|
329
|
+
}
|
|
330
|
+
choisis = r.choix.map(x => x.c);
|
|
331
|
+
}
|
|
332
|
+
const { noms, absents } = nomsDuGraphe(racine, choisis);
|
|
333
|
+
if (chemins.length && absents.length) {
|
|
334
|
+
process.stderr.write(
|
|
335
|
+
`⛔ ${absents.join(', ')} : pas un paquet du graphe (package.json absent) : npx grillhouse maj\n`
|
|
336
|
+
);
|
|
337
|
+
return 2;
|
|
338
|
+
}
|
|
339
|
+
direLesAbsents(absents);
|
|
340
|
+
if (noms.size === 0) {
|
|
341
|
+
return 0;
|
|
342
|
+
}
|
|
343
|
+
return lancerLesTaches({
|
|
344
|
+
outil: OUTIL,
|
|
345
|
+
racine,
|
|
346
|
+
taches: [SCRIPT_DES_TESTS],
|
|
347
|
+
noms,
|
|
348
|
+
tests: testsCibles({
|
|
349
|
+
arguments: [...chemins.map(c => path.resolve(racine, c)), ...options],
|
|
350
|
+
force: args.includes('--force'),
|
|
351
|
+
}),
|
|
352
|
+
env,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// The pass of `tests-du-paquet` in <racine>, its arguments <args>, under <env>: the body of the
|
|
357
|
+
// task `test:unit` of a project.
|
|
358
|
+
function testsDuPaquet(racine, args, env) {
|
|
359
|
+
const tous = composants(racine);
|
|
360
|
+
const donnes = args.filter(a => !a.startsWith('-'));
|
|
361
|
+
if (donnes.length === 0) {
|
|
362
|
+
process.stderr.write(
|
|
363
|
+
'⛔ tests-du-paquet : aucun chemin (un dossier de projet, ou un fichier de test).\n'
|
|
364
|
+
);
|
|
365
|
+
return 2;
|
|
366
|
+
}
|
|
367
|
+
const dossierDe = abs => composantDans(tous, racine, abs)?.dossier ?? null;
|
|
368
|
+
const { chemins, tranche } = cheminsDeLaTache({ racine, donnes, env, dossierDe });
|
|
369
|
+
const r = choisir(racine, tous, chemins);
|
|
370
|
+
if (r.refus) {
|
|
371
|
+
for (const l of r.refus) {
|
|
372
|
+
process.stderr.write(`⛔ ${l}\n`);
|
|
373
|
+
}
|
|
374
|
+
return 2;
|
|
375
|
+
}
|
|
376
|
+
// CTest has no split of its own: a tranche past the first plays none of its tests.
|
|
377
|
+
if (!joueCeQuiNeSeDivisePas(tranche)) {
|
|
378
|
+
return 0;
|
|
379
|
+
}
|
|
380
|
+
const p = passe(racine, env);
|
|
381
|
+
jouerLesTests(p, r.choix, env);
|
|
382
|
+
return p.code();
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// The pass of `verifier` in <racine>, under the lock of the machine: the typing and the tests of
|
|
386
|
+
// the projects as tasks of Turborepo. It keeps no green.
|
|
387
|
+
function verifier(racine, args, env) {
|
|
388
|
+
if (args.includes('--gardes')) {
|
|
389
|
+
return gardes(racine, passe(racine, env));
|
|
390
|
+
}
|
|
391
|
+
// Beside the module of package.json (composed command), its pass has played the tasks.
|
|
392
|
+
if (env[GRAPHE_JOUE]) {
|
|
393
|
+
return 0;
|
|
394
|
+
}
|
|
395
|
+
const { noms, absents } = nomsDuGraphe(racine, composants(racine));
|
|
396
|
+
direLesAbsents(absents);
|
|
397
|
+
if (noms.size === 0) {
|
|
398
|
+
return 0;
|
|
399
|
+
}
|
|
400
|
+
const code = lancerLesTaches({
|
|
401
|
+
outil: OUTIL,
|
|
402
|
+
racine,
|
|
403
|
+
taches: [TYPAGE, SCRIPT_DES_TESTS],
|
|
404
|
+
noms,
|
|
405
|
+
tests: testsCibles({ arguments: [], force: args.includes('--tout') }),
|
|
406
|
+
env,
|
|
407
|
+
});
|
|
408
|
+
if (code !== 0) {
|
|
409
|
+
process.stderr.write('⛔ rouge.\n');
|
|
410
|
+
}
|
|
411
|
+
return code === 0 ? 0 : 1;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// The scripts of guards of the project, in the order they play: the frame's, then its own.
|
|
415
|
+
const SCRIPTS_DE_GARDES = ['grillhouse:gardes', 'gardes'];
|
|
416
|
+
|
|
417
|
+
// The pass of `verifier --gardes` in <racine>: each script of SCRIPTS_DE_GARDES the root
|
|
418
|
+
// package.json holds, a task of the root; no test.
|
|
419
|
+
function gardes(racine, p) {
|
|
420
|
+
let scripts = {};
|
|
421
|
+
try {
|
|
422
|
+
scripts = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8')).scripts ?? {};
|
|
423
|
+
} catch {
|
|
424
|
+
scripts = {};
|
|
425
|
+
}
|
|
426
|
+
for (const nom of SCRIPTS_DE_GARDES.filter(n => typeof scripts[n] === 'string')) {
|
|
427
|
+
const t = p.prevoir(RACINE, racine, nom, false);
|
|
428
|
+
p.finir(t, jouer('npm', ['run', '--silent', nom], racine, p.env));
|
|
429
|
+
}
|
|
430
|
+
return p.code();
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// What the tools write at the root of the temporary directory, which the base removes with the
|
|
434
|
+
// rest: Node's compile cache, which npm enables.
|
|
435
|
+
const DES_OUTILS = n => n === 'node-compile-cache';
|
|
436
|
+
|
|
437
|
+
// Plays <jouerSous>(env) under the base of a pass of <genre> in the temporary directory of <env>:
|
|
438
|
+
// its code, 1 when the tests left something there, named.
|
|
439
|
+
function sousLaBase(genre, env, jouerSous) {
|
|
440
|
+
const base = ouvrirBase(genre, { dans: env.TMPDIR || tmpdir() });
|
|
441
|
+
const lacher = retirerALInterruption(base.fermer);
|
|
442
|
+
try {
|
|
443
|
+
const code = jouerSous({ ...env, ...base.env });
|
|
444
|
+
const ligne = ligneDesRestes(base.restes().filter(n => !DES_OUTILS(n)));
|
|
445
|
+
if (!ligne) {
|
|
446
|
+
return code;
|
|
447
|
+
}
|
|
448
|
+
process.stderr.write(`${ligne}\n`);
|
|
449
|
+
return code === 0 || code === A_REPASSER ? 1 : code;
|
|
450
|
+
} finally {
|
|
451
|
+
lacher();
|
|
452
|
+
base.fermer();
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Runs the command <nom> with <args> in the project at <racine>: its exit code.
|
|
458
|
+
* @param {string} nom one of NOMS
|
|
459
|
+
* @param {string[]} args its arguments
|
|
460
|
+
* @param {{ racine?: string, env?: NodeJS.ProcessEnv }} [o]
|
|
461
|
+
*/
|
|
462
|
+
export function lancer(nom, args, { racine = process.cwd(), env = process.env } = {}) {
|
|
463
|
+
if (nom === 'tester') {
|
|
464
|
+
return surUnePart(e => tester(racine, args, e), { env, racine });
|
|
465
|
+
}
|
|
466
|
+
if (nom === 'tests-du-paquet') {
|
|
467
|
+
return sousLaBase('tests', env, e => testsDuPaquet(racine, args, e));
|
|
468
|
+
}
|
|
469
|
+
if (nom === 'verifier') {
|
|
470
|
+
const dire = l => process.stdout.write(`${l}\n`);
|
|
471
|
+
try {
|
|
472
|
+
return sousLaBase('verification', env, envBase =>
|
|
473
|
+
avecLaPasse(envMachine => verifier(racine, args, envMachine), {
|
|
474
|
+
lourde: true,
|
|
475
|
+
env: envBase,
|
|
476
|
+
racine,
|
|
477
|
+
dire,
|
|
478
|
+
})
|
|
479
|
+
);
|
|
480
|
+
} catch (e) {
|
|
481
|
+
if (!(e instanceof AttenteDeLaMachine)) {
|
|
482
|
+
throw e;
|
|
483
|
+
}
|
|
484
|
+
dire(e.message);
|
|
485
|
+
return e.code;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
// The launcher's `construire` (`--echec <fichier> <plan>`) builds the copy for a session, the
|
|
489
|
+
// plan and its providers, as every language's.
|
|
490
|
+
if (nom === 'construire' && args.includes('--echec')) {
|
|
491
|
+
return construireDepuisLesArguments(OUTIL, args, racine);
|
|
492
|
+
}
|
|
493
|
+
if (nom === 'typer' || nom === 'construire') {
|
|
494
|
+
// `construire` and `typer` with a path: the one project of that folder; `typer` alone types
|
|
495
|
+
// them all.
|
|
496
|
+
let choisis = composants(racine);
|
|
497
|
+
if (nom === 'construire' || (nom === 'typer' && args.length)) {
|
|
498
|
+
const [chemin, ...autres] = args;
|
|
499
|
+
const abs = chemin === undefined ? null : path.resolve(racine, chemin);
|
|
500
|
+
const c = abs === null ? undefined : choisis.find(x => x.dossier === abs);
|
|
501
|
+
if (!c || autres.length) {
|
|
502
|
+
process.stderr.write(
|
|
503
|
+
`⛔ ${nom} : ${chemin ?? 'aucun chemin'} ne désigne pas un paquet C (un dossier de CMakeLists.txt avec project(), une fois).\n`
|
|
504
|
+
);
|
|
505
|
+
return 2;
|
|
506
|
+
}
|
|
507
|
+
choisis = [c];
|
|
508
|
+
}
|
|
509
|
+
return sousLaBase('tests', env, e => {
|
|
510
|
+
const p = passe(racine, e);
|
|
511
|
+
for (const c of choisis) {
|
|
512
|
+
const t = p.prevoir(c.nom, c.dossier, 'compile', false);
|
|
513
|
+
p.finir(t, manque(['cmake'], e) ? 127 : construire(p, c, t, e));
|
|
514
|
+
}
|
|
515
|
+
return p.code();
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
process.stderr.write(`⛔ commande inconnue du module c : ${nom} (${NOMS.join(', ')})\n`);
|
|
519
|
+
return 2;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
523
|
+
const [nom, ...args] = process.argv.slice(2);
|
|
524
|
+
try {
|
|
525
|
+
process.exitCode = lancer(nom, args);
|
|
526
|
+
} catch (e) {
|
|
527
|
+
process.stderr.write(`${e.message}\n`);
|
|
528
|
+
process.exitCode = 1;
|
|
529
|
+
}
|
|
530
|
+
}
|