@roomi-fields/grillhouse 0.46.0 → 0.47.1
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 +20 -0
- package/cadre/templates/c/package.json +19 -0
- package/cadre/templates/projet/.github/workflows/ci.yml +34 -49
- package/cadre/templates/projet/CLAUDE.md +6 -0
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/charte.md +17 -9
- package/dist/temporal/circuit/client.d.ts +14 -5
- package/dist/temporal/circuit/client.js +39 -9
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/file/activites.d.ts +2 -0
- package/dist/temporal/file/activites.js +7 -0
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +26 -18
- package/dist/temporal/file/contrat.js +8 -5
- package/dist/temporal/file/contrat.js.map +1 -1
- package/dist/temporal/file/deroule.d.ts +1 -1
- package/dist/temporal/file/deroule.js +91 -42
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/tickets/activites.js +4 -13
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/docs/ARCHITECTURE.md +117 -82
- package/docs/INTERFACE.md +36 -19
- package/hooks/register.tsx +1 -1
- package/package.json +1 -1
- package/scripts/activites.mjs +5 -11
- package/scripts/arbres-juges.mjs +59 -0
- package/scripts/avancement.mjs +2 -38
- package/scripts/branche-de-nuit.mjs +14 -45
- package/scripts/ci-de-main.mjs +276 -0
- package/scripts/circuit.mjs +2 -1
- package/scripts/commandes-composees.mjs +36 -6
- package/scripts/dernier-vert.mjs +12 -8
- package/scripts/etapes.mjs +1 -1
- package/scripts/faits-du-circuit.mjs +41 -25
- package/scripts/integration/file.mjs +126 -587
- package/scripts/integration/integrer.mjs +6 -5
- package/scripts/langages/c/binaires.json +4 -0
- package/scripts/langages/c/binaires.mjs +83 -0
- package/scripts/langages/c/clang-format.mjs +62 -0
- package/scripts/langages/c/clang-tidy.mjs +93 -0
- package/scripts/langages/c/clang.mjs +42 -0
- package/scripts/langages/c/commandes.mjs +530 -0
- package/scripts/langages/c/composants.mjs +209 -0
- package/scripts/langages/c/exemples.mjs +250 -0
- package/scripts/langages/c/index-interfaces.mjs +77 -0
- package/scripts/langages/c/index.mjs +120 -0
- package/scripts/langages/c/lot.mjs +41 -0
- package/scripts/langages/c/mise-a-jour.mjs +70 -0
- package/scripts/langages/c/squelette.mjs +61 -0
- package/scripts/langages/c/verdict.mjs +99 -0
- package/scripts/langages/typescript/turbo-des-paquets.mjs +16 -5
- package/scripts/langages-des-paquets.mjs +30 -2
- package/scripts/langages.mjs +1 -0
- package/scripts/mesure/avancement.mjs +1 -1
- package/scripts/migrations/0.47.0-ci-de-main.mjs +48 -0
- package/scripts/migrations.mjs +2 -2
- package/scripts/session-start.sh +0 -9
- package/scripts/sortie.mjs +1 -1
- package/scripts/superviseur.mjs +146 -88
- package/scripts/tableau.mjs +23 -8
- package/skills/grill/SKILL.md +6 -5
- package/skills/pitmaster/SKILL.md +9 -7
- package/skills/redacteur/references/documents-d-un-composant.md +1 -1
- package/scripts/ci-des-branches.mjs +0 -93
- package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +0 -31
package/scripts/activites.mjs
CHANGED
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
import path from 'node:path';
|
|
28
28
|
import { avecLAvancementDuTravail } from './avancement.mjs';
|
|
29
29
|
import { A_REPASSER, MEMOIRE_COUPEE } from './codes-de-sortie.mjs';
|
|
30
|
-
import { ecouteLesBranchesDeTicket } from './ci-des-branches.mjs';
|
|
31
30
|
import { BASE_DU_LOT, DEPUIS_LE_VERT } from './dernier-vert.mjs';
|
|
32
31
|
import { empreinteDEtape } from './empreinte-d-etape.mjs';
|
|
33
32
|
import { BASE as GARDES_DE_LA_BASE, FICHIER as DETTE } from './dette.mjs';
|
|
@@ -1476,17 +1475,12 @@ function npm(ctx, etape, args, env = {}, cwd = ctx.copie) {
|
|
|
1476
1475
|
}
|
|
1477
1476
|
|
|
1478
1477
|
// What the passes of the circuit (its proof, its checks, its final pass) measure their tests
|
|
1479
|
-
// against, as variables of their environment
|
|
1480
|
-
// (`
|
|
1481
|
-
//
|
|
1482
|
-
//
|
|
1483
|
-
//
|
|
1484
|
-
// the tests a change affects and leaves the rest to after the submit; else none: the passes
|
|
1485
|
-
// measure themselves against the last green, as `npm run verifier`.
|
|
1478
|
+
// against, as variables of their environment, in every project: the base of the lot
|
|
1479
|
+
// (`GRILLHOUSE_BASE_DU_LOT`: the copy's HEAD, the tip of main of its time), against which each
|
|
1480
|
+
// package plays the tests related to the lot, targeted (scripts/dernier-vert.mjs), and the complete
|
|
1481
|
+
// pass is the CI of main's and the night's, as Google's presubmit plays the tests a change affects
|
|
1482
|
+
// and leaves the rest to after the submit.
|
|
1486
1483
|
export function mesureDesPasses(ctx) {
|
|
1487
|
-
if (!ecouteLesBranchesDeTicket(ctx.copie)) {
|
|
1488
|
-
return {};
|
|
1489
|
-
}
|
|
1490
1484
|
const base = laBase(ctx);
|
|
1491
1485
|
return base ? { [BASE_DU_LOT]: base } : {};
|
|
1492
1486
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The trees judged by a final pass: the file `<git common dir>/grillhouse/arbres-juges.json`, beside
|
|
2
|
+
// the last green, keeps the tree each final pass of the circuit (the queue's, on the lot laid on the
|
|
3
|
+
// tip of main) and each complete verification of a lot of the direct way judged green. The pre-push
|
|
4
|
+
// hook (scripts/branche-de-nuit.mjs) lets a commit go to main only when its tree is there, as bors
|
|
5
|
+
// and the merge queues enter only a tree already judged. A tree is judged whatever the commit that
|
|
6
|
+
// holds it: an amended or replayed commit of a judged tree is judged too.
|
|
7
|
+
//
|
|
8
|
+
// The file is shared by the copies (worktrees) of the repository, as the common directory is, and
|
|
9
|
+
// is written whole, atomically; a path out of git keeps nothing and judges nothing, and never throws.
|
|
10
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { sortie } from './etat-du-depot.mjs';
|
|
13
|
+
|
|
14
|
+
// The file of the repository at <racine>, null out of git.
|
|
15
|
+
function fichier(racine) {
|
|
16
|
+
const commun = sortie(racine, ['rev-parse', '--path-format=absolute', '--git-common-dir']);
|
|
17
|
+
return commun ? path.join(commun, 'grillhouse', 'arbres-juges.json') : null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// The trees kept, in the order they were kept.
|
|
21
|
+
function lire(racine) {
|
|
22
|
+
const f = fichier(racine);
|
|
23
|
+
if (!f) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const l = JSON.parse(readFileSync(f, 'utf8'));
|
|
28
|
+
return Array.isArray(l) ? l.filter(a => typeof a === 'string') : [];
|
|
29
|
+
} catch {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Whether the tree <arbre> was kept as judged green, in the repository at <racine>. */
|
|
35
|
+
export function arbreEstJuge(racine, arbre) {
|
|
36
|
+
return lire(racine).includes(arbre);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The tree <arbre> kept as judged green; a tree already kept changes nothing, a path out of git does nothing. */
|
|
40
|
+
export function garderLArbreJuge(racine, arbre) {
|
|
41
|
+
const f = fichier(racine);
|
|
42
|
+
if (!f) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const gardes = lire(racine);
|
|
46
|
+
if (gardes.includes(arbre)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
mkdirSync(path.dirname(f), { recursive: true });
|
|
50
|
+
const provisoire = `${f}.${process.pid}`;
|
|
51
|
+
writeFileSync(provisoire, `${JSON.stringify([...gardes, arbre], null, 2)}\n`);
|
|
52
|
+
renameSync(provisoire, f);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Whether the tree of the commit <commit> was judged; an unknown commit or a path out of git, never. */
|
|
56
|
+
export function commitEstJuge(racine, commit) {
|
|
57
|
+
const arbre = sortie(racine, ['rev-parse', '--verify', '-q', `${commit}^{tree}`]);
|
|
58
|
+
return arbre ? arbreEstJuge(racine, arbre) : false;
|
|
59
|
+
}
|
package/scripts/avancement.mjs
CHANGED
|
@@ -9,14 +9,7 @@
|
|
|
9
9
|
// (scripts/langages/typescript/verifier.mjs). The directory holds `passe.json` (`{ genre, debut,
|
|
10
10
|
// precedent, totaux }`: its kind, its start, the total of the previous pass of that kind, and
|
|
11
11
|
// the file of the totals where its end keeps its own), the records of its tasks (`taches/`, written by the reporter of progress of the base configuration, one
|
|
12
|
-
// per run of Vitest, and
|
|
13
|
-
// and the plans of its runs of Turborepo (`plan/`).
|
|
14
|
-
// - The CI of a ticket's commit is read by one act at a time, each a process of its own: its
|
|
15
|
-
// readings share one progress directory in the working directory of the ticket,
|
|
16
|
-
// `avancement-ci` (`avancementDeLaCI`), opened by the first and emptied when a reading looks
|
|
17
|
-
// for a run again (another CI, after a reopening), where the board reads the steps
|
|
18
|
-
// of the run done over planned while the circuit waits for it; the next pass of the circuit
|
|
19
|
-
// removes it with the others (`avecLAvancementDuTravail`).
|
|
12
|
+
// per run of Vitest), and the plans of its runs of Turborepo (`plan/`).
|
|
20
13
|
// - The reading adds the records: the files done, and the files planned of the tasks started;
|
|
21
14
|
// while every task the plans name has not started, the total of the previous pass of the same
|
|
22
15
|
// kind stands when it is greater (a pass without a plan never knows all its tasks started).
|
|
@@ -34,7 +27,7 @@
|
|
|
34
27
|
// progress directory in the file of its part (`nommerLAvancement`); the board reads the parts
|
|
35
28
|
// held with their progress, and the waits for a part or for room (`lireLaMesure`).
|
|
36
29
|
import { spawnSync } from 'node:child_process';
|
|
37
|
-
import { existsSync,
|
|
30
|
+
import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync } from 'node:fs';
|
|
38
31
|
import { tmpdir } from 'node:os';
|
|
39
32
|
import path from 'node:path';
|
|
40
33
|
import { AVANCEMENT, ecrireAtomique, TACHES } from './mesure/avancement.mjs';
|
|
@@ -198,35 +191,6 @@ export function avancementDuTravail(travail) {
|
|
|
198
191
|
);
|
|
199
192
|
}
|
|
200
193
|
|
|
201
|
-
/**
|
|
202
|
-
* The progress directory of the readings of the CI of a ticket's commit, in the working directory
|
|
203
|
-
* <travail> of its circuit, where the board reads it (`avancementDuTravail`): one for all its
|
|
204
|
-
* readings, opened by the first, emptied when <nouvelle> (a reading that looks for its run, the
|
|
205
|
-
* records of another run gone); null when the circuit has no working directory.
|
|
206
|
-
* @param {string} travail
|
|
207
|
-
* @param {{ nouvelle?: boolean, debut?: number }} [o]
|
|
208
|
-
* @returns {string | null}
|
|
209
|
-
*/
|
|
210
|
-
export function avancementDeLaCI(travail, { nouvelle = false, debut = Date.now() } = {}) {
|
|
211
|
-
if (!existsSync(travail)) {
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
const dossier = path.join(travail, `${PREFIXE}ci`);
|
|
215
|
-
try {
|
|
216
|
-
if (nouvelle) {
|
|
217
|
-
rmSync(dossier, { recursive: true, force: true });
|
|
218
|
-
}
|
|
219
|
-
if (!existsSync(path.join(dossier, PASSE))) {
|
|
220
|
-
mkdirSync(dossier, { recursive: true });
|
|
221
|
-
ecrireAtomique(path.join(dossier, PASSE), { genre: null, debut, precedent: null });
|
|
222
|
-
}
|
|
223
|
-
} catch {
|
|
224
|
-
// A directory that does not write leaves the queue going, without its progress.
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
return dossier;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
194
|
/**
|
|
231
195
|
* Runs <passe> under a progress directory of the kind <genre> (null: none kept) opened in the
|
|
232
196
|
* working directory <travail> of a ticket's circuit, where the board reads it
|
|
@@ -13,34 +13,31 @@
|
|
|
13
13
|
// alone. It is a mark, not a secret: a human who sets it is trusted.
|
|
14
14
|
// - Exit 0 lets the push go on; exit 1 refuses it, the reason on the standard error.
|
|
15
15
|
//
|
|
16
|
-
// The judged main:
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
// the runs that fails lets the push go, the server judging it.
|
|
23
|
-
import { execFileSync, spawnSync } from 'node:child_process';
|
|
16
|
+
// The judged main: a push to origin of the branch main is pushed to (`grillhouse.poussee.commit`,
|
|
17
|
+
// `main` by default) carries only a commit whose tree a final pass of the circuit, or the
|
|
18
|
+
// verification of a lot of the direct way, judged green (scripts/arbres-juges.mjs), as bors and the
|
|
19
|
+
// merge queues enter only a tree already judged (`refusSurMain`), in every project. The queue
|
|
20
|
+
// pushes such a commit; the CI of main plays after, by batches. No CI of a ticket's branch is asked.
|
|
21
|
+
import { execFileSync } from 'node:child_process';
|
|
24
22
|
import { existsSync, readFileSync } from 'node:fs';
|
|
25
23
|
import path from 'node:path';
|
|
26
24
|
import { pathToFileURL } from 'node:url';
|
|
27
|
-
import {
|
|
25
|
+
import { commitEstJuge } from './arbres-juges.mjs';
|
|
28
26
|
import { lireCommit, lirePoussee } from './poussee-cles.mjs';
|
|
29
27
|
|
|
30
28
|
// A sha of zeros: the deletion of the remote branch.
|
|
31
29
|
const SUPPRESSION = /^0+$/;
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
|
-
* The refusals for a push to `remote` of `refs` to the branch `principale
|
|
35
|
-
*
|
|
36
|
-
* branch is refused, named.
|
|
32
|
+
* The refusals for a push to `remote` of `refs` to the branch `principale`: each commit
|
|
33
|
+
* <jugee(sha)> does not say judged by a final pass or a verification is refused, named.
|
|
37
34
|
* @param {string} remote
|
|
38
35
|
* @param {{ sha: string, distante: string }[]} refs
|
|
39
|
-
* @param {{ principale: string | null,
|
|
36
|
+
* @param {{ principale: string | null, jugee: (sha: string) => boolean }} o
|
|
40
37
|
* @returns {string[]}
|
|
41
38
|
*/
|
|
42
|
-
export function refusSurMain(remote, refs, { principale,
|
|
43
|
-
if (remote !== 'origin' || !
|
|
39
|
+
export function refusSurMain(remote, refs, { principale, jugee }) {
|
|
40
|
+
if (remote !== 'origin' || !principale) {
|
|
44
41
|
return [];
|
|
45
42
|
}
|
|
46
43
|
return refs
|
|
@@ -48,37 +45,10 @@ export function refusSurMain(remote, refs, { principale, ecoute, jugee }) {
|
|
|
48
45
|
.filter(r => !jugee(r.sha))
|
|
49
46
|
.map(
|
|
50
47
|
r =>
|
|
51
|
-
`⛔ ${r.sha.slice(0, 8)} n'est jugé vert par
|
|
48
|
+
`⛔ ${r.sha.slice(0, 8)} n'est jugé vert par aucune passe finale ni vérification de lot : main n'avance que sur un arbre jugé. Joue \`npm run verifier\` sur ce commit (lot direct), ou laisse la file du circuit jouer sa passe finale.`
|
|
52
49
|
);
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
/**
|
|
56
|
-
* Whether one of the runs <runs> of a commit (`gh run list --json headBranch,conclusion`)
|
|
57
|
-
* concluded green on a ticket branch. The conclusion is read run by run: the status filter of
|
|
58
|
-
* GitHub's API lags its runs by minutes (grillhouse-do5e).
|
|
59
|
-
* @param {{ headBranch?: string, conclusion?: string }[]} runs
|
|
60
|
-
*/
|
|
61
|
-
export const jugeeDansLesRuns = runs =>
|
|
62
|
-
runs.some(x => x.conclusion === 'success' && String(x.headBranch).startsWith('agent/'));
|
|
63
|
-
|
|
64
|
-
// Whether a run of the CI concluded green on the commit <sha> on a ticket branch, read by gh in
|
|
65
|
-
// <racine>; true when gh does not answer (the server's ruleset judges then).
|
|
66
|
-
function jugeeParGh(racine, sha) {
|
|
67
|
-
const r = spawnSync('gh', ['run', 'list', '--commit', sha, '--json', 'headBranch,conclusion'], {
|
|
68
|
-
cwd: racine,
|
|
69
|
-
encoding: 'utf8',
|
|
70
|
-
timeout: 30_000,
|
|
71
|
-
});
|
|
72
|
-
if (r.status !== 0) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
return jugeeDansLesRuns(JSON.parse(r.stdout || '[]'));
|
|
77
|
-
} catch {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
52
|
// The refusals for a push to `remote` of `refs` (the lines git writes) given the package.json
|
|
83
53
|
// object `pkg`; an empty list lets the push go on.
|
|
84
54
|
export function refus(remote, refs, pkg, env = process.env) {
|
|
@@ -117,8 +87,7 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
|
117
87
|
...refus(process.argv[2], refs, pkg),
|
|
118
88
|
...refusSurMain(process.argv[2], refs, {
|
|
119
89
|
principale: pkg ? lireCommit(pkg).commit : null,
|
|
120
|
-
|
|
121
|
-
jugee: sha => jugeeParGh(racine, sha),
|
|
90
|
+
jugee: sha => commitEstJuge(racine, sha),
|
|
122
91
|
}),
|
|
123
92
|
];
|
|
124
93
|
for (const l of lignes) {
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// The CI of main, read after the lots entered, as Google's TAP plays the whole suite after the
|
|
2
|
+
// submit, by batches of changes, and a red looks for its culprit among the lots entered since the
|
|
3
|
+
// last green. A lot enters main on its final pass (scripts/integration/file.mjs); the CI plays on
|
|
4
|
+
// main on an hourly schedule, and this module reads it:
|
|
5
|
+
//
|
|
6
|
+
// - `lireLaCiDeMain`: the latest finished pass of each workflow of the branch (`gh run list`),
|
|
7
|
+
// green when every one succeeded, red as soon as one failed (any conclusion but `success`,
|
|
8
|
+
// `cancelled` and `skipped`: a cancelled pass is replaced by a later one, the one before it
|
|
9
|
+
// decides, and a skipped pass judged nothing, as the flow that alerts on a red one, which skips
|
|
10
|
+
// itself on a green), and not
|
|
11
|
+
// read, never silence, when gh fails, does not start, answers garbage or no pass at all.
|
|
12
|
+
// - `lotsDepuisLeVert`: the lots of the circuit between the last green and the tip, by git alone
|
|
13
|
+
// (the commits whose subject ends with « (<ticket>) »), no state kept.
|
|
14
|
+
// - `alerteDeLaCiDeMain` and `ligneDeLaCiDeMain`: what is told to the supervisor and shown on the
|
|
15
|
+
// board; a green gives no alert, it clears.
|
|
16
|
+
// - `ouvrirLeDefautDeMain`: the defect ticket a red opens under `a-valider`, for the owner, which
|
|
17
|
+
// names the red pass and the candidate lots; the search of the culprit is that ticket, which the
|
|
18
|
+
// supervisor launches in the circuit. A lot already closed stays closed.
|
|
19
|
+
import { spawnSync } from 'node:child_process';
|
|
20
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
import { git, sortie } from './etat-du-depot.mjs';
|
|
23
|
+
|
|
24
|
+
const COURT = 7;
|
|
25
|
+
const court = sha => String(sha).slice(0, COURT);
|
|
26
|
+
const uneLigne = t => String(t).replace(/\s+/g, ' ').trim();
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The CI of the branch <branche> (main by default) read with <o.gh> in <o.racine>: `{ etat: 'verte',
|
|
30
|
+
* commit, passage }`, `{ etat: 'rouge', flux, passage, commit, vert }` (the workflow, its red pass,
|
|
31
|
+
* the commit of that pass and the commit of the last green pass of the same workflow, null when it
|
|
32
|
+
* never succeeded) or `{ etat: 'non-lue', raison }`.
|
|
33
|
+
*/
|
|
34
|
+
export function lireLaCiDeMain(o, { branche = 'main' } = {}) {
|
|
35
|
+
const r = o.gh([
|
|
36
|
+
'run',
|
|
37
|
+
'list',
|
|
38
|
+
'--branch',
|
|
39
|
+
branche,
|
|
40
|
+
'--limit',
|
|
41
|
+
'100',
|
|
42
|
+
'--json',
|
|
43
|
+
'databaseId,status,conclusion,workflowName,headSha',
|
|
44
|
+
]);
|
|
45
|
+
if (r.error) {
|
|
46
|
+
return { etat: 'non-lue', raison: `gh ne se lance pas (${r.error.code ?? r.error.message}).` };
|
|
47
|
+
}
|
|
48
|
+
if (r.status !== 0) {
|
|
49
|
+
return { etat: 'non-lue', raison: `gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}` };
|
|
50
|
+
}
|
|
51
|
+
let passages;
|
|
52
|
+
try {
|
|
53
|
+
passages = JSON.parse(r.stdout || '[]');
|
|
54
|
+
} catch {
|
|
55
|
+
return {
|
|
56
|
+
etat: 'non-lue',
|
|
57
|
+
raison: `gh run list rend une sortie illisible :\n${r.stdout.trim()}`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const finis = (Array.isArray(passages) ? passages : [])
|
|
61
|
+
.filter(
|
|
62
|
+
p =>
|
|
63
|
+
p?.databaseId &&
|
|
64
|
+
p.workflowName &&
|
|
65
|
+
p.status === 'completed' &&
|
|
66
|
+
p.conclusion !== 'cancelled' &&
|
|
67
|
+
p.conclusion !== 'skipped'
|
|
68
|
+
)
|
|
69
|
+
.sort((a, b) => b.databaseId - a.databaseId);
|
|
70
|
+
if (finis.length === 0) {
|
|
71
|
+
return { etat: 'non-lue', raison: `aucun passage fini de la CI sur ${branche}.` };
|
|
72
|
+
}
|
|
73
|
+
const derniers = [...new Set(finis.map(p => p.workflowName))].map(nom =>
|
|
74
|
+
finis.find(p => p.workflowName === nom)
|
|
75
|
+
);
|
|
76
|
+
const rouge = derniers.find(p => p.conclusion !== 'success');
|
|
77
|
+
if (rouge) {
|
|
78
|
+
const vert = finis.find(p => p.workflowName === rouge.workflowName && p.conclusion === 'success');
|
|
79
|
+
return {
|
|
80
|
+
etat: 'rouge',
|
|
81
|
+
flux: rouge.workflowName,
|
|
82
|
+
passage: String(rouge.databaseId),
|
|
83
|
+
commit: rouge.headSha,
|
|
84
|
+
vert: vert?.headSha ?? null,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const tete = derniers[0];
|
|
88
|
+
return { etat: 'verte', commit: tete.headSha, passage: String(tete.databaseId) };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The ticket a subject « … (<ticket>) » of the circuit's commits ends with, null otherwise.
|
|
92
|
+
const TICKET = /\(([A-Za-z0-9]+-[A-Za-z0-9.]+)\)\s*$/;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The lots of the circuit entered on main since the last green <vert> up to <pointe>, oldest first:
|
|
96
|
+
* `{ commit, ticket, titre }`, read by git in <racine>. Empty at the last green itself, without a
|
|
97
|
+
* last green, or when it is no ancestor of the tip (a history rewritten) or unknown.
|
|
98
|
+
*/
|
|
99
|
+
export function lotsDepuisLeVert(racine, { vert, pointe }) {
|
|
100
|
+
if (!vert || vert === pointe) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
if (git(racine, ['merge-base', '--is-ancestor', vert, pointe]).status !== 0) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
const l = sortie(racine, ['log', '--reverse', '--format=%H%x09%s', `${vert}..${pointe}`]);
|
|
107
|
+
if (!l) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
return l
|
|
111
|
+
.split('\n')
|
|
112
|
+
.map(ligne => {
|
|
113
|
+
const [commit, ...reste] = ligne.split('\t');
|
|
114
|
+
const titre = reste.join('\t');
|
|
115
|
+
const ticket = TICKET.exec(titre)?.[1];
|
|
116
|
+
return ticket ? { commit, ticket, titre } : null;
|
|
117
|
+
})
|
|
118
|
+
.filter(Boolean);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* What a reading tells the supervisor: `{ genre, cle, texte }`, null for a green (the alert clears).
|
|
123
|
+
* A red names the workflow, its pass, its commit and each lot <lots> entered since the last green;
|
|
124
|
+
* a CI not read is the alert « CI de main non lue ».
|
|
125
|
+
*/
|
|
126
|
+
export function alerteDeLaCiDeMain(lecture, lots) {
|
|
127
|
+
if (lecture.etat === 'verte') {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
if (lecture.etat === 'non-lue') {
|
|
131
|
+
return {
|
|
132
|
+
genre: 'non-lue',
|
|
133
|
+
cle: 'non-lue',
|
|
134
|
+
texte: `CI de main non lue : ${uneLigne(lecture.raison)} Main n'est pas jugé tant que la CI ne se lit pas ; la file continue.`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const depuis = lecture.vert
|
|
138
|
+
? lots.length
|
|
139
|
+
? `Lots entrés depuis le dernier vert (${court(lecture.vert)}) : ${lots.map(l => l.ticket).join(', ')}.`
|
|
140
|
+
: `aucun lot du circuit entré depuis le dernier vert (${court(lecture.vert)}).`
|
|
141
|
+
: 'aucun vert connu pour ce flux : les lots entrés ne se nomment pas.';
|
|
142
|
+
return {
|
|
143
|
+
genre: 'rouge',
|
|
144
|
+
cle: `rouge ${lecture.passage}`,
|
|
145
|
+
texte: `CI de main rouge : ${lecture.flux}, passage ${lecture.passage} (commit ${court(lecture.commit)}). ${depuis} La file continue d'avancer main ; la recherche du coupable est le ticket de défaut ouvert pour le responsable.`,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** The line of the board: the last green, the red with its workflow, pass and last green, or the CI not read. */
|
|
150
|
+
export function ligneDeLaCiDeMain(lecture) {
|
|
151
|
+
if (lecture.etat === 'verte') {
|
|
152
|
+
return `CI de main verte (${court(lecture.commit)})`;
|
|
153
|
+
}
|
|
154
|
+
if (lecture.etat === 'non-lue') {
|
|
155
|
+
return `CI de main non lue : ${uneLigne(lecture.raison)}`;
|
|
156
|
+
}
|
|
157
|
+
return `CI de main rouge : ${lecture.flux}, passage ${lecture.passage}, dernier vert ${lecture.vert ? court(lecture.vert) : 'aucun vert'}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const A_VALIDER = 'a-valider';
|
|
161
|
+
const titreDuDefaut = l => `CI de main rouge — ${l.flux}, passage ${l.passage}`;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The defect ticket a red <lecture> opens under `a-valider` with the tools <o> (`bd` of the
|
|
165
|
+
* project): its title names the workflow and the red pass, its description the commit and each
|
|
166
|
+
* candidate lot <lots>. One ticket per pass, closed or not: a pass that already has its ticket opens
|
|
167
|
+
* none, and `doublon` names it. A green or a CI not read opens none (the alert says it, no defect is
|
|
168
|
+
* proven). `{ ouvert, doublon?, faute? }`: a creation Beads refuses is a fault named.
|
|
169
|
+
*/
|
|
170
|
+
export function ouvrirLeDefautDeMain(o, lecture, lots) {
|
|
171
|
+
if (lecture.etat !== 'rouge') {
|
|
172
|
+
return { ouvert: false };
|
|
173
|
+
}
|
|
174
|
+
const titre = titreDuDefaut(lecture);
|
|
175
|
+
const existants = o.bd('list', '--all', '--label', A_VALIDER, '--limit', '0', '--json');
|
|
176
|
+
if (existants.status === 0) {
|
|
177
|
+
try {
|
|
178
|
+
const l = JSON.parse(existants.stdout || '[]');
|
|
179
|
+
const deja = (Array.isArray(l) ? l : []).find(t => t?.title === titre);
|
|
180
|
+
if (deja) {
|
|
181
|
+
return { ouvert: false, doublon: deja.id };
|
|
182
|
+
}
|
|
183
|
+
} catch {
|
|
184
|
+
// A list that does not read opens the ticket: a doublon is the lesser fault.
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const candidats = lots.length
|
|
188
|
+
? lots.map(l => `- ${l.ticket} (${court(l.commit)}) : ${l.titre}`).join('\n')
|
|
189
|
+
: "- aucun lot du circuit entré depuis le dernier vert (ou aucun vert connu).";
|
|
190
|
+
const description = [
|
|
191
|
+
`Le flux ${lecture.flux} de la CI de main est rouge : passage ${lecture.passage}, commit ${court(lecture.commit)}${lecture.vert ? `, dernier vert ${court(lecture.vert)}` : ', aucun vert connu'}.`,
|
|
192
|
+
'',
|
|
193
|
+
'Lots candidats (entrés sur main depuis le dernier vert) :',
|
|
194
|
+
candidats,
|
|
195
|
+
'',
|
|
196
|
+
'La recherche du coupable est ce ticket, que le superviseur lance dans le circuit. Un lot fautif déjà fermé reste fermé : son correctif ou son retrait est un ticket neuf. Ce défaut reste ouvert tant que ce ticket n’est pas fermé.',
|
|
197
|
+
].join('\n');
|
|
198
|
+
const r = o.bd(
|
|
199
|
+
'create',
|
|
200
|
+
titre,
|
|
201
|
+
'--type',
|
|
202
|
+
'bug',
|
|
203
|
+
'--labels',
|
|
204
|
+
A_VALIDER,
|
|
205
|
+
'--description',
|
|
206
|
+
description,
|
|
207
|
+
'--silent'
|
|
208
|
+
);
|
|
209
|
+
if (r.status !== 0) {
|
|
210
|
+
return {
|
|
211
|
+
ouvert: false,
|
|
212
|
+
faute: `bd create refuse : ${uneLigne(`${r.stderr ?? ''}${r.stdout ?? ''}`)}`,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
return { ouvert: true };
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// The GitHub CLI run in the main tree <racine>.
|
|
219
|
+
export const ghDans =
|
|
220
|
+
racine =>
|
|
221
|
+
(args, options = {}) =>
|
|
222
|
+
spawnSync('gh', args, {
|
|
223
|
+
cwd: racine,
|
|
224
|
+
encoding: 'utf8',
|
|
225
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
226
|
+
timeout: 30_000,
|
|
227
|
+
...options,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// How long a reading of the CI of main stays as read, for the board and the greffon, which ask
|
|
231
|
+
// again and again: the CI plays hourly, GitHub need not be asked at each refresh.
|
|
232
|
+
const VALIDITE_DE_LA_LECTURE = 5 * 60_000;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The CI of main of the project at <racine> as the board and the supervisor read it, kept for five
|
|
236
|
+
* minutes in `.claude/worktrees/ci-de-main-lue.json`; null for a project with no CI to read (no
|
|
237
|
+
* workflow in its main tree, no remote `origin`), which shows and says nothing.
|
|
238
|
+
*/
|
|
239
|
+
export function ciDeMainGardee(
|
|
240
|
+
racine,
|
|
241
|
+
{ maintenant = Date.now(), gh = ghDans(racine), validite = VALIDITE_DE_LA_LECTURE } = {}
|
|
242
|
+
) {
|
|
243
|
+
if (!existsSync(path.join(racine, '.github', 'workflows')) || !sortie(racine, ['remote', 'get-url', 'origin'])) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
const f = path.join(racine, '.claude', 'worktrees', 'ci-de-main-lue.json');
|
|
247
|
+
try {
|
|
248
|
+
const lu = JSON.parse(readFileSync(f, 'utf8'));
|
|
249
|
+
if (lu?.lecture && maintenant - lu.a < validite) {
|
|
250
|
+
return lu.lecture;
|
|
251
|
+
}
|
|
252
|
+
} catch {
|
|
253
|
+
// none yet, or unreadable: read again
|
|
254
|
+
}
|
|
255
|
+
const lecture = lireLaCiDeMain({ racine, gh });
|
|
256
|
+
try {
|
|
257
|
+
mkdirSync(path.dirname(f), { recursive: true });
|
|
258
|
+
writeFileSync(f, `${JSON.stringify({ a: maintenant, lecture })}\n`);
|
|
259
|
+
} catch {
|
|
260
|
+
// not kept: the next reading asks again
|
|
261
|
+
}
|
|
262
|
+
return lecture;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The alert of a <lecture> of the CI of the project at <racine>, its lots named by git up to the
|
|
267
|
+
* tip of its main tree: `{ genre, cle, texte }`, null for a green.
|
|
268
|
+
*/
|
|
269
|
+
export function alerteDuProjet(racine, lecture) {
|
|
270
|
+
if (lecture.etat !== 'rouge') {
|
|
271
|
+
return alerteDeLaCiDeMain(lecture, []);
|
|
272
|
+
}
|
|
273
|
+
const pointe = sortie(racine, ['rev-parse', 'HEAD']);
|
|
274
|
+
const lots = pointe ? lotsDepuisLeVert(racine, { vert: lecture.vert, pointe }) : [];
|
|
275
|
+
return alerteDeLaCiDeMain(lecture, lots);
|
|
276
|
+
}
|
package/scripts/circuit.mjs
CHANGED
|
@@ -606,7 +606,8 @@
|
|
|
606
606
|
// no reference writes, or whose command fails), 24 hors-plan (a testwriter or developpeur session its lock
|
|
607
607
|
// stops on a write out of the plan, `hors-plan` that lancer.sh ranges under the session's id), 25 inattendu
|
|
608
608
|
// (an act that fails, an exception no rule of the circuit settles: its message, its stack and its
|
|
609
|
-
// step in its question, `arretInattendu`), each a question for the supervisor;
|
|
609
|
+
// step in its question, `arretInattendu`), each a question for the supervisor; 26 limite-d-usage (a session the
|
|
610
|
+
// usage limit cuts: no question, the circuit reports itself to the hour the usage returns and resumes the step); 75 a-repasser (a check or the integration still at 75 once played again,
|
|
610
611
|
// or the branch still in the queue), the gesture `a-repasser`.
|
|
611
612
|
import { spawnSync } from 'node:child_process';
|
|
612
613
|
import { createHash } from 'node:crypto';
|
|
@@ -21,10 +21,15 @@
|
|
|
21
21
|
// module takes is refused, named, and nothing plays (code 2).
|
|
22
22
|
// - The launcher's `construire --echec <fichier> <plan>` is one implementation for every language
|
|
23
23
|
// (scripts/taches-du-graphe.mjs): the first module plays it, once.
|
|
24
|
-
// - No
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
24
|
+
// - No module is given a green to defer: the last green (scripts/dernier-vert.mjs) is kept by the
|
|
25
|
+
// one pass of the verification, once, when every task of every language of the graph is green
|
|
26
|
+
// (scripts/langages/typescript/verifier.mjs). A module that plays after a red one gets
|
|
27
|
+
// `PASSE_ROUGE` in its environment: that pass keeps none. A project without a module of
|
|
28
|
+
// package.json (cargo alone, python alone) has no such pass: the composed `verifier` keeps the
|
|
29
|
+
// green itself then, on the tree the repository had before the modules played, when every module
|
|
30
|
+
// is green and the verification is whole (`garderSansLeGraphe`). Without it no tree of such a
|
|
31
|
+
// project was ever judged, and the pre-push hook let none of its commits go to main
|
|
32
|
+
// (open-synth-descriptors and osc-bridge, 2026-11-21).
|
|
28
33
|
// - `verifier`: the module of package.json plays last, and passes over the whole graph (every task
|
|
29
34
|
// of every language, once); the others play before it in their declared order and get
|
|
30
35
|
// `GRAPHE_JOUE` and play no task of it again (cargo: its `deny check` alone), so that nextest
|
|
@@ -35,6 +40,8 @@ import { spawnSync } from 'node:child_process';
|
|
|
35
40
|
import { constants } from 'node:os';
|
|
36
41
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
37
42
|
import { moduleDuFichier } from './composition-des-langages.mjs';
|
|
43
|
+
import { garderLeVert } from './dernier-vert.mjs';
|
|
44
|
+
import { etatDuDepot } from './etat-du-depot.mjs';
|
|
38
45
|
import { langagesDe } from './langages.mjs';
|
|
39
46
|
import { GRAPHE_JOUE, PASSE_ROUGE } from './taches-du-graphe.mjs';
|
|
40
47
|
|
|
@@ -96,13 +103,30 @@ function repartir(nom, args, modules, racine) {
|
|
|
96
103
|
};
|
|
97
104
|
}
|
|
98
105
|
|
|
106
|
+
// The options that make a verification partial: its green is kept by no one.
|
|
107
|
+
const PARTIELLE = /^(--gardes|--sans-tests|--tranche(=.*)?|--filter(=.*)?|-F)$/;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The state a composed `verifier` keeps as the last green when its modules are all green: the one
|
|
111
|
+
* of the repository at <racine> before they play, for a whole verification (<args>) of a project
|
|
112
|
+
* that has no module of package.json (<duGraphe>), whose pass keeps it otherwise; null when this
|
|
113
|
+
* command keeps none.
|
|
114
|
+
*/
|
|
115
|
+
function garderSansLeGraphe(nom, args, duGraphe, racine) {
|
|
116
|
+
if (nom !== 'verifier' || duGraphe || args.some(a => PARTIELLE.test(a))) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const etat = etatDuDepot(racine);
|
|
120
|
+
return etat.raison ? null : etat;
|
|
121
|
+
}
|
|
122
|
+
|
|
99
123
|
/**
|
|
100
124
|
* Plays the command <nom> with <args> in each module of <modules> that describes it, in the
|
|
101
125
|
* project at <racine>, under <env>: the joined exit code.
|
|
102
126
|
* @param {string} nom
|
|
103
127
|
* @param {string[]} args
|
|
104
128
|
* @param {{ racine?: string, modules?: import('./jointure.js').Langage[], env?: NodeJS.ProcessEnv,
|
|
105
|
-
* dire?: (ligne: string) => void }} [o]
|
|
129
|
+
* dire?: (ligne: string) => void, garder?: (etat: object) => void }} [o]
|
|
106
130
|
* @returns {number}
|
|
107
131
|
*/
|
|
108
132
|
export function jouer(
|
|
@@ -113,6 +137,7 @@ export function jouer(
|
|
|
113
137
|
modules = langagesDe(racine),
|
|
114
138
|
env = process.env,
|
|
115
139
|
dire = l => process.stderr.write(`${l}\n`),
|
|
140
|
+
garder = garderLeVert,
|
|
116
141
|
} = {}
|
|
117
142
|
) {
|
|
118
143
|
const avec = modules.filter(m => Object.hasOwn(m.commandes(racine), nom));
|
|
@@ -133,6 +158,7 @@ export function jouer(
|
|
|
133
158
|
nom === 'verifier' && duGraphe
|
|
134
159
|
? [...r.parts.filter(x => x.module !== duGraphe), ...r.parts.filter(x => x.module === duGraphe)]
|
|
135
160
|
: r.parts;
|
|
161
|
+
const aGarder = garderSansLeGraphe(nom, args, duGraphe, racine);
|
|
136
162
|
for (const { module, args: siens } of ordre) {
|
|
137
163
|
const c = module.commandes(racine)[nom];
|
|
138
164
|
dire(`▶ ${module.nom} : ${nom}`);
|
|
@@ -153,7 +179,11 @@ export function jouer(
|
|
|
153
179
|
codes.push(p.status ?? 128 + (constants.signals[p.signal ?? 'SIGTERM'] ?? 0));
|
|
154
180
|
}
|
|
155
181
|
}
|
|
156
|
-
|
|
182
|
+
const code = unir(codes);
|
|
183
|
+
if (code === 0 && aGarder && codes.length) {
|
|
184
|
+
garder(aGarder);
|
|
185
|
+
}
|
|
186
|
+
return code;
|
|
157
187
|
}
|
|
158
188
|
|
|
159
189
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|