@roomi-fields/grillhouse 0.25.5 → 0.27.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/agents/testwriter.md +1 -1
- package/bin/grillhouse.mjs +20 -3
- package/cadre/templates/cargo/package.json +3 -0
- package/cadre/templates/projet/.gitattributes +1 -0
- package/cadre/templates/projet/CLAUDE.md +13 -0
- package/cadre/templates/projet/docs/ARCHITECTURE.md +15 -0
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/python/package.json +18 -0
- package/charte.md +32 -1
- package/docs/ARCHITECTURE.md +146 -40
- package/docs/CADRE.md +7 -6
- package/docs/INTERFACE.md +108 -32
- package/hooks/register.tsx +57 -16
- package/package.json +9 -3
- package/scripts/circuit.mjs +165 -27
- package/scripts/commande-du-langage.mjs +2 -2
- package/scripts/commandes-composees.mjs +156 -0
- package/scripts/composition-des-langages.mjs +306 -0
- package/scripts/conformite.mjs +1 -3
- package/scripts/copies-finies.mjs +167 -28
- package/scripts/crochets.mjs +9 -3
- package/scripts/dernier-vert.mjs +15 -2
- package/scripts/engendres.mjs +170 -0
- package/scripts/enveloppe/enveloppe.mjs +59 -17
- package/scripts/enveloppe/lancer.sh +15 -22
- package/scripts/enveloppe/travail-de-la-copie.mjs +262 -0
- package/scripts/etapes.mjs +1 -1
- package/scripts/fusion-du-changelog.mjs +120 -0
- package/scripts/gardes-du-cadre.mjs +7 -4
- package/scripts/grillhouse-maj.mjs +171 -99
- package/scripts/index-interfaces.mjs +78 -0
- package/scripts/init.mjs +5 -5
- package/scripts/integration/file.mjs +270 -117
- package/scripts/integration/integrer.mjs +50 -62
- package/scripts/jointure.d.ts +48 -14
- package/scripts/langages/cargo/binaires.json +2 -1
- package/scripts/langages/cargo/binaires.mjs +29 -6
- package/scripts/langages/cargo/clippy.mjs +12 -2
- package/scripts/langages/cargo/commandes.mjs +60 -7
- package/scripts/langages/cargo/composants.mjs +229 -8
- package/scripts/langages/cargo/exemples.mjs +1 -15
- package/scripts/langages/cargo/index-interfaces.mjs +20 -3
- package/scripts/langages/cargo/index.mjs +25 -17
- package/scripts/langages/cargo/mise-a-jour.mjs +2 -1
- package/scripts/langages/cargo/sccache.mjs +172 -0
- package/scripts/langages/cargo/verdict.mjs +50 -10
- package/scripts/langages/python/binaires.json +3 -0
- package/scripts/langages/python/binaires.mjs +59 -0
- package/scripts/langages/python/commandes.mjs +411 -0
- package/scripts/langages/python/composants.mjs +272 -0
- package/scripts/langages/python/exemples.mjs +260 -0
- package/scripts/langages/python/index-interfaces.mjs +77 -0
- package/scripts/langages/python/index.mjs +94 -0
- package/scripts/langages/python/lot.mjs +76 -0
- package/scripts/langages/python/mise-a-jour.mjs +54 -0
- package/scripts/langages/python/tailles-des-tests.mjs +102 -0
- package/scripts/langages/python/verdict.mjs +85 -0
- package/scripts/langages/typescript/exemples.mjs +1 -20
- package/scripts/langages/typescript/index-interfaces.mjs +10 -3
- package/scripts/langages/typescript/index.mjs +15 -17
- package/scripts/langages/typescript/regle-des-tests.mjs +37 -0
- package/scripts/langages-des-paquets.mjs +171 -0
- package/scripts/langages.mjs +60 -41
- package/scripts/migrations/0.27.0-langages-dans-l-architecture.mjs +182 -0
- package/scripts/migrations.mjs +2 -0
- package/scripts/nuit.sh +15 -1
- package/scripts/outils-cles.mjs +188 -0
- package/scripts/resultats.mjs +22 -6
- package/scripts/session-start.sh +34 -9
- package/scripts/sources.mjs +2 -1
- package/scripts/sous-commandes.mjs +21 -3
- package/scripts/tableau-des-composants.mjs +138 -0
- package/scripts/verrou-de-machine.mjs +14 -13
- package/scripts/verrous/verrou.mjs +53 -16
- package/skills/developpeur/SKILL.md +4 -0
- package/skills/explorateur/SKILL.md +3 -1
- package/skills/grill/SKILL.md +9 -1
- package/skills/pitmaster/SKILL.md +12 -3
- package/skills/pitmaster/references/consigne-agent.md +3 -3
- package/skills/redacteur/references/documents-d-un-composant.md +12 -0
- package/skills/relecteur/SKILL.md +6 -2
- package/skills/testwriter/SKILL.md +29 -6
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// The entries of the suite of conformity (scripts/conformite.mjs) for the module python, as the
|
|
2
|
+
// valid and invalid cases a rule of ESLint gives its RuleTester: each a trial, built under the
|
|
3
|
+
// directory the suite gives, with what a sound module answers on it.
|
|
4
|
+
//
|
|
5
|
+
// - A project of two packages, declared python in its architecture: `site` (its project
|
|
6
|
+
// `generateur`, a test of the day `pages/test_pages.py`, a night test, a `conftest.py`, its
|
|
7
|
+
// interface) and `outil` (its project `outil`, no test); the root's interface, and the index of
|
|
8
|
+
// the interfaces they give, up to date. Committed: `projet`; the same, a source of `site` then
|
|
9
|
+
// changed and a file out of every package added: `change`, measured from its commit; the same
|
|
10
|
+
// with a second commit that changes `site`, adds the package `neuf` and removes `outil`: `lot`;
|
|
11
|
+
// the same, the interface of `site` then changed, its index late: `enRetard`.
|
|
12
|
+
// - A directory without pyproject.toml: `vide`.
|
|
13
|
+
// - Two results directories of a run: every task and test green (`vert`); `site` red with a test
|
|
14
|
+
// failed, `outil` at 75, a task not played (`defaut`).
|
|
15
|
+
// - `depots`: the repositories, for the tests of the module beside the suite.
|
|
16
|
+
import { execFileSync } from 'node:child_process';
|
|
17
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
|
|
20
|
+
const ecrireDans = racine => (rel, texte) => {
|
|
21
|
+
mkdirSync(path.dirname(path.join(racine, rel)), { recursive: true });
|
|
22
|
+
writeFileSync(path.join(racine, rel), texte);
|
|
23
|
+
};
|
|
24
|
+
const git = (racine, ...args) => execFileSync('git', ['-C', racine, ...args], { stdio: 'pipe' });
|
|
25
|
+
const tete = racine =>
|
|
26
|
+
execFileSync('git', ['-C', racine, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
|
|
27
|
+
|
|
28
|
+
// Commits every file of <racine>, a new repository.
|
|
29
|
+
function engager(racine) {
|
|
30
|
+
git(racine, 'init', '-q', '-b', 'main');
|
|
31
|
+
git(racine, 'config', 'user.email', 'essai@example.com');
|
|
32
|
+
git(racine, 'config', 'user.name', 'essai');
|
|
33
|
+
git(racine, 'config', 'commit.gpgsign', 'false');
|
|
34
|
+
git(racine, 'add', '-A');
|
|
35
|
+
git(racine, 'commit', '-q', '-m', 'essai');
|
|
36
|
+
return racine;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The pyproject.toml of the project <nom>.
|
|
40
|
+
const manifeste = nom =>
|
|
41
|
+
`[project]\nname = "${nom}"\nversion = "0.1.0"\nrequires-python = ">=3.10"\ndependencies = []\n\n[dependency-groups]\ntest = ["pytest>=8"]\n`;
|
|
42
|
+
|
|
43
|
+
const ARCHITECTURE =
|
|
44
|
+
'# Architecture\n\n| Composant | Langage |\n| --- | --- |\n| `site` | python |\n| `outil` | python |\n| `neuf` | python |\n';
|
|
45
|
+
const INTERFACES = {
|
|
46
|
+
'site/docs/INTERFACE.md': '# site — interface\n\n`site` génère les pages. Une seconde phrase.\n',
|
|
47
|
+
'docs/INTERFACE.md': "# Le projet d'essai\n\nDeux paquets Python.\n",
|
|
48
|
+
};
|
|
49
|
+
/** The index of the interfaces the trial gives (./index-interfaces.mjs). */
|
|
50
|
+
export const INDEX = [
|
|
51
|
+
'# Index des interfaces',
|
|
52
|
+
'',
|
|
53
|
+
'Généré depuis les `INTERFACE.md` des paquets Python ; ne pas éditer.',
|
|
54
|
+
"Une ligne par composant ; l'interface donne le détail.",
|
|
55
|
+
'',
|
|
56
|
+
"## (racine) — Le projet d'essai",
|
|
57
|
+
'',
|
|
58
|
+
'Deux paquets Python. (`docs/INTERFACE.md`)',
|
|
59
|
+
'',
|
|
60
|
+
'## site — interface',
|
|
61
|
+
'',
|
|
62
|
+
'`site` génère les pages. (`site/docs/INTERFACE.md`)',
|
|
63
|
+
'',
|
|
64
|
+
].join('\n');
|
|
65
|
+
|
|
66
|
+
// The project of the two packages in a new directory under <dans>, committed.
|
|
67
|
+
function projet(dans) {
|
|
68
|
+
const racine = mkdtempSync(path.join(dans, 'projet-'));
|
|
69
|
+
const ecrire = ecrireDans(racine);
|
|
70
|
+
ecrire('package.json', JSON.stringify({ name: 'essai', private: true }));
|
|
71
|
+
ecrire('docs/ARCHITECTURE.md', ARCHITECTURE);
|
|
72
|
+
ecrire('README.md', "# Le projet d'essai\n");
|
|
73
|
+
ecrire('.gitignore', '.venv\n.pytest_cache\n__pycache__\n');
|
|
74
|
+
ecrire('site/pyproject.toml', manifeste('generateur'));
|
|
75
|
+
ecrire('site/uv.lock', 'version = 1\n');
|
|
76
|
+
ecrire('site/pages/generer.py', 'def generer():\n return 1\n');
|
|
77
|
+
ecrire('site/pages/test_pages.py', 'def test_generer():\n assert True\n');
|
|
78
|
+
ecrire('site/pages/site_nuit_test.py', 'def test_tout():\n assert True\n');
|
|
79
|
+
ecrire('site/conftest.py', '');
|
|
80
|
+
ecrire('outil/pyproject.toml', manifeste('outil'));
|
|
81
|
+
ecrire('outil/uv.lock', 'version = 1\n');
|
|
82
|
+
ecrire('outil/outil.py', 'def outil():\n return 1\n');
|
|
83
|
+
for (const [f, t] of Object.entries(INTERFACES)) {
|
|
84
|
+
ecrire(f, t);
|
|
85
|
+
}
|
|
86
|
+
ecrire('docs/agents/index-des-interfaces.md', INDEX);
|
|
87
|
+
return engager(racine);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// A results directory under <dans>: the tasks <taches> (`[paquet, script, code]`), and the JUnit
|
|
91
|
+
// report of `site` (`[[fichier, test, echoue]…]`), its folder <dossier>.
|
|
92
|
+
function resultats(dans, taches, cas, dossier) {
|
|
93
|
+
const d = mkdtempSync(path.join(dans, 'resultats-'));
|
|
94
|
+
const ecrire = ecrireDans(d);
|
|
95
|
+
ecrire(
|
|
96
|
+
'python/1-1.json',
|
|
97
|
+
`${JSON.stringify({
|
|
98
|
+
taches: taches.map(([paquet, script, code]) => ({
|
|
99
|
+
tache: `${paquet}#${script}`,
|
|
100
|
+
paquet,
|
|
101
|
+
dossier: paquet,
|
|
102
|
+
script,
|
|
103
|
+
tests: script === 'pytest',
|
|
104
|
+
code,
|
|
105
|
+
cache: null,
|
|
106
|
+
journal: null,
|
|
107
|
+
})),
|
|
108
|
+
rapports: { '1-1-site.xml': dossier },
|
|
109
|
+
})}\n`
|
|
110
|
+
);
|
|
111
|
+
const corps = cas
|
|
112
|
+
.map(
|
|
113
|
+
([fichier, test, echoue]) =>
|
|
114
|
+
`<testcase classname="x" name="${test}" file="${fichier}" line="1">${
|
|
115
|
+
echoue ? '<failure message="assert 1 == 2">assert 1 == 2</failure>' : ''
|
|
116
|
+
}</testcase>`
|
|
117
|
+
)
|
|
118
|
+
.join('');
|
|
119
|
+
ecrire(
|
|
120
|
+
'pytest/1-1-site.xml',
|
|
121
|
+
`<?xml version="1.0"?><testsuites><testsuite name="pytest">${corps}</testsuite></testsuites>`
|
|
122
|
+
);
|
|
123
|
+
return d;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export default {
|
|
127
|
+
// The trials under <dans>.
|
|
128
|
+
preparer(dans) {
|
|
129
|
+
const aJour = projet(dans);
|
|
130
|
+
const vide = mkdtempSync(path.join(dans, 'vide-'));
|
|
131
|
+
writeFileSync(path.join(vide, 'README.md'), 'aucun paquet\n');
|
|
132
|
+
const change = projet(dans);
|
|
133
|
+
const depuis = tete(change);
|
|
134
|
+
writeFileSync(path.join(change, 'site/pages/generer.py'), 'def generer():\n return 2\n');
|
|
135
|
+
writeFileSync(path.join(change, 'notes.txt'), 'hors des paquets\n');
|
|
136
|
+
const lot = projet(dans);
|
|
137
|
+
const avantLeLot = tete(lot);
|
|
138
|
+
const ecrireLot = ecrireDans(lot);
|
|
139
|
+
ecrireLot('site/pages/generer.py', 'def generer():\n return 3\n');
|
|
140
|
+
ecrireLot('neuf/pyproject.toml', manifeste('neuf'));
|
|
141
|
+
ecrireLot('neuf/neuf.py', 'def neuf():\n return 1\n');
|
|
142
|
+
rmSync(path.join(lot, 'outil'), { recursive: true, force: true });
|
|
143
|
+
git(lot, 'add', '-A');
|
|
144
|
+
git(lot, 'commit', '-q', '-m', 'lot');
|
|
145
|
+
const enRetard = projet(dans);
|
|
146
|
+
writeFileSync(
|
|
147
|
+
path.join(enRetard, 'site/docs/INTERFACE.md'),
|
|
148
|
+
'# site — interface\n\n`site` génère d’autres pages.\n'
|
|
149
|
+
);
|
|
150
|
+
const site = path.join(aJour, 'site');
|
|
151
|
+
return {
|
|
152
|
+
racine: aJour,
|
|
153
|
+
depots: { projet: aJour, change, depuis, lot, avantLeLot, enRetard, vide },
|
|
154
|
+
composants: {
|
|
155
|
+
valide: vide,
|
|
156
|
+
invalide: aJour,
|
|
157
|
+
attendu: ['outil (outil)', 'site (generateur)'],
|
|
158
|
+
},
|
|
159
|
+
composantDe: {
|
|
160
|
+
valide: [
|
|
161
|
+
{ fichier: 'site/pages/generer.py', composant: 'site' },
|
|
162
|
+
{ fichier: 'outil/outil.py', composant: 'outil' },
|
|
163
|
+
{ fichier: path.join(aJour, 'site/pyproject.toml'), composant: 'site' },
|
|
164
|
+
],
|
|
165
|
+
invalide: [{ fichier: 'README.md' }, { fichier: 'docs/INTERFACE.md' }],
|
|
166
|
+
attendu: [
|
|
167
|
+
'README.md : hors de tout composant',
|
|
168
|
+
'docs/INTERFACE.md : hors de tout composant',
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
lecteurs: {
|
|
172
|
+
valide: { racine: vide, noms: [] },
|
|
173
|
+
invalide: { racine: aJour, noms: ['generateur', 'absent'] },
|
|
174
|
+
attendu: ['absent : sans fournisseur'],
|
|
175
|
+
},
|
|
176
|
+
touches: {
|
|
177
|
+
valide: { racine: aJour, depuis: 'HEAD' },
|
|
178
|
+
invalide: { racine: change, depuis },
|
|
179
|
+
attendu: ['touché site', 'hors notes.txt'],
|
|
180
|
+
},
|
|
181
|
+
commandes: {
|
|
182
|
+
valide: ['tester', 'verifier', 'typer', 'preparer', 'tests-de-nuit', 'index-interfaces'],
|
|
183
|
+
invalide: ['tester', 'deployer'],
|
|
184
|
+
attendu: ['deployer : absente'],
|
|
185
|
+
},
|
|
186
|
+
verdict: {
|
|
187
|
+
valide: resultats(
|
|
188
|
+
dans,
|
|
189
|
+
[
|
|
190
|
+
['site', 'compileall', 0],
|
|
191
|
+
['site', 'pytest', 0],
|
|
192
|
+
],
|
|
193
|
+
[['pages/test_pages.py', 'test_generer', false]],
|
|
194
|
+
site
|
|
195
|
+
),
|
|
196
|
+
invalide: resultats(
|
|
197
|
+
dans,
|
|
198
|
+
[
|
|
199
|
+
['outil', 'compileall', 75],
|
|
200
|
+
['site', 'pytest', 1],
|
|
201
|
+
['neuf', 'pytest', null],
|
|
202
|
+
],
|
|
203
|
+
[
|
|
204
|
+
['pages/test_pages.py', 'test_generer', false],
|
|
205
|
+
['pages/test_pages.py', 'test_rendu', true],
|
|
206
|
+
],
|
|
207
|
+
site
|
|
208
|
+
),
|
|
209
|
+
attendu: [
|
|
210
|
+
'outil#compileall à repasser',
|
|
211
|
+
'site#pytest rouge (1), tests',
|
|
212
|
+
'test test_pages.py › test_rendu',
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
estUnTest: {
|
|
216
|
+
valide: [
|
|
217
|
+
'site/pages/generer.py',
|
|
218
|
+
'site/pyproject.toml',
|
|
219
|
+
'site/uv.lock',
|
|
220
|
+
'outil/outil.py',
|
|
221
|
+
'README.md',
|
|
222
|
+
],
|
|
223
|
+
invalide: ['site/pages/test_pages.py', 'site/conftest.py', 'site/tests/donnees.json'],
|
|
224
|
+
attendu: [
|
|
225
|
+
'site/pages/test_pages.py : joue, test',
|
|
226
|
+
'site/conftest.py : test',
|
|
227
|
+
'site/tests/donnees.json : test',
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
fichiersEngendres: {
|
|
231
|
+
valide: aJour,
|
|
232
|
+
invalide: enRetard,
|
|
233
|
+
attendu: ["l'index des interfaces : en retard"],
|
|
234
|
+
},
|
|
235
|
+
gardes: { valide: ['tailles-des-tests', 'index-interfaces'] },
|
|
236
|
+
elementsDuLot: {
|
|
237
|
+
valide: { racine: aJour, avant: 'HEAD', apres: 'HEAD' },
|
|
238
|
+
invalide: { racine: lot, avant: avantLeLot, apres: 'HEAD' },
|
|
239
|
+
attendu: [
|
|
240
|
+
'fichier neuf/neuf.py',
|
|
241
|
+
'fichier neuf/pyproject.toml',
|
|
242
|
+
'fichier outil/outil.py',
|
|
243
|
+
'fichier outil/pyproject.toml',
|
|
244
|
+
'fichier outil/uv.lock',
|
|
245
|
+
'fichier site/pages/generer.py',
|
|
246
|
+
'hors du service neuf/neuf.py',
|
|
247
|
+
'hors du service outil/outil.py',
|
|
248
|
+
'hors du service site/pages/generer.py',
|
|
249
|
+
],
|
|
250
|
+
},
|
|
251
|
+
// No shared test material in Python (./composants.mjs): the case has no defective entry.
|
|
252
|
+
matieres: { valide: aJour, invalide: aJour, attendu: [] },
|
|
253
|
+
joueDesTests: {
|
|
254
|
+
valide: vide,
|
|
255
|
+
invalide: aJour,
|
|
256
|
+
attendu: ['site (generateur) : joue des tests'],
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The index of the interfaces of a project of Python: one line per package, from its
|
|
3
|
+
// `docs/INTERFACE.md`, and one for the root's, which an agent loads at start before opening an
|
|
4
|
+
// interface; a generated file of the module (`fichiersEngendres` of ./index.mjs), as the module
|
|
5
|
+
// cargo's (../cargo/index-interfaces.mjs), whose file and form it keeps. In a project of several
|
|
6
|
+
// languages the core's index takes its place, assembled from each module's entries.
|
|
7
|
+
//
|
|
8
|
+
// node index-interfaces.mjs writes docs/agents/index-des-interfaces.md
|
|
9
|
+
// node index-interfaces.mjs --verifier refuses (exit 1) when that file is out of date, its
|
|
10
|
+
// finding in SARIF too (../../resultats.mjs)
|
|
11
|
+
// node index-interfaces.mjs --publie <composant>
|
|
12
|
+
// prints nothing: a package's interface names no
|
|
13
|
+
// consumer, which the launcher reads (lancer.sh)
|
|
14
|
+
//
|
|
15
|
+
// - The entries are those of ./composants.mjs (`entreesDeLIndex`), in their paths' order.
|
|
16
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
19
|
+
import { ecrireSarif } from '../../resultats.mjs';
|
|
20
|
+
import { entreesDeLIndex } from './composants.mjs';
|
|
21
|
+
|
|
22
|
+
export const SORTIE = 'docs/agents/index-des-interfaces.md';
|
|
23
|
+
export const GARDE = 'index-interfaces';
|
|
24
|
+
const ICI = fileURLToPath(import.meta.url);
|
|
25
|
+
|
|
26
|
+
/** The index of the interfaces of the project at <racine>, as its file holds it. */
|
|
27
|
+
export function index(racine) {
|
|
28
|
+
return [
|
|
29
|
+
'# Index des interfaces',
|
|
30
|
+
'',
|
|
31
|
+
'Généré depuis les `INTERFACE.md` des paquets Python ; ne pas éditer.',
|
|
32
|
+
"Une ligne par composant ; l'interface donne le détail.",
|
|
33
|
+
'',
|
|
34
|
+
...entreesDeLIndex(racine).flatMap(e => e.lignes),
|
|
35
|
+
].join('\n');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The findings of the check of the index at <racine>: none when its file is up to date. */
|
|
39
|
+
export function enRetard(racine) {
|
|
40
|
+
const cible = path.join(racine, SORTIE);
|
|
41
|
+
const present = existsSync(cible) ? readFileSync(cible, 'utf8') : '';
|
|
42
|
+
return present === index(racine)
|
|
43
|
+
? []
|
|
44
|
+
: [
|
|
45
|
+
{
|
|
46
|
+
fichier: SORTIE,
|
|
47
|
+
message: `${SORTIE} n'est pas à jour avec les interfaces : sa commande le régénère (node ${JSON.stringify(ICI)}).`,
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Runs the command in the project at <racine> with <args>: its exit code.
|
|
54
|
+
* @param {string} racine
|
|
55
|
+
* @param {string[]} args `--verifier` to check, `--publie` to print nothing, nothing to write
|
|
56
|
+
* @param {{ env?: NodeJS.ProcessEnv }} [o]
|
|
57
|
+
*/
|
|
58
|
+
export function commande(racine, args, { env = process.env } = {}) {
|
|
59
|
+
if (args.includes('--publie')) {
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
if (!args.includes('--verifier')) {
|
|
63
|
+
mkdirSync(path.dirname(path.join(racine, SORTIE)), { recursive: true });
|
|
64
|
+
writeFileSync(path.join(racine, SORTIE), index(racine));
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
const refus = enRetard(racine);
|
|
68
|
+
for (const r of refus) {
|
|
69
|
+
process.stderr.write(`⛔ ${r.message}\n`);
|
|
70
|
+
}
|
|
71
|
+
ecrireSarif({ garde: GARDE, racine, constats: refus, env });
|
|
72
|
+
return refus.length ? 1 : 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
76
|
+
process.exitCode = commande(process.cwd(), process.argv.slice(2));
|
|
77
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// The module of language python: what the core asks of a language (scripts/jointure.d.ts,
|
|
2
|
+
// docs/INTERFACE.md), answered for the packages of Python by uv and pytest, as Pants's Python
|
|
3
|
+
// backend reads a pyproject.toml. The core loads it by scripts/langages.mjs, and this module
|
|
4
|
+
// imports of the core its published entries alone.
|
|
5
|
+
//
|
|
6
|
+
// - The manifest of its package, which the guard of the languages asks of a package the
|
|
7
|
+
// architecture declares python (`manifeste`): a pyproject.toml (PEP 621), its group `test` of
|
|
8
|
+
// `[dependency-groups]` (PEP 735) and its uv.lock. Its one tool of npm is smol-toml, the reader
|
|
9
|
+
// of a pyproject.toml (`outils`); uv lives on the machine, installed by the update at its exact
|
|
10
|
+
// version (`binaires`, ./binaires.json). What uv, pytest and Python write in a project: `.venv`,
|
|
11
|
+
// `.pytest_cache`, `__pycache__` (`ignorer`).
|
|
12
|
+
// - Where they write, which the envelope opens to a session (`sorties`): in writing, `.venv` and
|
|
13
|
+
// `.pytest_cache` at the root, where the commands make uv and pytest write for each package
|
|
14
|
+
// (./commandes.mjs), and uv's cache, `~/.cache/uv`; proper to the session, the
|
|
15
|
+
// tree of the bytecode at the root, `__pycache__` (PYTHONPYCACHEPREFIX, ./commandes.mjs); read,
|
|
16
|
+
// the Pythons uv installs, `~/.local/share/uv/python`. The version of Python is uv's choice, from
|
|
17
|
+
// `requires-python` and `.python-version`. The rules that refuse a role that writes pytest run
|
|
18
|
+
// directly (`droits`).
|
|
19
|
+
// - The packages, a file's, the test files, what the testwriter writes, of the manifests too, the
|
|
20
|
+
// readers, the entries of the index of the interfaces (./composants.mjs); the packages touched
|
|
21
|
+
// since a commit and the elements of a lot (./lot.mjs).
|
|
22
|
+
// - The commands `tester`, `verifier`, `typer`, `preparer` and `tests-de-nuit` (./commandes.mjs),
|
|
23
|
+
// each described, never run, and the verdict of a run (./verdict.mjs); the guard of the sizes of
|
|
24
|
+
// the tests (./tailles-des-tests.mjs) and the index of the interfaces up to date, each a command
|
|
25
|
+
// by its name too. The generated file, the index of the interfaces (./index-interfaces.mjs), its
|
|
26
|
+
// command and its check, which the core's takes the place of in a project of several languages.
|
|
27
|
+
// No migration yet.
|
|
28
|
+
// - Its share of the update (./mise-a-jour.mjs): the template `templates/python/`, its test
|
|
29
|
+
// scripts, the generator of the index and the installation of uv.
|
|
30
|
+
import { readFileSync } from 'node:fs';
|
|
31
|
+
import path from 'node:path';
|
|
32
|
+
import { fileURLToPath } from 'node:url';
|
|
33
|
+
import { commandes, GARDES, PYCACHE } from './commandes.mjs';
|
|
34
|
+
import {
|
|
35
|
+
composantDans,
|
|
36
|
+
composants,
|
|
37
|
+
entreesDeLIndex,
|
|
38
|
+
estUnTest,
|
|
39
|
+
joueDesTests,
|
|
40
|
+
lecteurs,
|
|
41
|
+
manifestes,
|
|
42
|
+
} from './composants.mjs';
|
|
43
|
+
import { enRetard, SORTIE } from './index-interfaces.mjs';
|
|
44
|
+
import { elementsDuLot, touches } from './lot.mjs';
|
|
45
|
+
import { miseAJour } from './mise-a-jour.mjs';
|
|
46
|
+
import { verdict } from './verdict.mjs';
|
|
47
|
+
|
|
48
|
+
const ici = nom => path.join(path.dirname(fileURLToPath(import.meta.url)), nom);
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
nom: 'python',
|
|
52
|
+
manifeste: 'pyproject.toml',
|
|
53
|
+
outils: ['smol-toml'],
|
|
54
|
+
binaires: JSON.parse(readFileSync(ici('binaires.json'), 'utf8')),
|
|
55
|
+
ignorer: ['.venv', '.pytest_cache', PYCACHE],
|
|
56
|
+
sorties: {
|
|
57
|
+
ecrites: ['.venv/', '.pytest_cache/', '~/.cache/uv/'],
|
|
58
|
+
propres: [PYCACHE],
|
|
59
|
+
lues: ['~/.local/share/uv/python/'],
|
|
60
|
+
},
|
|
61
|
+
// pytest run directly, by itself, by Python or by uv: `npm test` and `npm run verifier` play it.
|
|
62
|
+
droits: [
|
|
63
|
+
'Bash(pytest*)',
|
|
64
|
+
'Bash(python -m pytest*)',
|
|
65
|
+
'Bash(python3 -m pytest*)',
|
|
66
|
+
'Bash(uv run*pytest*)',
|
|
67
|
+
],
|
|
68
|
+
composants,
|
|
69
|
+
composantDe: (racine, fichier) => composantDans(composants(racine), racine, fichier),
|
|
70
|
+
matieres: () => [],
|
|
71
|
+
joueDesTests,
|
|
72
|
+
lecteurs,
|
|
73
|
+
touches,
|
|
74
|
+
elementsDuLot,
|
|
75
|
+
commandes,
|
|
76
|
+
verdict,
|
|
77
|
+
estUnTest,
|
|
78
|
+
manifestes,
|
|
79
|
+
fichiersEngendres: () => [
|
|
80
|
+
{
|
|
81
|
+
nom: "l'index des interfaces",
|
|
82
|
+
commande: `node ${JSON.stringify(ici('index-interfaces.mjs'))}`,
|
|
83
|
+
fichiers: [SORTIE],
|
|
84
|
+
lit: ['docs/INTERFACE.md', '**/docs/INTERFACE.md'],
|
|
85
|
+
gardes: ['index-interfaces'],
|
|
86
|
+
entiers: [SORTIE],
|
|
87
|
+
verifier: enRetard,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
entreesDeLIndex,
|
|
91
|
+
gardes: () => GARDES.map(({ script, args }) => [script, ...args]),
|
|
92
|
+
migrations: [],
|
|
93
|
+
miseAJour,
|
|
94
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// The changes of a project of Python read by git: the packages touched since a commit (`touches`
|
|
2
|
+
// of the join, scripts/jointure.d.ts) and the elements of a lot (`elementsDuLot`).
|
|
3
|
+
//
|
|
4
|
+
// - The files changed since a commit: what git sees changed, the working tree and the untracked
|
|
5
|
+
// files included (`git diff --name-only --no-renames <depuis>`, `git ls-files -o
|
|
6
|
+
// --exclude-standard`). Each touches the package of the longest folder that holds it
|
|
7
|
+
// (./composants.mjs); a file out of every package is out of the graph. No dependent: the module
|
|
8
|
+
// reads no dependency between packages of Python.
|
|
9
|
+
// - The lot between two commits (`git diff --name-only --no-renames <avant> <apres>`): every file
|
|
10
|
+
// it changes in `fichiers`; the module reads no element of a source of Python, so each `.py` is
|
|
11
|
+
// named in `horsDuService`, which the reviewer surveys himself.
|
|
12
|
+
import { spawnSync } from 'node:child_process';
|
|
13
|
+
import { composantDans, composants } from './composants.mjs';
|
|
14
|
+
|
|
15
|
+
const lignesDeGit = (racine, args) => {
|
|
16
|
+
const r = spawnSync('git', ['-C', racine, ...args, '-z'], {
|
|
17
|
+
encoding: 'utf8',
|
|
18
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
19
|
+
});
|
|
20
|
+
if (r.status !== 0) {
|
|
21
|
+
throw new Error(`⛔ git ${args.join(' ')} : ${r.stderr.trim()}`);
|
|
22
|
+
}
|
|
23
|
+
return r.stdout.split('\0').filter(Boolean);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** The packages the files <fichiers> (from <racine>) touch, and the files out of the graph. */
|
|
27
|
+
export function touchesDesFichiers(racine, fichiers) {
|
|
28
|
+
const liste = composants(racine);
|
|
29
|
+
const touches = new Set();
|
|
30
|
+
const horsGraphe = [];
|
|
31
|
+
for (const f of new Set(fichiers)) {
|
|
32
|
+
const c = composantDans(liste, racine, f);
|
|
33
|
+
if (c) {
|
|
34
|
+
touches.add(c);
|
|
35
|
+
} else {
|
|
36
|
+
horsGraphe.push(f);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
touches: [...touches].sort((a, b) => a.nom.localeCompare(b.nom)),
|
|
41
|
+
dependants: [],
|
|
42
|
+
horsGraphe: horsGraphe.sort(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The packages touched in <racine> since the commit <depuis>, and the files out of the graph. */
|
|
47
|
+
export function touches(racine, { depuis }) {
|
|
48
|
+
return touchesDesFichiers(racine, [
|
|
49
|
+
...lignesDeGit(racine, ['diff', '--name-only', '--no-renames', depuis]),
|
|
50
|
+
...lignesDeGit(racine, ['ls-files', '-o', '--exclude-standard']),
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The elements of the lot of <racine> between <avant> and <apres>. */
|
|
55
|
+
export function elementsDuLot(racine, { avant, apres }) {
|
|
56
|
+
try {
|
|
57
|
+
const fichiers = [
|
|
58
|
+
...new Set(lignesDeGit(racine, ['diff', '--name-only', '--no-renames', avant, apres])),
|
|
59
|
+
].sort();
|
|
60
|
+
return {
|
|
61
|
+
etat: 'fait',
|
|
62
|
+
raison: null,
|
|
63
|
+
elements: [],
|
|
64
|
+
horsDuService: fichiers.filter(f => f.endsWith('.py')),
|
|
65
|
+
fichiers,
|
|
66
|
+
};
|
|
67
|
+
} catch (e) {
|
|
68
|
+
return {
|
|
69
|
+
etat: 'impossible',
|
|
70
|
+
raison: `erreur : ${String(e.message).split('\n')[0]}`,
|
|
71
|
+
elements: [],
|
|
72
|
+
horsDuService: [],
|
|
73
|
+
fichiers: [],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// What the module python brings to the update of a project (`grillhouse maj`,
|
|
2
|
+
// scripts/grillhouse-maj.mjs), the demand `miseAJour` of the join (scripts/jointure.d.ts).
|
|
3
|
+
//
|
|
4
|
+
// - The template: `templates/python/` of the frame's files. Its package.json gives the frame's
|
|
5
|
+
// scripts, which run the frame's commands, and smol-toml, the reader of a pyproject.toml.
|
|
6
|
+
// - The root scripts `test`, `test:forcer` and `verifier` a project lacks become the template's;
|
|
7
|
+
// a project's own script stays.
|
|
8
|
+
// - The generator: the index of the interfaces (./index-interfaces.mjs), run where the project
|
|
9
|
+
// holds it, as the module cargo's.
|
|
10
|
+
// - The installation of uv (./binaires.json) by the commands of ./binaires.mjs, which the core runs.
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
import { SORTIE } from './index-interfaces.mjs';
|
|
14
|
+
|
|
15
|
+
const BINAIRES = path.join(path.dirname(fileURLToPath(import.meta.url)), 'binaires.mjs');
|
|
16
|
+
const GABARIT = 'templates/python';
|
|
17
|
+
const SCRIPTS_DES_TESTS = ['test', 'test:forcer', 'verifier'];
|
|
18
|
+
|
|
19
|
+
/** @type {import('../../jointure.js').MiseAJour['appliquer']} */
|
|
20
|
+
function appliquer(_projet, { p, modele }) {
|
|
21
|
+
p.scripts ??= {};
|
|
22
|
+
const scripts = [];
|
|
23
|
+
for (const nom of SCRIPTS_DES_TESTS) {
|
|
24
|
+
const script = modele.scripts?.[nom];
|
|
25
|
+
if (typeof script !== 'string' || typeof p.scripts[nom] === 'string') {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
p.scripts[nom] = script;
|
|
29
|
+
scripts.push(nom);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
bilan: { scripts: scripts.length > 0 ? scripts : null },
|
|
33
|
+
lignes:
|
|
34
|
+
scripts.length > 0
|
|
35
|
+
? [
|
|
36
|
+
`Scripts des tests : ${scripts.map(n => `${n} (\`${p.scripts[n]}\`)`).join(', ')} écrits ; les agents lancent \`npm test\`, l'intégration et la nuit \`npm run verifier\`.`,
|
|
37
|
+
]
|
|
38
|
+
: [],
|
|
39
|
+
aFaire: [],
|
|
40
|
+
installer: false,
|
|
41
|
+
sansVerifier: null,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The share of the module python in the update. */
|
|
46
|
+
export const miseAJour = {
|
|
47
|
+
gabarit: GABARIT,
|
|
48
|
+
appliquer,
|
|
49
|
+
generateurs: [{ commande: 'index-interfaces', args: [], sortie: SORTIE }],
|
|
50
|
+
installation: {
|
|
51
|
+
liste: { script: BINAIRES, args: ['liste'] },
|
|
52
|
+
installer: (nom, version) => ({ script: BINAIRES, args: ['installer', `${nom}@${version}`] }),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The size of each test of Python, on the model of the test pyramid of Google and of Bazel's
|
|
3
|
+
// `size`, as the module typescript's guard (../typescript/tailles-des-tests.mjs): a large test of
|
|
4
|
+
// the day is refused, as it belongs to the night.
|
|
5
|
+
//
|
|
6
|
+
// npx grillhouse tailles-des-tests run from the repository root (a guard of grillhouse:gardes)
|
|
7
|
+
//
|
|
8
|
+
// - The test files are those of each package (./composants.mjs, `fichiersDeTest`): `test_*.py`
|
|
9
|
+
// and `*_test.py`, a night test `*_nuit_test.py`.
|
|
10
|
+
// - A test is classed by a static reading of its text and of its package's `conftest.py` files on
|
|
11
|
+
// its path, which pytest loads with it:
|
|
12
|
+
// - large (`grand`): it starts a process (it imports `subprocess`), mounts a trial repository
|
|
13
|
+
// (git's `init`, `clone` or `worktree add`) and starts there something else than git;
|
|
14
|
+
// - medium (`moyen`): it starts a process;
|
|
15
|
+
// - small (`petit`): it starts none.
|
|
16
|
+
// - A large test of the day is a finding, `{ fichier, regle: 'grand-de-jour', message }`; a night
|
|
17
|
+
// test never is one. A finding inscribed in the project's debt (`grillhouse-dette.json`,
|
|
18
|
+
// ../../dette.mjs) passes, and a new one is refused.
|
|
19
|
+
// - The guard writes on its error stream the count of each size, the night's included.
|
|
20
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
import { pathToFileURL } from 'node:url';
|
|
23
|
+
import { trancher } from '../../dette.mjs';
|
|
24
|
+
import { composants, estDeNuit, fichiersDeTest } from './composants.mjs';
|
|
25
|
+
|
|
26
|
+
// The name of its findings and of its debt, apart from the module typescript's guard of the same
|
|
27
|
+
// command, whose section of the debt it never writes.
|
|
28
|
+
export const GARDE = 'tailles-des-tests-python';
|
|
29
|
+
export const GRAND_DE_JOUR = 'grand-de-jour';
|
|
30
|
+
|
|
31
|
+
// The import of the module that starts a process.
|
|
32
|
+
const PROCESSUS = /^\s*(?:import\s+subprocess\b|from\s+subprocess\s+import\b)/m;
|
|
33
|
+
// A trial repository mounted: git's `init`, `clone` or `worktree add`, as an argument or a command.
|
|
34
|
+
const DEPOT_D_ESSAI =
|
|
35
|
+
/['"](?:init|clone)['"]|\bgit\s+(?:-C\s+\S+\s+)?(?:init|clone)\b|['"]worktree['"]\s*,\s*['"]add['"]|\bworktree\s+add\b/;
|
|
36
|
+
// A call of subprocess, its first argument captured.
|
|
37
|
+
const APPEL = /\bsubprocess\.(?:run|Popen|call|check_call|check_output)\s*\(\s*\[?\s*([^,\])\n]*)/g;
|
|
38
|
+
// A first argument that names git.
|
|
39
|
+
const GIT = /^['"]git(?:['"]|\s)/;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The size of the test file <fichier> (absolute) of the package at <dossier>: `petit`, `moyen` or
|
|
43
|
+
* `grand`.
|
|
44
|
+
*/
|
|
45
|
+
export function classer(fichier, dossier) {
|
|
46
|
+
const textes = [readFileSync(fichier, 'utf8')];
|
|
47
|
+
for (let d = path.dirname(fichier); ; d = path.dirname(d)) {
|
|
48
|
+
const conftest = path.join(d, 'conftest.py');
|
|
49
|
+
if (existsSync(conftest)) {
|
|
50
|
+
textes.push(readFileSync(conftest, 'utf8'));
|
|
51
|
+
}
|
|
52
|
+
if (d === dossier || path.dirname(d) === d) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const tout = textes.join('\n');
|
|
57
|
+
const processus = PROCESSUS.test(tout);
|
|
58
|
+
const autreQueGit = [...tout.matchAll(APPEL)].some(m => !GIT.test(m[1].trim()));
|
|
59
|
+
if (processus && autreQueGit && DEPOT_D_ESSAI.test(tout)) {
|
|
60
|
+
return 'grand';
|
|
61
|
+
}
|
|
62
|
+
return processus ? 'moyen' : 'petit';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Each test file of the project at <racine> and its size: `[{ fichier, taille, nuit }]`. */
|
|
66
|
+
export function tailles(racine) {
|
|
67
|
+
return composants(racine).flatMap(c =>
|
|
68
|
+
fichiersDeTest(c.dossier).map(f => ({
|
|
69
|
+
fichier: path.relative(racine, f).split(path.sep).join('/'),
|
|
70
|
+
taille: classer(f, c.dossier),
|
|
71
|
+
nuit: estDeNuit(path.basename(f)),
|
|
72
|
+
}))
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The findings of the project at <racine>: one per large test of the day. */
|
|
77
|
+
export function verifier(racine) {
|
|
78
|
+
return tailles(racine)
|
|
79
|
+
.filter(t => t.taille === 'grand' && !t.nuit)
|
|
80
|
+
.map(({ fichier }) => ({
|
|
81
|
+
fichier,
|
|
82
|
+
regle: GRAND_DE_JOUR,
|
|
83
|
+
message: `${fichier} : un grand test (il monte un dépôt d'essai et y lance le produit ou le cadre) est un test de nuit, jamais joué au fil du travail ; il se renomme en *_nuit_test.py, ou il se réduit à la plus petite taille qui prouve son critère.`,
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
88
|
+
const racine = process.cwd();
|
|
89
|
+
const toutes = tailles(racine);
|
|
90
|
+
const compte = t => toutes.filter(x => x.taille === t).length;
|
|
91
|
+
const { refus, lignes } = trancher(racine, GARDE, verifier(racine));
|
|
92
|
+
for (const r of refus) {
|
|
93
|
+
process.stderr.write(`⛔ ${r.message}\n`);
|
|
94
|
+
}
|
|
95
|
+
for (const l of lignes) {
|
|
96
|
+
process.stderr.write(`${l}\n`);
|
|
97
|
+
}
|
|
98
|
+
process.stderr.write(
|
|
99
|
+
`ℹ️ ${GARDE} : ${toutes.length} fichier(s) de tests, ${compte('petit')} petit(s), ${compte('moyen')} moyen(s), ${compte('grand')} grand(s) ; ${toutes.filter(x => x.nuit).length} de nuit.\n`
|
|
100
|
+
);
|
|
101
|
+
process.exitCode = refus.length ? 1 : 0;
|
|
102
|
+
}
|