@roomi-fields/grillhouse 0.47.1 → 0.49.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 +116 -0
- package/agents/direct.md +9 -0
- package/cadre/templates/projet/.github/workflows/ci.yml +24 -38
- package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -0
- package/cadre/templates/projet/.github/workflows/nuit.yml +14 -2
- package/cadre/templates/projet/CLAUDE.md +31 -10
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/turbo/paquets.json +3 -1
- package/cadre/templates/turbo/sans-paquets.json +3 -1
- package/charte.md +46 -13
- package/dist/temporal/circuit/appel.d.ts +4 -1
- package/dist/temporal/circuit/appel.js +15 -1
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +7 -1
- package/dist/temporal/circuit/client.js +54 -1
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/commande.js +35 -60
- package/dist/temporal/circuit/commande.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +2 -1
- package/dist/temporal/circuit/contrat.js +2 -1
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +9 -2
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/commande.js +2 -13
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/deroules.d.ts +1 -1
- package/dist/temporal/deroules.js +2 -2
- package/dist/temporal/deroules.js.map +1 -1
- package/dist/temporal/file/activites.d.ts +1 -4
- package/dist/temporal/file/activites.js +13 -14
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +34 -91
- package/dist/temporal/file/contrat.js +33 -5
- package/dist/temporal/file/contrat.js.map +1 -1
- package/dist/temporal/file/deroule.d.ts +1 -9
- package/dist/temporal/file/deroule.js +57 -166
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +26 -1
- package/dist/temporal/installation.js +111 -2
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/nuits/activites.d.ts +5 -10
- package/dist/temporal/nuits/activites.js +9 -57
- package/dist/temporal/nuits/activites.js.map +1 -1
- package/dist/temporal/nuits/choix.d.ts +15 -0
- package/dist/temporal/nuits/choix.js +20 -0
- package/dist/temporal/nuits/choix.js.map +1 -1
- package/dist/temporal/nuits/contrat.d.ts +11 -16
- package/dist/temporal/nuits/deroule.js +38 -67
- package/dist/temporal/nuits/deroule.js.map +1 -1
- package/dist/temporal/places/client.d.ts +9 -11
- package/dist/temporal/places/client.js +11 -19
- package/dist/temporal/places/client.js.map +1 -1
- package/dist/temporal/places/contrat.d.ts +25 -24
- package/dist/temporal/places/contrat.js +5 -7
- package/dist/temporal/places/contrat.js.map +1 -1
- package/dist/temporal/places/deroule.js +26 -36
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/tickets/activites.js +4 -2
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/dist/temporal/tickets/contrat.d.ts +2 -1
- package/docs/ARCHITECTURE.md +453 -133
- package/docs/CADRE.md +16 -13
- package/docs/INTERFACE.md +100 -25
- package/hooks/hooks.json +9 -0
- package/hooks/register.tsx +59 -5
- package/package.json +1 -1
- package/scripts/activites.mjs +319 -52
- package/scripts/aiguillage.mjs +5 -1
- package/scripts/attente-a-l-arret.mjs +2 -5
- package/scripts/attente-au-tour.mjs +2 -5
- package/scripts/bilan.mjs +125 -2
- package/scripts/branche-de-nuit.mjs +32 -44
- package/scripts/ci-de-main.mjs +215 -16
- package/scripts/circuit.mjs +275 -189
- package/scripts/circuits-cles.d.mts +3 -3
- package/scripts/circuits-cles.mjs +6 -5
- package/scripts/coeurs-dedies.mjs +4 -4
- package/scripts/commandes-composees.mjs +12 -5
- package/scripts/composition-des-langages.mjs +2 -0
- package/scripts/crochets.mjs +2 -2
- package/scripts/dette.d.ts +2 -1
- package/scripts/dette.mjs +49 -6
- package/scripts/direct.mjs +343 -0
- package/scripts/droits.mjs +19 -0
- package/scripts/effets.mjs +6 -5
- package/scripts/engendres.mjs +2 -1
- package/scripts/enveloppe/enveloppe.mjs +127 -18
- package/scripts/enveloppe/lancer.sh +14 -3
- package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
- package/scripts/enveloppe/travail-de-la-copie.mjs +121 -21
- package/scripts/etapes.mjs +14 -4
- package/scripts/etat-du-depot.mjs +23 -0
- package/scripts/faits-du-circuit.mjs +24 -34
- package/scripts/fermeture-de-la-machine.d.mts +27 -0
- package/scripts/fermeture-de-la-machine.mjs +98 -0
- package/scripts/fichiers-nommes.mjs +27 -1
- package/scripts/file-des-tickets.d.mts +18 -1
- package/scripts/file-des-tickets.mjs +63 -15
- package/scripts/greffons.mjs +1 -1
- package/scripts/grillhouse-maj.mjs +13 -25
- package/scripts/groupe-cles.d.mts +6 -0
- package/scripts/groupe-cles.mjs +29 -1
- package/scripts/integration/file.mjs +162 -48
- package/scripts/integration/integrer.mjs +2 -0
- package/scripts/jointure.d.ts +22 -3
- package/scripts/journal-des-etats.d.mts +16 -0
- package/scripts/journal-des-etats.mjs +44 -2
- package/scripts/journal.mjs +3 -0
- package/scripts/langages/c/commandes.mjs +5 -5
- package/scripts/langages/c/composants.mjs +13 -5
- package/scripts/langages/c/index.mjs +2 -0
- package/scripts/langages/c/squelette.mjs +1 -1
- package/scripts/langages/cargo/commandes.mjs +5 -6
- package/scripts/langages/cargo/index.mjs +2 -0
- package/scripts/langages/python/commandes.mjs +5 -5
- package/scripts/langages/python/composants.mjs +10 -2
- package/scripts/langages/python/index.mjs +2 -0
- package/scripts/langages/typescript/composants.mjs +10 -3
- package/scripts/langages/typescript/construire.mjs +2 -0
- package/scripts/langages/typescript/exemples.mjs +33 -1
- package/scripts/langages/typescript/index.mjs +22 -0
- package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
- package/scripts/langages/typescript/module-absent.mjs +24 -0
- package/scripts/langages/typescript/tests-de-nuit.mjs +152 -32
- package/scripts/langages/typescript/tests-du-poste.mjs +65 -23
- package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
- package/scripts/langages/typescript/turbo-des-paquets.mjs +40 -5
- package/scripts/langages/typescript/verifier.mjs +3 -5
- package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
- package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
- package/scripts/langages/typescript/vitest-config/lances.mjs +3 -1
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
- package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
- package/scripts/langages.mjs +25 -3
- package/scripts/machine.mjs +103 -0
- package/scripts/matieres-cles.mjs +17 -0
- package/scripts/matieres-lues.mjs +104 -0
- package/scripts/mesure/base-de-passe.mjs +2 -1
- package/scripts/migrations/0.48.0-ci-declenchee-par-la-file.mjs +32 -0
- package/scripts/migrations/0.48.0-poussee-retiree.mjs +31 -0
- package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
- package/scripts/migrations.mjs +6 -0
- package/scripts/nuit.sh +113 -46
- package/scripts/paquet.mjs +16 -5
- package/scripts/paquets.d.ts +4 -0
- package/scripts/paquets.mjs +57 -0
- package/scripts/passe-de-la-machine.mjs +13 -14
- package/scripts/places-de-la-machine.mjs +120 -44
- package/scripts/places-du-serveur.mjs +29 -8
- package/scripts/plafond-de-la-machine.d.mts +7 -13
- package/scripts/plafond-de-la-machine.mjs +19 -35
- package/scripts/poussee-retiree.mjs +18 -0
- package/scripts/prefixe-des-tickets.mjs +1 -1
- package/scripts/references-changees.mjs +159 -0
- package/scripts/registre.d.mts +2 -2
- package/scripts/regles-des-places.d.mts +20 -12
- package/scripts/regles-des-places.mjs +27 -30
- package/scripts/repli-de-la-nuit.mjs +112 -0
- package/scripts/reponses-du-circuit.d.mts +4 -2
- package/scripts/reponses-du-circuit.mjs +44 -9
- package/scripts/reprise.mjs +27 -8
- package/scripts/resultats.mjs +61 -9
- package/scripts/seances.mjs +258 -40
- package/scripts/services-du-noyau.mjs +3 -0
- package/scripts/sous-commandes.mjs +37 -7
- package/scripts/superviseur.mjs +241 -88
- package/scripts/tableau.mjs +327 -131
- package/scripts/taches-du-graphe.mjs +84 -4
- package/scripts/ticket.mjs +345 -0
- package/scripts/transitions.d.mts +52 -0
- package/scripts/transitions.mjs +194 -16
- package/scripts/un-commit-par-ticket.mjs +4 -3
- package/scripts/verdict-de-la-nuit.mjs +47 -20
- package/scripts/verrou-de-fichier.mjs +2 -2
- package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
- package/scripts/verrous/verrou.mjs +17 -1
- package/skills/developpeur/SKILL.md +1 -1
- package/skills/direct/SKILL.md +57 -0
- package/skills/explorateur/SKILL.md +10 -6
- package/skills/pitmaster/SKILL.md +37 -14
- package/skills/pitmaster/references/consigne-agent.md +7 -1
- package/skills/relecteur/SKILL.md +11 -1
- package/skills/testwriter/SKILL.md +10 -0
- package/scripts/poussee-cles.mjs +0 -46
- package/scripts/ticket.sh +0 -25
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The lock of the dependencies (package-lock.json) against the package.json it locks, on the model
|
|
3
|
+
// of `npm ci`, which refuses a lock out of step with its package.json: the lock is written by the
|
|
4
|
+
// frame at the integration (`fichiersEngendres` of ./index.mjs), and this guard refuses a copy
|
|
5
|
+
// whose lock is late.
|
|
6
|
+
//
|
|
7
|
+
// npx grillhouse verrou-des-dependances run from the repository root (a guard of grillhouse:gardes)
|
|
8
|
+
//
|
|
9
|
+
// - For each package.json of the repository (the root's, and each workspace's), its `dependencies`,
|
|
10
|
+
// `devDependencies`, `optionalDependencies` and `peerDependencies` are compared with the entry of
|
|
11
|
+
// its package in the `packages` key of the lock (`""` for the root), without the registry and
|
|
12
|
+
// whatever the version of npm: a declared dependency absent from the lock, a dependency removed
|
|
13
|
+
// from the package.json still in the lock's entry, a range that differs from the entry's, a
|
|
14
|
+
// resolved version of the lock that no longer satisfies the declared range.
|
|
15
|
+
// - A finding is `{ fichier, message }`, one per package and dependency, the message naming the
|
|
16
|
+
// command that writes the lock again (COMMANDE). A repository without a lock is not judged, nor
|
|
17
|
+
// one whose project declares package-lock.json in `grillhouse.engendres` (its command is its own).
|
|
18
|
+
// - This module's top level uses Node alone: ./index.mjs imports it for the command, and the write
|
|
19
|
+
// lock of a session loads that module where the package's dependencies may not be installed.
|
|
20
|
+
// semver is required when the guard compares (`verifierLesConstats`), as ./mise-a-jour.mjs does.
|
|
21
|
+
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
22
|
+
import { createRequire } from 'node:module';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
import { pathToFileURL } from 'node:url';
|
|
25
|
+
import { ecrireSarif } from '../../resultats.mjs';
|
|
26
|
+
|
|
27
|
+
export const GARDE = 'verrou-des-dependances';
|
|
28
|
+
export const COMMANDE = 'npm install --package-lock-only --no-audit --no-fund';
|
|
29
|
+
|
|
30
|
+
const SORTES = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
|
|
31
|
+
const LOCK = 'package-lock.json';
|
|
32
|
+
|
|
33
|
+
const lireJson = f => {
|
|
34
|
+
try {
|
|
35
|
+
return JSON.parse(readFileSync(f, 'utf8'));
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// The directories (from <racine>) the workspaces of the root package.json name: a literal path, or
|
|
42
|
+
// `<dossier>/*`.
|
|
43
|
+
function espaces(racine, manifeste) {
|
|
44
|
+
const motifs = Array.isArray(manifeste?.workspaces)
|
|
45
|
+
? manifeste.workspaces
|
|
46
|
+
: (manifeste?.workspaces?.packages ?? []);
|
|
47
|
+
const dossiers = [];
|
|
48
|
+
for (const m of motifs.filter(x => typeof x === 'string')) {
|
|
49
|
+
const motif = m.replace(/^\.\//, '').replace(/\/+$/, '');
|
|
50
|
+
if (motif.endsWith('/*')) {
|
|
51
|
+
const parent = motif.slice(0, -2);
|
|
52
|
+
const lus = existsSync(path.join(racine, parent))
|
|
53
|
+
? readdirSync(path.join(racine, parent), { withFileTypes: true })
|
|
54
|
+
: [];
|
|
55
|
+
dossiers.push(...lus.filter(e => e.isDirectory()).map(e => `${parent}/${e.name}`));
|
|
56
|
+
} else if (!motif.includes('*')) {
|
|
57
|
+
dossiers.push(motif);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return dossiers.filter(d => existsSync(path.join(racine, d, 'package.json')));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// The version the lock resolves <nom> to for the entry <cle>: the nearest `node_modules/<nom>`,
|
|
64
|
+
// following the link of a package of the repository; null when the lock holds none.
|
|
65
|
+
function resolue(packages, cle, nom) {
|
|
66
|
+
const candidats = [];
|
|
67
|
+
let c = cle;
|
|
68
|
+
for (;;) {
|
|
69
|
+
candidats.push(c ? `${c}/node_modules/${nom}` : `node_modules/${nom}`);
|
|
70
|
+
if (!c) {
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
const i = c.lastIndexOf('/node_modules/');
|
|
74
|
+
c = i === -1 ? '' : c.slice(0, i);
|
|
75
|
+
}
|
|
76
|
+
const trouve = candidats.map(c => packages[c]).find(Boolean);
|
|
77
|
+
if (!trouve) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const cible = trouve.link && trouve.resolved ? packages[trouve.resolved] : trouve;
|
|
81
|
+
return typeof cible?.version === 'string' ? cible.version : null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The findings of the repository at <racine>: `[{ fichier, message }]`, one per package and
|
|
86
|
+
* dependency whose lock entry is out of step with its package.json.
|
|
87
|
+
* @param {string} racine
|
|
88
|
+
* @returns {{ fichier: string, message: string }[]}
|
|
89
|
+
*/
|
|
90
|
+
export function verifierLesConstats(racine) {
|
|
91
|
+
const verrou = lireJson(path.join(racine, LOCK));
|
|
92
|
+
const racineManifeste = lireJson(path.join(racine, 'package.json'));
|
|
93
|
+
if (!verrou || typeof verrou.packages !== 'object' || !racineManifeste) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
// semver, required when the guard compares, not when the module loads (see the header).
|
|
97
|
+
const semver = createRequire(import.meta.url)('semver');
|
|
98
|
+
const packages = verrou.packages;
|
|
99
|
+
const cles = ['', ...espaces(racine, racineManifeste)];
|
|
100
|
+
const constats = [];
|
|
101
|
+
for (const cle of cles) {
|
|
102
|
+
const fichier = cle ? `${cle}/package.json` : 'package.json';
|
|
103
|
+
const manifeste = cle ? lireJson(path.join(racine, fichier)) : racineManifeste;
|
|
104
|
+
const entree = packages[cle] ?? {};
|
|
105
|
+
const dit = (nom, raison) =>
|
|
106
|
+
constats.push({
|
|
107
|
+
fichier,
|
|
108
|
+
message: `${cle || 'package.json'} : la dépendance ${nom} ${raison} ; \`${COMMANDE}\` réécrit le verrou.`,
|
|
109
|
+
});
|
|
110
|
+
for (const sorte of SORTES) {
|
|
111
|
+
const declare = manifeste?.[sorte] ?? {};
|
|
112
|
+
const verrouille = entree[sorte] ?? {};
|
|
113
|
+
for (const [nom, plage] of Object.entries(declare)) {
|
|
114
|
+
if (!(nom in verrouille)) {
|
|
115
|
+
dit(nom, `(${sorte}, ${plage}) est absente de l'entrée du verrou`);
|
|
116
|
+
} else if (verrouille[nom] !== plage) {
|
|
117
|
+
dit(
|
|
118
|
+
nom,
|
|
119
|
+
`(${sorte}) déclare ${plage} dans le package.json et ${verrouille[nom]} dans le verrou`
|
|
120
|
+
);
|
|
121
|
+
} else {
|
|
122
|
+
const version = resolue(packages, cle, nom);
|
|
123
|
+
if (version && semver.validRange(plage) && !semver.satisfies(version, plage)) {
|
|
124
|
+
dit(
|
|
125
|
+
nom,
|
|
126
|
+
`(${sorte}) déclare ${plage}, que la version ${version} du verrou ne satisfait pas`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
for (const nom of Object.keys(verrouille)) {
|
|
132
|
+
if (!(nom in declare)) {
|
|
133
|
+
dit(nom, `(${sorte}) est retirée du package.json et reste dans l'entrée du verrou`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return constats;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The refusals of the repository at <racine>, one line per package and dependency.
|
|
143
|
+
* @param {string} racine
|
|
144
|
+
* @returns {string[]}
|
|
145
|
+
*/
|
|
146
|
+
export const verifier = racine => verifierLesConstats(racine).map(c => c.message);
|
|
147
|
+
|
|
148
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
149
|
+
const racine = process.cwd();
|
|
150
|
+
// A project that declares the lock a generated file (`grillhouse.engendres`) keeps its command,
|
|
151
|
+
// and its own judgement of it: the guard does not play for it.
|
|
152
|
+
const duProjet = Object.values(
|
|
153
|
+
lireJson(path.join(racine, 'package.json'))?.grillhouse?.engendres ?? {}
|
|
154
|
+
).some(e => Array.isArray(e?.fichiers) && e.fichiers.includes(LOCK));
|
|
155
|
+
const constats = duProjet ? [] : verifierLesConstats(racine);
|
|
156
|
+
for (const c of constats) {
|
|
157
|
+
process.stderr.write(`⛔ ${c.message}\n`);
|
|
158
|
+
}
|
|
159
|
+
ecrireSarif({ garde: GARDE, racine, constats });
|
|
160
|
+
process.exitCode = constats.length ? 1 : 0;
|
|
161
|
+
}
|
|
@@ -73,6 +73,13 @@ export const NUIT_VARIABLE = 'GRILLHOUSE_TESTS_DE_NUIT';
|
|
|
73
73
|
* `i/n`, and `rapports`, the directory of its reports (`trancher`, ../tranches.mjs).
|
|
74
74
|
*/
|
|
75
75
|
export const NUIT_TRANCHE = 'GRILLHOUSE_TRANCHE_DE_NUIT';
|
|
76
|
+
/**
|
|
77
|
+
* The variable that carries the unit of a run of the night's configuration, JSON: `config`, the
|
|
78
|
+
* configuration of the package of the run (absent for the root), and `exclus`, the patterns of
|
|
79
|
+
* the units below it, which it leaves out. The night's configuration takes it out of the environment
|
|
80
|
+
* once read: no process the tests start receives it.
|
|
81
|
+
*/
|
|
82
|
+
export const NUIT_PAQUET = 'GRILLHOUSE_NUIT_PAQUET';
|
|
76
83
|
// Whether the file at <fichier> bears the name of <motif>, a globstar then a name: by the name of
|
|
77
84
|
// the file, since a globstar passes no directory whose name starts with a dot, and a ticket's copy
|
|
78
85
|
// lives under `.claude/worktrees/`.
|
|
@@ -106,6 +113,26 @@ export function porteLEtiquetteDuPoste(texte) {
|
|
|
106
113
|
}
|
|
107
114
|
return false;
|
|
108
115
|
}
|
|
116
|
+
// The tag of a night test that needs the equipment of a machine (the envelope, a Temporal server,
|
|
117
|
+
// the binaries of the module cargo): `// @equipee: <reason>` in the comment at the head of the file,
|
|
118
|
+
// beside `@poste` when the test needs both. A runner without equipment leaves it out.
|
|
119
|
+
const ETIQUETTE_EQUIPEE = /^\/\/\s*@equipee\b/;
|
|
120
|
+
/**
|
|
121
|
+
* Whether the text <texte> of a test file bears the tag `@equipee` in the comment at its head.
|
|
122
|
+
* @param {string} texte the text of the file
|
|
123
|
+
*/
|
|
124
|
+
export function porteLEtiquetteEquipee(texte) {
|
|
125
|
+
for (const ligne of texte.split('\n')) {
|
|
126
|
+
const l = ligne.trim();
|
|
127
|
+
if (ETIQUETTE_EQUIPEE.test(l)) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
if (l !== '' && !l.startsWith('//') && !l.startsWith('#!')) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
109
136
|
// Vitest's default `include` (its configDefaults).
|
|
110
137
|
const INCLUDE = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];
|
|
111
138
|
// The mark of a time witness: the import of `mesurerAuRepos`, on a line of its own, from the
|
|
@@ -289,6 +316,18 @@ async function cibler(config, test, valeur, temoins) {
|
|
|
289
316
|
* @param {string} dir the directory searched
|
|
290
317
|
*/
|
|
291
318
|
export function testsDuPoste(dir) {
|
|
319
|
+
return testsEtiquetes(dir, porteLEtiquetteDuPoste);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* The night tests under <dir> that bear the tag `@equipee`, listed as `testsDuPoste` lists its own.
|
|
324
|
+
* @param {string} dir the directory searched
|
|
325
|
+
*/
|
|
326
|
+
export function testsEquipes(dir) {
|
|
327
|
+
return testsEtiquetes(dir, porteLEtiquetteEquipee);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function testsEtiquetes(dir, porte) {
|
|
292
331
|
return [
|
|
293
332
|
...new Set(
|
|
294
333
|
globSync([NUIT], { cwd: dir, exclude: d => HORS_TEMOINS.has(path.basename(d)) }).map(f =>
|
|
@@ -296,14 +335,16 @@ export function testsDuPoste(dir) {
|
|
|
296
335
|
)
|
|
297
336
|
),
|
|
298
337
|
]
|
|
299
|
-
.filter(f =>
|
|
338
|
+
.filter(f => porte(lireTexte(path.join(dir, f))))
|
|
300
339
|
.sort();
|
|
301
340
|
}
|
|
302
341
|
|
|
303
342
|
/**
|
|
304
343
|
* The plugin of the night's configuration: the night tests, the benches and the time witnesses
|
|
305
344
|
* under its directory, or, as <env> chooses in NUIT_VARIABLE, the night tests alone (`nuit`), the
|
|
306
|
-
* night tests but those tagged `@poste` (`hors-poste`, the night of
|
|
345
|
+
* night tests but those tagged `@poste` (`hors-poste`, the night of an equipped runner), those
|
|
346
|
+
* tagged `@poste` or `@equipee` left out too (`hors-poste-sans-equipement`), those tagged `@poste`
|
|
347
|
+
* alone (`du-poste`, the night of the poste), or the
|
|
307
348
|
* measures alone (`mesures`), the benches and the witnesses; every choice plays one file at a time
|
|
308
349
|
* (`fileParallelism: false`), the night at rest; with NUIT_TRANCHE, the tranche it carries of these
|
|
309
350
|
* files.
|
|
@@ -324,15 +365,25 @@ export const nuit = (env = process.env) => ({
|
|
|
324
365
|
test.fileParallelism = false;
|
|
325
366
|
if (choix === 'nuit') {
|
|
326
367
|
test.include = [NUIT];
|
|
327
|
-
} else if (choix === 'hors-poste') {
|
|
368
|
+
} else if (choix === 'hors-poste' || choix === 'hors-poste-sans-equipement') {
|
|
328
369
|
test.include = [NUIT];
|
|
329
|
-
const
|
|
330
|
-
|
|
370
|
+
const dir = path.resolve(config.root ?? process.cwd(), test.dir ?? '');
|
|
371
|
+
const laisses = [
|
|
372
|
+
...new Set([
|
|
373
|
+
...testsDuPoste(dir),
|
|
374
|
+
...(choix === 'hors-poste-sans-equipement' ? testsEquipes(dir) : []),
|
|
375
|
+
]),
|
|
376
|
+
].sort();
|
|
377
|
+
if (laisses.length) {
|
|
331
378
|
test.exclude = [
|
|
332
379
|
...(test.exclude ?? ['**/node_modules/**']),
|
|
333
|
-
...
|
|
380
|
+
...laisses.map(r => r.replace(SPECIAUX, '\\$&')),
|
|
334
381
|
];
|
|
335
382
|
}
|
|
383
|
+
} else if (choix === 'du-poste') {
|
|
384
|
+
test.include = testsDuPoste(path.resolve(config.root ?? process.cwd(), test.dir ?? '')).map(
|
|
385
|
+
r => r.replace(SPECIAUX, '\\$&')
|
|
386
|
+
);
|
|
336
387
|
} else if (choix === 'mesures') {
|
|
337
388
|
test.include = [BUDGET, ...temoins];
|
|
338
389
|
} else {
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
// target of Bazel declares its `data`: a line `// @lit <motif> …` of the comment at its head,
|
|
40
40
|
// each pattern a glob from the top of the repository (`// @lit packages/grillhouse/scripts/**`).
|
|
41
41
|
// ./changements.mjs adds it to the tests of every pass, targeted or not, whose changes, files
|
|
42
|
-
// changed, added or removed, one of its patterns covers
|
|
42
|
+
// changed, added or removed, one of its patterns covers; the generator of the packages'
|
|
43
|
+
// turbo.json (../turbo-des-paquets.mjs) writes each pattern in the inputs of the package's test
|
|
44
|
+
// task, so that Turborepo's cache follows the same declaration.
|
|
43
45
|
// - What a test names without the frame reading it (`nonDeclares`): a string of the test's code or
|
|
44
46
|
// of its material that ends the path of a module of its package (`'verrou.mjs'`,
|
|
45
47
|
// `'verrous/verrou.mjs'`), out of a directory of tests, the module out of what the test reads and
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
// the temporary directory named after its process and a token, scripts/places-de-la-machine.mjs),
|
|
4
4
|
// which every process it starts inherits: a `npm run verifier` or a circuit that a test plays in
|
|
5
5
|
// a repository of trial takes its part there, among its own parts alone, and no test writes in the
|
|
6
|
-
// user's state. A directory already named in the environment stays.
|
|
6
|
+
// user's state. A directory already named in the environment stays. The directory the file named
|
|
7
|
+
// is removed at its end, with what a pass left there (the part of a pass a test killed, which
|
|
8
|
+
// never gave it back), as the register of the file is (./registre.setup.mjs): the guard of the
|
|
9
|
+
// temporary directory of the run finds nothing of it. Its passes want no room in
|
|
7
10
|
// the temporary directory (GRILLHOUSE_TEMPORAIRE_LIBRE, 0) nor on the disk of their copy
|
|
8
11
|
// (GRILLHOUSE_COPIE_LIBRE, 0): the room of the machine is the pass's that plays the file, which
|
|
9
12
|
// waited for it.
|
|
@@ -11,13 +14,16 @@
|
|
|
11
14
|
// That trial machine takes no place of the user's machine (scripts/places-de-la-machine.mjs): only
|
|
12
15
|
// the server of trial a test names (GRILLHOUSE_PLACES_D_ESSAI).
|
|
13
16
|
import { randomUUID } from 'node:crypto';
|
|
17
|
+
import { rmSync } from 'node:fs';
|
|
14
18
|
import { tmpdir } from 'node:os';
|
|
15
19
|
import path from 'node:path';
|
|
20
|
+
import { afterAll } from 'vitest';
|
|
16
21
|
|
|
17
|
-
process.env.GRILLHOUSE_PARTS_DE_LA_MACHINE
|
|
18
|
-
tmpdir(),
|
|
19
|
-
|
|
20
|
-
);
|
|
22
|
+
if (!process.env.GRILLHOUSE_PARTS_DE_LA_MACHINE) {
|
|
23
|
+
const parts = path.join(tmpdir(), `grillhouse-parts-${process.pid}-${randomUUID()}`);
|
|
24
|
+
process.env.GRILLHOUSE_PARTS_DE_LA_MACHINE = parts;
|
|
25
|
+
afterAll(() => rmSync(parts, { recursive: true, force: true }));
|
|
26
|
+
}
|
|
21
27
|
// The machine a test reads is a fixed one (GRILLHOUSE_MESURE_D_ESSAI, scripts/places-de-la-machine.mjs
|
|
22
28
|
// `etatDesPlaces`): no test reads the real load or memory of the user's machine.
|
|
23
29
|
process.env.GRILLHOUSE_MESURE_D_ESSAI ||= JSON.stringify({
|
|
@@ -10,17 +10,50 @@
|
|
|
10
10
|
// and the benches, and its plugin adds the witnesses under the root, or chooses the night tests
|
|
11
11
|
// alone, the night tests but those tagged `@poste` (the night of a shared machine, a CI), or the
|
|
12
12
|
// measures alone, one file at a time (`nuit` of ./vitest-config/cibles.mjs, the variable
|
|
13
|
-
// GRILLHOUSE_TESTS_DE_NUIT). It reads no day configuration of the
|
|
14
|
-
//
|
|
13
|
+
// GRILLHOUSE_TESTS_DE_NUIT). It reads no day configuration of the root, and that of each package
|
|
14
|
+
// only for its own files (below); it takes from the base configuration the common
|
|
15
15
|
// environment (git's settings) and the measure of time: the setup file that notes the CPU pressure
|
|
16
16
|
// of each test and the duration reporter, which gives 75, « à repasser », to a measure that fails
|
|
17
17
|
// under load (scripts/langages/typescript/vitest-config/duree.reporter.mjs).
|
|
18
|
+
//
|
|
19
|
+
// A run plays one unit of the project: the root, under this configuration alone, or a package that
|
|
20
|
+
// has a Vitest configuration (`vitest.config.*`, else `vite.config.*`, in its directory, found by
|
|
21
|
+
// ./tests-de-nuit.mjs), under this configuration merged over the package's, as Vitest's projects
|
|
22
|
+
// merge a package's configuration with the root's: what the package sets and the night does not
|
|
23
|
+
// set (environment, alias, plugins) stays, its setup files precede those of the base, and what the
|
|
24
|
+
// night sets wins (include, exclusions, reporters, delays, one file at a time, the tranche). The
|
|
25
|
+
// variable GRILLHOUSE_NUIT_PAQUET (NUIT_PAQUET), JSON, names the configuration of the package of
|
|
26
|
+
// the run (`config`) and the directories of the units below the unit of the run (`exclus`), which
|
|
27
|
+
// it leaves out; this configuration takes it out of the environment once read, as the plugin of
|
|
28
|
+
// the night does its choice and its tranche: the unit is the run's own, and a Vitest that a night
|
|
29
|
+
// test starts itself, in another package, plays under no configuration but its own. Node (>= 26)
|
|
30
|
+
// reads the package's configuration itself, TypeScript included; a configuration written as a
|
|
31
|
+
// function is called as Vite calls it, for a test run.
|
|
32
|
+
import { pathToFileURL } from 'node:url';
|
|
33
|
+
import { mergeConfig } from 'vitest/config';
|
|
18
34
|
import base from './vitest-config/base.mjs';
|
|
19
|
-
import { HORS_DU_JOUR, nuit } from './vitest-config/cibles.mjs';
|
|
35
|
+
import { HORS_DU_JOUR, nuit, NUIT_PAQUET } from './vitest-config/cibles.mjs';
|
|
20
36
|
import { DELAI_NUIT_MS } from './vitest-config/bornes.mjs';
|
|
21
37
|
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
const { config: fichier, exclus = [] } = process.env[NUIT_PAQUET]
|
|
39
|
+
? JSON.parse(process.env[NUIT_PAQUET])
|
|
40
|
+
: {};
|
|
41
|
+
delete process.env[NUIT_PAQUET];
|
|
42
|
+
|
|
43
|
+
// What the night sets wins over the configuration of a package, whose plugins have run first: the
|
|
44
|
+
// exclusions of its unit, the reporters, and the setup files, the package's before the base's.
|
|
45
|
+
const nuitGagne = {
|
|
46
|
+
name: 'grillhouse:nuit-gagne',
|
|
47
|
+
config(config) {
|
|
48
|
+
const test = (config.test ??= {});
|
|
49
|
+
test.exclude = ['**/node_modules/**', '**/dist/**', '**/.git/**', ...exclus];
|
|
50
|
+
test.reporters = base.test.reporters;
|
|
51
|
+
test.setupFiles = [...new Set([...(test.setupFiles ?? []), ...base.test.setupFiles])];
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const cadre = {
|
|
56
|
+
plugins: [nuitGagne, nuit()],
|
|
24
57
|
cacheDir: base.cacheDir,
|
|
25
58
|
test: {
|
|
26
59
|
env: base.test.env,
|
|
@@ -29,9 +62,24 @@ export default {
|
|
|
29
62
|
setupFiles: base.test.setupFiles,
|
|
30
63
|
include: HORS_DU_JOUR,
|
|
31
64
|
exclude: ['**/node_modules/**', '**/dist/**', '**/.git/**'],
|
|
65
|
+
// A unit may hold none of the files the run chooses.
|
|
66
|
+
passWithNoTests: true,
|
|
32
67
|
// The large delay of Bazel for a night test: 900 s (./vitest-config/delais.mjs).
|
|
33
68
|
testTimeout: DELAI_NUIT_MS,
|
|
34
69
|
hookTimeout: DELAI_NUIT_MS,
|
|
35
70
|
watch: false,
|
|
36
71
|
},
|
|
37
72
|
};
|
|
73
|
+
|
|
74
|
+
async function dePaquet(f) {
|
|
75
|
+
const lu = (await import(pathToFileURL(f).href)).default;
|
|
76
|
+
const paquet = typeof lu === 'function' ? await lu({ command: 'serve', mode: 'test' }) : lu;
|
|
77
|
+
// The environment and the setup files of the package are its own to set.
|
|
78
|
+
const { environment: _e, setupFiles: _s, ...test } = cadre.test;
|
|
79
|
+
return mergeConfig(paquet ?? {}, { ...cadre, test });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** @type {typeof cadre} */
|
|
83
|
+
const configuration = fichier ? await dePaquet(fichier) : cadre;
|
|
84
|
+
|
|
85
|
+
export default configuration;
|
package/scripts/langages.mjs
CHANGED
|
@@ -30,6 +30,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
30
30
|
import { createRequire } from 'node:module';
|
|
31
31
|
import path from 'node:path';
|
|
32
32
|
import { composer } from './composition-des-langages.mjs';
|
|
33
|
+
import { matieresDeclarees, sousUneMatiere } from './matieres-lues.mjs';
|
|
33
34
|
import {
|
|
34
35
|
ARCHITECTURE,
|
|
35
36
|
COLONNE,
|
|
@@ -98,10 +99,31 @@ export function langagesDe(racine) {
|
|
|
98
99
|
return noms.map(charger);
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
// The class of a file under a folder of test material the project declares
|
|
103
|
+
// (`grillhouse.matieres`, ./matieres-cles.mjs): shared test material, never played.
|
|
104
|
+
const MATIERE_DECLAREE = Object.freeze({ joue: false, test: false, matiere: true });
|
|
105
|
+
|
|
106
|
+
// <langage> with the answer of `estUnTest` completed after its modules: the first answer not null
|
|
107
|
+
// of a module stays the file's; a file under a declared folder, in any language, is test material;
|
|
108
|
+
// any other file keeps the answer of its module.
|
|
109
|
+
const avecLesMatieres = langage =>
|
|
110
|
+
Object.assign(Object.create(langage), {
|
|
111
|
+
estUnTest: (chemin, racine) =>
|
|
112
|
+
langage.estUnTest(chemin, racine) ??
|
|
113
|
+
(sousUneMatiere(
|
|
114
|
+
matieresDeclarees(racine, d => langage.composants(d)),
|
|
115
|
+
racine,
|
|
116
|
+
chemin
|
|
117
|
+
)
|
|
118
|
+
? MATIERE_DECLAREE
|
|
119
|
+
: null),
|
|
120
|
+
});
|
|
121
|
+
|
|
101
122
|
const composes = new Map();
|
|
102
123
|
/**
|
|
103
|
-
* The join of the modules that serve the project at <racine> (`langagesDe`):
|
|
104
|
-
* when the project declares one,
|
|
124
|
+
* The join of the modules that serve the project at <racine> (`langagesDe`): their composition
|
|
125
|
+
* (the module itself when the project declares one), the folders of test material the project
|
|
126
|
+
* declares (`grillhouse.matieres`) added to `estUnTest`, built once per list of languages.
|
|
105
127
|
* @param {string} racine the root of the project
|
|
106
128
|
* @returns {import('./jointure.js').Composition}
|
|
107
129
|
*/
|
|
@@ -109,7 +131,7 @@ export function langageDe(racine) {
|
|
|
109
131
|
const modules = langagesDe(racine);
|
|
110
132
|
const cle = modules.map(m => m.nom).join('+');
|
|
111
133
|
if (!composes.has(cle)) {
|
|
112
|
-
composes.set(cle, composer(modules));
|
|
134
|
+
composes.set(cle, avecLesMatieres(composer(modules)));
|
|
113
135
|
}
|
|
114
136
|
return composes.get(cle);
|
|
115
137
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// `grillhouse machine fermer [--attendre]` and `grillhouse machine rouvrir`: closes the machine to
|
|
2
|
+
// new work and reopens it, as `kubectl cordon` / `drain` / `uncordon` do for a node, so that the
|
|
3
|
+
// poste restarts without cutting a circuit in the middle of its work.
|
|
4
|
+
//
|
|
5
|
+
// - `fermer`: no place is given any more, to any project of the poste, and no ticket starts; each
|
|
6
|
+
// circuit alive finishes its step, then waits without starting the next. The command returns at
|
|
7
|
+
// once (as `cordon`), saying what still runs by project and by ticket, and « la machine est
|
|
8
|
+
// vide » when nothing plays; played again, it reads that state. With `--attendre` it returns
|
|
9
|
+
// only once the machine is empty (as `drain`): exit 0.
|
|
10
|
+
// - `rouvrir`: the circuits go on by themselves at the next step.
|
|
11
|
+
// - A night that holds the machine is never doubled nor lifted: the command says so (exit 0).
|
|
12
|
+
// - The closure lives in the state of the places on the Temporal server: it survives a restart of
|
|
13
|
+
// the poste, and no circuit starts again before the reopening.
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import { setTimeout as dormirVraiment } from 'node:timers/promises';
|
|
16
|
+
import { direLaFermeture } from './fermeture-de-la-machine.mjs';
|
|
17
|
+
import {
|
|
18
|
+
dossierDesParts,
|
|
19
|
+
fermerLaMachine,
|
|
20
|
+
lireLesParts,
|
|
21
|
+
lirePlaces,
|
|
22
|
+
rouvrirLaMachine,
|
|
23
|
+
} from './places-de-la-machine.mjs';
|
|
24
|
+
|
|
25
|
+
const SONDE_MS = 2_000;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* What the machine holds now: the sessions (places) and the passes (parts that hold their part),
|
|
29
|
+
* and the reservation in place.
|
|
30
|
+
* @param {Record<string, string | undefined>} env
|
|
31
|
+
*/
|
|
32
|
+
export function lireLaMachine(env = process.env) {
|
|
33
|
+
const lues = lirePlaces({ env });
|
|
34
|
+
return {
|
|
35
|
+
prises: lues.prises ?? [],
|
|
36
|
+
parts: lireLesParts(dossierDesParts(env)).prises,
|
|
37
|
+
fermeture: lues.fermeture ?? null,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Plays the command <mode> (`fermer` or `rouvrir`) with its arguments <args>: its lines, one per
|
|
43
|
+
* call of <dire>; the exit code.
|
|
44
|
+
* @param {string | undefined} mode
|
|
45
|
+
* @param {string[]} args
|
|
46
|
+
* @param {{ env?: Record<string, string | undefined>, dire?: (l: string) => void,
|
|
47
|
+
* maintenant?: () => number,
|
|
48
|
+
* agir?: (mode: 'fermer' | 'rouvrir', o: { env: Record<string, string | undefined> }) => string,
|
|
49
|
+
* lire?: (env: Record<string, string | undefined>) => ReturnType<typeof lireLaMachine>,
|
|
50
|
+
* dormir?: (ms: number) => Promise<unknown> }} [o]
|
|
51
|
+
* @returns {Promise<number>}
|
|
52
|
+
*/
|
|
53
|
+
export async function jouer(
|
|
54
|
+
mode,
|
|
55
|
+
args,
|
|
56
|
+
{
|
|
57
|
+
env = process.env,
|
|
58
|
+
dire = l => console.log(l),
|
|
59
|
+
maintenant = Date.now,
|
|
60
|
+
agir = (m, o) => (m === 'fermer' ? fermerLaMachine(o) : rouvrirLaMachine(o)),
|
|
61
|
+
lire = lireLaMachine,
|
|
62
|
+
dormir = dormirVraiment,
|
|
63
|
+
} = {},
|
|
64
|
+
) {
|
|
65
|
+
const attendre = args.includes('--attendre');
|
|
66
|
+
if ((mode !== 'fermer' && mode !== 'rouvrir') || args.some(a => a !== '--attendre') || (attendre && mode !== 'fermer')) {
|
|
67
|
+
process.stderr.write('usage : grillhouse machine fermer [--attendre] | rouvrir\n');
|
|
68
|
+
return 2;
|
|
69
|
+
}
|
|
70
|
+
const issue = agir(mode, { env });
|
|
71
|
+
const dit = () => {
|
|
72
|
+
const { prises, parts, fermeture } = lire(env);
|
|
73
|
+
for (const l of direLaFermeture({ issue, reservation: fermeture, prises, parts, maintenant: maintenant() })) {
|
|
74
|
+
dire(l);
|
|
75
|
+
}
|
|
76
|
+
return prises.length + parts.length;
|
|
77
|
+
};
|
|
78
|
+
const restent = dit();
|
|
79
|
+
if (!attendre) {
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
let encore = restent;
|
|
83
|
+
while (encore > 0) {
|
|
84
|
+
await dormir(SONDE_MS);
|
|
85
|
+
const { prises, parts } = lire(env);
|
|
86
|
+
if (prises.length + parts.length === 0) {
|
|
87
|
+
dire('la machine est vide');
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
encore = prises.length + parts.length;
|
|
91
|
+
}
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (process.argv[1] && path.basename(process.argv[1]) === 'machine.mjs') {
|
|
96
|
+
const [mode, ...args] = process.argv.slice(2);
|
|
97
|
+
try {
|
|
98
|
+
process.exitCode = await jouer(mode, args);
|
|
99
|
+
} catch (x) {
|
|
100
|
+
process.stderr.write(`⛔ grillhouse machine : ${x?.message ?? x}\n`);
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// The folders of test material a project declares (`grillhouse.matieres` of its root package.json,
|
|
2
|
+
// read by ./matieres-lues.mjs, which holds the rules of the key), asked by a directory of the
|
|
3
|
+
// project: the callers of the circuit, the envelope, the integration, the queue and the move of a
|
|
4
|
+
// copy, which refuse a faulty key by its name before any work.
|
|
5
|
+
import { langageDe } from './langages.mjs';
|
|
6
|
+
import { matieresDeclarees } from './matieres-lues.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The folders of test material that the project that holds <dir> declares, from the root, in the
|
|
10
|
+
* order of the key; none without the key.
|
|
11
|
+
* @param {string} dir a directory of the project: its main tree or a copy
|
|
12
|
+
* @returns {string[]}
|
|
13
|
+
* @throws {Error} the faults of the key, one per line
|
|
14
|
+
*/
|
|
15
|
+
export function matieresDeclareesDe(dir) {
|
|
16
|
+
return matieresDeclarees(dir, d => langageDe(d).composants(d));
|
|
17
|
+
}
|