@roomi-fields/grillhouse 0.28.3 → 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.
Files changed (68) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/grillhouse.mjs +55 -14
  3. package/cadre/templates/projet/CLAUDE.md +1 -1
  4. package/cadre/templates/projet/README.md +11 -11
  5. package/cadre/templates/projet/_gitignore +2 -5
  6. package/charte.md +13 -4
  7. package/docs/ARCHITECTURE.md +260 -29
  8. package/docs/INTERFACE.md +51 -12
  9. package/package.json +1 -1
  10. package/scripts/aiguillage.mjs +324 -0
  11. package/scripts/avancement.mjs +33 -50
  12. package/scripts/circuit.mjs +558 -146
  13. package/scripts/composition-des-langages.mjs +16 -1
  14. package/scripts/conformite.mjs +16 -0
  15. package/scripts/copies-finies.mjs +171 -30
  16. package/scripts/demon.mjs +134 -21
  17. package/scripts/enveloppe/lancer.sh +13 -14
  18. package/scripts/enveloppe/travail-de-la-copie.mjs +94 -11
  19. package/scripts/etapes.mjs +1 -1
  20. package/scripts/fusion-du-changelog.mjs +0 -1
  21. package/scripts/grillhouse-maj.mjs +16 -7
  22. package/scripts/integration/file.mjs +3 -3
  23. package/scripts/integration/integrer.mjs +3 -3
  24. package/scripts/jointure.d.ts +39 -17
  25. package/scripts/langages/cargo/commandes.mjs +152 -25
  26. package/scripts/langages/cargo/composants.mjs +90 -2
  27. package/scripts/langages/cargo/exemples.mjs +68 -1
  28. package/scripts/langages/cargo/index.mjs +17 -8
  29. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
  30. package/scripts/langages/cargo/sccache.mjs +54 -2
  31. package/scripts/langages/cargo/squelette.mjs +72 -3
  32. package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
  33. package/scripts/langages/cargo/tests-de-head.mjs +159 -0
  34. package/scripts/langages/python/commandes.mjs +44 -7
  35. package/scripts/langages/python/composants.mjs +33 -3
  36. package/scripts/langages/python/exemples.mjs +19 -0
  37. package/scripts/langages/python/index.mjs +4 -0
  38. package/scripts/langages/python/squelette.mjs +119 -17
  39. package/scripts/langages/typescript/exemples.mjs +16 -0
  40. package/scripts/langages/typescript/index.mjs +6 -3
  41. package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
  42. package/scripts/langages/typescript/squelette.mjs +18 -2
  43. package/scripts/langages/typescript/tests-de-nuit.mjs +41 -21
  44. package/scripts/langages/typescript/verifier.mjs +82 -288
  45. package/scripts/langages/typescript/vitest-config/base.mjs +8 -9
  46. package/scripts/langages/typescript/vitest-config/cibles.mjs +92 -53
  47. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +11 -5
  48. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +4 -2
  49. package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
  50. package/scripts/langages/typescript/vitest.nuit.config.mjs +18 -13
  51. package/scripts/lecture-unique.mjs +51 -0
  52. package/scripts/mesure/pression.mjs +9 -7
  53. package/scripts/nuit.sh +19 -12
  54. package/scripts/outil.mjs +72 -0
  55. package/scripts/paquet.mjs +39 -10
  56. package/scripts/resultats.mjs +22 -5
  57. package/scripts/services-du-noyau.mjs +8 -9
  58. package/scripts/session-start.sh +10 -1
  59. package/scripts/sortie.mjs +20 -1
  60. package/scripts/sources.mjs +3 -3
  61. package/scripts/sous-commandes.mjs +1 -0
  62. package/scripts/superviseur.mjs +369 -14
  63. package/scripts/tableau.mjs +219 -58
  64. package/scripts/verrou-de-machine.mjs +303 -58
  65. package/skills/developpeur/SKILL.md +11 -3
  66. package/skills/pitmaster/SKILL.md +58 -23
  67. package/skills/relecteur/SKILL.md +18 -6
  68. package/skills/testwriter/SKILL.md +11 -15
@@ -7,10 +7,9 @@
7
7
  //
8
8
  // - The value is JSON: `arguments`, Vitest's arguments (the paths, absolute, and the options
9
9
  // written `--<name>=<value>`), which Vitest's own parser of its command line (`parseCLI`,
10
- // vitest/node) reads; `rejouer`, the moment of a run that plays the tests for real (`--force`),
11
- // which only moves the hash; `temoins`, the time witnesses of a pass of `npm run verifier`
12
- // (below). The plugin takes the variable out of the environment once read: no
13
- // process the tests start receives it.
10
+ // vitest/node) reads; `rejouer`, the moment of a run that plays the tests for real (`--force`,
11
+ // a complete pass of `npm run verifier`), which only moves the hash. The plugin takes the
12
+ // variable out of the environment once read: no process the tests start receives it.
14
13
  // - A plugin of the base configuration (./base.mjs) reads it once the configuration is merged (its
15
14
  // `config` hook; Vitest reads the test options in `configResolved`, after every `config` hook):
16
15
  // the files played are the test files of the configuration's `include` (Vitest's default when
@@ -19,24 +18,27 @@
19
18
  // A path of another package names none of its files. Each option enters the test configuration
20
19
  // as Vitest merges its command line over it (`exclude` given on the command line is
21
20
  // `cliExclude`, as Vitest's `normalizeCliOptions` names it).
22
- // - A night test or a time budget bench (HORS_DU_JOUR, the day's exclusions of ./base.mjs) plays
23
- // when its own file is named, as Bazel's target tagged `manual` builds when named and never by a
24
- // pattern: the day's exclusions of both lift for that run, the include of the configuration
25
- // notwithstanding (the night's own include is HORS_DU_JOUR), and the measure of time of the base
26
- // configuration applies, its duration reporter giving 75, « à repasser », to a bench that fails
27
- // under load. A directory named leaves them out, as the day does.
28
- // - Without the variable, nothing changes. A run whose paths name no test file plays none, and
29
- // fails: the base configuration keeps Vitest's `passWithNoTests: false`.
30
- // - The time witnesses play alone, as Bazel plays a test tagged `exclusive` after the others, with
31
- // nothing beside it: a time witness is a test file that imports the mark of a measure of time
32
- // (`import { mesurerAuRepos } from '@roomi-fields/grillhouse/vitest-config/mesure'`, a line of its own,
33
- // `estTemoin`). `npm run verifier` (scripts/langages/typescript/verifier.mjs) plays its pass with `temoins: 'hors'`
34
- // in the value, which leaves every witness of the configuration's `include` out, then a pass of
35
- // its own with `temoins: 'seuls'`, which plays the witnesses alone, one file at a time
36
- // (`fileParallelism: false`), and passes without one (`passWithNoTests`); a targeted run sets
37
- // neither, and a witness named plays there as any test. The witnesses are found under the
38
- // configuration's directory (`fichiersTemoins`), node_modules, dist, .git, .turbo and .claude
39
- // left out.
21
+ // - Every measure of time plays at night (grillhouse-bd7), as Bazel leaves a target tagged
22
+ // `manual` out of every pattern and the benchmarks of Chromium and rustc-perf leave the CI of
23
+ // each commit for a machine at rest: a time budget bench (BUDGET) and a time witness, a test
24
+ // file that imports the mark of a measure of time (`import { mesurerAuRepos } from
25
+ // '@roomi-fields/grillhouse/vitest-config/mesure'`, a line of its own, `estTemoin`), are out of
26
+ // the day, as a night test (NUIT) is. The base configuration excludes the patterns HORS_DU_JOUR;
27
+ // the plugin excludes the witnesses found under the configuration's directory
28
+ // (`fichiersTemoins`, node_modules, dist, .git, .turbo and .claude left out), with or without
29
+ // the variable.
30
+ // - A night test, a bench or a witness plays when its own file is named, as Bazel's target tagged
31
+ // `manual` builds when named: the day's exclusions lift for that file, the include of the
32
+ // configuration notwithstanding, and the measure of time of the base configuration applies, its
33
+ // duration reporter giving 75, « à repasser », to a measure that fails under load. A directory
34
+ // named leaves them out, as the day does.
35
+ // - A run whose paths name no test file plays none, and fails: the base configuration keeps
36
+ // Vitest's `passWithNoTests: false`.
37
+ // - The night's configuration (scripts/langages/typescript/vitest.nuit.config.mjs) plays what the
38
+ // day leaves out, through the plugin `nuit`: the night tests, the benches and the witnesses; the
39
+ // variable `GRILLHOUSE_TESTS_DE_NUIT` (NUIT_VARIABLE) chooses `nuit`, the night tests alone, or
40
+ // `mesures`, the benches and the witnesses alone, one file at a time (`fileParallelism: false`),
41
+ // as scripts/langages/typescript/tests-de-nuit.mjs plays them.
40
42
  // - The changes since the last green (`GRILLHOUSE_CHANGEMENTS`, ./changements.mjs) restrict the
41
43
  // files played to those Vitest relates to them, the files named themselves kept, or leave every
42
44
  // test when a change lies out of Vitest's graph.
@@ -54,6 +56,8 @@ export const VARIABLE = 'GRILLHOUSE_TESTS';
54
56
  export const NUIT = '**/*.nuit.{test,spec}.?(c|m)[jt]s?(x)';
55
57
  export const BUDGET = '**/*.budget.{test,spec}.?(c|m)[jt]s?(x)';
56
58
  export const HORS_DU_JOUR = [NUIT, BUDGET];
59
+ /** The variable that chooses the tests of a run of the night's configuration: `nuit` or `mesures`. */
60
+ export const NUIT_VARIABLE = 'GRILLHOUSE_TESTS_DE_NUIT';
57
61
  // Whether <r>, a path relative to the configuration's directory, is a night test or a bench.
58
62
  const horsDuJour = r => HORS_DU_JOUR.some(p => path.matchesGlob(r, p));
59
63
  // Vitest's default `include` (its configDefaults).
@@ -64,19 +68,28 @@ const MARQUE_TEMOIN =
64
68
  /^import\s*\{[^}]*\bmesurerAuRepos\b[^}]*\}\s*from\s*['"][^'"]*vitest-config\/mesure(?:\.mjs)?['"]/m;
65
69
  // Whether the text <texte> of a test file is that of a time witness.
66
70
  const estTemoin = texte => MARQUE_TEMOIN.test(texte);
71
+ const lireTexte = f => {
72
+ try {
73
+ return readFileSync(f, 'utf8');
74
+ } catch {
75
+ return '';
76
+ }
77
+ };
78
+
79
+ /**
80
+ * Whether the test file at <fichier> is out of the day: a night test, a time budget bench or a
81
+ * time witness.
82
+ * @param {string} fichier the path of the file
83
+ */
84
+ export const estHorsDuJour = fichier =>
85
+ HORS_DU_JOUR.some(p => path.matchesGlob(fichier, p)) || estTemoin(lireTexte(fichier));
67
86
  // The directories a search of the witnesses leaves out.
68
87
  const HORS_TEMOINS = new Set(['node_modules', 'dist', '.git', '.turbo', '.claude']);
69
88
 
70
89
  // The time witnesses under <dir>: the test files of <include> (Vitest's default without it), the
71
90
  // day's exclusions left out, that `estTemoin`; each path relative to <dir>, sorted.
72
91
  export function fichiersTemoins(dir, include = INCLUDE) {
73
- const lire = f => {
74
- try {
75
- return readFileSync(path.join(dir, f), 'utf8');
76
- } catch {
77
- return '';
78
- }
79
- };
92
+ const lire = f => lireTexte(path.join(dir, f));
80
93
  return [
81
94
  ...new Set(
82
95
  globSync(include, { cwd: dir, exclude: d => HORS_TEMOINS.has(path.basename(d)) }).map(f =>
@@ -120,7 +133,16 @@ const fusion = (cible, valeur) =>
120
133
  )
121
134
  : valeur;
122
135
 
123
- // The plugin that restricts a run to the tests <env> names in VARIABLE.
136
+ // The time witnesses under the directory of the test options <test> of <config>, each a pattern
137
+ // relative to it that names its file alone.
138
+ const temoinsDe = (config, test) =>
139
+ fichiersTemoins(
140
+ path.resolve(config.root ?? process.cwd(), test.dir ?? ''),
141
+ test.include ?? INCLUDE
142
+ ).map(r => r.replace(SPECIAUX, '\\$&'));
143
+
144
+ // The plugin of the day: the time witnesses out of the run, and the run restricted to the tests
145
+ // <env> names in VARIABLE.
124
146
  export const ciblage = (env = process.env, dire = l => process.stdout.write(`${l}\n`)) => ({
125
147
  name: 'grillhouse:cibles',
126
148
  async config(config) {
@@ -128,14 +150,18 @@ export const ciblage = (env = process.env, dire = l => process.stdout.write(`${l
128
150
  const changements = env[CHANGEMENTS];
129
151
  delete env[VARIABLE];
130
152
  delete env[CHANGEMENTS];
131
- if (!texte && !changements) {
132
- return;
133
- }
134
153
  const test = (config.test ??= {});
154
+ const temoins = temoinsDe(config, test);
135
155
  // The files a targeted run names themselves, absolute.
136
156
  let nommes = [];
137
157
  if (texte) {
138
- nommes = await cibler(config, test, JSON.parse(texte));
158
+ nommes = await cibler(config, test, JSON.parse(texte), new Set(temoins));
159
+ }
160
+ // The witnesses out of the day, but those named themselves (in the include then).
161
+ const joues = new Set(Array.isArray(test.include) ? test.include : []);
162
+ const hors = nommes.length ? temoins.filter(t => !joues.has(t)) : temoins;
163
+ if (hors.length) {
164
+ test.exclude = [...(test.exclude ?? ['**/node_modules/**']), ...hors];
139
165
  }
140
166
  const ch = changements ? lireChangements(changements) : null;
141
167
  // A targeted run whose paths name no test file plays none, and fails, as without the changes.
@@ -145,26 +171,13 @@ export const ciblage = (env = process.env, dire = l => process.stdout.write(`${l
145
171
  },
146
172
  });
147
173
 
148
- // Applies the value <valeur> of VARIABLE to the configuration <config>, its test options <test>:
149
- // the files named themselves, absolute.
150
- async function cibler(config, test, valeur) {
174
+ // Applies the value <valeur> of VARIABLE to the configuration <config>, its test options <test>,
175
+ // <temoins> the time witnesses (patterns relative to its directory): the files named themselves,
176
+ // absolute.
177
+ async function cibler(config, test, valeur, temoins) {
151
178
  const { parseCLI } = await import('vitest/node');
152
179
  const { filter, options } = parseCLI(['vitest', ...(valeur.arguments ?? [])]);
153
180
  let nommes = [];
154
- // The time witnesses: left out of the pass, or played alone in their own.
155
- if (valeur.temoins === 'hors' || valeur.temoins === 'seuls') {
156
- const dir = path.resolve(config.root ?? process.cwd(), test.dir ?? '');
157
- const temoins = fichiersTemoins(dir, test.include ?? INCLUDE).map(r =>
158
- r.replace(SPECIAUX, '\\$&')
159
- );
160
- if (valeur.temoins === 'hors') {
161
- test.exclude = [...(test.exclude ?? ['**/node_modules/**']), ...temoins];
162
- } else {
163
- test.include = temoins.length ? temoins : [`${VARIABLE}-sans-temoin`];
164
- test.passWithNoTests = true;
165
- test.fileParallelism = false;
166
- }
167
- }
168
181
  if (filter.length) {
169
182
  const dir = path.resolve(config.root ?? process.cwd(), test.dir ?? '');
170
183
  const include = test.include ?? INCLUDE;
@@ -179,12 +192,14 @@ async function cibler(config, test, valeur) {
179
192
  if (r.startsWith('../')) {
180
193
  return false;
181
194
  }
182
- return horsDuJour(r) ? seuls.has(f) : include.some(p => path.matchesGlob(r, p));
195
+ return horsDuJour(r) || temoins.has(r.replace(SPECIAUX, '\\$&'))
196
+ ? seuls.has(f)
197
+ : include.some(p => path.matchesGlob(r, p));
183
198
  })
184
199
  .map(relatif)
185
200
  .sort();
186
201
  // A bench or a night test named itself plays: the day's exclusions of both lift, and the
187
- // files under a directory named stay out by the filter above.
202
+ // files under a directory named stay out by the filter above (a witness, by the plugin).
188
203
  if (joues.some(horsDuJour) && Array.isArray(test.exclude)) {
189
204
  test.exclude = test.exclude.filter(p => !HORS_DU_JOUR.includes(p));
190
205
  }
@@ -206,3 +221,27 @@ async function cibler(config, test, valeur) {
206
221
  }
207
222
  return nommes;
208
223
  }
224
+
225
+ /**
226
+ * The plugin of the night's configuration: the night tests, the benches and the time witnesses
227
+ * under its directory, or, as <env> chooses in NUIT_VARIABLE, the night tests alone (`nuit`) or
228
+ * the measures alone, one file at a time (`mesures`), the benches and the witnesses.
229
+ * @param {NodeJS.ProcessEnv} [env] the environment that holds the choice
230
+ */
231
+ export const nuit = (env = process.env) => ({
232
+ name: 'grillhouse:nuit',
233
+ config(config) {
234
+ const choix = env[NUIT_VARIABLE];
235
+ delete env[NUIT_VARIABLE];
236
+ const test = (config.test ??= {});
237
+ const temoins = temoinsDe(config, { ...test, include: INCLUDE });
238
+ if (choix === 'nuit') {
239
+ test.include = [NUIT];
240
+ } else if (choix === 'mesures') {
241
+ test.include = [BUDGET, ...temoins];
242
+ test.fileParallelism = false;
243
+ } else {
244
+ test.include = [...HORS_DU_JOUR, ...temoins];
245
+ }
246
+ },
247
+ });
@@ -3,10 +3,13 @@
3
3
  // (`--reporter=<entry>`, or `reporters` in a configuration; types ./duree.reporter.d.ts). At the end
4
4
  // of a run with failures, it reads each one:
5
5
  //
6
- // - a failure depends on a duration when it is a delay past (an error « Test timed out in <n>ms. »
7
- // or « Hook timed out in <n>ms. », Vitest's own message), a failure of a time budget bench (a
8
- // file `*.budget.test.*`, `*.budget.spec.*`), or of a test marked as a measure of time
9
- // (`mesurerAuRepos`, ./mesure.mjs); every other failure is a real red;
6
+ // - a failure depends on a duration when it is a failure of a time budget bench (a file
7
+ // `*.budget.test.*`, `*.budget.spec.*`), of a test marked as a measure of time (`mesurerAuRepos`,
8
+ // ./mesure.mjs), or a delay past (an error « Test timed out in <n>ms. » or « Hook timed out in
9
+ // <n>ms. », Vitest's own message) in a file out of the day (a night test, a bench, a time
10
+ // witness: `estHorsDuJour` of ./cibles.mjs); every other failure is a real red, a delay past in
11
+ // a day test included: a delay of the day is a safeguard, not a measure, as in Bazel and Vitest
12
+ // (grillhouse-bd7), and one too tight widens, far above the test's usual duration;
10
13
  // - it took place under load when the CPU pressure (./pression.mjs) was at or above the threshold
11
14
  // at the start or at the end of the test (noted by ./mesure.setup.mjs), or, for a hook or a file
12
15
  // that fails outside of a test, at the start or at the end of the run.
@@ -23,6 +26,7 @@ import {
23
26
  lirePression,
24
27
  SEUIL_PRESSION,
25
28
  } from '../../../services-du-noyau.mjs';
29
+ import { estHorsDuJour } from './cibles.mjs';
26
30
 
27
31
  const DELAI = /^(Test|Hook) timed out in \d+ms\./;
28
32
  const BANC = /\.budget\.(test|spec)\.(c|m)?[jt]sx?$/;
@@ -68,7 +72,9 @@ export default class DureeReporter {
68
72
  ? 'mesure de temps'
69
73
  : BANC.test(fichier)
70
74
  ? 'banc de temps'
71
- : erreurs.length > 0 && erreurs.every(e => DELAI.test(e.message ?? ''))
75
+ : erreurs.length > 0 &&
76
+ erreurs.every(e => DELAI.test(e.message ?? '')) &&
77
+ estHorsDuJour(fichier)
72
78
  ? 'délai dépassé'
73
79
  : null;
74
80
  if (!cause) {
@@ -4,8 +4,9 @@
4
4
  // process it starts inherits: a `npm run verifier` or a circuit that a test plays in a repository
5
5
  // of trial neither waits for the lock of the machine nor holds it, and no test writes in the
6
6
  // user's cache. A lock already named in the environment stays. Its heavy passes want no room in
7
- // the temporary directory (GRILLHOUSE_TEMPORAIRE_LIBRE, 0): the room of the machine is the pass's
8
- // that plays the file, which waited for it.
7
+ // the temporary directory (GRILLHOUSE_TEMPORAIRE_LIBRE, 0) nor on the disk of their copy
8
+ // (GRILLHOUSE_COPIE_LIBRE, 0): the room of the machine is the pass's that plays the file, which
9
+ // waited for it.
9
10
  import { randomUUID } from 'node:crypto';
10
11
  import { tmpdir } from 'node:os';
11
12
  import path from 'node:path';
@@ -15,3 +16,4 @@ process.env.GRILLHOUSE_VERROU_MACHINE ||= path.join(
15
16
  `grillhouse-mesure-${process.pid}-${randomUUID()}.lock`
16
17
  );
17
18
  process.env.GRILLHOUSE_TEMPORAIRE_LIBRE ||= '0';
19
+ process.env.GRILLHOUSE_COPIE_LIBRE ||= '0';
@@ -1,12 +1,13 @@
1
1
  // A test that measures time marks itself, so that its failure under load is « à repasser », not a
2
- // red (./duree.reporter.mjs):
2
+ // red (./duree.reporter.mjs), and its file, a time witness, plays at night alone, out of the day
3
+ // (./cibles.mjs, grillhouse-bd7):
3
4
  //
4
5
  // import { mesurerAuRepos } from '@roomi-fields/grillhouse/vitest-config/mesure';
5
6
  // it('rend en moins de 50 ms', ctx => mesurerAuRepos(ctx, () => { … expect(ms).toBeLessThan(50); }));
6
7
  //
7
8
  // `mesurerAuRepos(ctx, fn)` marks the test of the context <ctx> as a measure of time and gives back
8
9
  // what <fn> returns (a promise as it is, for the test to await). A time budget bench
9
- // (`*.budget.test.*`) and a delay past need no mark.
10
+ // (`*.budget.test.*`) needs no mark, nor a delay past in a night test.
10
11
  export function mesurerAuRepos(ctx, fn) {
11
12
  ctx.task.meta.mesureDeTemps = true;
12
13
  return fn();
@@ -1,19 +1,24 @@
1
- // The night tests of a project: the files `*.nuit.test.*` and `*.nuit.spec.*`, too long for the
2
- // day, and its time budget benches (`*.budget.test.*`, `*.budget.spec.*`), whose measures move with
3
- // the load of the day; `npm test`, `npm run verifier` and the integration leave them out (the
4
- // frame's base configuration of the day, the package @roomi-fields/grillhouse/vitest-config, which every day
5
- // configuration extends, excludes both). The night (scripts/nuit.sh, by ./tests-de-nuit.mjs) plays them with this
6
- // configuration, from the root of its copy (`vitest run --root <copy> --config <this file>`),
7
- // after a green full pass (`npm run verifier -- --force`) and before the project's night script.
8
- // It reads no day configuration of the project, whether the project has one at its root or one
9
- // per package; it takes from the base configuration the common environment (git's settings) and
10
- // the measure of time: the setup file that notes the CPU pressure of each test and the duration
11
- // reporter, which gives 75, « à repasser », to a bench that fails under load
12
- // (scripts/langages/typescript/vitest-config/duree.reporter.mjs).
1
+ // What the day leaves out of a project: the night tests (`*.nuit.test.*`, `*.nuit.spec.*`), too
2
+ // long for the day, and the measures of time, the time budget benches (`*.budget.test.*`,
3
+ // `*.budget.spec.*`) and the time witnesses (a test file that imports `mesurerAuRepos`), whose
4
+ // measures move with the load of the day (grillhouse-bd7); `npm test`, `npm run verifier` and the
5
+ // integration leave them out (the frame's base configuration of the day, the package
6
+ // @roomi-fields/grillhouse/vitest-config, which every day configuration extends). The night
7
+ // (scripts/nuit.sh, by ./tests-de-nuit.mjs) plays them with this configuration, from the root of
8
+ // its copy (`vitest run --root <copy> --config <this file>`), after a green full pass (`npm run
9
+ // verifier -- --force`) and before the project's night script: its include names the night tests
10
+ // and the benches, and its plugin adds the witnesses under the root, or chooses the night tests
11
+ // alone or the measures alone, one file at a time (`nuit` of ./vitest-config/cibles.mjs, the
12
+ // variable GRILLHOUSE_TESTS_DE_NUIT). It reads no day configuration of the project, whether the
13
+ // project has one at its root or one per package; it takes from the base configuration the common
14
+ // environment (git's settings) and the measure of time: the setup file that notes the CPU pressure
15
+ // of each test and the duration reporter, which gives 75, « à repasser », to a measure that fails
16
+ // under load (scripts/langages/typescript/vitest-config/duree.reporter.mjs).
13
17
  import base from './vitest-config/base.mjs';
14
- import { HORS_DU_JOUR } from './vitest-config/cibles.mjs';
18
+ import { HORS_DU_JOUR, nuit } from './vitest-config/cibles.mjs';
15
19
 
16
20
  export default {
21
+ plugins: [nuit()],
17
22
  test: {
18
23
  env: base.test.env,
19
24
  environment: base.test.environment,
@@ -0,0 +1,51 @@
1
+ // The readings done once in a scope, as a build of Bazel reads each file once whatever the number
2
+ // of targets that ask it: inside `avecUneLecture`, a reading kept under its key (`luUneFois`) is
3
+ // done at its first call and given again after; out of any scope, it is done at each call. A
4
+ // scope is the time of one gesture of the core that asks a module many questions on a tree that
5
+ // does not move (the sweep of the siblings of HEAD's version, scripts/circuit.mjs); a module of
6
+ // language keeps there what it reads at a cost (cargo's metadata). A reading that throws is not
7
+ // kept. The scope lives on the process under a global symbol, so that every instance of this file
8
+ // shares it: the modules of language are loaded by `require` (./langages.mjs), which a test
9
+ // runner may load apart from the core's imports.
10
+
11
+ const PORTEE = Symbol.for('grillhouse.lecture-unique');
12
+
13
+ /** @returns {Map<string, unknown> | undefined} */
14
+ const portee = () => /** @type {any} */ (globalThis)[PORTEE];
15
+
16
+ /**
17
+ * Runs <faire> in a scope of readings done once, and returns what it returns; inside a scope
18
+ * already open, in that one.
19
+ * @template T
20
+ * @param {() => T} faire
21
+ * @returns {T}
22
+ */
23
+ export function avecUneLecture(faire) {
24
+ if (portee()) {
25
+ return faire();
26
+ }
27
+ /** @type {any} */ (globalThis)[PORTEE] = new Map();
28
+ try {
29
+ return faire();
30
+ } finally {
31
+ delete (/** @type {any} */ (globalThis)[PORTEE]);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * What <lire> returns, read once under <cle> in the scope open, at each call out of any.
37
+ * @template T
38
+ * @param {string} cle
39
+ * @param {() => T} lire
40
+ * @returns {T}
41
+ */
42
+ export function luUneFois(cle, lire) {
43
+ const p = portee();
44
+ if (!p) {
45
+ return lire();
46
+ }
47
+ if (!p.has(cle)) {
48
+ p.set(cle, lire());
49
+ }
50
+ return /** @type {T} */ (p.get(cle));
51
+ }
@@ -1,7 +1,8 @@
1
- // The CPU pressure of the machine, the witness of rest for every measure of time: a time witness
2
- // is measured with the CPU at rest, and a failure that depends on a duration under load is played
3
- // again at rest (« à repasser »), never taken as a red nor as a green. The model is Bazel's
4
- // TIMEOUT/FLAKY and CTest's `--repeat after-timeout`: classify, then play again.
1
+ // The CPU pressure of the machine, the witness of rest for every measure of time, which plays at
2
+ // night (grillhouse-bd7): a measure is taken with the CPU at rest, and a failure that depends on a
3
+ // duration under load is played again at rest (« à repasser »), never taken as a red nor as a
4
+ // green. The model is Bazel's TIMEOUT/FLAKY and CTest's `--repeat after-timeout`: classify, then
5
+ // play again.
5
6
  //
6
7
  // - The signal is the kernel's pressure stall information, `/proc/pressure/cpu`, line `some`,
7
8
  // field `avg10`: the share of the last ten seconds in which a task waited for a CPU, in %.
@@ -10,9 +11,10 @@
10
11
  // - A file that does not read (no pressure stall information on the machine) gives null: whoever
11
12
  // reads it says « pression illisible » and leaves the verdict to the runner of the tests.
12
13
  // - A_REPASSER, 75, is the exit code of « à repasser » (EX_TEMPFAIL of sysexits.h: try again
13
- // later), neither green nor red: the duration reporter of the module of the language gives it
14
- // (scripts/langages/typescript/vitest-config/duree.reporter.mjs), `npm run verifier` reads it (scripts/langages/typescript/verifier.mjs),
15
- // and so do the integration, the queue and the night.
14
+ // later), neither green nor red: the measure of time of each module of language gives it
15
+ // (scripts/langages/typescript/vitest-config/duree.reporter.mjs, the benches of the module cargo),
16
+ // and the night reads it (scripts/nuit.sh). The day waits for no rest: `npm run verifier` takes a
17
+ // task at 75 for a red (scripts/langages/typescript/verifier.mjs).
16
18
  //
17
19
  // npx grillhouse pression attendre
18
20
  //
package/scripts/nuit.sh CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # The night: once a day, the full pass played for real, then what the day never plays: the night
3
- # tests and the time budget benches. During the day `npm run verifier` (the integration's) plays
3
+ # tests and the measures of time (the time budget benches and the time witnesses). During the day `npm run verifier` (the integration's) plays
4
4
  # what the changes since the last green touch (scripts/integration/integrer.mjs,
5
5
  # scripts/dernier-vert.mjs); the module of the project's language plays each step
6
6
  # (scripts/jointure.d.ts).
@@ -23,8 +23,9 @@
23
23
  # becomes the last green of the day's passes.
24
24
  # Its three steps (the full pass, the night tests, the project's night script) each play even
25
25
  # when one before is red, as a CI plays its independent jobs; the night is red when one of them
26
- # is. A full pass « à repasser » (75: a failure of duration under load, which found no rest in
27
- # its bound) ends the night there, « à repasser », below.
26
+ # is. A full pass « à repasser » (75: the wait for the machine reached its bound; the pass plays
27
+ # no measure of time, and a delay past is a red there) ends the night there, « à repasser »,
28
+ # below.
28
29
  # An existing copy that does not get ready (its move onto HEAD, its cleaning or the setting of
29
30
  # its submodules fails) is removed by `scripts/retirer-copie.sh --jetable` (local work does not
30
31
  # hold it, a lock does) and created again, once; a copy that does not get ready the second time
@@ -38,10 +39,13 @@
38
39
  # (scripts/outils-cles.mjs) gives each command of the project its variables, each set to its
39
40
  # path, whatever the environment of the night's launcher; a faulty key turns the night red, the
40
41
  # log naming it, and nothing runs.
41
- # - The night tests: after the full pass, the night tests and the time budget benches, which
42
- # `npm test` and the integration leave out, played by the command `tests-de-nuit` of the module
43
- # of the copy's language (the module typescript's: the files `*.nuit.test.*`, `*.nuit.spec.*`,
44
- # `*.budget.test.*` and `*.budget.spec.*`, by Vitest), when the project declares a language
42
+ # - The night tests: after the full pass, the night tests, then the measures of time alone (the
43
+ # time budget benches and the time witnesses), which `npm test` and the integration leave out
44
+ # (grillhouse-bd7), played by the command `tests-de-nuit` of the module of the copy's language
45
+ # (the module typescript's: the files `*.nuit.test.*` and `*.nuit.spec.*`, then the files
46
+ # `*.budget.test.*`, `*.budget.spec.*` and those that import `mesurerAuRepos`, one at a time, by
47
+ # Vitest; the module python's, `*_nuit_test.py`; the module cargo's, the test targets
48
+ # `tests/*_nuit.rs` then the benches `tests/*_budget.rs`, by nextest), when the project declares a language
45
49
  # whose module describes it (scripts/commande-du-langage.mjs); none otherwise. A red turns the night red, with a log line that
46
50
  # says so, and the project's night script still plays. A run « à repasser » (75: every failure
47
51
  # depended on a duration, one under load) waits for rest (`npx grillhouse pression attendre`,
@@ -75,8 +79,11 @@
75
79
  # refused (commits or work not entered, a lock) or held by a running circuit (its ticket in progress, its
76
80
  # `<copie>.travail`, the lock of the integration or of the queue) stays, its log line naming
77
81
  # why and the place it holds, a kept copy whose ticket is closed losing what the tools of its
78
- # languages wrote there. The removal never changes the night's verdict; the end of each
79
- # circuit runs it too (scripts/circuit.mjs).
82
+ # languages wrote there. The night names its own copy to the removal, its steps played: the copy
83
+ # stays, and loses what the tools of its languages wrote there (`target`, `.turbo`), its
84
+ # `node_modules` kept, which its next preparation would remove anyway (grillhouse-k5y). The
85
+ # removal never changes the night's verdict; the end of each circuit runs it too
86
+ # (scripts/circuit.mjs), the night's copy untouched.
80
87
  # - It takes no lock of the integration or of the queue (scripts/integration/file.mjs): an
81
88
  # integration and the queue run during the night, each in its own copy.
82
89
  # - Its log is <git common dir>/nuit/<date>.log. Green: HEAD becomes the last green commit
@@ -229,7 +236,7 @@ jouer() {
229
236
  GRILLHOUSE_ROUGES="$rouges" monter npm --prefix "$copie" run verifier -- --force
230
237
  code=$?
231
238
  if [ "$code" -eq 75 ]; then
232
- echo "⏱ la passe complète est à repasser (code 75) : un échec de durée sous charge, sans repos dans la borne."
239
+ echo "⏱ la passe complète est à repasser (code 75) : l'attente de la machine a atteint sa borne."
233
240
  return 75
234
241
  fi
235
242
  if [ "$code" -ne 0 ]; then
@@ -287,8 +294,8 @@ fin() {
287
294
  }
288
295
  jouer >> "$journal" 2>&1
289
296
  verdict=$?
290
- # The copies whose content is on main go once the steps are played, the night's own kept; their
291
- # removal never changes the verdict.
297
+ # The copies whose content is on main go once the steps are played, the night's own kept and
298
+ # pruned of its tools' outputs; their removal never changes the verdict.
292
299
  (cd "$racine" && node "$ici/copies-finies.mjs" "$copie") >> "$journal" 2>&1 || true
293
300
 
294
301
  if [ "$verdict" -eq 75 ]; then
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ // The installation of the published version that leads the frame's repository
3
+ // (scripts/aiguillage.mjs, the key `grillhouse.outil`, the cache, the switch).
4
+ //
5
+ // npx grillhouse outil installs the version the key names, nothing when it is there
6
+ // npx grillhouse outil <x.y.z> writes the key, then installs that version
7
+ //
8
+ // - The key is written in the package.json of the working directory, its other fields and its
9
+ // indentation kept; a version is installed under ~/.cache/grillhouse/outil/<version>/.
10
+ // - Without the key and without a version, the command says so, exit 2; a faulty key or argument
11
+ // too; a failed installation, exit 1. Changing the published version is this one gesture, which
12
+ // the release proposes (`grillhouse sortie --etiqueter`).
13
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
14
+ import path from 'node:path';
15
+ import { pathToFileURL } from 'node:url';
16
+ import { CLE, installer, NOM_DU_PAQUET, versionDeLOutil, X_Y_Z } from './aiguillage.mjs';
17
+
18
+ // Writes <version> as the key of the package.json at <racine>, its other fields and its
19
+ // indentation kept.
20
+ function ecrireLaCle(racine, version) {
21
+ const f = path.join(racine, 'package.json');
22
+ const texte = readFileSync(f, 'utf8');
23
+ const pkg = JSON.parse(texte);
24
+ pkg.grillhouse = { ...(pkg.grillhouse ?? {}), outil: version };
25
+ const retrait = /^\{\n([ \t]+)/.exec(texte)?.[1] ?? ' ';
26
+ writeFileSync(f, `${JSON.stringify(pkg, null, retrait)}\n`);
27
+ }
28
+
29
+ const USAGE = 'Usage : npx grillhouse outil [<x.y.z>]\n';
30
+
31
+ // The version to install in <racine>: <args>[0] written as the key, else the key's; the exit code
32
+ // 2 and its message for a faulty argument or key, or a key absent.
33
+ function versionAInstaller(racine, args) {
34
+ if (args.length > 1 || (args[0] !== undefined && !X_Y_Z.test(args[0]))) {
35
+ return { refus: USAGE };
36
+ }
37
+ if (!existsSync(path.join(racine, 'package.json'))) {
38
+ return {
39
+ refus: `⛔ grillhouse outil : aucun package.json dans ${racine} ; la clé ${CLE} s'écrit au package.json racine du dépôt.\n`,
40
+ };
41
+ }
42
+ if (args[0] !== undefined) ecrireLaCle(racine, args[0]);
43
+ try {
44
+ const version = versionDeLOutil(racine);
45
+ return version === null
46
+ ? {
47
+ refus: `⛔ la clé ${CLE} manque au package.json : \`npx grillhouse outil <x.y.z>\` l'écrit et installe la version.\n`,
48
+ }
49
+ : { version };
50
+ } catch (e) {
51
+ return { refus: `⛔ grillhouse outil : ${e.message}\n` };
52
+ }
53
+ }
54
+
55
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
56
+ const { version, refus } = versionAInstaller(process.cwd(), process.argv.slice(2));
57
+ if (refus) {
58
+ process.stderr.write(refus);
59
+ process.exitCode = 2;
60
+ } else {
61
+ try {
62
+ // Asked by hand: a failure kept by a launch does not stop it.
63
+ const r = installer(version, { retenue: 0 });
64
+ process.stdout.write(
65
+ `✓ ${NOM_DU_PAQUET}@${version} ${r.installe ? 'installé' : 'déjà installé'} sous ${r.dossier}.\n`
66
+ );
67
+ } catch (e) {
68
+ process.stderr.write(`⛔ grillhouse outil : ${e.message}\n`);
69
+ process.exitCode = 1;
70
+ }
71
+ }
72
+ }