@roomi-fields/grillhouse 0.47.1 → 0.49.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/CHANGELOG.md +116 -0
- package/agents/direct.md +9 -0
- package/cadre/templates/projet/.github/workflows/ci.yml +24 -38
- package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -0
- package/cadre/templates/projet/.github/workflows/nuit.yml +14 -2
- package/cadre/templates/projet/CLAUDE.md +31 -10
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/turbo/paquets.json +3 -1
- package/cadre/templates/turbo/sans-paquets.json +3 -1
- package/charte.md +46 -13
- package/dist/temporal/circuit/appel.d.ts +4 -1
- package/dist/temporal/circuit/appel.js +15 -1
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +7 -1
- package/dist/temporal/circuit/client.js +54 -1
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/commande.js +35 -60
- package/dist/temporal/circuit/commande.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +2 -1
- package/dist/temporal/circuit/contrat.js +2 -1
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +9 -2
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/commande.js +2 -13
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/deroules.d.ts +1 -1
- package/dist/temporal/deroules.js +2 -2
- package/dist/temporal/deroules.js.map +1 -1
- package/dist/temporal/file/activites.d.ts +1 -4
- package/dist/temporal/file/activites.js +13 -14
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +34 -91
- package/dist/temporal/file/contrat.js +33 -5
- package/dist/temporal/file/contrat.js.map +1 -1
- package/dist/temporal/file/deroule.d.ts +1 -9
- package/dist/temporal/file/deroule.js +57 -166
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +26 -1
- package/dist/temporal/installation.js +111 -2
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/nuits/activites.d.ts +5 -10
- package/dist/temporal/nuits/activites.js +9 -57
- package/dist/temporal/nuits/activites.js.map +1 -1
- package/dist/temporal/nuits/choix.d.ts +15 -0
- package/dist/temporal/nuits/choix.js +20 -0
- package/dist/temporal/nuits/choix.js.map +1 -1
- package/dist/temporal/nuits/contrat.d.ts +11 -16
- package/dist/temporal/nuits/deroule.js +38 -67
- package/dist/temporal/nuits/deroule.js.map +1 -1
- package/dist/temporal/places/client.d.ts +9 -11
- package/dist/temporal/places/client.js +11 -19
- package/dist/temporal/places/client.js.map +1 -1
- package/dist/temporal/places/contrat.d.ts +25 -24
- package/dist/temporal/places/contrat.js +5 -7
- package/dist/temporal/places/contrat.js.map +1 -1
- package/dist/temporal/places/deroule.js +26 -36
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/tickets/activites.js +4 -2
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/dist/temporal/tickets/contrat.d.ts +2 -1
- package/docs/ARCHITECTURE.md +453 -133
- package/docs/CADRE.md +16 -13
- package/docs/INTERFACE.md +100 -25
- package/hooks/hooks.json +9 -0
- package/hooks/register.tsx +59 -5
- package/package.json +1 -1
- package/scripts/activites.mjs +319 -52
- package/scripts/aiguillage.mjs +5 -1
- package/scripts/attente-a-l-arret.mjs +2 -5
- package/scripts/attente-au-tour.mjs +2 -5
- package/scripts/bilan.mjs +125 -2
- package/scripts/branche-de-nuit.mjs +32 -44
- package/scripts/ci-de-main.mjs +215 -16
- package/scripts/circuit.mjs +275 -189
- package/scripts/circuits-cles.d.mts +3 -3
- package/scripts/circuits-cles.mjs +6 -5
- package/scripts/coeurs-dedies.mjs +4 -4
- package/scripts/commandes-composees.mjs +12 -5
- package/scripts/composition-des-langages.mjs +2 -0
- package/scripts/crochets.mjs +2 -2
- package/scripts/dette.d.ts +2 -1
- package/scripts/dette.mjs +49 -6
- package/scripts/direct.mjs +343 -0
- package/scripts/droits.mjs +19 -0
- package/scripts/effets.mjs +6 -5
- package/scripts/engendres.mjs +2 -1
- package/scripts/enveloppe/enveloppe.mjs +127 -18
- package/scripts/enveloppe/lancer.sh +14 -3
- package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
- package/scripts/enveloppe/travail-de-la-copie.mjs +121 -21
- package/scripts/etapes.mjs +14 -4
- package/scripts/etat-du-depot.mjs +23 -0
- package/scripts/faits-du-circuit.mjs +24 -34
- package/scripts/fermeture-de-la-machine.d.mts +27 -0
- package/scripts/fermeture-de-la-machine.mjs +98 -0
- package/scripts/fichiers-nommes.mjs +27 -1
- package/scripts/file-des-tickets.d.mts +18 -1
- package/scripts/file-des-tickets.mjs +63 -15
- package/scripts/greffons.mjs +1 -1
- package/scripts/grillhouse-maj.mjs +13 -25
- package/scripts/groupe-cles.d.mts +6 -0
- package/scripts/groupe-cles.mjs +29 -1
- package/scripts/integration/file.mjs +162 -48
- package/scripts/integration/integrer.mjs +2 -0
- package/scripts/jointure.d.ts +22 -3
- package/scripts/journal-des-etats.d.mts +16 -0
- package/scripts/journal-des-etats.mjs +44 -2
- package/scripts/journal.mjs +3 -0
- package/scripts/langages/c/commandes.mjs +5 -5
- package/scripts/langages/c/composants.mjs +13 -5
- package/scripts/langages/c/index.mjs +2 -0
- package/scripts/langages/c/squelette.mjs +1 -1
- package/scripts/langages/cargo/commandes.mjs +5 -6
- package/scripts/langages/cargo/index.mjs +2 -0
- package/scripts/langages/python/commandes.mjs +5 -5
- package/scripts/langages/python/composants.mjs +10 -2
- package/scripts/langages/python/index.mjs +2 -0
- package/scripts/langages/typescript/composants.mjs +10 -3
- package/scripts/langages/typescript/construire.mjs +2 -0
- package/scripts/langages/typescript/exemples.mjs +33 -1
- package/scripts/langages/typescript/index.mjs +22 -0
- package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
- package/scripts/langages/typescript/module-absent.mjs +24 -0
- package/scripts/langages/typescript/tests-de-nuit.mjs +152 -32
- package/scripts/langages/typescript/tests-du-poste.mjs +65 -23
- package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
- package/scripts/langages/typescript/turbo-des-paquets.mjs +40 -5
- package/scripts/langages/typescript/verifier.mjs +3 -5
- package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
- package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
- package/scripts/langages/typescript/vitest-config/lances.mjs +3 -1
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
- package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
- package/scripts/langages.mjs +25 -3
- package/scripts/machine.mjs +103 -0
- package/scripts/matieres-cles.mjs +17 -0
- package/scripts/matieres-lues.mjs +104 -0
- package/scripts/mesure/base-de-passe.mjs +2 -1
- package/scripts/migrations/0.48.0-ci-declenchee-par-la-file.mjs +32 -0
- package/scripts/migrations/0.48.0-poussee-retiree.mjs +31 -0
- package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
- package/scripts/migrations.mjs +6 -0
- package/scripts/nuit.sh +113 -46
- package/scripts/paquet.mjs +16 -5
- package/scripts/paquets.d.ts +4 -0
- package/scripts/paquets.mjs +57 -0
- package/scripts/passe-de-la-machine.mjs +13 -14
- package/scripts/places-de-la-machine.mjs +120 -44
- package/scripts/places-du-serveur.mjs +29 -8
- package/scripts/plafond-de-la-machine.d.mts +7 -13
- package/scripts/plafond-de-la-machine.mjs +19 -35
- package/scripts/poussee-retiree.mjs +18 -0
- package/scripts/prefixe-des-tickets.mjs +1 -1
- package/scripts/references-changees.mjs +159 -0
- package/scripts/registre.d.mts +2 -2
- package/scripts/regles-des-places.d.mts +20 -12
- package/scripts/regles-des-places.mjs +27 -30
- package/scripts/repli-de-la-nuit.mjs +112 -0
- package/scripts/reponses-du-circuit.d.mts +4 -2
- package/scripts/reponses-du-circuit.mjs +44 -9
- package/scripts/reprise.mjs +27 -8
- package/scripts/resultats.mjs +61 -9
- package/scripts/seances.mjs +258 -40
- package/scripts/services-du-noyau.mjs +3 -0
- package/scripts/sous-commandes.mjs +37 -7
- package/scripts/superviseur.mjs +241 -88
- package/scripts/tableau.mjs +327 -131
- package/scripts/taches-du-graphe.mjs +84 -4
- package/scripts/ticket.mjs +345 -0
- package/scripts/transitions.d.mts +52 -0
- package/scripts/transitions.mjs +194 -16
- package/scripts/un-commit-par-ticket.mjs +4 -3
- package/scripts/verdict-de-la-nuit.mjs +47 -20
- package/scripts/verrou-de-fichier.mjs +2 -2
- package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
- package/scripts/verrous/verrou.mjs +17 -1
- package/skills/developpeur/SKILL.md +1 -1
- package/skills/direct/SKILL.md +57 -0
- package/skills/explorateur/SKILL.md +10 -6
- package/skills/pitmaster/SKILL.md +37 -14
- package/skills/pitmaster/references/consigne-agent.md +7 -1
- package/skills/relecteur/SKILL.md +11 -1
- package/skills/testwriter/SKILL.md +10 -0
- package/scripts/poussee-cles.mjs +0 -46
- package/scripts/ticket.sh +0 -25
package/scripts/ci-de-main.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// The CI of main, read after the lots entered, as Google's TAP plays the whole suite after the
|
|
2
2
|
// submit, by batches of changes, and a red looks for its culprit among the lots entered since the
|
|
3
3
|
// last green. A lot enters main on its final pass (scripts/integration/file.mjs); the CI plays on
|
|
4
|
-
// main
|
|
4
|
+
// main, started by the queue itself after a lot entered, one pass an hour at most, and this module
|
|
5
|
+
// starts it then reads it:
|
|
5
6
|
//
|
|
7
|
+
// - `declencherLaCiDeMain`: the start (`gh workflow run`), its delay and its fault kept in a file of
|
|
8
|
+
// the project; `alerteDeDeclenchement` tells the supervisor of a start GitHub refused.
|
|
6
9
|
// - `lireLaCiDeMain`: the latest finished pass of each workflow of the branch (`gh run list`),
|
|
7
10
|
// green when every one succeeded, red as soon as one failed (any conclusion but `success`,
|
|
8
11
|
// `cancelled` and `skipped`: a cancelled pass is replaced by a later one, the one before it
|
|
@@ -20,6 +23,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
20
23
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
21
24
|
import path from 'node:path';
|
|
22
25
|
import { git, sortie } from './etat-du-depot.mjs';
|
|
26
|
+
import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
|
|
23
27
|
|
|
24
28
|
const COURT = 7;
|
|
25
29
|
const court = sha => String(sha).slice(0, COURT);
|
|
@@ -88,6 +92,127 @@ export function lireLaCiDeMain(o, { branche = 'main' } = {}) {
|
|
|
88
92
|
return { etat: 'verte', commit: tete.headSha, passage: String(tete.databaseId) };
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
const HEURE = 3_600_000;
|
|
96
|
+
const FLUX_DE_LA_CI = 'ci.yml';
|
|
97
|
+
const EN_ATTENTE = state => state !== 'completed';
|
|
98
|
+
|
|
99
|
+
const etatDuDeclenchement = racine =>
|
|
100
|
+
path.join(racine, '.claude', 'worktrees', 'ci-de-main-declenchee.json');
|
|
101
|
+
|
|
102
|
+
// What the queue keeps of its starts: `declenche` (the instant of the last start, which covers the
|
|
103
|
+
// delay before the pass shows), `entree` (a lot entered whose pass is not started yet) and `faute`
|
|
104
|
+
// (the reason of the last refused start, null when none).
|
|
105
|
+
function lireLEtat(racine) {
|
|
106
|
+
try {
|
|
107
|
+
const lu = JSON.parse(readFileSync(etatDuDeclenchement(racine), 'utf8'));
|
|
108
|
+
return {
|
|
109
|
+
declenche: Number.isFinite(lu?.declenche) ? lu.declenche : null,
|
|
110
|
+
entree: lu?.entree === true,
|
|
111
|
+
faute: typeof lu?.faute === 'string' ? lu.faute : null,
|
|
112
|
+
};
|
|
113
|
+
} catch {
|
|
114
|
+
return { declenche: null, entree: false, faute: null };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function ecrireLEtat(racine, etat) {
|
|
118
|
+
try {
|
|
119
|
+
const f = etatDuDeclenchement(racine);
|
|
120
|
+
mkdirSync(path.dirname(f), { recursive: true });
|
|
121
|
+
writeFileSync(f, `${JSON.stringify(etat)}\n`);
|
|
122
|
+
} catch {
|
|
123
|
+
// not kept: the next quarter of an hour reads the passes again
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** The fault of the last refused start of the CI of the project at <racine>, null when none. */
|
|
128
|
+
export const fauteDeDeclenchement = racine => lireLEtat(racine).faute;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* What the supervisor is told of a start of the CI that GitHub refused: `{ genre, cle, texte }`,
|
|
132
|
+
* a kind apart from « CI de main non lue » and from a red.
|
|
133
|
+
*/
|
|
134
|
+
export function alerteDeDeclenchement(faute) {
|
|
135
|
+
return {
|
|
136
|
+
genre: 'declenchement',
|
|
137
|
+
cle: 'declenchement',
|
|
138
|
+
texte: `La CI de main n'a pas pu être déclenchée : ${uneLigne(faute)} La file continue et retente au quart d'heure suivant.`,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The queue starts the CI of main itself, as the schedulers of Google's TAP and Chromium's LUCI
|
|
144
|
+
* start the pass after the submit, by batches: it reads the passes of the workflow ci.yml on main
|
|
145
|
+
* (whatever started them) with <o.gh> in <o.racine>, and starts it (`gh workflow run`) when the tip
|
|
146
|
+
* of main differs from the commit of the last pass, no pass is running or waiting, and the last
|
|
147
|
+
* pass or the last start is an hour old or more. Without any pass known, only a lot entered
|
|
148
|
+
* (<p.apresEntree>, kept until a start succeeds) starts it, never the sole start of the queue.
|
|
149
|
+
* `{ declenche }`, with `faute` when GitHub refused: the fault is kept for the alert, the next
|
|
150
|
+
* quarter of an hour tries again, and nothing throws.
|
|
151
|
+
*/
|
|
152
|
+
export function declencherLaCiDeMain(o, { apresEntree = false, maintenant = Date.now() } = {}) {
|
|
153
|
+
const { racine } = o;
|
|
154
|
+
const avant = lireLEtat(racine);
|
|
155
|
+
const entree = apresEntree || avant.entree;
|
|
156
|
+
const garder = suite => ecrireLEtat(racine, { ...avant, entree, ...suite });
|
|
157
|
+
const lu = o.gh([
|
|
158
|
+
'run',
|
|
159
|
+
'list',
|
|
160
|
+
'--workflow',
|
|
161
|
+
FLUX_DE_LA_CI,
|
|
162
|
+
'--branch',
|
|
163
|
+
'main',
|
|
164
|
+
'--limit',
|
|
165
|
+
'20',
|
|
166
|
+
'--json',
|
|
167
|
+
'databaseId,status,conclusion,headSha,event,createdAt',
|
|
168
|
+
]);
|
|
169
|
+
let passages;
|
|
170
|
+
try {
|
|
171
|
+
if (lu.error || lu.status !== 0) {
|
|
172
|
+
throw new Error('illisible');
|
|
173
|
+
}
|
|
174
|
+
passages = JSON.parse(lu.stdout || '[]');
|
|
175
|
+
if (!Array.isArray(passages)) {
|
|
176
|
+
throw new Error('illisible');
|
|
177
|
+
}
|
|
178
|
+
} catch {
|
|
179
|
+
garder({});
|
|
180
|
+
return { declenche: false };
|
|
181
|
+
}
|
|
182
|
+
const connus = passages
|
|
183
|
+
.filter(p => p?.headSha)
|
|
184
|
+
.sort(
|
|
185
|
+
(a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt) || b.databaseId - a.databaseId
|
|
186
|
+
);
|
|
187
|
+
if (connus.some(p => EN_ATTENTE(p.status))) {
|
|
188
|
+
garder({});
|
|
189
|
+
return { declenche: false };
|
|
190
|
+
}
|
|
191
|
+
const dernier = connus[0];
|
|
192
|
+
const pointe = sortie(racine, ['rev-parse', 'main']) || sortie(racine, ['rev-parse', 'HEAD']);
|
|
193
|
+
if (dernier ? dernier.headSha === pointe : !entree) {
|
|
194
|
+
garder({ entree: false });
|
|
195
|
+
return { declenche: false };
|
|
196
|
+
}
|
|
197
|
+
const instants = [dernier ? Date.parse(dernier.createdAt) : null, avant.declenche].filter(
|
|
198
|
+
Number.isFinite
|
|
199
|
+
);
|
|
200
|
+
if (instants.length > 0 && maintenant - Math.max(...instants) < HEURE) {
|
|
201
|
+
garder({});
|
|
202
|
+
return { declenche: false };
|
|
203
|
+
}
|
|
204
|
+
const r = o.gh(['workflow', 'run', FLUX_DE_LA_CI, '--ref', 'main']);
|
|
205
|
+
if (r.error || r.status !== 0) {
|
|
206
|
+
const faute = r.error
|
|
207
|
+
? `gh ne se lance pas (${r.error.code ?? r.error.message}).`
|
|
208
|
+
: `gh workflow run refuse : ${uneLigne(`${r.stderr ?? ''} ${r.stdout ?? ''}`)}`;
|
|
209
|
+
garder({ faute });
|
|
210
|
+
return { declenche: false, faute };
|
|
211
|
+
}
|
|
212
|
+
ecrireLEtat(racine, { declenche: maintenant, entree: false, faute: null });
|
|
213
|
+
return { declenche: true };
|
|
214
|
+
}
|
|
215
|
+
|
|
91
216
|
// The ticket a subject « … (<ticket>) » of the circuit's commits ends with, null otherwise.
|
|
92
217
|
const TICKET = /\(([A-Za-z0-9]+-[A-Za-z0-9.]+)\)\s*$/;
|
|
93
218
|
|
|
@@ -120,10 +245,12 @@ export function lotsDepuisLeVert(racine, { vert, pointe }) {
|
|
|
120
245
|
|
|
121
246
|
/**
|
|
122
247
|
* 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
|
-
*
|
|
248
|
+
* A red names the workflow, its pass, its commit and each lot <lots> entered since the last green,
|
|
249
|
+
* then its defect ticket <defaut> (`ouvrirLeDefautDeMain`): the ticket by its number, a ticket open
|
|
250
|
+
* with no number read, or the fault that kept it from opening (its own key, so that the alert with
|
|
251
|
+
* the ticket is given in its turn); a CI not read is the alert « CI de main non lue ».
|
|
125
252
|
*/
|
|
126
|
-
export function alerteDeLaCiDeMain(lecture, lots) {
|
|
253
|
+
export function alerteDeLaCiDeMain(lecture, lots, defaut) {
|
|
127
254
|
if (lecture.etat === 'verte') {
|
|
128
255
|
return null;
|
|
129
256
|
}
|
|
@@ -139,10 +266,18 @@ export function alerteDeLaCiDeMain(lecture, lots) {
|
|
|
139
266
|
? `Lots entrés depuis le dernier vert (${court(lecture.vert)}) : ${lots.map(l => l.ticket).join(', ')}.`
|
|
140
267
|
: `aucun lot du circuit entré depuis le dernier vert (${court(lecture.vert)}).`
|
|
141
268
|
: 'aucun vert connu pour ce flux : les lots entrés ne se nomment pas.';
|
|
269
|
+
const sans = Boolean(defaut?.faute);
|
|
270
|
+
const defautDit = !defaut
|
|
271
|
+
? ''
|
|
272
|
+
: sans
|
|
273
|
+
? ` Le ticket de défaut n'a pas pu s'ouvrir : ${uneLigne(defaut.faute)} Chaque relevé retente.`
|
|
274
|
+
: defaut.ticket
|
|
275
|
+
? ` La recherche du coupable est le ticket de défaut ${defaut.ticket}, ouvert pour le responsable.`
|
|
276
|
+
: ` Un ticket de défaut est ouvert pour le responsable (son numéro ne s'est pas lu).`;
|
|
142
277
|
return {
|
|
143
278
|
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
|
|
279
|
+
cle: sans ? `rouge ${lecture.passage} sans ticket` : `rouge ${lecture.passage}`,
|
|
280
|
+
texte: `CI de main rouge : ${lecture.flux}, passage ${lecture.passage} (commit ${court(lecture.commit)}). ${depuis} La file continue d'avancer main.${defautDit}`,
|
|
146
281
|
};
|
|
147
282
|
}
|
|
148
283
|
|
|
@@ -164,13 +299,39 @@ const titreDuDefaut = l => `CI de main rouge — ${l.flux}, passage ${l.passage}
|
|
|
164
299
|
* The defect ticket a red <lecture> opens under `a-valider` with the tools <o> (`bd` of the
|
|
165
300
|
* project): its title names the workflow and the red pass, its description the commit and each
|
|
166
301
|
* candidate lot <lots>. One ticket per pass, closed or not: a pass that already has its ticket opens
|
|
167
|
-
* none
|
|
168
|
-
*
|
|
302
|
+
* none. The queue and the supervisor's reading both open it through this function, and the search
|
|
303
|
+
* of a doublon and the creation are played under a file lock of the project <o.racine>, so that
|
|
304
|
+
* two openings at once make one ticket. A green or a CI not read opens none (the alert says it, no
|
|
305
|
+
* defect is proven). `{ ouvert, ticket, faute? }`: `ticket` is the number of the ticket created
|
|
306
|
+
* (read on the output of the creation) or already holding the pass, null when none is readable; a
|
|
307
|
+
* creation Beads refuses is a fault named.
|
|
169
308
|
*/
|
|
170
309
|
export function ouvrirLeDefautDeMain(o, lecture, lots) {
|
|
171
310
|
if (lecture.etat !== 'rouge') {
|
|
172
|
-
return { ouvert: false };
|
|
311
|
+
return { ouvert: false, ticket: null };
|
|
173
312
|
}
|
|
313
|
+
const verrou = path.join(o.racine, '.claude', 'worktrees', 'ci-de-main-defaut.verrou');
|
|
314
|
+
try {
|
|
315
|
+
mkdirSync(path.dirname(verrou), { recursive: true });
|
|
316
|
+
} catch {
|
|
317
|
+
// the lock is then taken without its directory and fails: the creation goes on unlocked
|
|
318
|
+
}
|
|
319
|
+
let pris = false;
|
|
320
|
+
try {
|
|
321
|
+
pris = prendreVerrou(verrou, { attendre: true });
|
|
322
|
+
} catch {
|
|
323
|
+
// a lock that cannot be taken costs the race guard, not the ticket
|
|
324
|
+
}
|
|
325
|
+
try {
|
|
326
|
+
return ouvrirSousVerrou(o, lecture, lots);
|
|
327
|
+
} finally {
|
|
328
|
+
if (pris) {
|
|
329
|
+
lacherVerrou(verrou);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function ouvrirSousVerrou(o, lecture, lots) {
|
|
174
335
|
const titre = titreDuDefaut(lecture);
|
|
175
336
|
const existants = o.bd('list', '--all', '--label', A_VALIDER, '--limit', '0', '--json');
|
|
176
337
|
if (existants.status === 0) {
|
|
@@ -178,7 +339,7 @@ export function ouvrirLeDefautDeMain(o, lecture, lots) {
|
|
|
178
339
|
const l = JSON.parse(existants.stdout || '[]');
|
|
179
340
|
const deja = (Array.isArray(l) ? l : []).find(t => t?.title === titre);
|
|
180
341
|
if (deja) {
|
|
181
|
-
return { ouvert: false, doublon: deja.id };
|
|
342
|
+
return { ouvert: false, ticket: deja.id ?? null, doublon: deja.id };
|
|
182
343
|
}
|
|
183
344
|
} catch {
|
|
184
345
|
// A list that does not read opens the ticket: a doublon is the lesser fault.
|
|
@@ -209,12 +370,26 @@ export function ouvrirLeDefautDeMain(o, lecture, lots) {
|
|
|
209
370
|
if (r.status !== 0) {
|
|
210
371
|
return {
|
|
211
372
|
ouvert: false,
|
|
373
|
+
ticket: null,
|
|
212
374
|
faute: `bd create refuse : ${uneLigne(`${r.stderr ?? ''}${r.stdout ?? ''}`)}`,
|
|
213
375
|
};
|
|
214
376
|
}
|
|
215
|
-
|
|
377
|
+
const numero = /^([A-Za-z0-9]+-[A-Za-z0-9.]+)$/.exec(String(r.stdout ?? '').trim())?.[1];
|
|
378
|
+
return { ouvert: true, ticket: numero ?? null };
|
|
216
379
|
}
|
|
217
380
|
|
|
381
|
+
// `bd` run in the project at <racine>, found on the PATH as the project's own.
|
|
382
|
+
export const bdDans =
|
|
383
|
+
racine =>
|
|
384
|
+
(...args) =>
|
|
385
|
+
spawnSync('bd', args, {
|
|
386
|
+
cwd: racine,
|
|
387
|
+
env: process.env,
|
|
388
|
+
encoding: 'utf8',
|
|
389
|
+
timeout: 60_000,
|
|
390
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
391
|
+
});
|
|
392
|
+
|
|
218
393
|
// The GitHub CLI run in the main tree <racine>.
|
|
219
394
|
export const ghDans =
|
|
220
395
|
racine =>
|
|
@@ -228,7 +403,7 @@ export const ghDans =
|
|
|
228
403
|
});
|
|
229
404
|
|
|
230
405
|
// 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
|
|
406
|
+
// again and again: the CI plays an hour apart at most, GitHub need not be asked at each refresh.
|
|
232
407
|
const VALIDITE_DE_LA_LECTURE = 5 * 60_000;
|
|
233
408
|
|
|
234
409
|
/**
|
|
@@ -266,11 +441,35 @@ export function ciDeMainGardee(
|
|
|
266
441
|
* The alert of a <lecture> of the CI of the project at <racine>, its lots named by git up to the
|
|
267
442
|
* tip of its main tree: `{ genre, cle, texte }`, null for a green.
|
|
268
443
|
*/
|
|
269
|
-
export function alerteDuProjet(racine, lecture) {
|
|
444
|
+
export function alerteDuProjet(racine, lecture, defaut) {
|
|
445
|
+
return alerteDeLaCiDeMain(lecture, lotsDuProjet(racine, lecture), defaut);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** The lots entered since the last green of a red <lecture>, up to the tip of the tree at <racine>. */
|
|
449
|
+
export function lotsDuProjet(racine, lecture) {
|
|
270
450
|
if (lecture.etat !== 'rouge') {
|
|
271
|
-
return
|
|
451
|
+
return [];
|
|
272
452
|
}
|
|
273
453
|
const pointe = sortie(racine, ['rev-parse', 'HEAD']);
|
|
274
|
-
|
|
275
|
-
|
|
454
|
+
return pointe ? lotsDepuisLeVert(racine, { vert: lecture.vert, pointe }) : [];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* The CI of main read for the supervisor at <racine>, its defect ticket opened by the same function
|
|
459
|
+
* as the queue's (`ouvrirLeDefautDeMain`, in this project, with its own Beads): the alert, null for
|
|
460
|
+
* a green, undefined for a project with no CI to read. Only the supervisor's reading calls it, the
|
|
461
|
+
* board reads `ciDeMainGardee` alone.
|
|
462
|
+
*/
|
|
463
|
+
export function lireEtOuvrirLeDefautDeMain(racine, { gh } = {}) {
|
|
464
|
+
const lecture = ciDeMainGardee(racine, gh ? { gh } : {});
|
|
465
|
+
if (!lecture) {
|
|
466
|
+
return undefined;
|
|
467
|
+
}
|
|
468
|
+
const defaut =
|
|
469
|
+
lecture.etat === 'rouge'
|
|
470
|
+
? ouvrirLeDefautDeMain({ racine, bd: bdDans(racine) }, lecture, lotsDuProjet(racine, lecture))
|
|
471
|
+
: undefined;
|
|
472
|
+
const alerte = alerteDuProjet(racine, lecture, defaut);
|
|
473
|
+
const faute = fauteDeDeclenchement(racine);
|
|
474
|
+
return alerte ?? (faute ? alerteDeDeclenchement(faute) : alerte);
|
|
276
475
|
}
|