@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
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// The gestures of the queue, which brings the branches `agent/<ticket>` the integration committed
|
|
2
|
-
// onto main, one at a time, each judged by the
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// step 5.2, in their order of arrival.
|
|
2
|
+
// onto main, one at a time, each judged by a final pass on the tree that enters before main moves, as
|
|
3
|
+
// bors judges the tree that enters, and as Google's TAP plays the touched tests before the submit and
|
|
4
|
+
// the whole suite after it: the workflow of the queue of a project (`file:<racine>`,
|
|
5
|
+
// src/temporal/file/deroule.ts) plays them, each in an act of its own (scripts/faits-du-circuit.mjs),
|
|
6
|
+
// for the entries the circuits of the tickets send it at their step 5.2, in their order of arrival.
|
|
7
|
+
// The CI of the project plays after, on main, by batches (scripts/ci-de-main.mjs): the queue reads no
|
|
8
|
+
// CI and pushes no branch of a ticket.
|
|
7
9
|
//
|
|
8
10
|
// For each branch (`preparerLaBranche`), against the main of the moment:
|
|
9
11
|
// - main is an ancestor of the branch (main has not moved since its base): the branch is the
|
|
@@ -21,8 +23,6 @@
|
|
|
21
23
|
// commit; a command that fails makes the branch leave the queue, the command and its output
|
|
22
24
|
// named (OSC Bridge, 2026-10-31: four conflicts in one day on the generated files of synthhub
|
|
23
25
|
// and open-synth-descriptors);
|
|
24
|
-
// - the candidate is pushed to origin on `agent/<ticket>` (forced: the queue owns that branch,
|
|
25
|
-
// and a replay rewrites it), a push refused keeping the branch in the queue, its reason named;
|
|
26
26
|
// - a branch with nothing ahead of main does not enter: it leaves the queue, its ticket loses
|
|
27
27
|
// `en-file` and takes a comment, and stays as it is;
|
|
28
28
|
// - a branch that does not replace (the files in conflict) leaves the queue: its ticket loses
|
|
@@ -32,47 +32,30 @@
|
|
|
32
32
|
// its replaced commit) stays in the queue, the reason written to its ticket, which is neither
|
|
33
33
|
// reopened nor closed, and the queue goes on; the circuit of the ticket stops at
|
|
34
34
|
// « a-repasser », and its resumption sends the branch again.
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
// `
|
|
42
|
-
//
|
|
43
|
-
// its
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
// planned, which the board shows. The run is read at its current attempt (`gh run view <id>`
|
|
49
|
-
// without `--attempt`), as a merge queue judges the last attempt of a commit's checks.
|
|
50
|
-
// The CI concluded (`conclureLaCI`):
|
|
51
|
-
// - green: main moves forward onto the candidate (`avancerMain`, `merge
|
|
52
|
-
// --ff-only`), the tree the CI judged; main moved meanwhile (the candidate no longer on top of
|
|
53
|
-
// it), the workflow replaces the branch again and its CI is played again;
|
|
54
|
-
// - red: the ticket loses `en-file` and reopens, its comment giving the address of the run (`gh
|
|
55
|
-
// run view <id> --json url`) and the end of `gh run view <id> --log-failed`; main does not
|
|
56
|
-
// move, and the branch stays, here and on origin. After the supervisor had the failed jobs run
|
|
57
|
-
// again (`gh run rerun <id> --failed`), `--reprendre` sends the branch again, whose CI is read
|
|
58
|
-
// at its last attempt. A flaky test has no path of its own: the red comment gives the charter's
|
|
59
|
-
// rule, a test known red goes into quarantine in the test itself, with the ticket that fixes it;
|
|
60
|
-
// - no CI for the branch, or not read (without `gh`, without a run found, with `gh` refusing or
|
|
61
|
-
// past the wait): no green, no entry; the branch stays in the queue, the ticket told why,
|
|
62
|
-
// neither reopened nor closed.
|
|
35
|
+
// The branch stays local: it is never pushed.
|
|
36
|
+
// Then the final pass judges the candidate (`jugerLeCandidat`): `npm run verifier` played in the
|
|
37
|
+
// queue's copy on the lot laid on the tip of main, measured against that tip (the tests the lot
|
|
38
|
+
// reaches, the complete pass being the CI's of main and the night's), unless the tree was already
|
|
39
|
+
// judged (scripts/arbres-juges.mjs: a tree a final pass kept green, or a complete verification),
|
|
40
|
+
// which plays nothing again. Green, the tree is kept judged and main moves forward onto the
|
|
41
|
+
// candidate (`avancerMain`, `merge --ff-only`), the tree the pass judged; main moved meanwhile, the
|
|
42
|
+
// workflow replaces the branch again and judges it again. Red, the ticket loses `en-file` and
|
|
43
|
+
// reopens, its comment giving the end of the output of the pass; main does not move, and the branch
|
|
44
|
+
// stays. To play again (75, the part of the machine awaited), the branch stays in the queue, the
|
|
45
|
+
// ticket told, neither reopened nor closed. A flaky test has no path of its own: the red comment
|
|
46
|
+
// gives the charter's rule, a test known red goes into quarantine in the test itself, with the
|
|
47
|
+
// ticket that fixes it.
|
|
63
48
|
// At its entry on main (`fermerLEntree`), the branch's ticket closes « intégré : <commit> », loses
|
|
64
49
|
// `en-file`, and the branch is deleted; a branch git does not delete (its copy still in place) is
|
|
65
50
|
// written to the ticket, which closes all the same. Then main is pushed to origin, on the branch
|
|
66
|
-
// `grillhouse.poussee.commit` of main's package.json (`main` without the key),
|
|
67
|
-
//
|
|
68
|
-
// working directory of its circuit (`.claude/worktrees/<ticket>.travail`,
|
|
69
|
-
// which lives as long as the ticket
|
|
70
|
-
// removed then (`retirerLeTravail`).
|
|
51
|
+
// `grillhouse.poussee.commit` of main's package.json (`main` without the key), which the pre-push
|
|
52
|
+
// hook lets go as the tree is judged; a refused push is written to the ticket and does not stop the
|
|
53
|
+
// queue. The working directory of its circuit (`.claude/worktrees/<ticket>.travail`,
|
|
54
|
+
// scripts/circuit.mjs), which lives as long as the ticket, is removed then (`retirerLeTravail`).
|
|
71
55
|
// Every comment and change of the queue at a ticket is written under the author `file`, which bd
|
|
72
56
|
// reads in BEADS_ACTOR, as the circuit writes its own lines under `circuit`.
|
|
73
57
|
import { spawnSync } from 'node:child_process';
|
|
74
|
-
import { existsSync,
|
|
75
|
-
import { createRequire } from 'node:module';
|
|
58
|
+
import { existsSync, rmSync } from 'node:fs';
|
|
76
59
|
import path from 'node:path';
|
|
77
60
|
import {
|
|
78
61
|
aRejouer,
|
|
@@ -82,15 +65,21 @@ import {
|
|
|
82
65
|
prendreLesEngendres,
|
|
83
66
|
regenerer,
|
|
84
67
|
} from '../engendres.mjs';
|
|
68
|
+
import { arbreEstJuge, garderLArbreJuge } from '../arbres-juges.mjs';
|
|
69
|
+
import { A_REPASSER } from '../codes-de-sortie.mjs';
|
|
70
|
+
import { BASE_DU_LOT } from '../dernier-vert.mjs';
|
|
85
71
|
import { avecLesDonnees, donneesDe } from '../donnees-cles.mjs';
|
|
86
72
|
import { avecLesOutils, empreintesDe, outilsDe } from '../outils-cles.mjs';
|
|
87
73
|
import { lireCommit } from '../poussee-cles.mjs';
|
|
88
74
|
import { ouvrirCopie } from './rejeu.mjs';
|
|
89
75
|
import { lotSurMain } from './integrer.mjs';
|
|
90
|
-
import { ecrireTache } from '../mesure/avancement.mjs';
|
|
91
76
|
import { ACTEUR, emettre } from '../effets.mjs';
|
|
77
|
+
import { SUITE } from '../etapes.mjs';
|
|
92
78
|
import { enUneLigne } from '../ticket-du-circuit.mjs';
|
|
93
79
|
|
|
80
|
+
// The title of the final pass is read from the list of the steps, the only place that spells it.
|
|
81
|
+
const TITRE_PASSE_FINALE = SUITE.find(e => e.finale).titre;
|
|
82
|
+
|
|
94
83
|
// The queue's author.
|
|
95
84
|
export const AUTEUR_DE_LA_FILE = 'file';
|
|
96
85
|
|
|
@@ -102,379 +91,42 @@ const commenterAu = (o, ticket, texte) =>
|
|
|
102
91
|
// The reason of the closure of a ticket the queue brought onto main, before its commit, which the
|
|
103
92
|
// circuit reads to name that commit (scripts/circuit.mjs, the tri of the discoveries).
|
|
104
93
|
export const INTEGRE = 'intégré : ';
|
|
105
|
-
// The steps done over planned of the view <vue> of a run (`gh run view --json jobs`), written to
|
|
106
|
-
// the progress directory <avancement> as the record `etapes-de-la-ci`; nothing without one.
|
|
107
|
-
function ecrireLesEtapes(avancement, vue) {
|
|
108
|
-
if (!avancement) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const etapes = (Array.isArray(vue?.jobs) ? vue.jobs : []).flatMap(j =>
|
|
112
|
-
Array.isArray(j?.steps) ? j.steps : []
|
|
113
|
-
);
|
|
114
|
-
try {
|
|
115
|
-
ecrireTache(avancement, 'etapes-de-la-ci', {
|
|
116
|
-
faits: etapes.filter(e => e?.status === 'completed').length,
|
|
117
|
-
prevus: etapes.length,
|
|
118
|
-
});
|
|
119
|
-
} catch {
|
|
120
|
-
// A directory that does not write leaves the queue going, without its progress.
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// The directory of the workflows GitHub reads, and the extensions it reads in it.
|
|
125
|
-
const DOSSIER_DES_FLUX = '.github/workflows';
|
|
126
|
-
const EXTENSIONS_DES_FLUX = /\.ya?ml$/;
|
|
127
|
-
|
|
128
|
-
// The regular expression of a filter pattern of GitHub (« Filter pattern cheat sheet »): `*` any
|
|
129
|
-
// characters but `/`, `**` any characters, `?` zero or one and `+` one or more of the preceding
|
|
130
|
-
// character, `[…]` one character of the set, `\` escaping the next.
|
|
131
|
-
function motifDeGitHub(motif) {
|
|
132
|
-
let re = '';
|
|
133
|
-
for (let i = 0; i < motif.length; i++) {
|
|
134
|
-
const c = motif[i];
|
|
135
|
-
if (c === '\\' && i + 1 < motif.length) {
|
|
136
|
-
re += motif[++i].replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
|
|
137
|
-
} else if (c === '*') {
|
|
138
|
-
if (motif[i + 1] === '*') {
|
|
139
|
-
re += '.*';
|
|
140
|
-
i++;
|
|
141
|
-
} else {
|
|
142
|
-
re += '[^/]*';
|
|
143
|
-
}
|
|
144
|
-
} else if (c === '?' || c === '+') {
|
|
145
|
-
re += c;
|
|
146
|
-
} else if (c === '[') {
|
|
147
|
-
const fin = motif.indexOf(']', i + 1);
|
|
148
|
-
if (fin < 0) {
|
|
149
|
-
throw new Error(`motif sans fin : ${motif}`);
|
|
150
|
-
}
|
|
151
|
-
re += motif.slice(i, fin + 1);
|
|
152
|
-
i = fin;
|
|
153
|
-
} else {
|
|
154
|
-
re += c.replace(/[.^${}()|\]\\/]/g, '\\$&');
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return new RegExp(`^${re}$`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Whether the `on.push` of a workflow <push> runs on a push to <branche>, as GitHub reads its
|
|
161
|
-
// filters: none runs on every branch; `branches` in its order, a `!` pattern taking out what the
|
|
162
|
-
// ones before took in, the last match deciding; `branches-ignore` takes out what it matches;
|
|
163
|
-
// `tags` or `tags-ignore` alone run on no branch. GitHub asks both filters: a branch the branch
|
|
164
|
-
// filter leaves out never runs, whatever the paths; a filter on the paths leaves a branch it takes
|
|
165
|
-
// in counted as one that runs, as does a form the queue does not judge.
|
|
166
|
-
function pousseeSurLaBranche(push, branche) {
|
|
167
|
-
if (push === null || push === undefined) {
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
if (typeof push !== 'object' || Array.isArray(push)) {
|
|
171
|
-
return true;
|
|
172
|
-
}
|
|
173
|
-
const { branches, 'branches-ignore': ignorees } = push;
|
|
174
|
-
if (branches && ignorees) {
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
const motifs = l => (Array.isArray(l) ? l : [l]).map(String);
|
|
178
|
-
if (branches) {
|
|
179
|
-
let dedans = false;
|
|
180
|
-
for (const m of motifs(branches)) {
|
|
181
|
-
const negatif = m.startsWith('!');
|
|
182
|
-
if (motifDeGitHub(negatif ? m.slice(1) : m).test(branche)) {
|
|
183
|
-
dedans = !negatif;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return dedans;
|
|
187
|
-
}
|
|
188
|
-
if (ignorees) {
|
|
189
|
-
const l = motifs(ignorees);
|
|
190
|
-
if (l.some(m => m.startsWith('!'))) {
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
|
-
return !l.some(m => motifDeGitHub(m).test(branche));
|
|
194
|
-
}
|
|
195
|
-
return !(push.tags || push['tags-ignore']);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// The workflows of <fichiers> (`{ chemin, texte }`, `texte` null for a file git does not give)
|
|
199
|
-
// that run on a push to <branche>: their paths. A file the queue cannot read or judge counts as
|
|
200
|
-
// one that runs.
|
|
201
|
-
export function fluxDeLaBranche(fichiers, branche) {
|
|
202
|
-
return fichiers
|
|
203
|
-
.filter(({ texte }) => {
|
|
204
|
-
if (texte === null) {
|
|
205
|
-
return true;
|
|
206
|
-
}
|
|
207
|
-
try {
|
|
208
|
-
// Loaded only for a workflow to read: a project without one, or before its `npm install`,
|
|
209
|
-
// runs its queue without the library (which, absent, counts the workflow as one that runs).
|
|
210
|
-
const require = createRequire(import.meta.url);
|
|
211
|
-
const on = require('yaml').parse(texte)?.on;
|
|
212
|
-
if (typeof on === 'string') {
|
|
213
|
-
return on === 'push';
|
|
214
|
-
}
|
|
215
|
-
if (Array.isArray(on)) {
|
|
216
|
-
return on.includes('push');
|
|
217
|
-
}
|
|
218
|
-
if (on && typeof on === 'object') {
|
|
219
|
-
return 'push' in on && pousseeSurLaBranche(on.push, branche);
|
|
220
|
-
}
|
|
221
|
-
return false;
|
|
222
|
-
} catch {
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
})
|
|
226
|
-
.map(({ chemin }) => chemin);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// The verdicts of a reading of the CI (`lireLesPassagesDeLaCI`, then the workflow `ciDuCommit`).
|
|
230
|
-
const VERTE = 'verte';
|
|
231
|
-
const SANS_CI = 'sans-ci';
|
|
232
|
-
const NON_LUE = 'non-lue';
|
|
233
|
-
|
|
234
|
-
// The name GitHub gives the workflow of the file <texte>: its `name` key, its path <chemin> without
|
|
235
|
-
// one (or when the file is not given or its YAML not read).
|
|
236
|
-
function nomDuFlux(chemin, texte) {
|
|
237
|
-
if (texte === null) {
|
|
238
|
-
return chemin;
|
|
239
|
-
}
|
|
240
|
-
try {
|
|
241
|
-
const require = createRequire(import.meta.url);
|
|
242
|
-
const nom = require('yaml').parse(texte)?.name;
|
|
243
|
-
return typeof nom === 'string' && nom !== '' ? nom : chemin;
|
|
244
|
-
} catch {
|
|
245
|
-
return chemin;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* The workflows of the commit <sha> of the repository <racine> that run on a push to <branche>,
|
|
251
|
-
* in the order of the files of their directory: `{ chemin, nom }`, the path and the name GitHub
|
|
252
|
-
* gives the workflow (`workflowName` of `gh run list`).
|
|
253
|
-
*/
|
|
254
|
-
export function fluxDuCommit(racine, sha, branche) {
|
|
255
|
-
const git = (...a) => spawnSync('git', ['-C', racine, ...a], { encoding: 'utf8' });
|
|
256
|
-
const l = git('ls-tree', '--name-only', `${sha}:${DOSSIER_DES_FLUX}`);
|
|
257
|
-
const noms = l.status === 0 ? l.stdout.split('\n').filter(n => EXTENSIONS_DES_FLUX.test(n)) : [];
|
|
258
|
-
const fichiers = noms.map(n => {
|
|
259
|
-
const chemin = `${DOSSIER_DES_FLUX}/${n}`;
|
|
260
|
-
const f = git('show', `${sha}:${chemin}`);
|
|
261
|
-
return { chemin, texte: f.status === 0 ? f.stdout : null };
|
|
262
|
-
});
|
|
263
|
-
const attendus = new Set(fluxDeLaBranche(fichiers, branche));
|
|
264
|
-
return fichiers
|
|
265
|
-
.filter(({ chemin }) => attendus.has(chemin))
|
|
266
|
-
.map(({ chemin, texte }) => ({ chemin, nom: nomDuFlux(chemin, texte) }));
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* The workflows of the commit <sha> that run on a push to <main> and not on a push to the branch of
|
|
271
|
-
* the ticket <brancheDuTicket>: `{ chemin, nom }`, in the order of the files. The one the CI of the
|
|
272
|
-
* branch already judged is any workflow of the second set, found by its path.
|
|
273
|
-
* @param {string} racine
|
|
274
|
-
* @param {string} sha
|
|
275
|
-
* @param {string} main
|
|
276
|
-
* @param {string} brancheDuTicket
|
|
277
|
-
* @returns {{ chemin: string, nom: string }[]}
|
|
278
|
-
*/
|
|
279
|
-
export function fluxDeMainAbsentsDeLaBranche(racine, sha, main, brancheDuTicket) {
|
|
280
|
-
const jugés = new Set(fluxDuCommit(racine, sha, brancheDuTicket).map(f => f.chemin));
|
|
281
|
-
return fluxDuCommit(racine, sha, main).filter(f => !jugés.has(f.chemin));
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// The file of the readings due of the workflows of main, in the main tree <racine>.
|
|
285
|
-
const lecturesDues = racine => path.join(racine, '.claude', 'worktrees', 'flux-de-main-dus.json');
|
|
286
|
-
|
|
287
|
-
/** The readings due of the workflows of main of <racine>: `{ ticket, commit, branche, flux, poussee }`. */
|
|
288
|
-
export function lecturesDuesDe(racine) {
|
|
289
|
-
try {
|
|
290
|
-
const lu = JSON.parse(readFileSync(lecturesDues(racine), 'utf8'));
|
|
291
|
-
return Array.isArray(lu) ? lu : [];
|
|
292
|
-
} catch {
|
|
293
|
-
return [];
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// The readings due <dues> written whole, atomically.
|
|
298
|
-
function ecrireLesLecturesDues(racine, dues) {
|
|
299
|
-
const f = lecturesDues(racine);
|
|
300
|
-
mkdirSync(path.dirname(f), { recursive: true });
|
|
301
|
-
const provisoire = `${f}.${process.pid}`;
|
|
302
|
-
writeFileSync(provisoire, `${JSON.stringify(dues, null, 2)}\n`);
|
|
303
|
-
renameSync(provisoire, f);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* After the push of the commit <sha> of the ticket <ticket> to <branche> (main) at <poussee> ms, the
|
|
308
|
-
* reading of its workflows of main recorded as due, with the tools <o>: nothing is read, nothing
|
|
309
|
-
* waited for; none is due when every workflow of main is one the CI of <brancheDuTicket> judged.
|
|
310
|
-
* A reading of the same ticket and commit is replaced.
|
|
311
|
-
*/
|
|
312
|
-
export function inscrireLesFluxDeMain(o, { ticket, sha, branche, brancheDuTicket, poussee }) {
|
|
313
|
-
const flux = fluxDeMainAbsentsDeLaBranche(o.racine, sha, branche, brancheDuTicket);
|
|
314
|
-
if (flux.length === 0) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
const autres = lecturesDuesDe(o.racine).filter(l => !(l.ticket === ticket && l.commit === sha));
|
|
318
|
-
ecrireLesLecturesDues(o.racine, [...autres, { ticket, commit: sha, branche, flux, poussee }]);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// The conclusion of the run <id> read by <gh>: `{ fini, conclusion }`, or `{ raison }`.
|
|
322
|
-
function lireUnPassage(gh, id) {
|
|
323
|
-
const v = gh(['run', 'view', id, '--json', 'status,conclusion,jobs'], {
|
|
324
|
-
timeout: 60_000,
|
|
325
|
-
killSignal: 'SIGKILL',
|
|
326
|
-
});
|
|
327
|
-
if (v.error) {
|
|
328
|
-
return { raison: `gh ne se lance pas (${v.error.code ?? v.error.message}).` };
|
|
329
|
-
}
|
|
330
|
-
if (v.status !== 0) {
|
|
331
|
-
return { raison: `gh run view refuse :\n${`${v.stderr}${v.stdout}`.trim()}` };
|
|
332
|
-
}
|
|
333
|
-
try {
|
|
334
|
-
const vue = JSON.parse(v.stdout || '{}');
|
|
335
|
-
return { fini: vue?.status === 'completed', conclusion: vue?.conclusion ?? null };
|
|
336
|
-
} catch {
|
|
337
|
-
return { raison: `gh run view rend une sortie illisible :\n${v.stdout.trim()}` };
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
94
|
|
|
341
|
-
// The
|
|
342
|
-
|
|
343
|
-
const r = gh([
|
|
344
|
-
'run',
|
|
345
|
-
'list',
|
|
346
|
-
'--commit',
|
|
347
|
-
sha,
|
|
348
|
-
'--branch',
|
|
349
|
-
branche,
|
|
350
|
-
'--json',
|
|
351
|
-
'databaseId,status,conclusion,workflowName',
|
|
352
|
-
]);
|
|
353
|
-
if (r.error) {
|
|
354
|
-
return { raison: `gh ne se lance pas (${r.error.code ?? r.error.message}).` };
|
|
355
|
-
}
|
|
356
|
-
if (r.status !== 0) {
|
|
357
|
-
return { raison: `gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}` };
|
|
358
|
-
}
|
|
359
|
-
try {
|
|
360
|
-
const l = JSON.parse(r.stdout || '[]');
|
|
361
|
-
return { passages: Array.isArray(l) ? l : [] };
|
|
362
|
-
} catch {
|
|
363
|
-
return { raison: `gh run list rend une sortie illisible :\n${r.stdout.trim()}` };
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/** The label a ticket reopened by a red workflow of main bears, which the wait of the supervisor reads. */
|
|
368
|
-
export const FLUX_ROUGE = 'flux-rouge';
|
|
369
|
-
/** The title of the comment that gives the address of the red run, whose second paragraph is that address. */
|
|
370
|
-
export const TITRE_DU_FLUX_ROUGE = '## Flux de main rouge';
|
|
95
|
+
// The lines of the end of the output of a pass the comment of a red gives.
|
|
96
|
+
const FIN_DE_LA_SORTIE = 60;
|
|
371
97
|
|
|
372
98
|
/**
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
* a run cancelled (a later run of its concurrency group replaced it, or a person stopped it), or
|
|
379
|
-
* `gh` failing, a comment names the workflow and why, nothing is reopened. A reading with a workflow
|
|
380
|
-
* still to come stays due. `{ dues }`: the readings still due.
|
|
99
|
+
* The final pass played in the queue's own copy (`.claude/worktrees/file`) on the commit <commit>:
|
|
100
|
+
* `{ code, sortie }`, the code of `npm run verifier` (0 green, 75 to play again, any other red) and
|
|
101
|
+
* its output. The copy is made ready on <commit> (detached, its dependencies in agreement with the
|
|
102
|
+
* lock file), the pass measured against the tip of main (`GRILLHOUSE_BASE_DU_LOT`, the commit's base
|
|
103
|
+
* as the lot lies on it), as the pass of the circuit measures itself.
|
|
381
104
|
*/
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
for (const l of toutes) {
|
|
389
|
-
const court = l.commit.slice(0, 7);
|
|
390
|
-
const ecoule = maintenant - l.poussee;
|
|
391
|
-
const nonJuge = (nom, pourquoi) => {
|
|
392
|
-
commenterAu(
|
|
393
|
-
o,
|
|
394
|
-
l.ticket,
|
|
395
|
-
`## Flux de main non jugé\n\nLe flux ${nom} de ${court} sur ${l.branche} n'a pas été jugé : ${pourquoi}\n\nLa file ne le tient pas pour rouge : le superviseur le lit à la main.`
|
|
396
|
-
);
|
|
397
|
-
o.dire(`⚠ flux ${nom} de ${court} non jugé : ${pourquoi}`);
|
|
398
|
-
};
|
|
399
|
-
const lus = lirePassagesDe(o.gh, l.commit, l.branche);
|
|
400
|
-
if (lus.raison) {
|
|
401
|
-
for (const f of l.flux) {
|
|
402
|
-
nonJuge(f.nom, lus.raison);
|
|
403
|
-
}
|
|
404
|
-
continue;
|
|
105
|
+
function passeDeLaFile(racine, principale, dire) {
|
|
106
|
+
return ({ commit }) => {
|
|
107
|
+
const copie = path.join(racine, '.claude', 'worktrees', 'file');
|
|
108
|
+
const ouverte = ouvrirCopie({ racine, copie, ref: commit, dire });
|
|
109
|
+
if (ouverte.refus) {
|
|
110
|
+
return { code: A_REPASSER, sortie: ouverte.refus };
|
|
405
111
|
}
|
|
406
|
-
const
|
|
407
|
-
let rouge = null;
|
|
408
|
-
for (const f of l.flux) {
|
|
409
|
-
const p = lus.passages
|
|
410
|
-
.filter(x => x?.databaseId && x.workflowName === f.nom)
|
|
411
|
-
.reduce((m, x) => (m === null || x.databaseId > m.databaseId ? x : m), null);
|
|
412
|
-
if (p === null) {
|
|
413
|
-
if (ecoule > ci.rechercheMs) {
|
|
414
|
-
nonJuge(f.nom, `aucun passage trouvé en ${Math.round(ci.rechercheMs / 60_000)} min.`);
|
|
415
|
-
} else {
|
|
416
|
-
encore.push(f);
|
|
417
|
-
}
|
|
418
|
-
continue;
|
|
419
|
-
}
|
|
420
|
-
const id = String(p.databaseId);
|
|
421
|
-
const v = lireUnPassage(o.gh, id);
|
|
422
|
-
if (v.raison) {
|
|
423
|
-
nonJuge(f.nom, v.raison);
|
|
424
|
-
} else if (!v.fini) {
|
|
425
|
-
if (ecoule > ci.attenteMs) {
|
|
426
|
-
nonJuge(
|
|
427
|
-
f.nom,
|
|
428
|
-
`le passage ${id} n'est pas fini après ${Math.round(ci.attenteMs / 60_000)} min.`
|
|
429
|
-
);
|
|
430
|
-
} else {
|
|
431
|
-
encore.push(f);
|
|
432
|
-
}
|
|
433
|
-
} else if (v.conclusion === 'cancelled') {
|
|
434
|
-
nonJuge(
|
|
435
|
-
f.nom,
|
|
436
|
-
`le passage ${id} a été annulé (remplacé par un passage plus récent, ou arrêté à la main).`
|
|
437
|
-
);
|
|
438
|
-
} else if (v.conclusion !== 'success') {
|
|
439
|
-
rouge = { nom: f.nom, id };
|
|
440
|
-
break;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
if (rouge) {
|
|
444
|
-
const url =
|
|
445
|
-
o.gh(['run', 'view', rouge.id, '--json', 'url', '--jq', '.url']).stdout?.trim() || rouge.id;
|
|
446
|
-
commenterAu(
|
|
447
|
-
o,
|
|
448
|
-
l.ticket,
|
|
449
|
-
`${TITRE_DU_FLUX_ROUGE}\n\n${rouge.nom} : ${url} (commit ${court})\n\nLe flux ${rouge.nom} de ${court} est rouge sur ${l.branche}, après l'entrée du lot : le ticket est rouvert, le superviseur juge la cause.`
|
|
450
|
-
);
|
|
451
|
-
o.bd('update', l.ticket, '--status', 'open', '--add-label', FLUX_ROUGE);
|
|
452
|
-
o.dire(`✗ flux ${rouge.nom} de ${court} rouge sur ${l.branche} : ${l.ticket} rouvert`);
|
|
453
|
-
continue;
|
|
454
|
-
}
|
|
455
|
-
if (encore.length > 0) {
|
|
456
|
-
restantes.push({ ...l, flux: encore });
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
ecrireLesLecturesDues(o.racine, restantes);
|
|
460
|
-
return { dues: restantes.length };
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// The GitHub CLI run in the main tree <racine>.
|
|
464
|
-
const ghDans =
|
|
465
|
-
racine =>
|
|
466
|
-
(args, options = {}) =>
|
|
467
|
-
spawnSync('gh', args, {
|
|
468
|
-
cwd: racine,
|
|
112
|
+
const base = spawnSync('git', ['-C', racine, 'rev-parse', `refs/heads/${principale}`], {
|
|
469
113
|
encoding: 'utf8',
|
|
470
|
-
|
|
471
|
-
|
|
114
|
+
}).stdout.trim();
|
|
115
|
+
const r = spawnSync('bash', ouverte.monter('npm', 'run', 'verifier'), {
|
|
116
|
+
cwd: copie,
|
|
117
|
+
encoding: 'utf8',
|
|
118
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
119
|
+
env: base ? { ...process.env, [BASE_DU_LOT]: base } : process.env,
|
|
472
120
|
});
|
|
121
|
+
return { code: r.status ?? 1, sortie: `${r.stdout ?? ''}${r.stderr ?? ''}` };
|
|
122
|
+
};
|
|
123
|
+
}
|
|
473
124
|
|
|
474
125
|
/**
|
|
475
126
|
* The tools of the queue on the main tree <racine>, its lines said by <dire>: `{ racine,
|
|
476
|
-
* principale, bd,
|
|
477
|
-
* branch of the main tree (null when it is on none)
|
|
127
|
+
* principale, bd, passe, dire, avancement }`, bd run under the queue's author (BEADS_ACTOR), the
|
|
128
|
+
* branch of the main tree (null when it is on none), `passe` the final pass played in the queue's
|
|
129
|
+
* copy.
|
|
478
130
|
*/
|
|
479
131
|
export function outilsDeLaFile(racine, dire, avancement = null) {
|
|
480
132
|
const bd = (...a) => {
|
|
@@ -493,97 +145,14 @@ export function outilsDeLaFile(racine, dire, avancement = null) {
|
|
|
493
145
|
spawnSync('git', ['-C', racine, 'symbolic-ref', '--short', '-q', 'HEAD'], {
|
|
494
146
|
encoding: 'utf8',
|
|
495
147
|
}).stdout.trim() || null;
|
|
496
|
-
return {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
* do; `{ etat: 'verte', passage }`, every workflow green, `passage` the first workflow's; or `{
|
|
505
|
-
* etat: 'en-cours', flux: [{ nom, passage, fini }] }`, each workflow with its run (null while it
|
|
506
|
-
* is looked for). A run joins its workflow by its name (`workflowName`); one of no expected name
|
|
507
|
-
* does not count, the latest run (the greatest id) of a name decides, and workflows of one name count
|
|
508
|
-
* for one, which `gh run list` does not tell apart. Each run is read at its current attempt (`gh
|
|
509
|
-
* run view <id>` without `--attempt`). Nothing is kept from one reading to the next; nothing is
|
|
510
|
-
* written to the ticket: `conclureLaCI` does.
|
|
511
|
-
*/
|
|
512
|
-
export function lireLesPassagesDeLaCI(o, { sha, branche }) {
|
|
513
|
-
const { gh } = o;
|
|
514
|
-
const attendus = [...new Set(fluxDuCommit(o.racine, sha, branche).map(f => f.nom))];
|
|
515
|
-
if (attendus.length === 0) {
|
|
516
|
-
return { etat: SANS_CI };
|
|
517
|
-
}
|
|
518
|
-
const r = gh([
|
|
519
|
-
'run',
|
|
520
|
-
'list',
|
|
521
|
-
'--commit',
|
|
522
|
-
sha,
|
|
523
|
-
'--branch',
|
|
524
|
-
branche,
|
|
525
|
-
'--json',
|
|
526
|
-
'databaseId,status,conclusion,workflowName',
|
|
527
|
-
]);
|
|
528
|
-
if (r.error) {
|
|
529
|
-
return { etat: NON_LUE, raison: `gh ne se lance pas (${r.error.code ?? r.error.message}).` };
|
|
530
|
-
}
|
|
531
|
-
if (r.status !== 0) {
|
|
532
|
-
return { etat: NON_LUE, raison: `gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}` };
|
|
533
|
-
}
|
|
534
|
-
let passages;
|
|
535
|
-
try {
|
|
536
|
-
passages = JSON.parse(r.stdout || '[]');
|
|
537
|
-
} catch {
|
|
538
|
-
return {
|
|
539
|
-
etat: NON_LUE,
|
|
540
|
-
raison: `gh run list rend une sortie illisible :\n${r.stdout.trim()}`,
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
const recent = nom =>
|
|
544
|
-
(Array.isArray(passages) ? passages : [])
|
|
545
|
-
.filter(x => x?.databaseId && x.workflowName === nom)
|
|
546
|
-
.reduce((m, x) => (m === null || x.databaseId > m.databaseId ? x : m), null);
|
|
547
|
-
const lus = [];
|
|
548
|
-
for (const nom of attendus) {
|
|
549
|
-
const p = recent(nom);
|
|
550
|
-
if (p === null) {
|
|
551
|
-
lus.push({ nom, passage: null, fini: false });
|
|
552
|
-
continue;
|
|
553
|
-
}
|
|
554
|
-
const id = String(p.databaseId);
|
|
555
|
-
const v = gh(['run', 'view', id, '--json', 'status,conclusion,jobs'], {
|
|
556
|
-
timeout: 60_000,
|
|
557
|
-
killSignal: 'SIGKILL',
|
|
558
|
-
});
|
|
559
|
-
if (v.error) {
|
|
560
|
-
return { etat: NON_LUE, raison: `gh ne se lance pas (${v.error.code ?? v.error.message}).` };
|
|
561
|
-
}
|
|
562
|
-
if (v.status !== 0) {
|
|
563
|
-
return { etat: NON_LUE, raison: `gh run view refuse :\n${`${v.stderr}${v.stdout}`.trim()}` };
|
|
564
|
-
}
|
|
565
|
-
let vue;
|
|
566
|
-
try {
|
|
567
|
-
vue = JSON.parse(v.stdout || '{}');
|
|
568
|
-
} catch {
|
|
569
|
-
return {
|
|
570
|
-
etat: NON_LUE,
|
|
571
|
-
raison: `gh run view rend une sortie illisible :\n${v.stdout.trim()}`,
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
const fini = vue?.status === 'completed';
|
|
575
|
-
if (!fini) {
|
|
576
|
-
ecrireLesEtapes(o.avancement, vue);
|
|
577
|
-
}
|
|
578
|
-
if (fini && vue.conclusion !== 'success') {
|
|
579
|
-
return { etat: 'rouge', passage: id, flux: nom };
|
|
580
|
-
}
|
|
581
|
-
lus.push({ nom, passage: id, fini });
|
|
582
|
-
}
|
|
583
|
-
if (lus.every(f => f.fini)) {
|
|
584
|
-
return { etat: VERTE, passage: lus[0].passage };
|
|
585
|
-
}
|
|
586
|
-
return { etat: 'en-cours', flux: lus };
|
|
148
|
+
return {
|
|
149
|
+
racine,
|
|
150
|
+
principale,
|
|
151
|
+
bd,
|
|
152
|
+
passe: passeDeLaFile(racine, principale ?? 'main', dire),
|
|
153
|
+
dire,
|
|
154
|
+
avancement,
|
|
155
|
+
};
|
|
587
156
|
}
|
|
588
157
|
|
|
589
158
|
/**
|
|
@@ -597,57 +166,6 @@ export function retirerLeTravail(o, ticket) {
|
|
|
597
166
|
});
|
|
598
167
|
}
|
|
599
168
|
|
|
600
|
-
/**
|
|
601
|
-
* The CI of the candidate <sha> of the ticket <ticket> on its branch <branche> concluded with the
|
|
602
|
-
* tools <o>, its verdict <verdict> (VERTE, `rouge`, SANS_CI or NON_LUE), its run <passage> and the
|
|
603
|
-
* reason <raison> of a CI not read: what is said to the ticket and what becomes of the entry.
|
|
604
|
-
* `{ avancer: true }`: green, main moves onto the candidate; `{ issue }`, the issue for the circuit
|
|
605
|
-
* (src/temporal/file/deroule.ts): red, `rouvert`, its comment giving the address of the run and
|
|
606
|
-
* the end of its failed log, the ticket reopened without `en-file`; no CI for the branch, or not
|
|
607
|
-
* read, `en-file`, the ticket told why: no green, no entry.
|
|
608
|
-
*/
|
|
609
|
-
export function conclureLaCI(o, { ticket, sha, branche, verdict, passage = null, raison = null }) {
|
|
610
|
-
const court = sha.slice(0, 7);
|
|
611
|
-
const commenter = texte => commenterAu(o, ticket, texte);
|
|
612
|
-
if (verdict === VERTE) {
|
|
613
|
-
o.dire(`✓ CI de ${court} sur ${branche} verte (passage ${passage})`);
|
|
614
|
-
return { avancer: true };
|
|
615
|
-
}
|
|
616
|
-
if (verdict === SANS_CI) {
|
|
617
|
-
const texte = `## Aucune CI ne juge ${branche}\n\nAucun flux de ${DOSSIER_DES_FLUX} de ${court} ne se lance sur un push vers ${branche} : la CI du projet doit écouter agent/** (\`npx grillhouse maj\` l'ajoute à son flux). ${o.principale} n'avance pas sans son vert ; la branche reste en file, et la reprise du circuit la renvoie.`;
|
|
618
|
-
commenter(texte);
|
|
619
|
-
o.dire(`⚠ aucune CI ne juge ${branche} : la CI du projet doit écouter agent/**`);
|
|
620
|
-
return {
|
|
621
|
-
issue: {
|
|
622
|
-
etat: 'en-file',
|
|
623
|
-
raison: `aucune CI ne juge ${branche} : la CI du projet doit écouter agent/**`,
|
|
624
|
-
},
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
if (verdict === NON_LUE) {
|
|
628
|
-
const texte = `## CI non lue\n\nLa CI de ${court} sur ${branche} n'a pas été lue : ${raison}\n\n${o.principale} n'avance pas sans son vert ; la branche reste en file, et la reprise du circuit la renvoie.`;
|
|
629
|
-
commenter(texte);
|
|
630
|
-
o.dire(`⚠ CI de ${court} non lue : ${raison}`);
|
|
631
|
-
return { issue: { etat: 'en-file', raison: texte } };
|
|
632
|
-
}
|
|
633
|
-
const { gh } = o;
|
|
634
|
-
const url =
|
|
635
|
-
gh(['run', 'view', passage, '--json', 'url', '--jq', '.url']).stdout?.trim() || passage;
|
|
636
|
-
const journal = `${gh(['run', 'view', passage, '--log-failed']).stdout ?? ''}`
|
|
637
|
-
.trim()
|
|
638
|
-
.split('\n')
|
|
639
|
-
.slice(-60)
|
|
640
|
-
.join('\n');
|
|
641
|
-
commenter(
|
|
642
|
-
`## CI rouge\n\nLa CI de ${court} sur ${branche} est rouge : ${url}\n\nLa fin de gh run view ${passage} --log-failed :\n\n${journal}\n\n${o.principale} n'avance pas et le ticket est rouvert : sa correction entre sous son numéro. Un rejeu vert de la même CI (\`gh run rerun ${passage} --failed\`), puis \`--reprendre\` du circuit, renvoie la branche, que la file juge au dernier essai ; un test connu instable se met en quarantaine dans le test, avec le ticket qui le corrige.`
|
|
643
|
-
);
|
|
644
|
-
o.bd('update', ticket, '--status', 'open', '--remove-label', 'en-file');
|
|
645
|
-
o.dire(`✗ CI de ${court} sur ${branche} rouge (passage ${passage}) : ${ticket} rouvert`);
|
|
646
|
-
return {
|
|
647
|
-
issue: { etat: 'rouvert', raison: `La CI de ${court} sur ${branche} est rouge : ${url}` },
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
|
|
651
169
|
/**
|
|
652
170
|
* Where the lot of the ticket <ticket> stands, with the tools <o>: `{ statut, raison }`, its status
|
|
653
171
|
* in Beads and its reason of closure.
|
|
@@ -757,14 +275,14 @@ function remplacer(o, tip, tete) {
|
|
|
757
275
|
}
|
|
758
276
|
|
|
759
277
|
/**
|
|
760
|
-
* The branch of <entree> (`{ ticket, branche }`) made the candidate the
|
|
761
|
-
* <o>, against the main of the moment, without a word to the ticket: `{ candidat: { commit }
|
|
762
|
-
* the branch on top of main (replaced when main moved)
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
278
|
+
* The branch of <entree> (`{ ticket, branche }`) made the candidate the final pass judges, with the
|
|
279
|
+
* tools <o>, against the main of the moment, without a word to the ticket: `{ candidat: { commit }
|
|
280
|
+
* }`, the branch on top of main (replaced when main moved), kept local; `{ entre: { commit } }`, a
|
|
281
|
+
* lot already on main (the branch points at the commit of main that delivers its ticket, or each of
|
|
282
|
+
* its commits has its equivalent on main, or the branch is gone), as an attempt played again after
|
|
283
|
+
* its worker died finds it: main does not move again; `{ sortie: [titre, détail] }` (it leaves the
|
|
284
|
+
* queue: gone, not replaced); `{ garde }` (it stays in the queue, the reason); `{ ecartee: true }`
|
|
285
|
+
* (nothing ahead of main).
|
|
768
286
|
*/
|
|
769
287
|
export function preparerLaBranche(o, entree) {
|
|
770
288
|
const git = (...args) => spawnSync('git', ['-C', o.racine, ...args], { encoding: 'utf8' });
|
|
@@ -806,26 +324,57 @@ export function preparerLaBranche(o, entree) {
|
|
|
806
324
|
}
|
|
807
325
|
candidat = r.nouveau;
|
|
808
326
|
}
|
|
809
|
-
|
|
810
|
-
'git',
|
|
811
|
-
['-C', o.racine, 'push', '-q', '--force', 'origin', `${candidat}:${refBranche}`],
|
|
812
|
-
{ encoding: 'utf8', env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } }
|
|
813
|
-
);
|
|
814
|
-
if (pousse.status !== 0) {
|
|
815
|
-
return {
|
|
816
|
-
garde: `la poussée de ${candidat.slice(0, 7)} vers origin/${entree.branche} est refusée :\n${pousse.stderr.trim()}`,
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
o.dire(`✓ ${entree.branche} poussée en ${candidat.slice(0, 7)} : sa CI la juge`);
|
|
327
|
+
o.dire(`✓ ${entree.branche} prête en ${candidat.slice(0, 7)} : la passe finale la juge`);
|
|
820
328
|
return { candidat: { commit: candidat } };
|
|
821
329
|
}
|
|
822
330
|
|
|
331
|
+
/**
|
|
332
|
+
* The candidate <commit> of <entree> (`{ ticket, branche, commit }`) judged by the final pass with
|
|
333
|
+
* the tools <o>: `{ juge: true }`, green (or its tree already judged: nothing is played again), its
|
|
334
|
+
* tree kept judged (scripts/arbres-juges.mjs); or `{ issue }`, the issue for the circuit
|
|
335
|
+
* (src/temporal/file/deroule.ts): red, `rouvert`, the end of the output of the pass in the comment,
|
|
336
|
+
* the ticket reopened without `en-file`; to play again (75), `en-file`, the ticket told, neither
|
|
337
|
+
* reopened nor closed. `o.passe({ commit })` gives `{ code, sortie }`.
|
|
338
|
+
*/
|
|
339
|
+
export function jugerLeCandidat(o, entree) {
|
|
340
|
+
const git = (...args) => spawnSync('git', ['-C', o.racine, ...args], { encoding: 'utf8' });
|
|
341
|
+
const arbre = git('rev-parse', '--verify', '-q', `${entree.commit}^{tree}`).stdout.trim();
|
|
342
|
+
const court = entree.commit.slice(0, 7);
|
|
343
|
+
if (arbre && arbreEstJuge(o.racine, arbre)) {
|
|
344
|
+
o.dire(`✓ arbre de ${court} déjà jugé par une passe finale`);
|
|
345
|
+
return { juge: true };
|
|
346
|
+
}
|
|
347
|
+
const { code, sortie } = o.passe({ commit: entree.commit });
|
|
348
|
+
if (code === 0) {
|
|
349
|
+
if (arbre) {
|
|
350
|
+
garderLArbreJuge(o.racine, arbre);
|
|
351
|
+
}
|
|
352
|
+
o.dire(`✓ passe finale verte sur ${court}`);
|
|
353
|
+
return { juge: true };
|
|
354
|
+
}
|
|
355
|
+
const fin = `${sortie ?? ''}`.trim().split('\n').slice(-FIN_DE_LA_SORTIE).join('\n');
|
|
356
|
+
if (code === A_REPASSER) {
|
|
357
|
+
const texte = `## ${TITRE_PASSE_FINALE} à repasser\n\nLa passe finale de ${court} sur ${entree.branche} est à repasser (code ${code}) :\n\n${fin}\n\n${o.principale} n'avance pas sans son vert ; la branche reste en file, et la reprise du circuit la renvoie.`;
|
|
358
|
+
commenterAu(o, entree.ticket, texte);
|
|
359
|
+
o.dire(`⚠ passe finale de ${court} à repasser`);
|
|
360
|
+
return { issue: { etat: 'en-file', raison: texte } };
|
|
361
|
+
}
|
|
362
|
+
const texte = `## ${TITRE_PASSE_FINALE} rouge\n\nLa passe finale de ${court} sur ${entree.branche}, le lot posé sur la pointe de ${o.principale}, est rouge (code ${code}). La fin de sa sortie :\n\n${fin}\n\n${o.principale} n'avance pas et le ticket est rouvert : sa correction entre sous son numéro. Un test connu instable se met en quarantaine dans le test, avec le ticket qui le corrige.`;
|
|
363
|
+
commenterAu(o, entree.ticket, texte);
|
|
364
|
+
o.bd('update', entree.ticket, '--status', 'open', '--remove-label', 'en-file');
|
|
365
|
+
o.dire(`✗ passe finale de ${court} rouge : ${entree.ticket} rouvert`);
|
|
366
|
+
return {
|
|
367
|
+
issue: { etat: 'rouvert', raison: `La passe finale de ${court} sur ${entree.branche} est rouge.` },
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
|
|
823
371
|
/**
|
|
824
372
|
* Main moved forward onto the candidate <commit> of <entree> (`{ ticket, branche, commit }`) once
|
|
825
|
-
*
|
|
826
|
-
* judged. `{ entre: { commit } }`, main at <commit> (or <commit> already on main, an
|
|
827
|
-
* played again); `{ bouge: true }`, main moved meanwhile and the candidate is no longer on
|
|
828
|
-
* it, which the workflow replaces and judges again; `{ garde }`, main does not move, the
|
|
373
|
+
* the final pass judged it, with the tools <o>, by fast-forward: the tree that enters is the tree
|
|
374
|
+
* the pass judged. `{ entre: { commit } }`, main at <commit> (or <commit> already on main, an
|
|
375
|
+
* attempt played again); `{ bouge: true }`, main moved meanwhile and the candidate is no longer on
|
|
376
|
+
* top of it, which the workflow replaces and judges again; `{ garde }`, main does not move, the
|
|
377
|
+
* reason.
|
|
829
378
|
*/
|
|
830
379
|
export function avancerMain(o, entree) {
|
|
831
380
|
const git = (...args) => spawnSync('git', ['-C', o.racine, ...args], { encoding: 'utf8' });
|
|
@@ -878,13 +427,12 @@ function livrerLesCapacites(o, ticket, labels) {
|
|
|
878
427
|
* The ticket of <entree> (`{ ticket, branche, commit }`) entered on main at <commit>, with the
|
|
879
428
|
* tools <o>: it closes « intégré : <commit> » and loses `en-file` (a ticket already closed is left
|
|
880
429
|
* as it is), the branch is deleted, then main is pushed to origin on the branch
|
|
881
|
-
* `grillhouse.poussee.commit` of main's package.json
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
*
|
|
887
|
-
* its comment at the ticket whole.
|
|
430
|
+
* `grillhouse.poussee.commit` of main's package.json; the queue is then done with the ticket, and
|
|
431
|
+
* removes the working directory of its circuit (`retirerLeTravail`). Each of its gestures replays
|
|
432
|
+
* without harm (a ticket closed is left closed, a branch gone stays gone, a commit pushed is pushed
|
|
433
|
+
* again as it is), and never reopens the ticket; its comments are effects (`commenterAu`), which
|
|
434
|
+
* the workflow of the queue writes once each. `{ poussee, raison }`: the branch pushed to, or null
|
|
435
|
+
* and why, in one line (`enUneLigne`), its comment at the ticket whole.
|
|
888
436
|
*/
|
|
889
437
|
export function fermerLEntree(o, entree) {
|
|
890
438
|
const { racine } = o;
|
|
@@ -930,15 +478,6 @@ export function fermerLEntree(o, entree) {
|
|
|
930
478
|
return { poussee: null, raison: enUneLigne(raison), ...ferme };
|
|
931
479
|
}
|
|
932
480
|
o.dire(`✓ poussée : ${court} est sur origin/${commit}`);
|
|
933
|
-
// The branch the CI judged leaves origin with its entry; one already gone is no fault.
|
|
934
|
-
const distante = spawnSync(
|
|
935
|
-
'git',
|
|
936
|
-
['-C', racine, 'push', '-q', 'origin', '--delete', `refs/heads/${entree.branche}`],
|
|
937
|
-
sansInvite
|
|
938
|
-
);
|
|
939
|
-
if (distante.status !== 0) {
|
|
940
|
-
o.dire(`⚠ origin/${entree.branche} n'est pas effacée : ${distante.stderr.trim()}`);
|
|
941
|
-
}
|
|
942
481
|
return { poussee: commit, raison: null, ...ferme };
|
|
943
482
|
}
|
|
944
483
|
|