@roomi-fields/grillhouse 0.28.2 → 0.29.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/bin/grillhouse.mjs +55 -14
- package/cadre/templates/projet/CLAUDE.md +1 -1
- package/cadre/templates/projet/README.md +11 -11
- package/cadre/templates/projet/_gitignore +2 -5
- package/charte.md +24 -3
- package/docs/ARCHITECTURE.md +279 -31
- package/docs/INTERFACE.md +59 -11
- package/package.json +1 -1
- package/scripts/aiguillage.mjs +324 -0
- package/scripts/avancement.mjs +33 -50
- package/scripts/circuit.mjs +558 -146
- package/scripts/composition-des-langages.mjs +16 -1
- package/scripts/conformite.mjs +16 -0
- package/scripts/copies-finies.mjs +181 -29
- package/scripts/demon.mjs +134 -21
- package/scripts/enveloppe/enveloppe.mjs +8 -5
- package/scripts/enveloppe/lancer.sh +24 -15
- package/scripts/enveloppe/travail-de-la-copie.mjs +94 -11
- package/scripts/etapes.mjs +1 -1
- package/scripts/fusion-du-changelog.mjs +0 -1
- package/scripts/grillhouse-maj.mjs +16 -7
- package/scripts/integration/file.mjs +3 -3
- package/scripts/integration/integrer.mjs +3 -3
- package/scripts/jointure.d.ts +53 -17
- package/scripts/langages/cargo/commandes.mjs +152 -25
- package/scripts/langages/cargo/composants.mjs +94 -2
- package/scripts/langages/cargo/exemples.mjs +68 -1
- package/scripts/langages/cargo/index.mjs +21 -10
- package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
- package/scripts/langages/cargo/sccache.mjs +89 -6
- package/scripts/langages/cargo/squelette.mjs +72 -3
- package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
- package/scripts/langages/cargo/tests-de-head.mjs +159 -0
- package/scripts/langages/python/commandes.mjs +53 -9
- package/scripts/langages/python/composants.mjs +33 -3
- package/scripts/langages/python/exemples.mjs +19 -0
- package/scripts/langages/python/index.mjs +7 -2
- package/scripts/langages/python/squelette.mjs +119 -17
- package/scripts/langages/typescript/exemples.mjs +16 -0
- package/scripts/langages/typescript/index.mjs +6 -3
- package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
- package/scripts/langages/typescript/squelette.mjs +18 -2
- package/scripts/langages/typescript/tests-de-nuit.mjs +50 -20
- package/scripts/langages/typescript/verifier.mjs +82 -288
- package/scripts/langages/typescript/vitest-config/base.mjs +8 -9
- package/scripts/langages/typescript/vitest-config/cibles.mjs +92 -53
- package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +11 -5
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -1
- package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
- package/scripts/langages/typescript/vitest.nuit.config.mjs +18 -13
- package/scripts/lecture-unique.mjs +51 -0
- package/scripts/mesure/base-de-passe.mjs +202 -9
- package/scripts/mesure/pression.mjs +9 -7
- package/scripts/nuit.sh +19 -12
- package/scripts/outil.mjs +72 -0
- package/scripts/paquet.mjs +39 -10
- package/scripts/resultats.mjs +22 -5
- package/scripts/services-du-noyau.mjs +16 -10
- package/scripts/session-start.sh +10 -1
- package/scripts/sortie.mjs +20 -1
- package/scripts/sources.mjs +3 -3
- package/scripts/sous-commandes.mjs +2 -0
- package/scripts/superviseur.mjs +369 -14
- package/scripts/tableau.mjs +219 -58
- package/scripts/verrou-de-machine.mjs +425 -37
- package/skills/developpeur/SKILL.md +11 -3
- package/skills/pitmaster/SKILL.md +64 -23
- package/skills/pitmaster/references/consigne-agent.md +4 -0
- package/skills/relecteur/SKILL.md +18 -6
- package/skills/testwriter/SKILL.md +11 -15
|
@@ -5,31 +5,42 @@
|
|
|
5
5
|
//
|
|
6
6
|
// node tests-de-nuit.mjs from the root of the copy
|
|
7
7
|
//
|
|
8
|
-
// - The files `*.nuit.test
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
8
|
+
// - The files `*.nuit.test.*` and `*.nuit.spec.*` of the copy, outside node_modules, dist and
|
|
9
|
+
// .git, the night tests, then its measures of time, the time budget benches (`*.budget.test.*`,
|
|
10
|
+
// `*.budget.spec.*`) and the time witnesses (a test file that imports `mesurerAuRepos`,
|
|
11
|
+
// `fichiersTemoins` of ./vitest-config/cibles.mjs): what `npm test` and the integration leave
|
|
12
|
+
// out (./vitest-config/cibles.mjs). A copy with none plays nothing, and the exit code is 0.
|
|
12
13
|
// - Vitest plays them with the frame's configuration (./vitest.nuit.config.mjs), from the root of
|
|
13
|
-
// the copy
|
|
14
|
-
//
|
|
15
|
-
//
|
|
14
|
+
// the copy: `npx --no-install vitest run --root <copie> --config <configuration>`, once for the
|
|
15
|
+
// night tests (GRILLHOUSE_TESTS_DE_NUIT=nuit), then once for the measures alone, one file at a
|
|
16
|
+
// time (GRILLHOUSE_TESTS_DE_NUIT=mesures), as Bazel plays a test tagged `exclusive` after the
|
|
17
|
+
// others, nothing beside it, and as the module cargo plays its benches after its night tests
|
|
18
|
+
// (grillhouse-bd7). Each run plays when the copy holds its files.
|
|
19
|
+
// - The exit code: 0 when every run is green; 75, « à repasser », when every red run is at 75
|
|
20
|
+
// (every failure depended on a duration, one under load, ./vitest-config/duree.reporter.mjs);
|
|
21
|
+
// else the code of the first red run.
|
|
22
|
+
// - They play once the temporary directory has room, as every heavy pass
|
|
23
|
+
// (`attendreDeLaPlace` of scripts/verrou-de-machine.mjs): a wait that reaches its bound ends at 75.
|
|
16
24
|
import { spawnSync } from 'node:child_process';
|
|
17
25
|
import { readdirSync } from 'node:fs';
|
|
18
26
|
import path from 'node:path';
|
|
19
27
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
28
|
+
import { A_REPASSER, attendreDeLaPlace } from '../../services-du-noyau.mjs';
|
|
29
|
+
import { fichiersTemoins, NUIT_VARIABLE } from './vitest-config/cibles.mjs';
|
|
20
30
|
|
|
21
31
|
const CONFIGURATION = fileURLToPath(new URL('./vitest.nuit.config.mjs', import.meta.url));
|
|
22
32
|
const HORS = new Set(['node_modules', 'dist', '.git']);
|
|
23
|
-
const DE_NUIT = /\.
|
|
33
|
+
const DE_NUIT = /\.nuit\.(test|spec)\.(c|m)?[jt]sx?$/;
|
|
34
|
+
const BANC = /\.budget\.(test|spec)\.(c|m)?[jt]sx?$/;
|
|
24
35
|
|
|
25
|
-
// Whether a
|
|
26
|
-
function enTient(dossier) {
|
|
36
|
+
// Whether a file whose name <motif> matches lies under <dossier>.
|
|
37
|
+
function enTient(dossier, motif) {
|
|
27
38
|
for (const e of readdirSync(dossier, { withFileTypes: true })) {
|
|
28
39
|
if (e.isDirectory()) {
|
|
29
|
-
if (!HORS.has(e.name) && enTient(path.join(dossier, e.name))) {
|
|
40
|
+
if (!HORS.has(e.name) && enTient(path.join(dossier, e.name), motif)) {
|
|
30
41
|
return true;
|
|
31
42
|
}
|
|
32
|
-
} else if (e.isFile() &&
|
|
43
|
+
} else if (e.isFile() && motif.test(e.name)) {
|
|
33
44
|
return true;
|
|
34
45
|
}
|
|
35
46
|
}
|
|
@@ -37,19 +48,38 @@ function enTient(dossier) {
|
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
/**
|
|
40
|
-
* Plays the night tests of the copy at <racine>:
|
|
51
|
+
* Plays the night tests, then the measures of time, of the copy at <racine>: 0, 75 or the code of
|
|
52
|
+
* the first red run of Vitest; 0 when there is none.
|
|
41
53
|
* @param {string} racine the root of the copy
|
|
42
54
|
*/
|
|
43
55
|
export function testsDeNuit(racine) {
|
|
44
|
-
|
|
56
|
+
const runs = [
|
|
57
|
+
enTient(racine, DE_NUIT) && 'nuit',
|
|
58
|
+
(enTient(racine, BANC) || fichiersTemoins(racine).length > 0) && 'mesures',
|
|
59
|
+
].filter(Boolean);
|
|
60
|
+
if (runs.length === 0) {
|
|
45
61
|
return 0;
|
|
46
62
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
try {
|
|
64
|
+
attendreDeLaPlace();
|
|
65
|
+
} catch (e) {
|
|
66
|
+
if (e?.name !== 'AttenteDeLaMachine') throw e;
|
|
67
|
+
process.stdout.write(`${e.message}\n`);
|
|
68
|
+
return e.code;
|
|
69
|
+
}
|
|
70
|
+
const codes = runs.map(choix => {
|
|
71
|
+
const r = spawnSync(
|
|
72
|
+
'npx',
|
|
73
|
+
['--no-install', 'vitest', 'run', '--root', racine, '--config', CONFIGURATION],
|
|
74
|
+
{ cwd: racine, stdio: 'inherit', env: { ...process.env, [NUIT_VARIABLE]: choix } }
|
|
75
|
+
);
|
|
76
|
+
return r.status ?? 1;
|
|
77
|
+
});
|
|
78
|
+
const rouges = codes.filter(c => c !== 0);
|
|
79
|
+
if (rouges.length === 0) {
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
return rouges.every(c => c === A_REPASSER) ? A_REPASSER : rouges.find(c => c !== A_REPASSER);
|
|
53
83
|
}
|
|
54
84
|
|
|
55
85
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// `npm run verifier`: the full pass, what the integration, the queue, the continuous integration
|
|
3
|
-
// and the night play. Its verdict is green (0)
|
|
3
|
+
// and the night play. Its verdict is green (0) or red (1); « à repasser » (75) only when the wait
|
|
4
|
+
// for the lock of the machine, or for room in the temporary directory, reaches its bound.
|
|
4
5
|
//
|
|
5
6
|
// npx grillhouse verifier [<argument of Turborepo>…] (npm run verifier -- --force)
|
|
6
7
|
// npx grillhouse verifier --tout [<argument>…] every test, played for real
|
|
@@ -35,19 +36,13 @@
|
|
|
35
36
|
// side, is half the cores of the machine, one at least (`concurrence`): each task of tests is
|
|
36
37
|
// itself parallel (Vitest's workers), as make's `-j` and Bazel's `--local_cpu_resources` bound a
|
|
37
38
|
// build by the machine; a `--concurrency` among the arguments replaces it.
|
|
38
|
-
// - The
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
// its own pass: a load it meets comes from elsewhere on the machine.
|
|
46
|
-
// - A pass restricted by filters of Turborepo among the arguments (`--filter`, `-F`: the circuit's
|
|
47
|
-
// final pass after a review sent back, `--filter=...[<avant>...<après>] --filter=//`,
|
|
48
|
-
// scripts/circuit.mjs) plays the witnesses of the packages those filters choose alone
|
|
49
|
-
// (`turbo ls <filtres> --output=json`): the pass of the witnesses carries no filter of its own
|
|
50
|
-
// beside theirs, which Turborepo would join to them.
|
|
39
|
+
// - The pass plays no measure of time (grillhouse-bd7): the time budget benches and the time
|
|
40
|
+
// witnesses (a test file that imports `mesurerAuRepos`) are out of the day, as the night tests
|
|
41
|
+
// are, and the night plays them (scripts/langages/typescript/vitest-config/cibles.mjs,
|
|
42
|
+
// scripts/langages/typescript/tests-de-nuit.mjs), as Bazel leaves a test tagged `manual` out of
|
|
43
|
+
// its patterns and the benchmarks of Chromium and rustc-perf leave the CI of each commit for a
|
|
44
|
+
// machine at rest. The day waits for no rest: a delay past is a red (the duration reporter
|
|
45
|
+
// classifies a delay of a day test as a real red), and so is a task at 75.
|
|
51
46
|
// - `--gardes` plays the two tasks of guards alone, `turbo run grillhouse:gardes gardes …`, with the
|
|
52
47
|
// same verdict: what the reviewer plays on the ticket's copy, the tests aside.
|
|
53
48
|
// - The verdict reads the exit code of each task in the summary of each run
|
|
@@ -55,74 +50,54 @@
|
|
|
55
50
|
// would hide a 1). The summary each run writes is removed, and `.turbo/runs` with it when the
|
|
56
51
|
// run created it; while the pass names a results directory (`GRILLHOUSE_RESULTATS`,
|
|
57
52
|
// scripts/resultats.mjs), it goes there instead, where the circuit reads it.
|
|
58
|
-
// - A task at 0 is green. A task at any other code
|
|
59
|
-
//
|
|
60
|
-
// task of the witnesses' pass with « (témoins de temps) ».
|
|
61
|
-
// - A task at 75 (« à repasser »: every failure of its tests depended on a duration and one took
|
|
62
|
-
// place under load, scripts/langages/typescript/vitest-config/duree.reporter.mjs) is played again alone, once the CPU
|
|
63
|
-
// pressure is back under the threshold (scripts/mesure/pression.mjs; one line per 30 s at
|
|
64
|
-
// most while it waits, with the pressure), one task after the other, in the choice of its run
|
|
65
|
-
// (a task of the witnesses' pass plays its witnesses alone again):
|
|
66
|
-
// `turbo run <task> --filter=<package>`, the arguments given after it, with what it depends on,
|
|
67
|
-
// which passed in the pass and replays from the cache: its hash holds theirs, as in the pass.
|
|
68
|
-
// Green at rest, it is green; at any code other
|
|
69
|
-
// than 0 and 75, red; at 75 again (the load came back during the run), it waits and plays again.
|
|
70
|
-
// - The wait is bounded: 15 min after the pass. The bound reached, the verdict is 75, « à
|
|
71
|
-
// repasser »: neither green nor red; whoever launched the pass presents it again later
|
|
72
|
-
// (scripts/integration/integrer.mjs, scripts/integration/file.mjs, scripts/nuit.sh).
|
|
53
|
+
// - A task at 0 is green. A task at any other code, 75 included, and a summary that does not read
|
|
54
|
+
// while Turborepo failed: red, code 1, each task named.
|
|
73
55
|
// - The progress of the pass (scripts/avancement.mjs): the directory its caller names in
|
|
74
56
|
// GRILLHOUSE_AVANCEMENT (the circuit's), else one of its own, which it names beside the lock of
|
|
75
|
-
// the machine while it plays (
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
57
|
+
// the machine it holds while it plays (`nommerLAvancement`), as the board shows its holder, and
|
|
58
|
+
// removes at its end, its total kept. Before its run of Turborepo, the plan of
|
|
59
|
+
// the run (`turbo run … --dry=json`) names its tasks of tests and counts done the files of those
|
|
60
|
+
// Turborepo replays from its cache.
|
|
79
61
|
// - The red tasks: while the variable `GRILLHOUSE_ROUGES` (`ROUGES`) names a file, the pass writes
|
|
80
62
|
// there, one Turborepo task id per line (`<package>#<task>`, `//#<task>` for the root), then a
|
|
81
63
|
// tab and the command that replays it alone (`npx turbo run <task> --filter=<package>`), each task
|
|
82
|
-
// red on its own exit code, a task
|
|
83
|
-
//
|
|
84
|
-
// file is empty. The night reads it for its bisect commands (scripts/nuit.sh), with no second
|
|
64
|
+
// red on its own exit code, once each; a task that did not play is none of them (its
|
|
65
|
+
// prerequisite red is). Green, the file is empty. The night reads it for its bisect commands (scripts/nuit.sh), with no second
|
|
85
66
|
// reading of the summaries.
|
|
86
67
|
// - The pass has a base of its own (scripts/mesure/base-de-passe.mjs), in the temporary
|
|
87
68
|
// directory of its environment, which it sweeps first of the bases a killed pass left: every
|
|
88
69
|
// run of Turborepo gets it in TMPDIR, TMP and TEMP, the root's `globalPassThroughEnv` passing
|
|
89
70
|
// TMPDIR on to every task (scripts/langages/typescript/turbo-des-paquets.mjs), and the pass
|
|
90
71
|
// removes it at its end, green, red or interrupted (SIGINT, SIGTERM, SIGHUP).
|
|
91
|
-
// -
|
|
92
|
-
// (scripts/langages/typescript/vitest-config/cibles.mjs) carries only
|
|
93
|
-
//
|
|
72
|
+
// - The run plays without the paths of a targeted run's tests: the variable `GRILLHOUSE_TESTS`
|
|
73
|
+
// (scripts/langages/typescript/vitest-config/cibles.mjs) carries only `rejouer`, for a complete
|
|
74
|
+
// pass.
|
|
94
75
|
import { spawnSync } from 'node:child_process';
|
|
95
76
|
import { existsSync, readdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
96
77
|
import { availableParallelism, tmpdir } from 'node:os';
|
|
97
78
|
import path from 'node:path';
|
|
98
79
|
import { pathToFileURL } from 'node:url';
|
|
99
80
|
import {
|
|
100
|
-
A_REPASSER,
|
|
101
|
-
attendreLeRepos,
|
|
102
81
|
AttenteDeLaMachine,
|
|
103
82
|
AVANCEMENT,
|
|
104
83
|
avecLaMachine,
|
|
105
|
-
BORNE_ATTENTE_MS,
|
|
106
84
|
CHANGEMENTS,
|
|
107
|
-
ecrireLaMesure,
|
|
108
85
|
garderLeTotal,
|
|
109
86
|
garderLeVert,
|
|
110
|
-
lirePression,
|
|
111
87
|
mesure,
|
|
88
|
+
nommerLAvancement,
|
|
112
89
|
ouvrirAvancement,
|
|
113
90
|
ouvrirBase,
|
|
114
|
-
paquetsDeLEnveloppe,
|
|
115
91
|
retirerALInterruption,
|
|
116
92
|
} from '../../services-du-noyau.mjs';
|
|
117
93
|
import { paquets, TYPAGE } from '../../paquets.mjs';
|
|
118
94
|
import { planifier } from './turbo-des-paquets.mjs';
|
|
119
95
|
import { SCRIPT_DES_TESTS } from './script-des-tests.mjs';
|
|
120
96
|
import { garderLesResumes } from './verdict.mjs';
|
|
121
|
-
import {
|
|
97
|
+
import { VARIABLE as TESTS_CIBLES } from './vitest-config/cibles.mjs';
|
|
122
98
|
|
|
123
99
|
const GARDES = ['grillhouse:gardes', 'gardes'];
|
|
124
100
|
const TACHES = [...GARDES, TYPAGE, SCRIPT_DES_TESTS];
|
|
125
|
-
const TEMOINS = ' (témoins de temps)';
|
|
126
101
|
const CONCURRENCE = /^--concurrency(?:=|$)/;
|
|
127
102
|
// The variable that names the file of the red tasks, which the night reads.
|
|
128
103
|
const ROUGES = 'GRILLHOUSE_ROUGES';
|
|
@@ -135,71 +110,16 @@ const rejeu = id => {
|
|
|
135
110
|
|
|
136
111
|
const lister = dossier => (existsSync(dossier) ? readdirSync(dossier) : []);
|
|
137
112
|
|
|
138
|
-
// The filters of Turborepo among <args> (`--filter=<f>`, `--filter <f>`, `-F <f>`) and the other
|
|
139
|
-
// arguments: `{ filtres, autres }`, the filters each written `--filter=<f>`.
|
|
140
|
-
function separerLesFiltres(args) {
|
|
141
|
-
const filtres = [];
|
|
142
|
-
const autres = [];
|
|
143
|
-
for (let i = 0; i < args.length; i++) {
|
|
144
|
-
if (args[i].startsWith('--filter=')) filtres.push(args[i]);
|
|
145
|
-
else if ((args[i] === '--filter' || args[i] === '-F') && i + 1 < args.length)
|
|
146
|
-
filtres.push(`--filter=${args[++i]}`);
|
|
147
|
-
else autres.push(args[i]);
|
|
148
|
-
}
|
|
149
|
-
return { filtres, autres };
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// The names of the packages of <racine> the filters <filtres> choose, as Turborepo lists them.
|
|
153
|
-
function paquetsChoisis(racine, filtres, env) {
|
|
154
|
-
const r = spawnSync('turbo', ['ls', ...filtres, '--output=json'], {
|
|
155
|
-
cwd: racine,
|
|
156
|
-
env,
|
|
157
|
-
encoding: 'utf8',
|
|
158
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
159
|
-
});
|
|
160
|
-
try {
|
|
161
|
-
return new Set(JSON.parse(r.stdout).packages.items.map(p => p.name));
|
|
162
|
-
} catch {
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
113
|
// The tasks a pass plays side by side on a machine of <coeurs> cores: half of them, one at least.
|
|
168
114
|
const concurrence = (coeurs = availableParallelism()) => Math.max(1, Math.floor(coeurs / 2));
|
|
169
115
|
|
|
170
|
-
// <args> without a `--concurrency` (`--concurrency=<n>` or `--concurrency <n>`).
|
|
171
|
-
function sansConcurrence(args) {
|
|
172
|
-
const out = [];
|
|
173
|
-
for (let i = 0; i < args.length; i++) {
|
|
174
|
-
if (args[i] === '--concurrency') i++;
|
|
175
|
-
else if (!CONCURRENCE.test(args[i])) out.push(args[i]);
|
|
176
|
-
}
|
|
177
|
-
return out;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// The filters of the packages of <racine> that hold a time witness, `--filter=<name>` each; in a
|
|
181
|
-
// repository without packages, none when its root holds one. Null without a witness.
|
|
182
|
-
function filtresDesTemoins(racine) {
|
|
183
|
-
const liste = paquets(racine);
|
|
184
|
-
if (liste.length === 0) return fichiersTemoins(racine).length ? [] : null;
|
|
185
|
-
const noms = liste
|
|
186
|
-
.filter(p => !p.hors && p.pkg.scripts?.[SCRIPT_DES_TESTS])
|
|
187
|
-
.filter(p => fichiersTemoins(path.resolve(racine, p.dossier)).length > 0)
|
|
188
|
-
.map(p => p.pkg.name);
|
|
189
|
-
return noms.length ? noms.map(n => `--filter=${n}`) : null;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
116
|
// The full pass in <racine>, its arguments <args> (`--gardes` among them: the guards alone), under
|
|
193
|
-
// <env> and the lock of the machine; its verdict, 0
|
|
194
|
-
//
|
|
195
|
-
// `pasMs` are the bound of the wait and the gap between two readings of the pressure; `coeurs`,
|
|
196
|
-
// the cores of the machine.
|
|
117
|
+
// <env> and the lock of the machine; its verdict, 0 or 1, or 75 when the wait for the lock, or for
|
|
118
|
+
// room in the temporary directory, reaches its bound. `dire` writes a line; `coeurs`, the cores of the machine.
|
|
197
119
|
export function verifier({
|
|
198
120
|
racine = process.cwd(),
|
|
199
121
|
args: demandes = [],
|
|
200
122
|
env = process.env,
|
|
201
|
-
borneMs = BORNE_ATTENTE_MS,
|
|
202
|
-
pasMs = 2_000,
|
|
203
123
|
dire = l => process.stdout.write(`${l}\n`),
|
|
204
124
|
coeurs = availableParallelism(),
|
|
205
125
|
}) {
|
|
@@ -211,29 +131,16 @@ export function verifier({
|
|
|
211
131
|
return avecLaMachine(
|
|
212
132
|
envMachine => {
|
|
213
133
|
// The progress of the pass: the directory its caller names (the circuit's), else its own,
|
|
214
|
-
// named beside the lock of the machine while it plays.
|
|
134
|
+
// named beside the lock of the machine, which it holds, while it plays.
|
|
215
135
|
const propre = !envMachine[AVANCEMENT];
|
|
216
136
|
const dossier =
|
|
217
137
|
envMachine[AVANCEMENT] || ouvrirAvancement({ racine, genre: 'verification' });
|
|
218
|
-
const effacer =
|
|
219
|
-
propre && !paquetsDeLEnveloppe(envMachine)
|
|
220
|
-
? ecrireLaMesure({
|
|
221
|
-
env: envMachine,
|
|
222
|
-
depot: nomDuDepot(racine),
|
|
223
|
-
commande: [
|
|
224
|
-
'npm run verifier',
|
|
225
|
-
...(demandes.length ? ['--', ...demandes] : []),
|
|
226
|
-
].join(' '),
|
|
227
|
-
dossier,
|
|
228
|
-
})
|
|
229
|
-
: () => {};
|
|
138
|
+
const effacer = propre ? nommerLAvancement({ env: envMachine, dossier }) : () => {};
|
|
230
139
|
try {
|
|
231
140
|
return passe({
|
|
232
141
|
racine,
|
|
233
142
|
demandes,
|
|
234
143
|
env: { ...envMachine, [AVANCEMENT]: dossier, ...base.env },
|
|
235
|
-
borneMs,
|
|
236
|
-
pasMs,
|
|
237
144
|
dire,
|
|
238
145
|
coeurs,
|
|
239
146
|
});
|
|
@@ -257,19 +164,6 @@ export function verifier({
|
|
|
257
164
|
}
|
|
258
165
|
}
|
|
259
166
|
|
|
260
|
-
// The name of the repository at <racine>: the folder of its main tree, its copies included; the
|
|
261
|
-
// folder of <racine> out of git.
|
|
262
|
-
function nomDuDepot(racine) {
|
|
263
|
-
const r = spawnSync(
|
|
264
|
-
'git',
|
|
265
|
-
['-C', racine, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
|
|
266
|
-
{
|
|
267
|
-
encoding: 'utf8',
|
|
268
|
-
}
|
|
269
|
-
);
|
|
270
|
-
return path.basename(r.status === 0 ? path.dirname(r.stdout.trim()) : path.resolve(racine));
|
|
271
|
-
}
|
|
272
|
-
|
|
273
167
|
// Whether a package of <racine>, or its root, plays tests (a script `test:unit`).
|
|
274
168
|
function depotAvecTests(racine) {
|
|
275
169
|
const liste = paquets(racine);
|
|
@@ -287,11 +181,13 @@ function depotAvecTests(racine) {
|
|
|
287
181
|
return liste.some(p => !p.hors && p.pkg.scripts?.[SCRIPT_DES_TESTS]);
|
|
288
182
|
}
|
|
289
183
|
|
|
290
|
-
|
|
184
|
+
// Whether <args> hold a filter of Turborepo (`--filter=<f>`, `--filter <f>`, `-F <f>`).
|
|
185
|
+
const filtre = args => args.some(a => a.startsWith('--filter=') || a === '--filter' || a === '-F');
|
|
186
|
+
|
|
187
|
+
function passe({ racine, demandes, env, dire, coeurs }) {
|
|
291
188
|
const gardesSeules = demandes.includes('--gardes');
|
|
292
189
|
const tout = demandes.includes('--tout') || demandes.includes('--force');
|
|
293
190
|
const args = demandes.filter(a => a !== '--gardes' && a !== '--tout');
|
|
294
|
-
const { filtres: filtresDeLaPasse } = separerLesFiltres(args);
|
|
295
191
|
// The measure against the last green: the guards alone need none.
|
|
296
192
|
const m = gardesSeules ? null : mesure(racine, { tout, dans: env.TMPDIR });
|
|
297
193
|
if (m) dire(m.ligne);
|
|
@@ -304,8 +200,6 @@ function passe({ racine, demandes, env, borneMs, pasMs, dire, coeurs }) {
|
|
|
304
200
|
tout,
|
|
305
201
|
ajouts: m?.env ?? {},
|
|
306
202
|
env,
|
|
307
|
-
borneMs,
|
|
308
|
-
pasMs,
|
|
309
203
|
dire,
|
|
310
204
|
coeurs,
|
|
311
205
|
taches,
|
|
@@ -313,178 +207,78 @@ function passe({ racine, demandes, env, borneMs, pasMs, dire, coeurs }) {
|
|
|
313
207
|
if (env[ROUGES])
|
|
314
208
|
writeFileSync(env[ROUGES], [...taches].map(t => `${t}\t${rejeu(t)}\n`).join(''));
|
|
315
209
|
// A pass green on every package keeps its tree as the last green.
|
|
316
|
-
if (code === 0 && m?.etat &&
|
|
210
|
+
if (code === 0 && m?.etat && !filtre(args)) garderLeVert(m.etat);
|
|
317
211
|
return code;
|
|
318
212
|
} finally {
|
|
319
213
|
m?.retirer();
|
|
320
214
|
}
|
|
321
215
|
}
|
|
322
216
|
|
|
323
|
-
function jouerLaPasse({
|
|
324
|
-
racine,
|
|
325
|
-
gardesSeules,
|
|
326
|
-
args,
|
|
327
|
-
tout,
|
|
328
|
-
ajouts,
|
|
329
|
-
env,
|
|
330
|
-
borneMs,
|
|
331
|
-
pasMs,
|
|
332
|
-
dire,
|
|
333
|
-
coeurs,
|
|
334
|
-
taches,
|
|
335
|
-
}) {
|
|
217
|
+
function jouerLaPasse({ racine, gardesSeules, args, tout, ajouts, env, dire, coeurs, taches }) {
|
|
336
218
|
const { [TESTS_CIBLES]: _, [CHANGEMENTS]: __, ...propre } = env;
|
|
337
|
-
// The
|
|
338
|
-
// real.
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
spawnSync('turbo', ['run', ...a], { cwd: racine, env: e, stdio: 'inherit' });
|
|
349
|
-
// Each red named, then the verdict 1.
|
|
350
|
-
const rouge = liste => {
|
|
351
|
-
for (const r of liste) dire(`⛔ ${r}`);
|
|
352
|
-
dire('⛔ rouge.');
|
|
353
|
-
return 1;
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
// One run of Turborepo, and its summary.
|
|
357
|
-
const runs = path.join(racine, '.turbo', 'runs');
|
|
358
|
-
const jouer = (a, e, libelle) => {
|
|
359
|
-
const existait = existsSync(runs);
|
|
360
|
-
const avant = new Set(lister(runs));
|
|
361
|
-
const r = turbo([...a, '--summarize'], e);
|
|
362
|
-
const nouveaux = lister(runs).filter(f => !avant.has(f) && f.endsWith('.json'));
|
|
363
|
-
let resume = null;
|
|
364
|
-
if (nouveaux.length === 1) {
|
|
365
|
-
try {
|
|
366
|
-
resume = JSON.parse(readFileSync(path.join(runs, nouveaux[0]), 'utf8'));
|
|
367
|
-
} catch {
|
|
368
|
-
resume = null;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
garderLesResumes(racine, avant, e);
|
|
372
|
-
if (!existait && existsSync(runs) && lister(runs).length === 0) rmdirSync(runs);
|
|
373
|
-
return { r, resume, env: e, libelle };
|
|
374
|
-
};
|
|
375
|
-
|
|
219
|
+
// The environment of the run: measured against the last green; the moment of a complete pass,
|
|
220
|
+
// which moves the hash of every task of tests, so that each plays for real.
|
|
221
|
+
const e = gardesSeules
|
|
222
|
+
? propre
|
|
223
|
+
: {
|
|
224
|
+
...propre,
|
|
225
|
+
...ajouts,
|
|
226
|
+
...(tout
|
|
227
|
+
? { [TESTS_CIBLES]: JSON.stringify({ arguments: [], rejouer: new Date().toISOString() }) }
|
|
228
|
+
: {}),
|
|
229
|
+
};
|
|
376
230
|
const borne = args.some(a => CONCURRENCE.test(a)) ? [] : [`--concurrency=${concurrence(coeurs)}`];
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
...borne,
|
|
383
|
-
...args,
|
|
384
|
-
],
|
|
385
|
-
e: gardesSeules ? propre : choix('hors'),
|
|
386
|
-
libelle: '',
|
|
387
|
-
},
|
|
231
|
+
const a = [
|
|
232
|
+
...(gardesSeules ? GARDES : TACHES),
|
|
233
|
+
'--continue=dependencies-successful',
|
|
234
|
+
...borne,
|
|
235
|
+
...args,
|
|
388
236
|
];
|
|
389
|
-
// The
|
|
390
|
-
const { filtres: filtresDeLaPasse, autres } = separerLesFiltres(args);
|
|
391
|
-
let filtres = gardesSeules ? null : filtresDesTemoins(racine);
|
|
392
|
-
if (filtres?.length && filtresDeLaPasse.length) {
|
|
393
|
-
const choisis = paquetsChoisis(racine, filtresDeLaPasse, propre);
|
|
394
|
-
if (choisis) filtres = filtres.filter(f => choisis.has(f.slice('--filter='.length)));
|
|
395
|
-
if (filtres.length === 0) filtres = null;
|
|
396
|
-
}
|
|
397
|
-
if (filtres) {
|
|
398
|
-
lancements.push({
|
|
399
|
-
a: [
|
|
400
|
-
SCRIPT_DES_TESTS,
|
|
401
|
-
...filtres,
|
|
402
|
-
'--continue=dependencies-successful',
|
|
403
|
-
'--concurrency=1',
|
|
404
|
-
...sansConcurrence(filtres.length || !filtresDeLaPasse.length ? autres : args),
|
|
405
|
-
],
|
|
406
|
-
e: choix('seuls'),
|
|
407
|
-
libelle: TEMOINS,
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
// The plan of each run that plays tests, before the first: the progress knows all its tasks.
|
|
237
|
+
// The plan of the run, before it: the progress knows all its tasks.
|
|
411
238
|
if (!gardesSeules && depotAvecTests(racine)) {
|
|
412
|
-
|
|
239
|
+
planifier(env[AVANCEMENT], { racine, args: a, env: e });
|
|
413
240
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
241
|
+
// The run of Turborepo, and its summary.
|
|
242
|
+
const runs = path.join(racine, '.turbo', 'runs');
|
|
243
|
+
const existait = existsSync(runs);
|
|
244
|
+
const avant = new Set(lister(runs));
|
|
245
|
+
const r = spawnSync('turbo', ['run', ...a, '--summarize'], {
|
|
246
|
+
cwd: racine,
|
|
247
|
+
env: e,
|
|
248
|
+
stdio: 'inherit',
|
|
249
|
+
});
|
|
250
|
+
const nouveaux = lister(runs).filter(f => !avant.has(f) && f.endsWith('.json'));
|
|
251
|
+
let resume = null;
|
|
252
|
+
if (nouveaux.length === 1) {
|
|
253
|
+
try {
|
|
254
|
+
resume = JSON.parse(readFileSync(path.join(runs, nouveaux[0]), 'utf8'));
|
|
255
|
+
} catch {
|
|
256
|
+
resume = null;
|
|
419
257
|
}
|
|
420
|
-
passes.push(jouer(a, e, libelle));
|
|
421
258
|
}
|
|
422
|
-
|
|
259
|
+
garderLesResumes(racine, avant, e);
|
|
260
|
+
if (!existait && existsSync(runs) && lister(runs).length === 0) rmdirSync(runs);
|
|
261
|
+
if (r.status === 0) return 0;
|
|
423
262
|
|
|
424
|
-
// The verdict of each task.
|
|
263
|
+
// The verdict of each task: any code but 0 is a red, named.
|
|
425
264
|
const rouges = [];
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
`rouge${libelle} : Turborepo sort en ${r.status ?? r.signal}, et le résumé de la passe ne se lit pas.`
|
|
432
|
-
);
|
|
433
|
-
continue;
|
|
434
|
-
}
|
|
435
|
-
let echecs = 0;
|
|
265
|
+
if (!Array.isArray(resume?.tasks)) {
|
|
266
|
+
rouges.push(
|
|
267
|
+
`rouge : Turborepo sort en ${r.status ?? r.signal}, et le résumé de la passe ne se lit pas.`
|
|
268
|
+
);
|
|
269
|
+
} else {
|
|
436
270
|
for (const t of resume.tasks) {
|
|
437
271
|
const code = t.execution?.exitCode;
|
|
438
272
|
if (code === 0) continue;
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
if (code === A_REPASSER && (t.dependents ?? []).length === 0)
|
|
442
|
-
aRepasser.push({ ...t, nom, env: e });
|
|
443
|
-
else if (code === A_REPASSER)
|
|
444
|
-
rouges.push(`${nom} à repasser, mais ${t.dependents.join(', ')} l'attendent`);
|
|
445
|
-
else {
|
|
446
|
-
rouges.push(`${nom} (code ${code ?? 'absent'})`);
|
|
447
|
-
if (typeof code === 'number') taches.add(t.taskId);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
if (echecs === 0)
|
|
451
|
-
rouges.push(`Turborepo sort en ${r.status ?? r.signal}${libelle} sans tâche en échec`);
|
|
452
|
-
}
|
|
453
|
-
if (rouges.length > 0) return rouge(rouges);
|
|
454
|
-
|
|
455
|
-
// The tasks à repasser, each played again at rest in the choice of its run, until the bound.
|
|
456
|
-
const limite = Date.now() + borneMs;
|
|
457
|
-
const lire = () => lirePression(env.GRILLHOUSE_PRESSION_CPU || undefined);
|
|
458
|
-
let restants = aRepasser;
|
|
459
|
-
dire(
|
|
460
|
-
`⏱ à repasser : ${restants.map(t => t.nom).join(', ')} ; chaque tâche se rejoue seule, au repos.`
|
|
461
|
-
);
|
|
462
|
-
while (restants.length > 0) {
|
|
463
|
-
const suivants = [];
|
|
464
|
-
for (const [i, t] of restants.entries()) {
|
|
465
|
-
if (Date.now() >= limite || !attendreLeRepos({ lire, limite, pasMs, dire })) {
|
|
466
|
-
const ouverts = [...suivants, ...restants.slice(i)].map(x => x.nom).join(', ');
|
|
467
|
-
const borneTexte =
|
|
468
|
-
borneMs >= 60_000 ? `${Math.round(borneMs / 60_000)} min` : `${borneMs / 1000} s`;
|
|
469
|
-
dire(`⏱ pas de repos en ${borneTexte} : ${ouverts} ni vert ni rouge.`);
|
|
470
|
-
// A task red at rest makes the pass red, whatever remains to play.
|
|
471
|
-
if (rouges.length > 0) return rouge(rouges);
|
|
472
|
-
dire(`⏱ à repasser (code ${A_REPASSER}).`);
|
|
473
|
-
return A_REPASSER;
|
|
474
|
-
}
|
|
475
|
-
dire(`↻ ${t.nom} : relance au repos.`);
|
|
476
|
-
const r = turbo([t.task, `--filter=${t.package}`, ...args], t.env);
|
|
477
|
-
if (r.status === 0) dire(`✓ ${t.nom} vert au repos.`);
|
|
478
|
-
else if (r.status === A_REPASSER) suivants.push(t);
|
|
479
|
-
else {
|
|
480
|
-
rouges.push(`${t.nom} rouge au repos (code ${r.status ?? r.signal})`);
|
|
481
|
-
taches.add(t.taskId);
|
|
482
|
-
}
|
|
273
|
+
rouges.push(`${t.taskId} (code ${code ?? 'absent'})`);
|
|
274
|
+
if (typeof code === 'number') taches.add(t.taskId);
|
|
483
275
|
}
|
|
484
|
-
|
|
276
|
+
if (rouges.length === 0)
|
|
277
|
+
rouges.push(`Turborepo sort en ${r.status ?? r.signal} sans tâche en échec`);
|
|
485
278
|
}
|
|
486
|
-
|
|
487
|
-
|
|
279
|
+
for (const l of rouges) dire(`⛔ ${l}`);
|
|
280
|
+
dire('⛔ rouge.');
|
|
281
|
+
return 1;
|
|
488
282
|
}
|
|
489
283
|
|
|
490
284
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|