@roomi-fields/grillhouse 0.52.0 → 0.54.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 +96 -0
- package/agents/direct.md +1 -1
- package/cadre/templates/projet/docs/agents/issue-tracker.md +2 -2
- package/cadre/templates/projet/vitest.config.cjs +45 -0
- package/charte/superviseur.md +36 -37
- package/charte.md +13 -1
- package/dist/temporal/circuit/appel.d.ts +2 -0
- package/dist/temporal/circuit/appel.js +24 -2
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +14 -5
- package/dist/temporal/circuit/client.js +41 -9
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/commande.js +17 -6
- package/dist/temporal/circuit/commande.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +9 -0
- package/dist/temporal/circuit/contrat.js +6 -0
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +29 -12
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/client.d.ts +35 -1
- package/dist/temporal/client.js +144 -1
- package/dist/temporal/client.js.map +1 -1
- package/dist/temporal/commande.js +31 -13
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/etat.d.ts +3 -1
- package/dist/temporal/etat.js +31 -17
- package/dist/temporal/etat.js.map +1 -1
- package/dist/temporal/file/activites.js +1 -1
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +4 -5
- package/dist/temporal/file/contrat.js +2 -2
- package/dist/temporal/file/contrat.js.map +1 -1
- package/dist/temporal/file/deroule.js +7 -5
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +116 -53
- package/dist/temporal/installation.js +898 -241
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/nuits/deroule.js +3 -1
- package/dist/temporal/nuits/deroule.js.map +1 -1
- package/dist/temporal/places/deroule.js +2 -1
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/sonde/deroule.js +2 -1
- package/dist/temporal/sonde/deroule.js.map +1 -1
- package/dist/temporal/tickets/deroule.js +4 -3
- package/dist/temporal/tickets/deroule.js.map +1 -1
- package/dist/temporal/travailleur.d.ts +7 -1
- package/dist/temporal/travailleur.js +49 -25
- package/dist/temporal/travailleur.js.map +1 -1
- package/docs/INTERFACE.md +37 -12
- package/docs/architecture/circuit.md +21 -18
- package/docs/architecture/entree.md +10 -11
- package/docs/architecture/greffon.md +45 -27
- package/docs/architecture/installation.md +92 -59
- package/docs/architecture/machine.md +2 -2
- package/docs/architecture/tests.md +15 -6
- package/docs/lexique.md +2 -2
- package/hooks/hooks.json +10 -0
- package/hooks/register.tsx +59 -39
- package/package.json +3 -2
- package/scripts/activites.mjs +5 -4
- package/scripts/aiguillage.mjs +5 -2
- package/scripts/bd-garde.mjs +69 -0
- package/scripts/ci-de-main.mjs +259 -56
- package/scripts/circuit.mjs +274 -47
- package/scripts/circuits-du-serveur.mjs +3 -2
- package/scripts/circuits-tenus.d.mts +7 -0
- package/scripts/circuits-tenus.mjs +17 -0
- package/scripts/commandes-composees.mjs +1 -1
- package/scripts/copie-de-montee.mjs +354 -0
- package/scripts/copies-du-depot.d.mts +13 -0
- package/scripts/copies-du-depot.mjs +66 -0
- package/scripts/copies-finies.mjs +6 -40
- package/scripts/crochets.mjs +16 -2
- package/scripts/direct.mjs +2 -2
- package/scripts/droits.mjs +13 -6
- package/scripts/engendres.mjs +5 -3
- package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
- package/scripts/etapes.mjs +11 -3
- package/scripts/faits-du-circuit.mjs +12 -5
- package/scripts/file-des-tickets.d.mts +13 -2
- package/scripts/file-des-tickets.mjs +71 -21
- package/scripts/greffons.mjs +42 -27
- package/scripts/grillhouse-maj.mjs +105 -85
- package/scripts/init.mjs +1 -1
- package/scripts/integration/file.mjs +5 -2
- package/scripts/integration/integrer.mjs +14 -4
- package/scripts/jointure.d.ts +16 -0
- package/scripts/langages/c/commandes.mjs +18 -8
- package/scripts/langages/cargo/commandes.mjs +88 -35
- package/scripts/langages/cargo/index.mjs +6 -3
- package/scripts/langages/cargo/sccache.mjs +15 -12
- package/scripts/langages/cargo/tailles-des-tests.mjs +115 -6
- package/scripts/langages/python/commandes.mjs +19 -9
- package/scripts/langages/python/squelette.mjs +2 -2
- package/scripts/langages/typescript/code-mort.mjs +36 -3
- package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
- package/scripts/langages/typescript/index.mjs +2 -0
- package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +370 -0
- package/scripts/langages/typescript/mise-a-jour.mjs +49 -12
- package/scripts/langages/typescript/parcours.mjs +5 -1
- package/scripts/langages/typescript/squelette.mjs +20 -17
- package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
- package/scripts/langages/typescript/turbo-des-paquets.mjs +24 -37
- package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
- package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
- package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
- package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
- package/scripts/langages.d.mts +6 -0
- package/scripts/langages.mjs +6 -0
- package/scripts/lire.mjs +236 -0
- package/scripts/mesure/pression.mjs +5 -3
- package/scripts/migrations/cout-des-jetons-au-registre.mjs +136 -0
- package/scripts/migrations/lire-un-ticket.mjs +46 -0
- package/scripts/migrations.mjs +4 -0
- package/scripts/montee.mjs +588 -0
- package/scripts/nuit.sh +21 -12
- package/scripts/outil.mjs +5 -3
- package/scripts/paquet-npm.mjs +22 -0
- package/scripts/paquet.mjs +5 -5
- package/scripts/pre-compact.mjs +25 -0
- package/scripts/registre.d.mts +7 -1
- package/scripts/registre.mjs +114 -102
- package/scripts/reponses-du-circuit.d.mts +17 -2
- package/scripts/reponses-du-circuit.mjs +78 -20
- package/scripts/resultats.mjs +55 -17
- package/scripts/retirer-les-copies-finies.mjs +4 -7
- package/scripts/seances.mjs +28 -3
- package/scripts/services-du-noyau.mjs +7 -2
- package/scripts/session-start.sh +18 -11
- package/scripts/sortie.mjs +4 -7
- package/scripts/sous-commandes.mjs +2 -0
- package/scripts/suiveur.mjs +12 -4
- package/scripts/superviseur.mjs +135 -84
- package/scripts/tableau.mjs +651 -224
- package/scripts/tarifs.mjs +67 -0
- package/scripts/ticket-du-circuit.mjs +25 -4
- package/scripts/transitions.d.mts +6 -14
- package/scripts/transitions.mjs +126 -49
- package/scripts/verdict-de-la-nuit.mjs +2 -2
- package/scripts/verrou-de-fichier.d.mts +11 -0
- package/skills/direct/SKILL.md +21 -11
- package/skills/explorateur/SKILL.md +16 -6
- package/skills/grill/SKILL.md +9 -7
- package/skills/grill/references/paquets.md +4 -4
- package/skills/mesure/SKILL.md +4 -3
- package/skills/pitmaster/SKILL.md +56 -35
- package/skills/pitmaster/references/consigne-agent.md +1 -1
- package/skills/pitmaster/references/erreurs.md +4 -2
- package/skills/pitmaster/references/tour.md +11 -4
- package/skills/relecteur/SKILL.md +8 -1
- package/skills/testwriter/SKILL.md +1 -1
- package/types/index.d.ts +3 -1
- package/cadre/templates/projet/vitest.config.ts +0 -44
- package/scripts/base-des-workflows.mjs +0 -58
package/scripts/ci-de-main.mjs
CHANGED
|
@@ -7,21 +7,29 @@
|
|
|
7
7
|
//
|
|
8
8
|
// - `declencherLaCiDeMain`: the start (`gh workflow run`), its delay and its fault kept in a file of
|
|
9
9
|
// the project; `alerteDeDeclenchement` tells the supervisor of a start GitHub refused.
|
|
10
|
-
// - `lireLaCiDeMain`: the latest finished pass of the flow CI (ci.yml) on the branch
|
|
10
|
+
// - `lireLaCiDeMain`: the latest finished pass of the flow CI (ci.yml) on the branch that judged
|
|
11
11
|
// (`gh run list`), the other flows judging nothing: green when it succeeded, red on any other
|
|
12
|
-
// conclusion
|
|
13
|
-
//
|
|
12
|
+
// conclusion, and not read, never silence, when gh fails, does not start, answers garbage or no
|
|
13
|
+
// judged pass. A cancelled, skipped or « à repasser » pass judged nothing, the one before it
|
|
14
|
+
// decides. A pass is « à repasser » when its only failures are passes of verification of the
|
|
15
|
+
// frame ending in 75, and the merge that follows from a tranche to repeat (`estARepasser`).
|
|
14
16
|
// - `lotsDepuisLeVert`: the lots of the circuit between the last green and the tip, by git alone
|
|
15
17
|
// (the commits whose subject ends with « (<ticket>) »), no state kept.
|
|
16
18
|
// - `alerteDeLaCiDeMain` and `ligneDeLaCiDeMain`: what is told to the supervisor and shown on the
|
|
17
|
-
// board; a green gives no alert, it clears.
|
|
19
|
+
// board; a green gives no alert, it clears, unless three passes or more are « à repasser » since.
|
|
18
20
|
// - `ouvrirLeDefautDeMain`: the defect ticket a red opens under `a-valider`, for the owner, which
|
|
19
21
|
// names the red pass and the candidate lots; the search of the culprit is that ticket, which the
|
|
20
22
|
// supervisor launches in the circuit. A lot already closed stays closed.
|
|
23
|
+
// - `composantsDuDefaut`: the components of the title of a defect ticket, this one and the
|
|
24
|
+
// night's (scripts/nuit.sh, which runs this file as `node ci-de-main.mjs composants`).
|
|
21
25
|
import { spawnSync } from 'node:child_process';
|
|
22
26
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
23
27
|
import path from 'node:path';
|
|
28
|
+
import { pathToFileURL } from 'node:url';
|
|
29
|
+
import { A_REPASSER } from './codes-de-sortie.mjs';
|
|
24
30
|
import { git, sortie } from './etat-du-depot.mjs';
|
|
31
|
+
import { composantsLisibles } from './langages.mjs';
|
|
32
|
+
import { prefixe } from './prefixe-des-tickets.mjs';
|
|
25
33
|
import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
|
|
26
34
|
|
|
27
35
|
const COURT = 7;
|
|
@@ -30,39 +38,112 @@ const uneLigne = t => String(t).replace(/\s+/g, ' ').trim();
|
|
|
30
38
|
|
|
31
39
|
const FLUX_DE_LA_CI = 'ci.yml';
|
|
32
40
|
|
|
41
|
+
// The steps of the frame's ci.yml (this repository's and the template's) that play a pass of
|
|
42
|
+
// verification, and the step of the merge of the tranches.
|
|
43
|
+
const TRANCHE = /^Tranche \d+$/;
|
|
44
|
+
const estUneVerification = nom => nom === 'Verification without the tests' || TRANCHE.test(nom);
|
|
45
|
+
const FUSION = 'Merge of the tranches';
|
|
46
|
+
const CODE_DE_SORTIE = /^Process completed with exit code (\d+)\.$/;
|
|
47
|
+
|
|
48
|
+
// What gh prints in JSON for <args>, <vide> read when it prints nothing; throws the reason when gh
|
|
49
|
+
// does not start, refuses or answers garbage.
|
|
50
|
+
function lireEnJson(gh, args, vide = '') {
|
|
51
|
+
const r = gh(args);
|
|
52
|
+
const appel = `gh ${args.slice(0, 2).join(' ')}`;
|
|
53
|
+
if (r.error) {
|
|
54
|
+
throw new Error(`gh ne se lance pas (${r.error.code ?? r.error.message}).`);
|
|
55
|
+
}
|
|
56
|
+
if (r.status !== 0) {
|
|
57
|
+
throw new Error(`${appel} refuse :\n${`${r.stderr}${r.stdout}`.trim()}`);
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
return JSON.parse(r.stdout || vide);
|
|
61
|
+
} catch {
|
|
62
|
+
throw new Error(`${appel} rend une sortie illisible :\n${String(r.stdout).trim()}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// The exit codes the failure annotations of the job <id> declare.
|
|
67
|
+
function codesDeSortie(gh, id) {
|
|
68
|
+
const annotations = lireEnJson(gh, [
|
|
69
|
+
'api',
|
|
70
|
+
`repos/{owner}/{repo}/check-runs/${id}/annotations?per_page=100`,
|
|
71
|
+
]);
|
|
72
|
+
if (!Array.isArray(annotations)) {
|
|
73
|
+
throw new Error(`gh api ne rend pas les annotations du job ${id}.`);
|
|
74
|
+
}
|
|
75
|
+
return annotations
|
|
76
|
+
.filter(a => a?.annotation_level === 'failure')
|
|
77
|
+
.map(a => CODE_DE_SORTIE.exec(String(a.message).trim())?.[1])
|
|
78
|
+
.filter(Boolean)
|
|
79
|
+
.map(Number);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Whether the failed pass <passage> is « à repasser », by its jobs and their annotations read with
|
|
83
|
+
// <gh>: at least one job failed in passes of verification alone, each of its exit codes 75, and
|
|
84
|
+
// every other failed job is one too, or the merge failed at its own step alone after a tranche to
|
|
85
|
+
// repeat. Throws the reason when gh does not give the jobs or the annotations.
|
|
86
|
+
function estARepasser(gh, passage) {
|
|
87
|
+
const jobs = lireEnJson(gh, ['run', 'view', String(passage), '--json', 'jobs'])?.jobs;
|
|
88
|
+
if (!Array.isArray(jobs)) {
|
|
89
|
+
throw new Error(`gh run view ne rend pas les jobs du passage ${passage}.`);
|
|
90
|
+
}
|
|
91
|
+
let aRepasser = false;
|
|
92
|
+
let tranche = false;
|
|
93
|
+
let fusion = false;
|
|
94
|
+
for (const j of jobs) {
|
|
95
|
+
if (['success', 'skipped', 'cancelled'].includes(j?.conclusion)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (j?.conclusion !== 'failure') {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const enEchec = (j.steps ?? []).filter(e => e?.conclusion === 'failure').map(e => e.name);
|
|
102
|
+
if (enEchec.length === 1 && enEchec[0] === FUSION) {
|
|
103
|
+
fusion = true;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (enEchec.length === 0 || !enEchec.every(estUneVerification)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const codes = codesDeSortie(gh, j.databaseId);
|
|
110
|
+
if (codes.length === 0 || codes.some(c => c !== A_REPASSER)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
aRepasser = true;
|
|
114
|
+
tranche ||= enEchec.some(nom => TRANCHE.test(nom));
|
|
115
|
+
}
|
|
116
|
+
return aRepasser && (!fusion || tranche);
|
|
117
|
+
}
|
|
118
|
+
|
|
33
119
|
/**
|
|
34
120
|
* The CI of the branch <branche> (main by default) read with <o.gh> in <o.racine>: `{ etat: 'verte',
|
|
35
121
|
* commit, passage }`, `{ etat: 'rouge', flux, passage, commit, vert }` (the name of the flow, its
|
|
36
122
|
* red pass, the commit of that pass and the commit of its last green pass, null when none is read)
|
|
37
|
-
* or `{ etat: 'non-lue', raison }`.
|
|
123
|
+
* or `{ etat: 'non-lue', raison }`. A green or a red carries `aRepasser: { passage, nombre }` when
|
|
124
|
+
* passes « à repasser » are more recent than the one that decides: the latest and their count.
|
|
38
125
|
*/
|
|
39
126
|
export function lireLaCiDeMain(o, { branche = 'main' } = {}) {
|
|
40
|
-
const r = o.gh([
|
|
41
|
-
'run',
|
|
42
|
-
'list',
|
|
43
|
-
'--branch',
|
|
44
|
-
branche,
|
|
45
|
-
'--workflow',
|
|
46
|
-
FLUX_DE_LA_CI,
|
|
47
|
-
'--limit',
|
|
48
|
-
'100',
|
|
49
|
-
'--json',
|
|
50
|
-
'databaseId,status,conclusion,workflowName,headSha',
|
|
51
|
-
]);
|
|
52
|
-
if (r.error) {
|
|
53
|
-
return { etat: 'non-lue', raison: `gh ne se lance pas (${r.error.code ?? r.error.message}).` };
|
|
54
|
-
}
|
|
55
|
-
if (r.status !== 0) {
|
|
56
|
-
return { etat: 'non-lue', raison: `gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}` };
|
|
57
|
-
}
|
|
58
127
|
let passages;
|
|
59
128
|
try {
|
|
60
|
-
passages =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
129
|
+
passages = lireEnJson(
|
|
130
|
+
o.gh,
|
|
131
|
+
[
|
|
132
|
+
'run',
|
|
133
|
+
'list',
|
|
134
|
+
'--branch',
|
|
135
|
+
branche,
|
|
136
|
+
'--workflow',
|
|
137
|
+
FLUX_DE_LA_CI,
|
|
138
|
+
'--limit',
|
|
139
|
+
'100',
|
|
140
|
+
'--json',
|
|
141
|
+
'databaseId,status,conclusion,workflowName,headSha',
|
|
142
|
+
],
|
|
143
|
+
'[]'
|
|
144
|
+
);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
return { etat: 'non-lue', raison: e.message };
|
|
66
147
|
}
|
|
67
148
|
const finis = (Array.isArray(passages) ? passages : [])
|
|
68
149
|
.filter(
|
|
@@ -77,18 +158,53 @@ export function lireLaCiDeMain(o, { branche = 'main' } = {}) {
|
|
|
77
158
|
if (finis.length === 0) {
|
|
78
159
|
return { etat: 'non-lue', raison: `aucun passage fini de la CI sur ${branche}.` };
|
|
79
160
|
}
|
|
80
|
-
const
|
|
81
|
-
|
|
161
|
+
const repasses = [];
|
|
162
|
+
let juge;
|
|
163
|
+
try {
|
|
164
|
+
juge = finis.find(p => {
|
|
165
|
+
const repasse = p.conclusion === 'failure' && estARepasser(o.gh, p.databaseId);
|
|
166
|
+
if (repasse) {
|
|
167
|
+
repasses.push(String(p.databaseId));
|
|
168
|
+
}
|
|
169
|
+
return !repasse;
|
|
170
|
+
});
|
|
171
|
+
} catch (e) {
|
|
172
|
+
return { etat: 'non-lue', raison: e.message };
|
|
173
|
+
}
|
|
174
|
+
if (!juge) {
|
|
175
|
+
return {
|
|
176
|
+
etat: 'non-lue',
|
|
177
|
+
raison: `aucun passage jugé de la CI sur ${branche} : passage ${repasses[0]} à repasser.`,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const suite = repasses.length
|
|
181
|
+
? { aRepasser: { passage: repasses[0], nombre: repasses.length } }
|
|
182
|
+
: {};
|
|
183
|
+
if (juge.conclusion !== 'success') {
|
|
82
184
|
const vert = finis.find(p => p.conclusion === 'success');
|
|
83
185
|
return {
|
|
84
186
|
etat: 'rouge',
|
|
85
|
-
flux:
|
|
86
|
-
passage: String(
|
|
87
|
-
commit:
|
|
187
|
+
flux: juge.workflowName,
|
|
188
|
+
passage: String(juge.databaseId),
|
|
189
|
+
commit: juge.headSha,
|
|
88
190
|
vert: vert?.headSha ?? null,
|
|
191
|
+
...suite,
|
|
89
192
|
};
|
|
90
193
|
}
|
|
91
|
-
return { etat: 'verte', commit:
|
|
194
|
+
return { etat: 'verte', commit: juge.headSha, passage: String(juge.databaseId), ...suite };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Whether the pass <p> of `gh run list` is finished and « à repasser »; false when gh does not give
|
|
198
|
+
// its jobs or its annotations, which starts nothing.
|
|
199
|
+
function finiARepasser(gh, p) {
|
|
200
|
+
if (p.status !== 'completed' || p.conclusion !== 'failure') {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
return estARepasser(gh, p.databaseId);
|
|
205
|
+
} catch {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
92
208
|
}
|
|
93
209
|
|
|
94
210
|
const HEURE = 3_600_000;
|
|
@@ -141,8 +257,9 @@ export function alerteDeDeclenchement(faute) {
|
|
|
141
257
|
* The queue starts the CI of main itself, as the schedulers of Google's TAP and Chromium's LUCI
|
|
142
258
|
* start the pass after the submit, by batches: it reads the passes of the workflow ci.yml on main
|
|
143
259
|
* (whatever started them) with <o.gh> in <o.racine>, and starts it (`gh workflow run`) when the tip
|
|
144
|
-
* of main differs from the commit of the last pass,
|
|
145
|
-
* pass or the last start is an hour old or
|
|
260
|
+
* of main differs from the commit of the last pass, or that pass is « à repasser » and so judged
|
|
261
|
+
* nothing, no pass is running or waiting, and the last pass or the last start is an hour old or
|
|
262
|
+
* more. Without any pass known, only a lot entered
|
|
146
263
|
* (<p.apresEntree>, kept until a start succeeds) starts it, never the sole start of the queue.
|
|
147
264
|
* `{ declenche }`, with `faute` when GitHub refused: the fault is kept for the alert, the next
|
|
148
265
|
* quarter of an hour tries again, and nothing throws.
|
|
@@ -188,7 +305,7 @@ export function declencherLaCiDeMain(o, { apresEntree = false, maintenant = Date
|
|
|
188
305
|
}
|
|
189
306
|
const dernier = connus[0];
|
|
190
307
|
const pointe = sortie(racine, ['rev-parse', 'main']) || sortie(racine, ['rev-parse', 'HEAD']);
|
|
191
|
-
if (dernier ? dernier.headSha === pointe : !entree) {
|
|
308
|
+
if (dernier ? dernier.headSha === pointe && !finiARepasser(o.gh, dernier) : !entree) {
|
|
192
309
|
garder({ entree: false });
|
|
193
310
|
return { declenche: false };
|
|
194
311
|
}
|
|
@@ -212,7 +329,8 @@ export function declencherLaCiDeMain(o, { apresEntree = false, maintenant = Date
|
|
|
212
329
|
}
|
|
213
330
|
|
|
214
331
|
// The ticket a subject « … (<ticket>) » of the circuit's commits ends with, null otherwise.
|
|
215
|
-
|
|
332
|
+
// The prefix of a project may hold hyphens.
|
|
333
|
+
const TICKET = /\(([A-Za-z0-9]+(?:-[A-Za-z0-9.]+)+)\)\s*$/;
|
|
216
334
|
|
|
217
335
|
/**
|
|
218
336
|
* The lots of the circuit entered on main since the last green <vert> up to <pointe>, oldest first:
|
|
@@ -241,8 +359,13 @@ export function lotsDepuisLeVert(racine, { vert, pointe }) {
|
|
|
241
359
|
.filter(Boolean);
|
|
242
360
|
}
|
|
243
361
|
|
|
362
|
+
// From how many passes « à repasser » after a green the supervisor is told main is not judged.
|
|
363
|
+
const SERIE_QUI_ALERTE = 3;
|
|
364
|
+
|
|
244
365
|
/**
|
|
245
|
-
* What a reading tells the supervisor: `{ genre, cle, texte }`, null for a green (the alert clears)
|
|
366
|
+
* What a reading tells the supervisor: `{ genre, cle, texte }`, null for a green (the alert clears),
|
|
367
|
+
* unless three passes or more are « à repasser » since (genre `plus-juge`, one key per deciding
|
|
368
|
+
* pass).
|
|
246
369
|
* A red names the workflow, its pass, its commit and each lot <lots> entered since the last green,
|
|
247
370
|
* then its defect ticket <defaut> (`ouvrirLeDefautDeMain`): the ticket by its number, a ticket open
|
|
248
371
|
* with no number read, or the fault that kept it from opening (its own key, so that the alert with
|
|
@@ -250,7 +373,14 @@ export function lotsDepuisLeVert(racine, { vert, pointe }) {
|
|
|
250
373
|
*/
|
|
251
374
|
export function alerteDeLaCiDeMain(lecture, lots, defaut) {
|
|
252
375
|
if (lecture.etat === 'verte') {
|
|
253
|
-
|
|
376
|
+
const nombre = lecture.aRepasser?.nombre ?? 0;
|
|
377
|
+
return nombre < SERIE_QUI_ALERTE
|
|
378
|
+
? null
|
|
379
|
+
: {
|
|
380
|
+
genre: 'plus-juge',
|
|
381
|
+
cle: `plus-juge ${lecture.passage}`,
|
|
382
|
+
texte: `Main n'est plus jugé depuis le passage vert ${lecture.passage} (commit ${court(lecture.commit)}) : ${nombre} passages de la CI de main à repasser depuis. La file continue d'avancer main et relance le flux.`,
|
|
383
|
+
};
|
|
254
384
|
}
|
|
255
385
|
if (lecture.etat === 'non-lue') {
|
|
256
386
|
return {
|
|
@@ -279,24 +409,78 @@ export function alerteDeLaCiDeMain(lecture, lots, defaut) {
|
|
|
279
409
|
};
|
|
280
410
|
}
|
|
281
411
|
|
|
282
|
-
/**
|
|
412
|
+
/**
|
|
413
|
+
* The line of the board: the last green, the red with its workflow, pass and last green, or the CI
|
|
414
|
+
* not read; the latest pass « à repasser » beside the one that decides.
|
|
415
|
+
*/
|
|
283
416
|
export function ligneDeLaCiDeMain(lecture) {
|
|
284
|
-
if (lecture.etat === 'verte') {
|
|
285
|
-
return `CI de main verte (${court(lecture.commit)})`;
|
|
286
|
-
}
|
|
287
417
|
if (lecture.etat === 'non-lue') {
|
|
288
418
|
return `CI de main non lue : ${uneLigne(lecture.raison)}`;
|
|
289
419
|
}
|
|
290
|
-
|
|
420
|
+
const repasse = lecture.aRepasser ? `, passage ${lecture.aRepasser.passage} à repasser` : '';
|
|
421
|
+
if (lecture.etat === 'verte') {
|
|
422
|
+
return `CI de main verte (${court(lecture.commit)})${repasse}`;
|
|
423
|
+
}
|
|
424
|
+
return `CI de main rouge : ${lecture.flux}, passage ${lecture.passage}, dernier vert ${lecture.vert ? court(lecture.vert) : 'aucun vert'}${repasse}`;
|
|
291
425
|
}
|
|
292
426
|
|
|
293
427
|
const A_VALIDER = 'a-valider';
|
|
294
|
-
|
|
428
|
+
// The package of the frame, which takes a defect whose lots name no component.
|
|
429
|
+
const PAQUET_DU_CADRE = '@roomi-fields/grillhouse';
|
|
430
|
+
// The scope of the commit of a lot, « type(a,b): subject (ticket) ».
|
|
431
|
+
const PORTEE = /^[A-Za-z]+\(([^()]*)\)!?:/;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* The components of the title of a defect ticket of main, in the repository at <racine>: the names
|
|
435
|
+
* of the components the scope of the commit of each lot of <lots> names, each once, in the order of
|
|
436
|
+
* the lots; a name that is no component of the repository is left aside. Without any, the package
|
|
437
|
+
* of the frame when the repository holds it, else the root « . », which is also what a repository
|
|
438
|
+
* whose components do not read gives: the departure of the ticket reads each of them.
|
|
439
|
+
*/
|
|
440
|
+
export function composantsDuDefaut(racine, lots) {
|
|
441
|
+
let liste = [];
|
|
442
|
+
try {
|
|
443
|
+
liste = composantsLisibles(racine);
|
|
444
|
+
} catch {
|
|
445
|
+
// components that do not read: the root, which needs none
|
|
446
|
+
}
|
|
447
|
+
const nommes = lots
|
|
448
|
+
.flatMap(l => PORTEE.exec(l.titre)?.[1].split(',') ?? [])
|
|
449
|
+
.map(n => n.trim())
|
|
450
|
+
.map(n => liste.find(p => p.pkg.name === n || p.dossier === n)?.pkg.name)
|
|
451
|
+
.filter(Boolean);
|
|
452
|
+
if (nommes.length > 0) {
|
|
453
|
+
return [...new Set(nommes)];
|
|
454
|
+
}
|
|
455
|
+
return [liste.some(p => p.pkg.name === PAQUET_DU_CADRE) ? PAQUET_DU_CADRE : '.'];
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
const sujetDuDefaut = l => `CI de main rouge : ${l.flux}, passage ${l.passage}`;
|
|
459
|
+
|
|
460
|
+
// The pass a title of a defect ticket holds, with or without its number and its components, the
|
|
461
|
+
// former title « CI de main rouge — <flux>, passage <n> » included.
|
|
462
|
+
const PASSAGE_TENU = /^(?:\S+ — )?CI de main rouge (?::|—) .*?, passage (\d+)(?=$| — )/;
|
|
463
|
+
const passageTenu = titre => PASSAGE_TENU.exec(String(titre ?? ''))?.[1];
|
|
464
|
+
|
|
465
|
+
// Titles the ticket <id> « number — <titre> », the number being its id without the prefix of the
|
|
466
|
+
// project. A prefix that does not read or a renaming refused leaves the ticket as created.
|
|
467
|
+
function numeroter(o, id, titre) {
|
|
468
|
+
let debut;
|
|
469
|
+
try {
|
|
470
|
+
debut = `${prefixe(o.racine)}-`;
|
|
471
|
+
} catch {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (id.startsWith(debut)) {
|
|
475
|
+
o.bd('update', id, '--title', `${id.slice(debut.length)} — ${titre}`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
295
478
|
|
|
296
479
|
/**
|
|
297
480
|
* The defect ticket a red <lecture> opens under `a-valider` with the tools <o> (`bd` of the
|
|
298
|
-
* project): its title names the workflow
|
|
299
|
-
* candidate
|
|
481
|
+
* project): its title « number — subject — components » names the workflow, the red pass and the
|
|
482
|
+
* components of the candidate lots <lots> (`composantsDuDefaut`), its description the commit and
|
|
483
|
+
* each of those lots. One ticket per pass, closed or not: a pass that already has its ticket opens
|
|
300
484
|
* none. The queue and the supervisor's reading both open it through this function, and the search
|
|
301
485
|
* of a doublon and the creation are played under a file lock of the project <o.racine>, so that
|
|
302
486
|
* two openings at once make one ticket. A green or a CI not read opens none (the alert says it, no
|
|
@@ -330,12 +514,13 @@ export function ouvrirLeDefautDeMain(o, lecture, lots) {
|
|
|
330
514
|
}
|
|
331
515
|
|
|
332
516
|
function ouvrirSousVerrou(o, lecture, lots) {
|
|
333
|
-
const titre = titreDuDefaut(lecture);
|
|
334
517
|
const existants = o.bd('list', '--all', '--label', A_VALIDER, '--limit', '0', '--json');
|
|
335
518
|
if (existants.status === 0) {
|
|
336
519
|
try {
|
|
337
520
|
const l = JSON.parse(existants.stdout || '[]');
|
|
338
|
-
const deja = (Array.isArray(l) ? l : []).find(
|
|
521
|
+
const deja = (Array.isArray(l) ? l : []).find(
|
|
522
|
+
t => passageTenu(t?.title) === String(lecture.passage)
|
|
523
|
+
);
|
|
339
524
|
if (deja) {
|
|
340
525
|
return { ouvert: false, ticket: deja.id ?? null, doublon: deja.id };
|
|
341
526
|
}
|
|
@@ -354,6 +539,7 @@ function ouvrirSousVerrou(o, lecture, lots) {
|
|
|
354
539
|
'',
|
|
355
540
|
'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é.',
|
|
356
541
|
].join('\n');
|
|
542
|
+
const titre = `${sujetDuDefaut(lecture)} — ${composantsDuDefaut(o.racine, lots).join(', ')}`;
|
|
357
543
|
const r = o.bd(
|
|
358
544
|
'create',
|
|
359
545
|
titre,
|
|
@@ -372,8 +558,11 @@ function ouvrirSousVerrou(o, lecture, lots) {
|
|
|
372
558
|
faute: `bd create refuse : ${uneLigne(`${r.stderr ?? ''}${r.stdout ?? ''}`)}`,
|
|
373
559
|
};
|
|
374
560
|
}
|
|
375
|
-
const
|
|
376
|
-
|
|
561
|
+
const id = /^([A-Za-z0-9]+(?:-[A-Za-z0-9.]+)+)$/.exec(String(r.stdout ?? '').trim())?.[1];
|
|
562
|
+
if (id) {
|
|
563
|
+
numeroter(o, id, titre);
|
|
564
|
+
}
|
|
565
|
+
return { ouvert: true, ticket: id ?? null };
|
|
377
566
|
}
|
|
378
567
|
|
|
379
568
|
// `bd` run in the project at <racine>, found on the PATH as the project's own.
|
|
@@ -437,7 +626,7 @@ export function ciDeMainGardee(
|
|
|
437
626
|
|
|
438
627
|
/**
|
|
439
628
|
* The alert of a <lecture> of the CI of the project at <racine>, its lots named by git up to the
|
|
440
|
-
* tip of its main tree: `{ genre, cle, texte }`, null
|
|
629
|
+
* tip of its main tree: `{ genre, cle, texte }`, null when the reading tells nothing.
|
|
441
630
|
*/
|
|
442
631
|
export function alerteDuProjet(racine, lecture, defaut) {
|
|
443
632
|
return alerteDeLaCiDeMain(lecture, lotsDuProjet(racine, lecture), defaut);
|
|
@@ -454,8 +643,8 @@ export function lotsDuProjet(racine, lecture) {
|
|
|
454
643
|
|
|
455
644
|
/**
|
|
456
645
|
* The CI of main read for the supervisor at <racine>, its defect ticket opened by the same function
|
|
457
|
-
* as the queue's (`ouvrirLeDefautDeMain`, in this project, with its own Beads): the alert, null
|
|
458
|
-
*
|
|
646
|
+
* as the queue's (`ouvrirLeDefautDeMain`, in this project, with its own Beads): the alert, null
|
|
647
|
+
* when there is nothing to tell, undefined for a project with no CI to read. Only the supervisor's reading calls it, the
|
|
459
648
|
* board reads `ciDeMainGardee` alone.
|
|
460
649
|
*/
|
|
461
650
|
export function lireEtOuvrirLeDefautDeMain(racine, { gh } = {}) {
|
|
@@ -471,3 +660,17 @@ export function lireEtOuvrirLeDefautDeMain(racine, { gh } = {}) {
|
|
|
471
660
|
const faute = fauteDeDeclenchement(racine);
|
|
472
661
|
return alerte ?? (faute ? alerteDeDeclenchement(faute) : alerte);
|
|
473
662
|
}
|
|
663
|
+
|
|
664
|
+
// Run as `node ci-de-main.mjs composants <racine> <vert> <pointe>`, the night (nuit.sh) takes the
|
|
665
|
+
// components of its ticket by the same functions: those of the lots entered between its last green
|
|
666
|
+
// <vert>, empty without one, and its tip <pointe>, as its title writes them.
|
|
667
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
668
|
+
const [commande, racine, vert, pointe] = process.argv.slice(2);
|
|
669
|
+
if (commande === 'composants' && racine && pointe) {
|
|
670
|
+
const lots = lotsDepuisLeVert(racine, { vert, pointe });
|
|
671
|
+
process.stdout.write(composantsDuDefaut(racine, lots).join(', '));
|
|
672
|
+
} else {
|
|
673
|
+
process.stderr.write('Usage : node ci-de-main.mjs composants <racine> <vert> <pointe>\n');
|
|
674
|
+
process.exitCode = 2;
|
|
675
|
+
}
|
|
676
|
+
}
|