@roomi-fields/grillhouse 0.25.4 → 0.26.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 +6 -0
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/charte.md +10 -1
- package/docs/ARCHITECTURE.md +107 -19
- package/docs/INTERFACE.md +19 -5
- package/hooks/register.tsx +57 -16
- package/package.json +9 -3
- package/scripts/circuit.mjs +244 -66
- package/scripts/copies-finies.mjs +345 -0
- package/scripts/crochets.mjs +9 -3
- package/scripts/enveloppe/enveloppe.mjs +59 -17
- package/scripts/enveloppe/lancer.sh +15 -22
- package/scripts/enveloppe/travail-de-la-copie.mjs +188 -0
- package/scripts/etapes.mjs +1 -1
- package/scripts/fusion-du-changelog.mjs +120 -0
- package/scripts/grillhouse-maj.mjs +19 -0
- package/scripts/integration/file.mjs +196 -104
- package/scripts/jointure.d.ts +26 -1
- package/scripts/langages/cargo/binaires.json +2 -1
- package/scripts/langages/cargo/clippy.mjs +10 -2
- package/scripts/langages/cargo/commandes.mjs +77 -22
- package/scripts/langages/cargo/composants.mjs +236 -9
- package/scripts/langages/cargo/index.mjs +17 -8
- package/scripts/langages/cargo/sccache.mjs +143 -0
- package/scripts/langages/cargo/verdict.mjs +52 -11
- package/scripts/langages/typescript/consommateurs.mjs +10 -2
- package/scripts/langages/typescript/index.mjs +4 -2
- package/scripts/langages/typescript/lecteurs.mjs +13 -4
- package/scripts/langages/typescript/references-par-les-types.mjs +5 -1
- package/scripts/langages/typescript/regle-des-tests.mjs +37 -0
- package/scripts/nuit.sh +25 -0
- package/scripts/outils-cles.mjs +188 -0
- package/scripts/resultats.mjs +26 -7
- package/scripts/retirer-copie.sh +2 -1
- package/scripts/sous-commandes.mjs +16 -0
- package/scripts/verrou-de-machine.mjs +14 -13
- package/scripts/verrous/verrou.mjs +50 -14
- package/skills/developpeur/SKILL.md +14 -2
- package/skills/explorateur/SKILL.md +3 -1
- package/skills/pitmaster/SKILL.md +10 -3
- package/skills/pitmaster/references/consigne-agent.md +11 -10
- package/skills/relecteur/SKILL.md +13 -2
- package/skills/testwriter/SKILL.md +23 -6
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
// circuit of a ticket (scripts/circuit.mjs), once it has put the ticket's branch in the queue, and
|
|
5
5
|
// by the supervisor by hand.
|
|
6
6
|
//
|
|
7
|
-
// npx grillhouse file
|
|
7
|
+
// npx grillhouse file [--ci <ticket>]
|
|
8
8
|
//
|
|
9
|
-
// No argument (exit 2 and the usage otherwise). It takes the branches waiting one by one until none is
|
|
9
|
+
// No argument, or `--ci <ticket>` (below; exit 2 and the usage otherwise). It takes the branches waiting one by one until none is
|
|
10
10
|
// left, then exits 0, whatever became of each branch. A queue launched while another runs exits 0 at
|
|
11
11
|
// once, refusing nothing: the running queue takes the branch that arrived (it reads the entries
|
|
12
12
|
// again before it lets go of its lock, `.git/file-integration.lock`).
|
|
@@ -58,7 +58,16 @@
|
|
|
58
58
|
// `npm run verifier` play out of it. A red CI reopens the ticket (`bd reopen`), its comment giving the
|
|
59
59
|
// address of the run (`gh run view <id> --json url`) and the end of `gh run view <id>
|
|
60
60
|
// --log-failed`. Without `gh`, without a run found, with `gh` refusing or past the 30 min, the
|
|
61
|
-
// ticket is told that the CI was not read, and why, and stays closed.
|
|
61
|
+
// ticket is told that the CI was not read, and why, and stays closed. The run is read at its current
|
|
62
|
+
// attempt (`gh run view <id>` without `--attempt`), as a merge queue judges the last attempt of a
|
|
63
|
+
// commit's checks.
|
|
64
|
+
// `--ci <ticket>` reads again the CI of a ticket a red CI reopened, which the circuit runs at 5.2
|
|
65
|
+
// on `--reprendre` (scripts/circuit.mjs, `argumentsDeLaFile`), once the supervisor had the failed
|
|
66
|
+
// jobs run again (`gh run rerun <id> --failed`): the commit of main that delivers the ticket, its
|
|
67
|
+
// CI read as above (`relireCI`); green, the ticket closes « intégré : <commit> », the run named at
|
|
68
|
+
// it; red or not read, it stays open, the reading at the ticket. A flaky test has no path of its
|
|
69
|
+
// own: the red comment gives the charter's rule, a test known red goes into quarantine in the test
|
|
70
|
+
// itself, with the ticket that fixes it. It takes no lock: it does not move main.
|
|
62
71
|
// Every comment and change of the queue at a ticket is written under the author `file`, which bd
|
|
63
72
|
// reads in BEADS_ACTOR, as the circuit writes its own lines under `circuit`.
|
|
64
73
|
import { spawnSync } from 'node:child_process';
|
|
@@ -67,6 +76,7 @@ import { createRequire } from 'node:module';
|
|
|
67
76
|
import path from 'node:path';
|
|
68
77
|
import { pathToFileURL } from 'node:url';
|
|
69
78
|
import { lireCommit } from '../poussee-cles.mjs';
|
|
79
|
+
import { commitsDelivering, gitLog } from '../un-commit-par-ticket.mjs';
|
|
70
80
|
import { attendreUnPeu, lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
|
|
71
81
|
import { dossierCommun, lireEntrees, retirerEntree } from './file-attente.mjs';
|
|
72
82
|
import { ouvrirCopie } from './rejeu.mjs';
|
|
@@ -193,9 +203,185 @@ export function fluxDeLaBranche(fichiers, branche) {
|
|
|
193
203
|
.map(({ chemin }) => chemin);
|
|
194
204
|
}
|
|
195
205
|
|
|
206
|
+
// The verdicts of a reading of the CI (`lireCI`).
|
|
207
|
+
const VERTE = 'verte';
|
|
208
|
+
const ROUGE = 'rouge';
|
|
209
|
+
const SANS_CI = 'sans-ci';
|
|
210
|
+
const NON_LUE = 'non-lue';
|
|
211
|
+
|
|
212
|
+
// The workflows of the commit <sha> of the repository <racine> that run on a push to <branche>:
|
|
213
|
+
// their paths.
|
|
214
|
+
function fluxDuCommit(racine, sha, branche) {
|
|
215
|
+
const git = (...a) => spawnSync('git', ['-C', racine, ...a], { encoding: 'utf8' });
|
|
216
|
+
const l = git('ls-tree', '--name-only', `${sha}:${DOSSIER_DES_FLUX}`);
|
|
217
|
+
const noms = l.status === 0 ? l.stdout.split('\n').filter(n => EXTENSIONS_DES_FLUX.test(n)) : [];
|
|
218
|
+
const fichiers = noms.map(n => {
|
|
219
|
+
const chemin = `${DOSSIER_DES_FLUX}/${n}`;
|
|
220
|
+
const f = git('show', `${sha}:${chemin}`);
|
|
221
|
+
return { chemin, texte: f.status === 0 ? f.stdout : null };
|
|
222
|
+
});
|
|
223
|
+
return fluxDeLaBranche(fichiers, branche);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// The GitHub CLI run in the main tree <racine>.
|
|
227
|
+
const ghDans =
|
|
228
|
+
racine =>
|
|
229
|
+
(args, options = {}) =>
|
|
230
|
+
spawnSync('gh', args, {
|
|
231
|
+
cwd: racine,
|
|
232
|
+
encoding: 'utf8',
|
|
233
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
234
|
+
...options,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// The CI of the commit <sha> pushed to <branche>, for the ticket <ticket>, read with the tools <o>
|
|
238
|
+
// (`{ racine, principale, bd, gh, dire, avancement }`: the main tree, its branch, bd, the GitHub
|
|
239
|
+
// CLI, a line of the output, the progress directory or null): `{ verdict, passage }`, the verdict
|
|
240
|
+
// VERTE, ROUGE, SANS_CI or NON_LUE, and the id of the run read. The run is read by `gh run view
|
|
241
|
+
// <id>`, which gives its current attempt: a run whose failed jobs were run again
|
|
242
|
+
// (`gh run rerun <id> --failed`) is judged on that attempt, as a merge queue judges the last
|
|
243
|
+
// attempt of a commit's checks. No CI, red or not read, the ticket is told so; green, nothing is
|
|
244
|
+
// written to it.
|
|
245
|
+
function lireCI(o, ticket, sha, branche) {
|
|
246
|
+
const court = sha.slice(0, 7);
|
|
247
|
+
const commenter = texte => o.bd('comments', 'add', ticket, texte);
|
|
248
|
+
if (fluxDuCommit(o.racine, sha, branche).length === 0) {
|
|
249
|
+
const texte = `Aucune CI pour origin/${branche} : aucun flux de ${DOSSIER_DES_FLUX} de ${court} ne se lance sur la branche ${branche}, la file n'en attend pas.`;
|
|
250
|
+
commenter(texte);
|
|
251
|
+
o.dire(`✓ ${texte}`);
|
|
252
|
+
return { verdict: SANS_CI, passage: null };
|
|
253
|
+
}
|
|
254
|
+
const { gh } = o;
|
|
255
|
+
const nonLue = raison => {
|
|
256
|
+
commenter(`## CI non lue\n\nLa CI de ${court} n'a pas été lue : ${raison}`);
|
|
257
|
+
o.dire(`⚠ CI de ${court} non lue : ${raison}`);
|
|
258
|
+
return { verdict: NON_LUE, passage: null };
|
|
259
|
+
};
|
|
260
|
+
const recherche = delai('GRILLHOUSE_CI_RECHERCHE_MS', RECHERCHE_CI_MS);
|
|
261
|
+
const debut = Date.now();
|
|
262
|
+
let passage = null;
|
|
263
|
+
for (;;) {
|
|
264
|
+
const r = gh(['run', 'list', '--commit', sha, '--json', 'databaseId,status,conclusion']);
|
|
265
|
+
if (r.error) return nonLue(`gh ne se lance pas (${r.error.code ?? r.error.message}).`);
|
|
266
|
+
if (r.status !== 0) return nonLue(`gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}`);
|
|
267
|
+
let passages = [];
|
|
268
|
+
try {
|
|
269
|
+
passages = JSON.parse(r.stdout || '[]');
|
|
270
|
+
} catch {
|
|
271
|
+
return nonLue(`gh run list rend une sortie illisible :\n${r.stdout.trim()}`);
|
|
272
|
+
}
|
|
273
|
+
passage = passages.find(x => x?.databaseId);
|
|
274
|
+
const reste = recherche - (Date.now() - debut);
|
|
275
|
+
if (passage || reste <= 0) break;
|
|
276
|
+
attendreUnPeu(Math.min(10_000, reste));
|
|
277
|
+
}
|
|
278
|
+
if (!passage) {
|
|
279
|
+
return nonLue(`aucun passage de la CI pour ce commit en ${Math.round(recherche / 1000)} s.`);
|
|
280
|
+
}
|
|
281
|
+
const id = String(passage.databaseId);
|
|
282
|
+
const attente = delai('GRILLHOUSE_CI_ATTENTE_MS', ATTENTE_CI_MS);
|
|
283
|
+
const pas = delai('GRILLHOUSE_CI_PAS_MS', PAS_CI_MS);
|
|
284
|
+
const limite = Date.now() + attente;
|
|
285
|
+
let vue = null;
|
|
286
|
+
for (;;) {
|
|
287
|
+
const v = gh(['run', 'view', id, '--json', 'status,conclusion,jobs'], {
|
|
288
|
+
timeout: 60_000,
|
|
289
|
+
killSignal: 'SIGKILL',
|
|
290
|
+
});
|
|
291
|
+
if (v.error) return nonLue(`gh ne se lance pas (${v.error.code ?? v.error.message}).`);
|
|
292
|
+
if (v.status !== 0) return nonLue(`gh run view refuse :\n${`${v.stderr}${v.stdout}`.trim()}`);
|
|
293
|
+
try {
|
|
294
|
+
vue = JSON.parse(v.stdout || '{}');
|
|
295
|
+
} catch {
|
|
296
|
+
return nonLue(`gh run view rend une sortie illisible :\n${v.stdout.trim()}`);
|
|
297
|
+
}
|
|
298
|
+
ecrireLesEtapes(o.avancement, vue);
|
|
299
|
+
if (vue?.status === 'completed') break;
|
|
300
|
+
const reste = limite - Date.now();
|
|
301
|
+
if (reste <= 0) {
|
|
302
|
+
return nonLue(`le passage ${id} n'a pas fini en ${Math.round(attente / 60_000)} min.`);
|
|
303
|
+
}
|
|
304
|
+
attendreUnPeu(Math.min(pas, reste));
|
|
305
|
+
}
|
|
306
|
+
if (vue.conclusion === 'success') {
|
|
307
|
+
o.dire(`✓ CI de ${court} verte (passage ${id})`);
|
|
308
|
+
return { verdict: VERTE, passage: id };
|
|
309
|
+
}
|
|
310
|
+
const url = gh(['run', 'view', id, '--json', 'url', '--jq', '.url']).stdout?.trim() || id;
|
|
311
|
+
const journal = `${gh(['run', 'view', id, '--log-failed']).stdout ?? ''}`
|
|
312
|
+
.trim()
|
|
313
|
+
.split('\n')
|
|
314
|
+
.slice(-60)
|
|
315
|
+
.join('\n');
|
|
316
|
+
commenter(
|
|
317
|
+
`## CI rouge\n\nLa CI de ${court} sur ${o.principale} est rouge : ${url}\n\nLa fin de gh run view ${id} --log-failed :\n\n${journal}\n\nLe ticket est rouvert : sa correction entre sous son numéro. Un rejeu vert de la même CI (\`gh run rerun ${id} --failed\`), puis \`--reprendre\` du circuit, le ferme ; un test connu instable se met en quarantaine dans le test, avec le ticket qui le corrige.`
|
|
318
|
+
);
|
|
319
|
+
o.dire(`✗ CI de ${court} rouge (passage ${id}) : ${ticket} rouvert`);
|
|
320
|
+
return { verdict: ROUGE, passage: id };
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The CI of the ticket's commit on main read again, with the tools <o> (`{ racine, principale,
|
|
325
|
+
* ticket, bd, gh, dire, avancement }`, as `lireCI`), for a ticket a red CI reopened: as a merge
|
|
326
|
+
* queue judges the last attempt of a commit's checks, a run whose failed jobs were run again green
|
|
327
|
+
* is green. The commit is the last of main that delivers the ticket (its title line names it,
|
|
328
|
+
* `commitsDelivering` of ../un-commit-par-ticket.mjs, the prefix read from bd); green, or no CI
|
|
329
|
+
* for the branch pushed to, the ticket closes as an entry closes it (« intégré : <commit> »), its
|
|
330
|
+
* run named at the ticket; red or not read, it stays open, the reading at the ticket. No commit of
|
|
331
|
+
* main delivering it, or its branch `agent/<ticket>` still ahead of main (a lot not yet on main),
|
|
332
|
+
* the ticket is told that the CI is not read again. Exit 0.
|
|
333
|
+
*/
|
|
334
|
+
export function relireCI(o) {
|
|
335
|
+
const { racine, principale, ticket } = o;
|
|
336
|
+
const git = (...a) => spawnSync('git', ['-C', racine, ...a], { encoding: 'utf8' });
|
|
337
|
+
const nonRelue = raison => {
|
|
338
|
+
o.bd('comments', 'add', ticket, `## CI non relue\n\n${raison}`);
|
|
339
|
+
o.dire(`⚠ CI non relue : ${raison}`);
|
|
340
|
+
return 0;
|
|
341
|
+
};
|
|
342
|
+
const refPrincipale = `refs/heads/${principale}`;
|
|
343
|
+
const branche = `agent/${ticket}`;
|
|
344
|
+
const enAvance = git('rev-list', '--count', `${refPrincipale}..refs/heads/${branche}`);
|
|
345
|
+
if (enAvance.status === 0 && Number(enAvance.stdout.trim()) > 0) {
|
|
346
|
+
return nonRelue(
|
|
347
|
+
`La branche ${branche} a des commits hors de ${principale} : son lot n'est pas sur ${principale}, la file n'en relit pas la CI.`
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
const prefixe = o.bd('config', 'get', 'issue_prefix').stdout?.trim() ?? '';
|
|
351
|
+
const sha = commitsDelivering(ticket, prefixe, gitLog(racine))
|
|
352
|
+
.map(c => git('rev-parse', '--verify', '-q', `${c}^{commit}`).stdout.trim())
|
|
353
|
+
.find(c => c && git('merge-base', '--is-ancestor', c, refPrincipale).status === 0);
|
|
354
|
+
if (!sha) {
|
|
355
|
+
return nonRelue(
|
|
356
|
+
`Aucun commit de ${principale} ne livre ${ticket} : la file n'a pas de CI à relire.`
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
const court = sha.slice(0, 7);
|
|
360
|
+
const paquet = git('show', `${refPrincipale}:package.json`);
|
|
361
|
+
const { commit, faute } = lireCommit(paquet.status === 0 ? JSON.parse(paquet.stdout) : null);
|
|
362
|
+
if (faute) {
|
|
363
|
+
return nonRelue(`grillhouse.poussee.commit vaut ${faute}, pas un nom de branche.`);
|
|
364
|
+
}
|
|
365
|
+
const ci = lireCI(o, ticket, sha, commit);
|
|
366
|
+
if (ci.verdict === VERTE || ci.verdict === SANS_CI) {
|
|
367
|
+
o.bd('close', ticket, '--reason', `${INTEGRE}${court}`);
|
|
368
|
+
if (ci.passage) {
|
|
369
|
+
o.bd(
|
|
370
|
+
'comments',
|
|
371
|
+
'add',
|
|
372
|
+
ticket,
|
|
373
|
+
`## CI relue\n\nLa CI de ${court} sur ${principale} est verte au dernier essai du passage ${ci.passage} : le ticket se ferme.`
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
o.dire(`✓ ${ticket} fermé : ${court} est sur ${principale}`);
|
|
377
|
+
}
|
|
378
|
+
return 0;
|
|
379
|
+
}
|
|
380
|
+
|
|
196
381
|
function main(argv) {
|
|
197
|
-
|
|
198
|
-
|
|
382
|
+
const relecture = argv.length === 2 && argv[0] === '--ci' && argv[1] ? argv[1] : null;
|
|
383
|
+
if (argv.length && !relecture) {
|
|
384
|
+
process.stderr.write('usage: file.mjs [--ci <ticket>]\n');
|
|
199
385
|
return 2;
|
|
200
386
|
}
|
|
201
387
|
// The progress directory of the circuit's step (scripts/avancement.mjs), where the queue writes
|
|
@@ -227,6 +413,9 @@ function main(argv) {
|
|
|
227
413
|
process.stderr.write("⛔ L'arbre principal n'est pas sur une branche.\n");
|
|
228
414
|
return 1;
|
|
229
415
|
}
|
|
416
|
+
// The tools of the reading of the CI, the queue's and its reading again.
|
|
417
|
+
const lecture = { racine, principale, bd, gh: ghDans(racine), dire, avancement };
|
|
418
|
+
if (relecture) return relireCI({ ...lecture, ticket: relecture });
|
|
230
419
|
const refPrincipale = `refs/heads/${principale}`;
|
|
231
420
|
const copie = path.join(racine, '.claude', 'worktrees', 'file');
|
|
232
421
|
const verrou = path.join(dossierCommun(racine), 'file-integration.lock');
|
|
@@ -342,108 +531,11 @@ function main(argv) {
|
|
|
342
531
|
dire(`⚠ poussée de ${court} refusée`);
|
|
343
532
|
} else {
|
|
344
533
|
dire(`✓ poussée : ${court} est sur origin/${commit}`);
|
|
345
|
-
lireCI(entree, nouveau, commit);
|
|
534
|
+
const ci = lireCI(lecture, entree.ticket, nouveau, commit);
|
|
535
|
+
if (ci.verdict === ROUGE) bd('reopen', entree.ticket);
|
|
346
536
|
}
|
|
347
537
|
};
|
|
348
538
|
|
|
349
|
-
// The workflows of the commit <sha> that run on a push to <branche>: their paths.
|
|
350
|
-
const fluxDuCommit = (sha, branche) => {
|
|
351
|
-
const l = git('ls-tree', '--name-only', `${sha}:${DOSSIER_DES_FLUX}`);
|
|
352
|
-
const noms =
|
|
353
|
-
l.status === 0 ? l.stdout.split('\n').filter(n => EXTENSIONS_DES_FLUX.test(n)) : [];
|
|
354
|
-
const fichiers = noms.map(n => {
|
|
355
|
-
const chemin = `${DOSSIER_DES_FLUX}/${n}`;
|
|
356
|
-
const f = git('show', `${sha}:${chemin}`);
|
|
357
|
-
return { chemin, texte: f.status === 0 ? f.stdout : null };
|
|
358
|
-
});
|
|
359
|
-
return fluxDeLaBranche(fichiers, branche);
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
// The CI of the commit <sha> pushed to <branche>: none, the ticket is told so in one line; green,
|
|
363
|
-
// the ticket stays closed; red, it reopens; not read, the ticket is told why.
|
|
364
|
-
const lireCI = (entree, sha, branche) => {
|
|
365
|
-
const court = sha.slice(0, 7);
|
|
366
|
-
if (fluxDuCommit(sha, branche).length === 0) {
|
|
367
|
-
const texte = `Aucune CI pour origin/${branche} : aucun flux de ${DOSSIER_DES_FLUX} de ${court} ne se lance sur la branche ${branche}, la file n'en attend pas.`;
|
|
368
|
-
commenter(entree.ticket, texte);
|
|
369
|
-
dire(`✓ ${texte}`);
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
const gh = (args, options = {}) =>
|
|
373
|
-
spawnSync('gh', args, {
|
|
374
|
-
cwd: racine,
|
|
375
|
-
encoding: 'utf8',
|
|
376
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
377
|
-
...options,
|
|
378
|
-
});
|
|
379
|
-
const nonLue = raison => {
|
|
380
|
-
commenter(entree.ticket, `## CI non lue\n\nLa CI de ${court} n'a pas été lue : ${raison}`);
|
|
381
|
-
dire(`⚠ CI de ${court} non lue : ${raison}`);
|
|
382
|
-
};
|
|
383
|
-
const recherche = delai('GRILLHOUSE_CI_RECHERCHE_MS', RECHERCHE_CI_MS);
|
|
384
|
-
const debut = Date.now();
|
|
385
|
-
let passage = null;
|
|
386
|
-
for (;;) {
|
|
387
|
-
const r = gh(['run', 'list', '--commit', sha, '--json', 'databaseId,status,conclusion']);
|
|
388
|
-
if (r.error) return nonLue(`gh ne se lance pas (${r.error.code ?? r.error.message}).`);
|
|
389
|
-
if (r.status !== 0) return nonLue(`gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}`);
|
|
390
|
-
let passages = [];
|
|
391
|
-
try {
|
|
392
|
-
passages = JSON.parse(r.stdout || '[]');
|
|
393
|
-
} catch {
|
|
394
|
-
return nonLue(`gh run list rend une sortie illisible :\n${r.stdout.trim()}`);
|
|
395
|
-
}
|
|
396
|
-
passage = passages.find(x => x?.databaseId);
|
|
397
|
-
const reste = recherche - (Date.now() - debut);
|
|
398
|
-
if (passage || reste <= 0) break;
|
|
399
|
-
attendreUnPeu(Math.min(10_000, reste));
|
|
400
|
-
}
|
|
401
|
-
if (!passage) {
|
|
402
|
-
return nonLue(`aucun passage de la CI pour ce commit en ${Math.round(recherche / 1000)} s.`);
|
|
403
|
-
}
|
|
404
|
-
const id = String(passage.databaseId);
|
|
405
|
-
const attente = delai('GRILLHOUSE_CI_ATTENTE_MS', ATTENTE_CI_MS);
|
|
406
|
-
const pas = delai('GRILLHOUSE_CI_PAS_MS', PAS_CI_MS);
|
|
407
|
-
const limite = Date.now() + attente;
|
|
408
|
-
let vue = null;
|
|
409
|
-
for (;;) {
|
|
410
|
-
const v = gh(['run', 'view', id, '--json', 'status,conclusion,jobs'], {
|
|
411
|
-
timeout: 60_000,
|
|
412
|
-
killSignal: 'SIGKILL',
|
|
413
|
-
});
|
|
414
|
-
if (v.error) return nonLue(`gh ne se lance pas (${v.error.code ?? v.error.message}).`);
|
|
415
|
-
if (v.status !== 0) return nonLue(`gh run view refuse :\n${`${v.stderr}${v.stdout}`.trim()}`);
|
|
416
|
-
try {
|
|
417
|
-
vue = JSON.parse(v.stdout || '{}');
|
|
418
|
-
} catch {
|
|
419
|
-
return nonLue(`gh run view rend une sortie illisible :\n${v.stdout.trim()}`);
|
|
420
|
-
}
|
|
421
|
-
ecrireLesEtapes(avancement, vue);
|
|
422
|
-
if (vue?.status === 'completed') break;
|
|
423
|
-
const reste = limite - Date.now();
|
|
424
|
-
if (reste <= 0) {
|
|
425
|
-
return nonLue(`le passage ${id} n'a pas fini en ${Math.round(attente / 60_000)} min.`);
|
|
426
|
-
}
|
|
427
|
-
attendreUnPeu(Math.min(pas, reste));
|
|
428
|
-
}
|
|
429
|
-
if (vue.conclusion === 'success') {
|
|
430
|
-
dire(`✓ CI de ${court} verte (passage ${id})`);
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
const url = gh(['run', 'view', id, '--json', 'url', '--jq', '.url']).stdout?.trim() || id;
|
|
434
|
-
const journal = `${gh(['run', 'view', id, '--log-failed']).stdout ?? ''}`
|
|
435
|
-
.trim()
|
|
436
|
-
.split('\n')
|
|
437
|
-
.slice(-60)
|
|
438
|
-
.join('\n');
|
|
439
|
-
bd('reopen', entree.ticket);
|
|
440
|
-
commenter(
|
|
441
|
-
entree.ticket,
|
|
442
|
-
`## CI rouge\n\nLa CI de ${court} sur ${principale} est rouge : ${url}\n\nLa fin de gh run view ${id} --log-failed :\n\n${journal}\n\nLe ticket est rouvert : sa correction entre sous son numéro.`
|
|
443
|
-
);
|
|
444
|
-
dire(`✗ CI de ${court} rouge (passage ${id}) : ${entree.ticket} rouvert`);
|
|
445
|
-
};
|
|
446
|
-
|
|
447
539
|
// One branch of the queue, against the main of the moment.
|
|
448
540
|
const traiter = entree => {
|
|
449
541
|
const tip = git('rev-parse', '--verify', '-q', `refs/heads/${entree.branche}`).stdout.trim();
|
package/scripts/jointure.d.ts
CHANGED
|
@@ -68,6 +68,25 @@ export interface FichierEngendre {
|
|
|
68
68
|
* does not write. */
|
|
69
69
|
export type ClasseDeTest = { joue: boolean; test: boolean; matiere: boolean } | null;
|
|
70
70
|
|
|
71
|
+
/** What the testwriter writes of the manifests, as the author of a test of Bazel declares the deps
|
|
72
|
+
* of its target: the part of a component's manifest that declares what its tests depend on, and
|
|
73
|
+
* the lock files of the versions. */
|
|
74
|
+
export interface Manifestes {
|
|
75
|
+
/** The lock files of the versions, from the root: the testwriter writes them, and the envelope
|
|
76
|
+
* opens them to him. */
|
|
77
|
+
verrous: string[];
|
|
78
|
+
/** The parts of a file of a component at `chemin` (absolute, or from `racine`) that change from
|
|
79
|
+
* `avant` (null: no file) to `apres` out of the part of its tests, each named, empty for none:
|
|
80
|
+
* of its manifest, the part that declares what its tests depend on; for cargo, of a file of code
|
|
81
|
+
* of `src/`, its test module. Null for a file the module does not judge. */
|
|
82
|
+
horsDesTests(
|
|
83
|
+
chemin: string,
|
|
84
|
+
racine: string,
|
|
85
|
+
avant: string | null,
|
|
86
|
+
apres: string
|
|
87
|
+
): string[] | null;
|
|
88
|
+
}
|
|
89
|
+
|
|
71
90
|
/** The readers, by the code, of the elements a ticket names (composants-affectes). */
|
|
72
91
|
export interface Lecteurs {
|
|
73
92
|
elements: {
|
|
@@ -85,7 +104,11 @@ export interface Lecteurs {
|
|
|
85
104
|
lecteurs: Map<Composant, Set<string>>;
|
|
86
105
|
}[];
|
|
87
106
|
};
|
|
107
|
+
/** What each component reads: its production code, and its dependencies of every kind. */
|
|
88
108
|
lit: Map<Composant, Set<Composant>>;
|
|
109
|
+
/** What each component's tests read: the components they import, its dependencies of
|
|
110
|
+
* development. */
|
|
111
|
+
parLesTests: Map<Composant, Set<Composant>>;
|
|
89
112
|
}
|
|
90
113
|
|
|
91
114
|
/** The elements a lot adds, changes or removes between two commits, each with its place. */
|
|
@@ -181,7 +204,8 @@ export interface Langage {
|
|
|
181
204
|
* the update installs each one missing or at another version (`miseAJour.installation`). */
|
|
182
205
|
binaires: Record<string, string>;
|
|
183
206
|
/** The directories the language's tools write in a project, by name: the source files leave them
|
|
184
|
-
* out,
|
|
207
|
+
* out, the update writes them in the project's `.gitignore`, and the removal of the finished
|
|
208
|
+
* copies removes them from a kept copy whose ticket is closed (scripts/copies-finies.mjs). */
|
|
185
209
|
ignorer: string[];
|
|
186
210
|
/** Where a run of the language's tools writes, which the envelope opens to a session. */
|
|
187
211
|
sorties: {
|
|
@@ -218,6 +242,7 @@ export interface Langage {
|
|
|
218
242
|
): { tester: Commande; verifier: Commande; typer: Commande } & Record<string, Commande>;
|
|
219
243
|
verdict(dossier: string): { rapports: RapportDeTest[]; taches: TacheJouee[] };
|
|
220
244
|
estUnTest(chemin: string, racine: string): ClasseDeTest;
|
|
245
|
+
manifestes: Manifestes;
|
|
221
246
|
fichiersEngendres(racine: string): FichierEngendre[];
|
|
222
247
|
gardes(racine: string): string[][];
|
|
223
248
|
migrations: Migration[];
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
// node clippy.mjs in the root of the workspace; 0 green, 1 a finding refused
|
|
6
6
|
//
|
|
7
7
|
// - It runs `cargo clippy --all-targets --message-format=json -- -D warnings`: every target, the
|
|
8
|
-
// tests of `tests/` included, which clippy reads only with `--all-targets`; every warning denied
|
|
8
|
+
// tests of `tests/` included, which clippy reads only with `--all-targets`; every warning denied;
|
|
9
|
+
// rustc wrapped by sccache, as every command of the module that compiles (./sccache.mjs); a
|
|
10
|
+
// PATH without sccache refuses before cargo runs, the line naming `npx grillhouse maj`.
|
|
9
11
|
// - Each diagnostic of the compiler that carries a code is a finding: its file, the primary span's
|
|
10
12
|
// from the root, its line, its message the compiler's. A lint (`clippy::needless_return`, a lint
|
|
11
13
|
// of rustc such as `unused_variables`) is its rule, which the debt keys; an error of compilation
|
|
@@ -20,6 +22,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
20
22
|
import path from 'node:path';
|
|
21
23
|
import { pathToFileURL } from 'node:url';
|
|
22
24
|
import { MODE, trancher } from '../../dette.mjs';
|
|
25
|
+
import { avecSccache, sccacheAbsent } from './sccache.mjs';
|
|
23
26
|
|
|
24
27
|
export const GARDE = 'clippy';
|
|
25
28
|
export const ARGS = ['clippy', '--all-targets', '--message-format=json', '--', '-D', 'warnings'];
|
|
@@ -76,9 +79,14 @@ export function constatsDeClippy(sortie, racine) {
|
|
|
76
79
|
* @param {{ env?: NodeJS.ProcessEnv }} [o] the environment (the results directory, the debt's mode)
|
|
77
80
|
*/
|
|
78
81
|
export function commande(racine, { env = process.env } = {}) {
|
|
82
|
+
const absent = sccacheAbsent(racine, env);
|
|
83
|
+
if (absent) {
|
|
84
|
+
process.stderr.write(`${absent}\n`);
|
|
85
|
+
return 1;
|
|
86
|
+
}
|
|
79
87
|
const r = spawnSync('cargo', ARGS, {
|
|
80
88
|
cwd: racine,
|
|
81
|
-
env,
|
|
89
|
+
env: avecSccache(racine, env),
|
|
82
90
|
encoding: 'utf8',
|
|
83
91
|
maxBuffer: 256 * 1024 * 1024,
|
|
84
92
|
});
|
|
@@ -12,12 +12,18 @@
|
|
|
12
12
|
// - Each guard of structure of the module (./clippy.mjs, ./frontieres.mjs, ./index-interfaces.mjs)
|
|
13
13
|
// is a command by its name too, its own script, as the module typescript's: the line of a red
|
|
14
14
|
// guard (`grillhouse <garde>`, scripts/gardes-du-cadre.mjs) names a command that exists.
|
|
15
|
-
// - `tester` plays the tests of each crate chosen, one crate after the other
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
15
|
+
// - `tester` plays the tests of each crate chosen, one crate after the other. For a crate that
|
|
16
|
+
// plays tests (./composants.mjs, `joueDesTests`): the build of its test targets, `cargo test
|
|
17
|
+
// --no-run -p <crate>`, a task `build` of its own, as Turborepo's `test` depends on `build`
|
|
18
|
+
// (grillhouse-egm); then `cargo nextest run -p <crate> --no-fail-fast`, which finds them built.
|
|
19
|
+
// Then `cargo test --doc -p <crate>` for a crate whose library has doctests, which nextest does
|
|
20
|
+
// not play. A failed build leaves the crate's other tasks not played (`code` null): a test that
|
|
21
|
+
// does not compile is a red of the build, which the proof of the red reads as one (« construction
|
|
22
|
+
// de <crate> », scripts/circuit.mjs), and the tests play at the checks. The output of the build
|
|
23
|
+
// goes to its log, `<target>/grillhouse/<crate>-build.log`, the task's `journal` from the root,
|
|
24
|
+
// then to the error stream. A path, written from the root, chooses the crate that holds it; the
|
|
25
|
+
// source of a test target (`<crate>/tests/<nom>.rs`) builds and plays that target alone
|
|
26
|
+
// (`--test <nom>`), without the doctests. A path out of every crate, or in a crate without tests, is refused, named, and
|
|
21
27
|
// nothing plays (code 2). Without a path, every crate plays, or, under the circuit's mark
|
|
22
28
|
// (`GRILLHOUSE_DEPUIS_LE_VERT`), the crates the changes since the last green touch and their
|
|
23
29
|
// dependents (./touches.mjs), every crate when no last green counts. `--force` changes nothing:
|
|
@@ -38,6 +44,10 @@
|
|
|
38
44
|
// directory or file with the crate `tempfile` (`TempDir`, `NamedTempFile`), removed when dropped,
|
|
39
45
|
// a failed test included, never a path built by hand under `std::env::temp_dir()`.
|
|
40
46
|
// - `typer`: `cargo check --all-targets`. `preparer`: `cargo fetch --locked`.
|
|
47
|
+
// - Cargo runs with rustc wrapped by sccache, its cache common to the copies of the machine
|
|
48
|
+
// (./sccache.mjs), in a copy as in an agent's envelope (grillhouse-cyr). `tester`, `verifier`
|
|
49
|
+
// and `typer` refuse, before any run of cargo, a PATH without sccache, in one line that names it
|
|
50
|
+
// and `npx grillhouse maj`, which installs it (code 2).
|
|
41
51
|
// - Nextest reads the frame's profile `grillhouse` (./nextest.toml, a tool's configuration under
|
|
42
52
|
// the project's own, `--tool-config-file`), whose JUnit report lands at
|
|
43
53
|
// `<target>/nextest/grillhouse/junit.xml`.
|
|
@@ -55,7 +65,16 @@
|
|
|
55
65
|
// - The exit code: 0 when every task is green, 75 when the only reds are « à repasser », 1
|
|
56
66
|
// otherwise; 2 for a path refused, a Cargo.lock not tracked or a command unknown.
|
|
57
67
|
import { spawnSync } from 'node:child_process';
|
|
58
|
-
import {
|
|
68
|
+
import {
|
|
69
|
+
closeSync,
|
|
70
|
+
copyFileSync,
|
|
71
|
+
existsSync,
|
|
72
|
+
mkdirSync,
|
|
73
|
+
openSync,
|
|
74
|
+
readFileSync,
|
|
75
|
+
rmSync,
|
|
76
|
+
writeFileSync,
|
|
77
|
+
} from 'node:fs';
|
|
59
78
|
import { constants, tmpdir } from 'node:os';
|
|
60
79
|
import path from 'node:path';
|
|
61
80
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
@@ -72,6 +91,7 @@ import {
|
|
|
72
91
|
retirerALInterruption,
|
|
73
92
|
} from '../../services-du-noyau.mjs';
|
|
74
93
|
import { composantDans, crates, joueDesTests, metadonnees } from './composants.mjs';
|
|
94
|
+
import { avecSccache, sccacheAbsent } from './sccache.mjs';
|
|
75
95
|
import { touchesDesFichiers } from './touches.mjs';
|
|
76
96
|
import { JUNIT, TACHES } from './verdict.mjs';
|
|
77
97
|
|
|
@@ -84,6 +104,8 @@ const RACINE = '//';
|
|
|
84
104
|
const VERROU = 'Cargo.lock';
|
|
85
105
|
// The commands that play the exact versions of the repository, refused without its Cargo.lock.
|
|
86
106
|
const VERROUILLEES = ['tester', 'verifier', 'preparer'];
|
|
107
|
+
// The commands that compile, refused without sccache on the PATH (./sccache.mjs).
|
|
108
|
+
const COMPILENT = ['tester', 'verifier', 'typer'];
|
|
87
109
|
|
|
88
110
|
/** The guards of structure of the module, in the order they play: each its name, its script beside
|
|
89
111
|
* this one, and its arguments as a guard. */
|
|
@@ -125,6 +147,8 @@ function passe(racine, env) {
|
|
|
125
147
|
const id = `${Date.now()}-${process.pid}`;
|
|
126
148
|
const taches = [];
|
|
127
149
|
const cibles = {};
|
|
150
|
+
// Cargo compiles through sccache (./sccache.mjs).
|
|
151
|
+
const compilation = avecSccache(racine, env);
|
|
128
152
|
const ecrire = () => {
|
|
129
153
|
if (!dossier) {
|
|
130
154
|
return;
|
|
@@ -152,12 +176,31 @@ function passe(racine, env) {
|
|
|
152
176
|
ecrire();
|
|
153
177
|
return { t, args };
|
|
154
178
|
},
|
|
155
|
-
jouer({ t, args }, junit = null) {
|
|
179
|
+
jouer({ t, args }, { junit = null, journal = null } = {}) {
|
|
156
180
|
// A report of an earlier run is no report of this one, which may write none.
|
|
157
181
|
if (junit) {
|
|
158
182
|
rmSync(junit, { force: true });
|
|
159
183
|
}
|
|
160
|
-
|
|
184
|
+
let r;
|
|
185
|
+
if (journal) {
|
|
186
|
+
// The output of cargo, both streams in their order, goes to the task's log, then to the
|
|
187
|
+
// command's error stream, where cargo writes it.
|
|
188
|
+
mkdirSync(path.dirname(journal), { recursive: true });
|
|
189
|
+
const fd = openSync(journal, 'w');
|
|
190
|
+
try {
|
|
191
|
+
r = spawnSync('cargo', args, {
|
|
192
|
+
cwd: racine,
|
|
193
|
+
env: compilation,
|
|
194
|
+
stdio: ['inherit', fd, fd],
|
|
195
|
+
});
|
|
196
|
+
} finally {
|
|
197
|
+
closeSync(fd);
|
|
198
|
+
}
|
|
199
|
+
process.stderr.write(readFileSync(journal, 'utf8'));
|
|
200
|
+
t.journal = path.relative(racine, journal);
|
|
201
|
+
} else {
|
|
202
|
+
r = spawnSync('cargo', args, { cwd: racine, env: compilation, stdio: 'inherit' });
|
|
203
|
+
}
|
|
161
204
|
t.code = r.error ? 127 : (r.status ?? 128 + (constants.signals[r.signal] ?? 0));
|
|
162
205
|
if (junit && dossier && existsSync(junit)) {
|
|
163
206
|
mkdirSync(path.join(dossier, JUNIT), { recursive: true });
|
|
@@ -192,30 +235,40 @@ function depuisLeVert(racine, tous, tout, env) {
|
|
|
192
235
|
}
|
|
193
236
|
|
|
194
237
|
// Plans and plays the tests of the crates <choix> (each `{ c, cibles }`, `cibles` the test targets
|
|
195
|
-
// named, empty for the whole crate) in the run <p
|
|
238
|
+
// named, empty for the whole crate) in the run <p>: for a crate that plays tests, the build of its
|
|
239
|
+
// test targets first, then nextest, then its doctests; a failed build leaves the crate's other
|
|
240
|
+
// tasks not played.
|
|
196
241
|
function jouerLesTests(racine, p, choix, options) {
|
|
197
242
|
const m = metadonnees(racine);
|
|
198
243
|
const junit = path.join(m.target_directory, 'nextest', PROFIL, 'junit.xml');
|
|
199
|
-
const
|
|
244
|
+
const parCrate = [];
|
|
200
245
|
for (const { c, cibles } of choix) {
|
|
201
246
|
Object.assign(p.cibles, binaires(c));
|
|
202
247
|
const d = c.composant.dossier;
|
|
248
|
+
const nom = c.composant.nom;
|
|
249
|
+
const prevues = [];
|
|
203
250
|
if (joueDesTests(racine, c.composant)) {
|
|
251
|
+
const selection = ['-p', nom, ...cibles.flatMap(n => ['--test', n])];
|
|
252
|
+
const journal = path.join(m.target_directory, 'grillhouse', `${nom}-build.log`);
|
|
253
|
+
const construction = ['test', '--no-run', ...selection];
|
|
254
|
+
prevues.push([p.prevoir(nom, d, 'build', false, construction), { journal }]);
|
|
204
255
|
const args = ['nextest', 'run', '--tool-config-file', `${PROFIL}:${NEXTEST}`];
|
|
205
|
-
args.push('--profile', PROFIL, '--no-fail-fast',
|
|
206
|
-
|
|
207
|
-
args.push('--test', n);
|
|
208
|
-
}
|
|
209
|
-
prevues.push([p.prevoir(c.composant.nom, d, 'nextest', true, [...args, ...options]), junit]);
|
|
256
|
+
args.push('--profile', PROFIL, '--no-fail-fast', ...selection);
|
|
257
|
+
prevues.push([p.prevoir(nom, d, 'nextest', true, [...args, ...options]), { junit }]);
|
|
210
258
|
}
|
|
211
259
|
const doctests = c.cibles.some(t => t.kind.includes('lib') && t.doctest !== false);
|
|
212
260
|
if (cibles.length === 0 && doctests) {
|
|
213
|
-
const args = ['test', '--doc', '-p',
|
|
214
|
-
prevues.push([p.prevoir(
|
|
261
|
+
const args = ['test', '--doc', '-p', nom];
|
|
262
|
+
prevues.push([p.prevoir(nom, d, 'doctest', true, args), {}]);
|
|
215
263
|
}
|
|
264
|
+
parCrate.push(prevues);
|
|
216
265
|
}
|
|
217
|
-
for (const
|
|
218
|
-
|
|
266
|
+
for (const prevues of parCrate) {
|
|
267
|
+
for (const [t, o] of prevues) {
|
|
268
|
+
if (p.jouer(t, o) !== 0 && t.t.script === 'build') {
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
219
272
|
}
|
|
220
273
|
}
|
|
221
274
|
|
|
@@ -237,7 +290,7 @@ function choisir(racine, tous, chemins) {
|
|
|
237
290
|
continue;
|
|
238
291
|
}
|
|
239
292
|
if (!joueDesTests(racine, c)) {
|
|
240
|
-
refus.push(`${chemin} : ${c.nom} n'a
|
|
293
|
+
refus.push(`${chemin} : ${c.nom} n'a aucun test, ni dossier tests/, ni tests.rs sous src/`);
|
|
241
294
|
continue;
|
|
242
295
|
}
|
|
243
296
|
const cible = crate.cibles.find(t => t.kind.includes('test') && t.src === abs);
|
|
@@ -329,7 +382,9 @@ export function verrouNonVersionne(racine) {
|
|
|
329
382
|
* @param {{ racine?: string, env?: NodeJS.ProcessEnv }} [o]
|
|
330
383
|
*/
|
|
331
384
|
export function lancer(nom, args, { racine = process.cwd(), env = process.env } = {}) {
|
|
332
|
-
const refus =
|
|
385
|
+
const refus =
|
|
386
|
+
(VERROUILLEES.includes(nom) ? verrouNonVersionne(racine) : null) ??
|
|
387
|
+
(COMPILENT.includes(nom) ? sccacheAbsent(racine, env) : null);
|
|
333
388
|
if (refus) {
|
|
334
389
|
process.stderr.write(`${refus}\n`);
|
|
335
390
|
return 2;
|