@roomi-fields/grillhouse 0.38.0 → 0.38.2
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 +8 -0
- package/charte.md +13 -0
- package/docs/ARCHITECTURE.md +21 -26
- package/docs/INTERFACE.md +15 -34
- package/package.json +1 -1
- package/scripts/activites.mjs +24 -286
- package/scripts/circuit.mjs +6 -22
- package/scripts/composition-des-langages.mjs +1 -16
- package/scripts/conformite.mjs +0 -31
- package/scripts/dernier-vert.mjs +4 -86
- package/scripts/etat-du-depot.mjs +92 -0
- package/scripts/jointure.d.ts +0 -29
- package/scripts/langages/cargo/commandes.mjs +10 -9
- package/scripts/langages/cargo/composants.mjs +1 -100
- package/scripts/langages/cargo/exemples.mjs +0 -73
- package/scripts/langages/cargo/index.mjs +0 -6
- package/scripts/langages/python/commandes.mjs +2 -11
- package/scripts/langages/python/composants.mjs +2 -13
- package/scripts/langages/python/exemples.mjs +0 -19
- package/scripts/langages/python/index.mjs +2 -14
- package/scripts/langages/typescript/exemples.mjs +0 -16
- package/scripts/langages/typescript/index.mjs +1 -7
- package/scripts/langages/typescript/regle-des-tests.mjs +0 -15
- package/scripts/langages/typescript/verifier.mjs +30 -0
- package/scripts/nuit.sh +7 -1
- package/scripts/registre-des-resultats.mjs +119 -0
- package/scripts/services-du-noyau.mjs +6 -0
- package/scripts/langages/cargo/tests-de-head.mjs +0 -178
package/scripts/circuit.mjs
CHANGED
|
@@ -228,22 +228,11 @@
|
|
|
228
228
|
// those in `portent_le_travail` (`fichier` from the root, `test` its full name or its title, or
|
|
229
229
|
// none for every test of the file). A green test the sheet names is a defect of the proof, named
|
|
230
230
|
// in the report; a green test it does not name is accepted with no reason, counted and listed
|
|
231
|
-
// under « Verts non nommés ». A green test
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
// Python: the copy with that file alone replaced by its version of HEAD, in the temporary
|
|
237
|
-
// directory of the ticket, removed after the run, a red included, so that no test of the lot
|
|
238
|
-
// sees a file more), and a green test whose full name HEAD's version holds, green there too, is
|
|
239
|
-
// set aside, counted; a body changed under the same name is not told apart. A file its tool
|
|
240
|
-
// cannot play twice in a run (cargo: a unit test of `src/`, a target `tests/<dossier>/main.rs`)
|
|
241
|
-
// has neither: the module reads the names of the tests of its HEAD's version without playing
|
|
242
|
-
// them (`testsDeHead` of the join), and each is held for a green HEAD holds, as main stays
|
|
243
|
-
// green. A tree that no longer compiles (cargo: HEAD's version of a target against the lot's
|
|
244
|
-
// `tests/common`) is not a red of the lot: when the build fails with the trees and the lot
|
|
245
|
-
// alone builds, the package plays without them, the names of HEAD's tests of those files read
|
|
246
|
-
// (`testsDeHead`); a build the lot alone breaks stays a red (`jouerAvecLesVersionsDAvant`). The proof passes with a red (of the lot, existing or of a build), even without
|
|
231
|
+
// under « Verts non nommés ». A green test main already holds has nothing to prove: the registry
|
|
232
|
+
// of results (scripts/registre-des-resultats.mjs), written by the last complete green pass of
|
|
233
|
+
// main, holds the passed tests of each file by their full name; a green test of the lot whose
|
|
234
|
+
// full name the registry holds for its file is set aside, counted, as main stays green; a body
|
|
235
|
+
// changed under the same name is not told apart. The proof passes with a red (of the lot, existing or of a build), even without
|
|
247
236
|
// a file of the lot: a testwriter with no new test to write says so in his handover, the existing
|
|
248
237
|
// reds are enough. Under a plan « comportement changé » it fails without a red, with a broken file
|
|
249
238
|
// of the lot, or with a green the sheet names; under a plan « comportement
|
|
@@ -659,7 +648,6 @@ import {
|
|
|
659
648
|
import { departDepuis } from './reprise.mjs';
|
|
660
649
|
import {
|
|
661
650
|
arbreDeLaCopie,
|
|
662
|
-
balayerLesSoeurs,
|
|
663
651
|
controles,
|
|
664
652
|
empreinte,
|
|
665
653
|
empreinteDeLEtape,
|
|
@@ -2401,13 +2389,9 @@ export async function ouvrirJusquAuPlan(ctx, e) {
|
|
|
2401
2389
|
return { debut: o.debut, plan: aEcrire ? planAuDebut(ctx) : null };
|
|
2402
2390
|
}
|
|
2403
2391
|
|
|
2404
|
-
/** The end of the opening of <ctx> at the step <d>: the sort of the ticket
|
|
2392
|
+
/** The end of the opening of <ctx> at the step <d>: the sort of the ticket. `{ debut }`. */
|
|
2405
2393
|
export function finirLOuverture(ctx, d) {
|
|
2406
2394
|
// The sort of the ticket its plan says, which the run reads at each step.
|
|
2407
2395
|
ctx.sorte = sorteDuTicket(ctx);
|
|
2408
|
-
// A sibling of HEAD's version a killed circuit left in the copy never enters the lot.
|
|
2409
|
-
if (existsSync(ctx.copie)) {
|
|
2410
|
-
balayerLesSoeurs(ctx);
|
|
2411
|
-
}
|
|
2412
2396
|
return { debut: d };
|
|
2413
2397
|
}
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
// is refused, named with both languages: a package has one language. A file belongs to the
|
|
9
9
|
// module of the component that holds it, the deepest (`moduleDuFichier`); a file out of every
|
|
10
10
|
// component stays the core's, as with one language: the first module, in the order of the
|
|
11
|
-
// declaration, whose answer is not null judges it (`estUnTest`, `
|
|
12
|
-
// `testsDeHead`, `manifestes.horsDesTests`).
|
|
11
|
+
// declaration, whose answer is not null judges it (`estUnTest`, `manifestes.horsDesTests`).
|
|
13
12
|
// - Whether a component plays tests, the readers of components and the components touched are
|
|
14
13
|
// each module's on its own components, the results joined: a name without supplier is without
|
|
15
14
|
// supplier in every module, a file out of the graph is out of every module's graph.
|
|
@@ -270,20 +269,6 @@ export function composer(modules) {
|
|
|
270
269
|
premiereReponse(modules, racine, chemin, m => m.estUnTest(chemin, racine)),
|
|
271
270
|
horsDuJour: (chemin, racine) =>
|
|
272
271
|
Boolean(premiereReponse(modules, racine, chemin, m => m.horsDuJour(chemin, racine))),
|
|
273
|
-
soeurDAvant: (chemin, racine) =>
|
|
274
|
-
premiereReponse(modules, racine, chemin, m =>
|
|
275
|
-
typeof m.soeurDAvant === 'function' ? m.soeurDAvant(chemin, racine) : null
|
|
276
|
-
),
|
|
277
|
-
arbreDAvant: (chemin, racine) =>
|
|
278
|
-
Boolean(
|
|
279
|
-
premiereReponse(modules, racine, chemin, m =>
|
|
280
|
-
typeof m.arbreDAvant === 'function' ? m.arbreDAvant(chemin, racine) : null
|
|
281
|
-
)
|
|
282
|
-
),
|
|
283
|
-
envDArbre: (chemin, racine) =>
|
|
284
|
-
moduleDuFichier(modules, racine, chemin)?.envDArbre?.(chemin, racine) ?? {},
|
|
285
|
-
testsDeHead: (chemin, racine, lire, options) =>
|
|
286
|
-
premiereReponse(modules, racine, chemin, m => m.testsDeHead(chemin, racine, lire, options)),
|
|
287
272
|
manifestes: {
|
|
288
273
|
verrous: unique(modules.flatMap(m => m.manifestes.verrous)),
|
|
289
274
|
horsDesTests: (chemin, racine, avant, apres) =>
|
package/scripts/conformite.mjs
CHANGED
|
@@ -22,11 +22,6 @@
|
|
|
22
22
|
// - verdict: each task neither green nor unplayed (« à repasser » at 75, red otherwise), the one
|
|
23
23
|
// that plays the tests marked, and each test failed;
|
|
24
24
|
// - estUnTest: each path the testwriter writes, with what it is (`joue`, `test`, `matiere`);
|
|
25
|
-
// - versionDeHead (`soeurDAvant`, `arbreDAvant`, `testsDeHead`): each path whose HEAD's version
|
|
26
|
-
// plays in a tree (`→ un arbre`), and each that has a sibling for it, with it, said when the sibling is the path itself or lies in another folder, and each path
|
|
27
|
-
// whose names of tests the module reads in HEAD's version (the entry a path, or `{ chemin,
|
|
28
|
-
// textes }`, HEAD's text of each file by its path), with them, said when it has both; the
|
|
29
|
-
// entry's expected siblings are names the module's tool plays, of their file's class;
|
|
30
25
|
// - fichiersEngendres: each generated file whose check finds a gap;
|
|
31
26
|
// - gardes: each guard named that the module does not play, and each script it plays that does
|
|
32
27
|
// not exist;
|
|
@@ -168,32 +163,6 @@ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
|
|
|
168
163
|
}
|
|
169
164
|
return [`${chemin} : ${['joue', 'test', 'matiere'].filter(k => c[k]).join(', ')}`];
|
|
170
165
|
}),
|
|
171
|
-
versionDeHead: entrees =>
|
|
172
|
-
entrees.flatMap(x => {
|
|
173
|
-
const { chemin, textes = {} } = typeof x === 'string' ? { chemin: x } : x;
|
|
174
|
-
const s =
|
|
175
|
-
typeof langage.soeurDAvant === 'function' ? langage.soeurDAvant(chemin, e.racine) : null;
|
|
176
|
-
const arbre =
|
|
177
|
-
typeof langage.arbreDAvant === 'function' && langage.arbreDAvant(chemin, e.racine);
|
|
178
|
-
const noms = langage.testsDeHead(chemin, e.racine, f => textes[f] ?? null);
|
|
179
|
-
if (s !== null && arbre) {
|
|
180
|
-
return [`${chemin} : une sœur et un arbre`];
|
|
181
|
-
}
|
|
182
|
-
if (arbre) {
|
|
183
|
-
return [`${chemin} → un arbre`];
|
|
184
|
-
}
|
|
185
|
-
if (s !== null && noms !== null) {
|
|
186
|
-
return [`${chemin} : une sœur et des noms lus`];
|
|
187
|
-
}
|
|
188
|
-
if (noms !== null) {
|
|
189
|
-
return [`${chemin} : ${noms.join(', ') || 'aucun test'}`];
|
|
190
|
-
}
|
|
191
|
-
if (s === null) {
|
|
192
|
-
return [];
|
|
193
|
-
}
|
|
194
|
-
const aCote = s !== chemin && path.dirname(s) === path.dirname(chemin);
|
|
195
|
-
return [aCote ? `${chemin} → ${s}` : `${chemin} → ${s} : pas à côté du fichier`];
|
|
196
|
-
}),
|
|
197
166
|
fichiersEngendres: racine =>
|
|
198
167
|
langage
|
|
199
168
|
.fichiersEngendres(racine)
|
package/scripts/dernier-vert.mjs
CHANGED
|
@@ -47,19 +47,10 @@
|
|
|
47
47
|
// (the tests of a crate or a Python project are tasks of Turborepo, which its cache selects).
|
|
48
48
|
// The green is kept by the one pass of the verification (scripts/langages/typescript/verifier.mjs),
|
|
49
49
|
// once, when every task of every language of the graph is green, and never when one is red.
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
copyFileSync,
|
|
53
|
-
existsSync,
|
|
54
|
-
mkdirSync,
|
|
55
|
-
mkdtempSync,
|
|
56
|
-
readFileSync,
|
|
57
|
-
realpathSync,
|
|
58
|
-
rmSync,
|
|
59
|
-
writeFileSync,
|
|
60
|
-
} from 'node:fs';
|
|
50
|
+
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
61
51
|
import os from 'node:os';
|
|
62
52
|
import path from 'node:path';
|
|
53
|
+
import { etatDuDepot, fichierSous, git, SHA, sortie } from './etat-du-depot.mjs';
|
|
63
54
|
// The variable that names the file of the changes since the last green, which the runner of the
|
|
64
55
|
// tests of the module of the language reads in each package.
|
|
65
56
|
export const CHANGEMENTS = 'GRILLHOUSE_CHANGEMENTS';
|
|
@@ -67,84 +58,11 @@ export const DEPUIS_LE_VERT = 'GRILLHOUSE_DEPUIS_LE_VERT';
|
|
|
67
58
|
// The variable that gives a pass of the circuit the base of its lot, against which it measures
|
|
68
59
|
// itself, targeted.
|
|
69
60
|
export const BASE_DU_LOT = 'GRILLHOUSE_BASE_DU_LOT';
|
|
70
|
-
const SHA = /^[0-9a-f]{40,64}$/;
|
|
71
|
-
|
|
72
|
-
const git = (racine, args, env = process.env) =>
|
|
73
|
-
spawnSync('git', ['-C', racine, ...args], {
|
|
74
|
-
encoding: 'utf8',
|
|
75
|
-
env,
|
|
76
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
77
|
-
});
|
|
78
|
-
const sortie = (racine, args, env) => {
|
|
79
|
-
const r = git(racine, args, env);
|
|
80
|
-
return r.status === 0 ? r.stdout.trim() : null;
|
|
81
|
-
};
|
|
82
61
|
|
|
83
62
|
// The file of the last green of the branch <branche> of the repository at <racine>, null out of
|
|
84
|
-
// git.
|
|
63
|
+
// git (`fichierSous` of scripts/etat-du-depot.mjs).
|
|
85
64
|
function fichierDuVert(racine, branche) {
|
|
86
|
-
|
|
87
|
-
return commun ? path.join(commun, 'grillhouse', 'dernier-vert', `${branche}.json`) : null;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Main, the branch of the main tree of the repository at <racine> (HEAD of git's common
|
|
91
|
-
// directory); null when that tree is detached.
|
|
92
|
-
function brancheDeMain(racine) {
|
|
93
|
-
const commun = sortie(racine, ['rev-parse', '--path-format=absolute', '--git-common-dir']);
|
|
94
|
-
return commun
|
|
95
|
-
? sortie(racine, [`--git-dir=${commun}`, 'symbolic-ref', '--short', '-q', 'HEAD'])
|
|
96
|
-
: null;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Whether a submodule of the repository at <racine> differs from the commit its parent records.
|
|
100
|
-
function sousModuleModifie(racine) {
|
|
101
|
-
const r = git(racine, ['status', '--porcelain=v2', '-z', '--ignore-submodules=none']);
|
|
102
|
-
if (r.status !== 0) {
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
// An entry of a changed path: `1 <XY> <sub> …` (or `2` for a rename), <sub> `S<c><m><u>` for a
|
|
106
|
-
// submodule whose commit, tracked files or untracked files changed, `N...` for any other path.
|
|
107
|
-
return r.stdout.split('\0').some(e => /^[12] \S+ S/.test(e));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// The state of the repository at <racine> as it stands: `{ racine, commit, arbre, branche, main }`,
|
|
111
|
-
// its top (its real path), HEAD, the tree of its working tree, the branch of HEAD (null when
|
|
112
|
-
// detached) and main (brancheDeMain); `{ raison }` when no last green can count.
|
|
113
|
-
function etatDuDepot(racine) {
|
|
114
|
-
const haut = sortie(racine, ['rev-parse', '--show-toplevel']);
|
|
115
|
-
if (!haut) {
|
|
116
|
-
return { raison: 'hors de git' };
|
|
117
|
-
}
|
|
118
|
-
const top = realpathSync(haut);
|
|
119
|
-
const commit = sortie(top, ['rev-parse', '--verify', '-q', 'HEAD^{commit}']);
|
|
120
|
-
if (!commit) {
|
|
121
|
-
return { raison: 'aucun commit' };
|
|
122
|
-
}
|
|
123
|
-
if (sousModuleModifie(top)) {
|
|
124
|
-
return { raison: 'un sous-module diffère de son commit' };
|
|
125
|
-
}
|
|
126
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'grillhouse-vert-'));
|
|
127
|
-
try {
|
|
128
|
-
const index = path.join(dir, 'index');
|
|
129
|
-
const reel = sortie(top, ['rev-parse', '--path-format=absolute', '--git-path', 'index']);
|
|
130
|
-
const env = { ...process.env, GIT_INDEX_FILE: index };
|
|
131
|
-
if (reel && existsSync(reel)) {
|
|
132
|
-
copyFileSync(reel, index);
|
|
133
|
-
} else if (git(top, ['read-tree', 'HEAD'], env).status !== 0) {
|
|
134
|
-
return { raison: 'git échoue' };
|
|
135
|
-
}
|
|
136
|
-
if (git(top, ['add', '-A'], env).status !== 0) {
|
|
137
|
-
return { raison: 'git échoue' };
|
|
138
|
-
}
|
|
139
|
-
const arbre = sortie(top, ['write-tree'], env);
|
|
140
|
-
if (!arbre) {
|
|
141
|
-
return { raison: 'git échoue' };
|
|
142
|
-
}
|
|
143
|
-
const branche = sortie(top, ['symbolic-ref', '--short', '-q', 'HEAD']);
|
|
144
|
-
return { racine: top, commit, arbre, branche, main: brancheDeMain(top) };
|
|
145
|
-
} finally {
|
|
146
|
-
rmSync(dir, { recursive: true, force: true });
|
|
147
|
-
}
|
|
65
|
+
return fichierSous(racine, 'dernier-vert', branche);
|
|
148
66
|
}
|
|
149
67
|
|
|
150
68
|
// The last green that a pass in the state <etat> (etatDuDepot) measures itself against: its
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// The state of a git repository and the place of the per-branch files the frame keeps beside it:
|
|
2
|
+
// the layer the last green (scripts/dernier-vert.mjs) and the registry of results
|
|
3
|
+
// (scripts/registre-des-resultats.mjs) share. Each keeps `{ … }` per branch under
|
|
4
|
+
// `<git common dir>/grillhouse/<sous>/<branche>.json`, and each measures what counts against the
|
|
5
|
+
// repository's state as it stands, so the place of the file (`fichierSous`) and the repository's
|
|
6
|
+
// identity (`etatDuDepot`) live here, once, for both.
|
|
7
|
+
import { spawnSync } from 'node:child_process';
|
|
8
|
+
import { copyFileSync, existsSync, mkdtempSync, realpathSync, rmSync } from 'node:fs';
|
|
9
|
+
import os from 'node:os';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
|
|
12
|
+
export const SHA = /^[0-9a-f]{40,64}$/;
|
|
13
|
+
|
|
14
|
+
export const git = (racine, args, env = process.env) =>
|
|
15
|
+
spawnSync('git', ['-C', racine, ...args], {
|
|
16
|
+
encoding: 'utf8',
|
|
17
|
+
env,
|
|
18
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const sortie = (racine, args, env) => {
|
|
22
|
+
const r = git(racine, args, env);
|
|
23
|
+
return r.status === 0 ? r.stdout.trim() : null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// The file `<git common dir>/grillhouse/<sous>/<branche>.json` of the repository at <racine>, null
|
|
27
|
+
// out of git. The last green (`dernier-vert`) and the registry of results (`resultats`,
|
|
28
|
+
// scripts/registre-des-resultats.mjs) both live under it, one file per branch.
|
|
29
|
+
export function fichierSous(racine, sous, branche) {
|
|
30
|
+
const commun = sortie(racine, ['rev-parse', '--path-format=absolute', '--git-common-dir']);
|
|
31
|
+
return commun ? path.join(commun, 'grillhouse', sous, `${branche}.json`) : null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Main, the branch of the main tree of the repository at <racine> (HEAD of git's common
|
|
35
|
+
// directory); null when that tree is detached.
|
|
36
|
+
function brancheDeMain(racine) {
|
|
37
|
+
const commun = sortie(racine, ['rev-parse', '--path-format=absolute', '--git-common-dir']);
|
|
38
|
+
return commun
|
|
39
|
+
? sortie(racine, [`--git-dir=${commun}`, 'symbolic-ref', '--short', '-q', 'HEAD'])
|
|
40
|
+
: null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Whether a submodule of the repository at <racine> differs from the commit its parent records.
|
|
44
|
+
function sousModuleModifie(racine) {
|
|
45
|
+
const r = git(racine, ['status', '--porcelain=v2', '-z', '--ignore-submodules=none']);
|
|
46
|
+
if (r.status !== 0) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
// An entry of a changed path: `1 <XY> <sub> …` (or `2` for a rename), <sub> `S<c><m><u>` for a
|
|
50
|
+
// submodule whose commit, tracked files or untracked files changed, `N...` for any other path.
|
|
51
|
+
return r.stdout.split('\0').some(e => /^[12] \S+ S/.test(e));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// The state of the repository at <racine> as it stands: `{ racine, commit, arbre, branche, main }`,
|
|
55
|
+
// its top (its real path), HEAD, the tree of its working tree, the branch of HEAD (null when
|
|
56
|
+
// detached) and main (brancheDeMain); `{ raison }` when no last green can count.
|
|
57
|
+
export function etatDuDepot(racine) {
|
|
58
|
+
const haut = sortie(racine, ['rev-parse', '--show-toplevel']);
|
|
59
|
+
if (!haut) {
|
|
60
|
+
return { raison: 'hors de git' };
|
|
61
|
+
}
|
|
62
|
+
const top = realpathSync(haut);
|
|
63
|
+
const commit = sortie(top, ['rev-parse', '--verify', '-q', 'HEAD^{commit}']);
|
|
64
|
+
if (!commit) {
|
|
65
|
+
return { raison: 'aucun commit' };
|
|
66
|
+
}
|
|
67
|
+
if (sousModuleModifie(top)) {
|
|
68
|
+
return { raison: 'un sous-module diffère de son commit' };
|
|
69
|
+
}
|
|
70
|
+
const dir = mkdtempSync(path.join(os.tmpdir(), 'grillhouse-vert-'));
|
|
71
|
+
try {
|
|
72
|
+
const index = path.join(dir, 'index');
|
|
73
|
+
const reel = sortie(top, ['rev-parse', '--path-format=absolute', '--git-path', 'index']);
|
|
74
|
+
const env = { ...process.env, GIT_INDEX_FILE: index };
|
|
75
|
+
if (reel && existsSync(reel)) {
|
|
76
|
+
copyFileSync(reel, index);
|
|
77
|
+
} else if (git(top, ['read-tree', 'HEAD'], env).status !== 0) {
|
|
78
|
+
return { raison: 'git échoue' };
|
|
79
|
+
}
|
|
80
|
+
if (git(top, ['add', '-A'], env).status !== 0) {
|
|
81
|
+
return { raison: 'git échoue' };
|
|
82
|
+
}
|
|
83
|
+
const arbre = sortie(top, ['write-tree'], env);
|
|
84
|
+
if (!arbre) {
|
|
85
|
+
return { raison: 'git échoue' };
|
|
86
|
+
}
|
|
87
|
+
const branche = sortie(top, ['symbolic-ref', '--short', '-q', 'HEAD']);
|
|
88
|
+
return { racine: top, commit, arbre, branche, main: brancheDeMain(top) };
|
|
89
|
+
} finally {
|
|
90
|
+
rmSync(dir, { recursive: true, force: true });
|
|
91
|
+
}
|
|
92
|
+
}
|
package/scripts/jointure.d.ts
CHANGED
|
@@ -255,12 +255,6 @@ export interface Composition {
|
|
|
255
255
|
* plays (a night test, a time budget bench, a time witness), by the module's own definitions;
|
|
256
256
|
* false for any other file. */
|
|
257
257
|
horsDuJour(chemin: string, racine: string): boolean;
|
|
258
|
-
/** Optional, for a tool that reads a test file beside it (typescript): the sibling of HEAD's
|
|
259
|
-
* version of the test file `chemin` (from `racine`), from the root: a file beside it, a test
|
|
260
|
-
* the tool plays in the same run as it, its tests named in the run's report as the file's, of
|
|
261
|
-
* its class (day, night, bench), which the proof of the red writes, plays and removes; null for
|
|
262
|
-
* a file that has none. */
|
|
263
|
-
soeurDAvant?(chemin: string, racine: string): string | null;
|
|
264
258
|
/** Optional, for the module that drives the task runner (typescript), which the core serves to
|
|
265
259
|
* the others: the names of the summaries of a run present in `racine` before a run. */
|
|
266
260
|
resumesDuLancement?(racine: string): Set<string>;
|
|
@@ -275,29 +269,6 @@ export interface Composition {
|
|
|
275
269
|
/** Optional, typescript's alone: the tasks of the summaries under the results directory
|
|
276
270
|
* `dossier`, in their order, each with its cache status; `code` null for a task that did not run. */
|
|
277
271
|
lireLesResumes?(dossier: string): TacheDuResume[];
|
|
278
|
-
/** Whether HEAD's version of the test file `chemin` (from `racine`) plays in a tree of its own,
|
|
279
|
-
* the copy's with that file alone replaced, under the file's own name, which the proof of the
|
|
280
|
-
* red builds, plays and removes (cargo, python); false for a file the tool cannot play so
|
|
281
|
-
* (cargo: a target `tests/<dossier>/main.rs`, a unit test of `src/`: `testsDeHead`), plays
|
|
282
|
-
* beside it (typescript: `soeurDAvant`) or does not play. */
|
|
283
|
-
arbreDAvant(chemin: string, racine: string): boolean;
|
|
284
|
-
/** The environment a tree of HEAD's version of `chemin` plays under (cargo: the target
|
|
285
|
-
* directory of the copy's compilations; python: the copy's folder of uv environments, which the
|
|
286
|
-
* tree reuses, `GRILLHOUSE_VENV_DE_LA_COPIE`); empty for none. */
|
|
287
|
-
envDArbre(chemin: string, racine: string): Record<string, string>;
|
|
288
|
-
/** The names of the tests of HEAD's version of the test file `chemin` (from `racine`), as the
|
|
289
|
-
* verdict names them, read without playing them, for a file whose tree the proof does not play
|
|
290
|
-
* (cargo: a unit test of `src/`, a target `tests/<dossier>/main.rs`, its out-of-line modules read
|
|
291
|
-
* too), or whose tree breaks the build of its package while the lot alone builds (cargo: a
|
|
292
|
-
* target `tests/<nom>.rs` whose HEAD's version no longer compiles against the lot's
|
|
293
|
-
* `tests/common`, grillhouse-3e2.2); the proof of the red holds each for a green HEAD already
|
|
294
|
-
* holds. `lire` gives HEAD's text of a file from the root, null for none. Null for any other
|
|
295
|
-
* file, or one HEAD does not hold. */
|
|
296
|
-
testsDeHead(
|
|
297
|
-
chemin: string,
|
|
298
|
-
racine: string,
|
|
299
|
-
lire: (fichier: string) => string | null
|
|
300
|
-
): string[] | null;
|
|
301
272
|
manifestes: Manifestes;
|
|
302
273
|
fichiersEngendres(racine: string): FichierEngendre[];
|
|
303
274
|
gardes(racine: string): string[][];
|
|
@@ -158,7 +158,6 @@ import {
|
|
|
158
158
|
} from '../../services-du-noyau.mjs';
|
|
159
159
|
import {
|
|
160
160
|
BANC,
|
|
161
|
-
COPIE_DE_L_ARBRE,
|
|
162
161
|
composantDans,
|
|
163
162
|
crates,
|
|
164
163
|
DE_NUIT,
|
|
@@ -806,18 +805,21 @@ function sousLaBase(genre, env, jouer) {
|
|
|
806
805
|
|
|
807
806
|
/**
|
|
808
807
|
* The line that refuses the workspace at <racine> whose Cargo.lock git does not track, the
|
|
809
|
-
* gesture named; null when git tracks it
|
|
810
|
-
* has no `.git`: its copy's, where the same file is tracked).
|
|
808
|
+
* gesture named; null when git tracks it, and null for a tree with no git at all.
|
|
811
809
|
* @param {string} racine
|
|
812
|
-
* @param {string} [copie]
|
|
813
810
|
* @returns {string | null}
|
|
814
811
|
*/
|
|
815
|
-
export function verrouNonVersionne(racine
|
|
812
|
+
export function verrouNonVersionne(racine) {
|
|
816
813
|
if (!existsSync(path.join(racine, VERROU))) {
|
|
817
814
|
return `⛔ ${VERROU} absent : cargo generate-lockfile, puis git add ${VERROU}`;
|
|
818
815
|
}
|
|
816
|
+
// A tree with no `.git` carries HEAD's Cargo.lock, versioned by construction: nothing is
|
|
817
|
+
// unversioned. The check runs git only in <racine> when it is a real git tree (grillhouse-uja).
|
|
818
|
+
if (!existsSync(path.join(racine, '.git'))) {
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
819
821
|
const r = spawnSync('git', ['ls-files', '--error-unmatch', '--', VERROU], {
|
|
820
|
-
cwd:
|
|
822
|
+
cwd: racine,
|
|
821
823
|
stdio: 'ignore',
|
|
822
824
|
});
|
|
823
825
|
return r.status === 0 ? null : `⛔ ${VERROU} non versionné : git add ${VERROU}`;
|
|
@@ -850,9 +852,8 @@ export function lancer(nom, args, { racine = process.cwd(), env = process.env }
|
|
|
850
852
|
}
|
|
851
853
|
}
|
|
852
854
|
const refus =
|
|
853
|
-
(VERROUILLEES.includes(nom)
|
|
854
|
-
|
|
855
|
-
: null) ?? (COMPILENT.includes(nom) ? sccacheAbsent(racine, env) : null);
|
|
855
|
+
(VERROUILLEES.includes(nom) ? verrouNonVersionne(racine) : null) ??
|
|
856
|
+
(COMPILENT.includes(nom) ? sccacheAbsent(racine, env) : null);
|
|
856
857
|
if (refus) {
|
|
857
858
|
process.stderr.write(`${refus}\n`);
|
|
858
859
|
return 2;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The components of a workspace of cargo, as cargo itself describes them (`cargo metadata
|
|
2
2
|
// --format-version 1 --no-deps --offline`): the crates the module cargo answers the join with
|
|
3
3
|
// (scripts/jointure.d.ts, `composants`, `composantDe`, `matieres`, `joueDesTests`, `lecteurs`,
|
|
4
|
-
// `estUnTest
|
|
4
|
+
// `estUnTest`).
|
|
5
5
|
//
|
|
6
6
|
// - A component is a member of the workspace (`workspace_members`): its folder, the manifest's;
|
|
7
7
|
// its name and its package, the crate's name. A directory without a Cargo.toml at its root holds
|
|
@@ -29,13 +29,6 @@
|
|
|
29
29
|
// `tests.rs` under `src/`, and any file of a folder `tests/` under `src/`, is a unit test file,
|
|
30
30
|
// played with its crate when it is Rust; a file of a crate of the shared test material is
|
|
31
31
|
// material; any other file of a crate (the code of `src/`) is none of them.
|
|
32
|
-
// - HEAD's version of a test file plays in a tree of its own (`arbreDAvant`), never beside the
|
|
33
|
-
// file: a target `tests/<nom>.rs`, a target cargo finds by itself, its tree the copy's with that
|
|
34
|
-
// file replaced, built in the cargo target directory of the copy (`envDArbre`); none for
|
|
35
|
-
// `tests/<dossier>/main.rs` nor a unit test of `src/`, whose names of tests HEAD's version holds
|
|
36
|
-
// are read without playing them (`testsDeHead`, ./tests-de-head.mjs), the proof holding each for
|
|
37
|
-
// a green HEAD holds; those of a target `tests/<nom>.rs` too, when its tree no longer compiles
|
|
38
|
-
// (grillhouse-3e2.2).
|
|
39
32
|
// - What the testwriter writes of the manifests (`manifestes`): the tables that declare what the
|
|
40
33
|
// tests of a crate depend on, `[dev-dependencies]` and `[target.<cible>.dev-dependencies]` of
|
|
41
34
|
// its Cargo.toml (cargo's book, « Development dependencies »), as the author of a test of Bazel
|
|
@@ -55,7 +48,6 @@ import path from 'node:path';
|
|
|
55
48
|
import { isDeepStrictEqual } from 'node:util';
|
|
56
49
|
import { luUneFois } from '../../services-du-noyau.mjs';
|
|
57
50
|
import { cibleDeCompilation } from './sccache.mjs';
|
|
58
|
-
import { nomsDeHead } from './tests-de-head.mjs';
|
|
59
51
|
|
|
60
52
|
// The loader of the optional peers this module reads when it needs them (smol-toml), under the
|
|
61
53
|
// name by which knip reads a dependency.
|
|
@@ -270,97 +262,6 @@ export function estUnTest(chemin, racine) {
|
|
|
270
262
|
export const DE_NUIT = '_nuit';
|
|
271
263
|
export const BANC = '_budget';
|
|
272
264
|
|
|
273
|
-
/**
|
|
274
|
-
* Whether HEAD's version of the test file <chemin> (from the root <racine>) plays in a tree of its
|
|
275
|
-
* own, in the same proof as the lot's: a test target `tests/<nom>.rs`, a target cargo finds by
|
|
276
|
-
* itself (`autotests`), its `mod` of the same folder read as the file's; false for any other
|
|
277
|
-
* file: a target `tests/<dossier>/main.rs` holds its modules beside it, and a unit test of
|
|
278
|
-
* `src/` is compiled in its crate's module (`testsDeHead` reads their names).
|
|
279
|
-
* @param {string} chemin
|
|
280
|
-
* @param {string} racine
|
|
281
|
-
*/
|
|
282
|
-
export function arbreDAvant(chemin, racine) {
|
|
283
|
-
const abs = path.resolve(racine, chemin);
|
|
284
|
-
const c = composantDans(
|
|
285
|
-
crates(racine).map(x => x.composant),
|
|
286
|
-
racine,
|
|
287
|
-
abs
|
|
288
|
-
);
|
|
289
|
-
const parts = c ? path.relative(c.dossier, abs).split(path.sep) : [];
|
|
290
|
-
return parts.length === 2 && parts[0] === 'tests' && parts[1].endsWith('.rs');
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/** The variable that names, to the launcher, the copy whose git tracks the `Cargo.lock` of a tree. */
|
|
294
|
-
export const COPIE_DE_L_ARBRE = 'GRILLHOUSE_COPIE_DE_L_ARBRE';
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* The environment a tree of HEAD's version plays under: the target directory of the copy's
|
|
298
|
-
* compilations, so that the tree builds there, whatever its place (`cibleDeCompilation`
|
|
299
|
-
* (./sccache.mjs) for a copy in the temporary directory, its `target/` otherwise; the caller's
|
|
300
|
-
* own `CARGO_TARGET_DIR` stays), and the copy itself (`COPIE_DE_L_ARBRE`), where git tracks the
|
|
301
|
-
* `Cargo.lock` the tree, which has no `.git`, carries.
|
|
302
|
-
* @param {string} _chemin
|
|
303
|
-
* @param {string} racine
|
|
304
|
-
* @returns {NodeJS.ProcessEnv}
|
|
305
|
-
*/
|
|
306
|
-
export function envDArbre(_chemin, racine) {
|
|
307
|
-
const cible = cibleDeCompilation(racine, process.env, { creer: false });
|
|
308
|
-
return {
|
|
309
|
-
...(process.env.CARGO_TARGET_DIR || cible.CARGO_TARGET_DIR
|
|
310
|
-
? cible
|
|
311
|
-
: { CARGO_TARGET_DIR: path.join(racine, 'target') }),
|
|
312
|
-
[COPIE_DE_L_ARBRE]: racine,
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* The names of the tests of HEAD's version of the test file <chemin> (from the root <racine>),
|
|
318
|
-
* read without playing them, for a file whose tree the proof does not play: a unit test file of
|
|
319
|
-
* `src/` (`tests.rs`, a file of a folder `tests/` under `src/`, out of `src/bin/`) and each file
|
|
320
|
-
* of a target `tests/<dossier>/main.rs`, its root and its modules (`tests/it/foo.rs`, the names
|
|
321
|
-
* `foo::…`), each its own tests as the verdict gives them (./tests-de-head.mjs,
|
|
322
|
-
* ./verdict.mjs), and a target `tests/<nom>.rs`, whose tree the
|
|
323
|
-
* proof plays unless it no longer compiles (grillhouse-3e2.2): its names as nextest gives them,
|
|
324
|
-
* without the target, its out-of-line modules read (`mod common;`, `common::<fn>`). <lire> gives
|
|
325
|
-
* HEAD's text of a file from the root. Null for any other file, or one HEAD does not hold.
|
|
326
|
-
* @param {string} chemin
|
|
327
|
-
* @param {string} racine
|
|
328
|
-
* @param {(f: string) => string | null} lire
|
|
329
|
-
*/
|
|
330
|
-
export function testsDeHead(chemin, racine, lire) {
|
|
331
|
-
const abs = path.resolve(racine, chemin);
|
|
332
|
-
const c = composantDans(
|
|
333
|
-
crates(racine).map(x => x.composant),
|
|
334
|
-
racine,
|
|
335
|
-
abs
|
|
336
|
-
);
|
|
337
|
-
if (!c || !chemin.endsWith('.rs')) {
|
|
338
|
-
return null;
|
|
339
|
-
}
|
|
340
|
-
const parts = path.relative(c.dossier, abs).split(path.sep);
|
|
341
|
-
// A file of a target `tests/<dossier>/main.rs`, out of the helpers of `tests/common/`.
|
|
342
|
-
if (parts.length >= 3 && parts[0] === 'tests' && parts[1] !== 'common') {
|
|
343
|
-
const module = parts.slice(2);
|
|
344
|
-
module[module.length - 1] = module[module.length - 1].replace(/\.rs$/, '');
|
|
345
|
-
if (module.at(-1) === 'mod' || (module.length === 1 && module[0] === 'main')) {
|
|
346
|
-
module.pop();
|
|
347
|
-
}
|
|
348
|
-
return nomsDeHead(chemin, module, lire);
|
|
349
|
-
}
|
|
350
|
-
if (arbreDAvant(chemin, racine)) {
|
|
351
|
-
return nomsDeHead(chemin, null, lire);
|
|
352
|
-
}
|
|
353
|
-
if (!unitaire(parts) || parts[1] === 'bin') {
|
|
354
|
-
return null;
|
|
355
|
-
}
|
|
356
|
-
const module = parts.slice(1);
|
|
357
|
-
module[module.length - 1] = module[module.length - 1].replace(/\.rs$/, '');
|
|
358
|
-
if (module.at(-1) === 'mod') {
|
|
359
|
-
module.pop();
|
|
360
|
-
}
|
|
361
|
-
return nomsDeHead(chemin, module, lire);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
265
|
// The tables of a manifest that declare what its tests depend on.
|
|
365
266
|
const DES_TESTS = 'dev-dependencies';
|
|
366
267
|
|
|
@@ -201,37 +201,6 @@ function resultats(dans, taches, rapports, cibles) {
|
|
|
201
201
|
return dossier;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
// HEAD's text of a unit test file of `src/`: two tests, one in an inline module, and braces and
|
|
205
|
-
// a false test in a comment, a raw string and a character, which are not counted.
|
|
206
|
-
const UNITAIRE = [
|
|
207
|
-
'use super::*;',
|
|
208
|
-
'// fn faux() { #[test]',
|
|
209
|
-
'#[test]',
|
|
210
|
-
'fn ancien() {',
|
|
211
|
-
' let _ = r#"{ #[test] fn dans_la_chaine() {} "#;',
|
|
212
|
-
" let _ = '{';",
|
|
213
|
-
'}',
|
|
214
|
-
'/* } #[test] fn commentee() {} */',
|
|
215
|
-
'mod groupe {',
|
|
216
|
-
' #[test]',
|
|
217
|
-
' #[ignore]',
|
|
218
|
-
' fn interne() {}',
|
|
219
|
-
'}',
|
|
220
|
-
'',
|
|
221
|
-
].join('\n');
|
|
222
|
-
// HEAD's text of a target `tests/<dossier>/main.rs`: a test, one under `#[tokio::test]` in an
|
|
223
|
-
// inline module, and an out-of-line module `aide`.
|
|
224
|
-
const PRINCIPAL = [
|
|
225
|
-
'mod aide;',
|
|
226
|
-
'#[test]',
|
|
227
|
-
'fn principal() {}',
|
|
228
|
-
'mod m {',
|
|
229
|
-
' #[tokio::test]',
|
|
230
|
-
' async fn dedans() {}',
|
|
231
|
-
'}',
|
|
232
|
-
'',
|
|
233
|
-
].join('\n');
|
|
234
|
-
|
|
235
204
|
export default {
|
|
236
205
|
// The trials under <dans>.
|
|
237
206
|
preparer(dans) {
|
|
@@ -365,48 +334,6 @@ export default {
|
|
|
365
334
|
'crates/matiere/src/lib.rs : matiere',
|
|
366
335
|
],
|
|
367
336
|
},
|
|
368
|
-
versionDeHead: {
|
|
369
|
-
valide: [
|
|
370
|
-
'crates/core/src/lib.rs',
|
|
371
|
-
'crates/core/src/tests.rs',
|
|
372
|
-
'crates/core/tests/common/mod.rs',
|
|
373
|
-
'crates/core/tests/scenario/main.rs',
|
|
374
|
-
'Cargo.toml',
|
|
375
|
-
],
|
|
376
|
-
// A target, a night test and a bench play in a tree, under their own name.
|
|
377
|
-
invalide: [
|
|
378
|
-
'crates/core/tests/t.rs',
|
|
379
|
-
'crates/core/tests/t_nuit.rs',
|
|
380
|
-
'crates/core/tests/t_budget.rs',
|
|
381
|
-
// A unit test of `src/` and a target `tests/<dossier>/main.rs` have no tree: the
|
|
382
|
-
// names of HEAD's tests are read, as nextest reports them (its module path), the
|
|
383
|
-
// braces of a comment, a string or a character not counted; each file of the target
|
|
384
|
-
// its own, as the verdict gives them: main.rs its tests, a module of it its own.
|
|
385
|
-
{
|
|
386
|
-
chemin: 'crates/core/src/rendu/tests.rs',
|
|
387
|
-
textes: { 'crates/core/src/rendu/tests.rs': UNITAIRE },
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
chemin: 'crates/core/tests/scenario/main.rs',
|
|
391
|
-
textes: {
|
|
392
|
-
'crates/core/tests/scenario/main.rs': PRINCIPAL,
|
|
393
|
-
'crates/core/tests/scenario/aide.rs': '#[test]\nfn aidant() {}\n',
|
|
394
|
-
},
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
chemin: 'crates/core/tests/scenario/aide.rs',
|
|
398
|
-
textes: { 'crates/core/tests/scenario/aide.rs': '#[test]\nfn aidant() {}\n' },
|
|
399
|
-
},
|
|
400
|
-
],
|
|
401
|
-
attendu: [
|
|
402
|
-
'crates/core/tests/t.rs → un arbre',
|
|
403
|
-
'crates/core/tests/t_nuit.rs → un arbre',
|
|
404
|
-
'crates/core/tests/t_budget.rs → un arbre',
|
|
405
|
-
'crates/core/src/rendu/tests.rs : rendu::tests::ancien, rendu::tests::groupe::interne',
|
|
406
|
-
'crates/core/tests/scenario/main.rs : principal, m::dedans',
|
|
407
|
-
'crates/core/tests/scenario/aide.rs : aide::aidant',
|
|
408
|
-
],
|
|
409
|
-
},
|
|
410
337
|
fichiersEngendres: {
|
|
411
338
|
valide: aJour,
|
|
412
339
|
invalide: enRetard,
|
|
@@ -45,9 +45,6 @@ import {
|
|
|
45
45
|
composantDans,
|
|
46
46
|
composants,
|
|
47
47
|
estUnTest,
|
|
48
|
-
arbreDAvant,
|
|
49
|
-
envDArbre,
|
|
50
|
-
testsDeHead,
|
|
51
48
|
joueDesTests,
|
|
52
49
|
lecteurs,
|
|
53
50
|
liensDuManifeste,
|
|
@@ -144,9 +141,6 @@ export default {
|
|
|
144
141
|
echecDeCompilation,
|
|
145
142
|
estUnTest,
|
|
146
143
|
horsDuJour: fichierHorsDuJour,
|
|
147
|
-
arbreDAvant,
|
|
148
|
-
envDArbre,
|
|
149
|
-
testsDeHead,
|
|
150
144
|
manifestes,
|
|
151
145
|
fichiersEngendres: () => [
|
|
152
146
|
{
|