@roomi-fields/grillhouse 0.49.0 → 0.49.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.
@@ -21,6 +21,13 @@
21
21
  // keyring, the session of the user (`/run/user/`), or the command claude started for more than
22
22
  // `plugin` or `--version` (a session, a model). A mark the reading does not see (a path built at
23
23
  // run time, a dependency of the product's code) escapes it: such a test takes the tag by hand.
24
+ // - A night test that plays other night tests by their name carries what they ask, as a tag of
25
+ // Bazel reaches the target that runs the tagged one: a string of its code, or of its material's,
26
+ // that ends with the name of a night test (`tests/enveloppe.nuit.spec.ts`) names each night
27
+ // test of the repository whose path is that string or ends with it from a directory. A test
28
+ // named that bears the tag `@poste`, or shows a mark of the poste, is a mark of the poste of
29
+ // the one that names it; one tagged `@equipee`, or showing a mark of equipment, a mark of
30
+ // equipment. A name built at run time is not read.
24
31
  // - A night test that depends on the poste without the tag is a finding,
25
32
  // `{ fichier, regle: 'poste-sans-etiquette', message }`, naming its marks; a tag without a mark
26
33
  // passes. A finding inscribed in the project's debt (`grillhouse-dette.json`, ../../dette.mjs)
@@ -91,17 +98,21 @@ export const DEPENDANCES = [
91
98
  },
92
99
  ];
93
100
 
101
+ // A string of the code that ends with the name of a night test, to the end of its string.
102
+ const TEST_NOMME = /['"`]((?:[\w.@-]+\/)*[\w.@-]+\.nuit\.(?:test|spec)\.[cm]?[jt]sx?)['"`]/g;
103
+
94
104
  /**
95
105
  * The marks of the poste the test file <fichier> (absolute) shows, with the test material it
96
106
  * imports by a relative path, read by <lire> (a path → its text, null when it does not read), in
97
107
  * the repository at <racine>: the names of DEPENDANCES, each once, in their order.
98
108
  */
99
109
  export function dependancesDu(fichier, lire = lireLeDisque, racine = path.parse(fichier).root) {
100
- return marquesDu(fichier, lire, racine).map(d => d.nom);
110
+ return DEPENDANCES.filter(d => d.voit(codeDu(fichier, lire, racine))).map(d => d.nom);
101
111
  }
102
112
 
103
- // The marks (the entries of DEPENDANCES) the test file <fichier> shows, as `dependancesDu` reads them.
104
- function marquesDu(fichier, lire, racine) {
113
+ // The code of the test file <fichier> and of the test material it imports by a relative path,
114
+ // from file to file, their comments and imports left out.
115
+ function codeDu(fichier, lire, racine) {
105
116
  const vus = new Set();
106
117
  const codes = [];
107
118
  const suivre = f => {
@@ -124,28 +135,56 @@ function marquesDu(fichier, lire, racine) {
124
135
  }
125
136
  };
126
137
  suivre(fichier);
127
- const tout = codes.join('\n');
128
- return DEPENDANCES.filter(d => d.voit(tout));
138
+ return codes.join('\n');
139
+ }
140
+
141
+ // The night tests of <fichiers> (each from the root) the code <tout> of <fichier> names: those
142
+ // whose path is a string of the code, or ends with it from a directory; itself left out.
143
+ function nommesPar(fichier, tout, fichiers) {
144
+ const noms = new Set([...tout.matchAll(TEST_NOMME)].map(m => m[1].replace(/^(?:\.\/)+/, '')));
145
+ return fichiers.filter(f => f !== fichier && [...noms].some(n => f === n || f.endsWith(`/${n}`)));
129
146
  }
130
147
 
131
148
  /**
132
149
  * Each night test of the repository at <racine>: `[{ fichier, etiquete, equipee, marques }]`,
133
150
  * `fichier` from its root, `etiquete` whether it bears the tag `@poste`, `equipee` whether it bears
134
- * the tag `@equipee`, `marques` the marks it shows, `{ nom, classe }` each.
151
+ * the tag `@equipee`, `marques` the marks it shows, `{ nom, classe }` each: those of
152
+ * DEPENDANCES, then one per class for each night test it names that asks for that class.
153
+ * @param {string} racine the root of the repository
154
+ * @returns {{ fichier: string, etiquete: boolean, equipee: boolean, marques: { nom: string, classe: string }[] }[]}
135
155
  */
136
156
  export function testsDeNuitDuDepot(racine) {
137
- return testsDuDepot(racine)
138
- .filter(estUnTestDeNuit)
139
- .map(fichier => {
140
- const abs = path.join(racine, fichier);
141
- const texte = lireLeDisque(abs) ?? '';
142
- return {
143
- fichier,
144
- etiquete: porteLEtiquetteDuPoste(texte),
145
- equipee: porteLEtiquetteEquipee(texte),
146
- marques: marquesDu(abs, lireLeDisque, racine).map(({ nom, classe }) => ({ nom, classe })),
147
- };
148
- });
157
+ const fichiers = testsDuDepot(racine).filter(estUnTestDeNuit);
158
+ const lus = fichiers.map(fichier => {
159
+ const abs = path.join(racine, fichier);
160
+ const texte = lireLeDisque(abs) ?? '';
161
+ const tout = codeDu(abs, lireLeDisque, racine);
162
+ return {
163
+ fichier,
164
+ etiquete: porteLEtiquetteDuPoste(texte),
165
+ equipee: porteLEtiquetteEquipee(texte),
166
+ marques: DEPENDANCES.filter(d => d.voit(tout)).map(({ nom, classe }) => ({ nom, classe })),
167
+ nommes: nommesPar(fichier, tout, fichiers),
168
+ };
169
+ });
170
+ const parFichier = new Map(lus.map(t => [t.fichier, t]));
171
+ // Whether the night test <t> asks for the class <classe>: its tag, or a mark it shows itself.
172
+ const demande = (t, classe) =>
173
+ (classe === 'poste' ? t.etiquete : t.equipee) || t.marques.some(m => m.classe === classe);
174
+ return lus.map(({ nommes, ...t }) => ({
175
+ ...t,
176
+ marques: [
177
+ ...t.marques,
178
+ ...['poste', 'equipee'].flatMap(classe =>
179
+ nommes
180
+ .filter(n => demande(parFichier.get(n), classe))
181
+ .map(n => ({
182
+ nom: `${n}, ${classe === 'poste' ? 'test du poste' : 'test équipé'} joué par son nom`,
183
+ classe,
184
+ }))
185
+ ),
186
+ ],
187
+ }));
149
188
  }
150
189
 
151
190
  /**
@@ -155,8 +194,7 @@ export function testsDeNuitDuDepot(racine) {
155
194
  * `@equipee` (REGLE_EQUIPEE).
156
195
  */
157
196
  export function verifier(racine, tous = testsDeNuitDuDepot(racine)) {
158
- const noms = (marques, classe) =>
159
- marques.filter(m => m.classe === classe).map(m => m.nom);
197
+ const noms = (marques, classe) => marques.filter(m => m.classe === classe).map(m => m.nom);
160
198
  return tous.flatMap(({ fichier, etiquete, equipee, marques }) => {
161
199
  /** @type {{ fichier: string, regle: string, message: string }[]} */
162
200
  const constats = [];
package/scripts/nuit.sh CHANGED
@@ -67,9 +67,13 @@
67
67
  # bound 15 min) and plays once more; green then, the night goes on; à repasser again, or no rest in the bound, the night
68
68
  # ends there, « à repasser », red if the full pass is.
69
69
  # - The two parts of the night: a project whose `.github/workflows/nuit.yml` plays on the label
70
- # `pc2` leaves PC2 its night tests but those tagged @poste and the measures of time (the flow's
71
- # tranches, `tests-de-nuit --hors-du-poste`, then `--mesures`). The night of PC3 plays the tests
72
- # tagged @poste alone (`tests-de-nuit --du-poste`, on its part), then reads the day's flow by `gh`
70
+ # `pc2` leaves PC2 its night tests but those tagged @poste (the flow's tranches,
71
+ # `tests-de-nuit --hors-du-poste`). The measures of time play on PC3, on dedicated cores, unless
72
+ # the flow declares a job that plays them (a command `tests-de-nuit --mesures`, as the flow of
73
+ # Grillhouse: scripts/flux-de-la-nuit.mjs): then that job's verdict, read for the commit of the
74
+ # night, stands for them, and PC3 plays them only when the job was interrupted. The night of PC3
75
+ # plays the tests tagged @poste, then the measures (`tests-de-nuit --du-poste`, on its part), then
76
+ # reads the flow of its commit by `gh`
73
77
  # (scripts/repli-de-la-nuit.mjs): a tranche whose job has not started 60 minutes after the flow's
74
78
  # hour is cancelled and played on PC3, a tranche started then interrupted plays whole again, a
75
79
  # tranche finished on PC2, green or red, is never replayed; the log says which tranches played
@@ -105,7 +109,8 @@
105
109
  # - It takes no lock of the integration or of the queue (scripts/integration/file.mjs): an
106
110
  # integration and the queue run during the night, each in its own copy.
107
111
  # - Its log is <git common dir>/nuit/<date>.log. Green: HEAD becomes the last green commit
108
- # (<git common dir>/nuit/dernier-vert). Red: the red tasks, each grouped by its cause as an
112
+ # (<git common dir>/nuit/dernier-vert), only once the measures of time were played and are green,
113
+ # by PC3 or by the flow's job for that commit. Red: the red tasks, each grouped by its cause as an
109
114
  # alerting system groups by fingerprint: each red task of the full pass (the file
110
115
  # GRILLHOUSE_ROUGES names, which the verification of the module writes: `<task>` per line, then
111
116
  # a tab and the command that replays it alone when the language has one, no task à repasser
@@ -185,7 +190,7 @@ preparer() {
185
190
  fi
186
191
  partages=$(bash "$ici/sous-modules.sh" pose "$copie")
187
192
  }
188
- # The part of PC2: reads the day's Nuit flow by `gh` (scripts/repli-de-la-nuit.mjs), which cancels the
193
+ # The part of PC2: reads the Nuit flow of the commit the night plays by `gh` (scripts/repli-de-la-nuit.mjs), which cancels the
189
194
  # run when a tranche has not started 60 minutes after the flow's hour, then plays on PC3, whole, each
190
195
  # tranche not played on PC2 (never one finished there, green or red). A tranche still running or
191
196
  # waiting leaves the part of PC2 « à repasser » (75). The statement says which tranches played where.
@@ -197,18 +202,19 @@ repli() {
197
202
  code_pc2=75
198
203
  return
199
204
  fi
200
- if ! decision="$(node "$ici/repli-de-la-nuit.mjs" "$depot" "$tranches")"; then
205
+ if ! decision="$(node "$ici/repli-de-la-nuit.mjs" "$depot" "$tranches" "" "$tete")"; then
201
206
  echo "⏱ le repli de la nuit ne lit pas le flux Nuit : la part de PC2 reste à repasser."
202
207
  code_pc2=75
203
208
  return
204
209
  fi
205
- local lignes rejouer= rouges_pc2= attend=
206
- lignes="$(printf '%s' "$decision" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const d=JSON.parse(s);const l=k=>(d[k]??[]).join(" ");process.stdout.write(["pc2","pc3","rouges","enAttente","enCours"].map(k=>k+"\t"+l(k)).join("\n")+"\n")})')"
210
+ local lignes rejouer= rouges_pc2= attend= mesures_du_flux=
211
+ lignes="$(printf '%s' "$decision" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const d=JSON.parse(s);const l=k=>(d[k]??[]).join(" ");process.stdout.write(["pc2","pc3","rouges","enAttente","enCours","mesures"].map(k=>k+"\t"+l(k)).join("\n")+"\n")})')"
207
212
  while IFS= read -r ligne; do
208
213
  case "$ligne" in
209
214
  pc2$'\t'*) echo "relevé de la nuit : tranches jouées sur PC2 : ${ligne#pc2$'\t'}" ;;
210
215
  pc3$'\t'*) rejouer="${ligne#pc3$'\t'}"; echo "relevé de la nuit : tranches jouées sur PC3 : ${rejouer:-aucune}" ;;
211
216
  rouges$'\t'*) rouges_pc2="${ligne#rouges$'\t'}" ;;
217
+ mesures$'\t'*) mesures_du_flux="${ligne#mesures$'\t'}"; echo "relevé de la nuit : mesures de temps du flux : ${mesures_du_flux}" ;;
212
218
  enAttente$'\t'*|enCours$'\t'*) attend="$attend ${ligne#*$'\t'}" ;;
213
219
  esac
214
220
  done <<< "$lignes"
@@ -229,6 +235,28 @@ repli() {
229
235
  attend="$attend $t"
230
236
  fi
231
237
  done
238
+ # The measures of time: the flow's job plays them when its file declares one; the night of the
239
+ # poste plays them itself otherwise (tests-de-nuit --du-poste), so no last green without them.
240
+ if node "$ici/flux-de-la-nuit.mjs" mesures "$copie"; then
241
+ case "$mesures_du_flux" in
242
+ rouge)
243
+ echo "✗ les mesures de temps du flux sont rouges sur PC2."
244
+ etapes_pc2+=("les mesures de temps de la nuit sur PC2")
245
+ taches_pc2+=("les mesures de temps de la nuit sur PC2") ;;
246
+ a-rejouer)
247
+ (cd "$copie" && monter node "$ici/commande-du-langage.mjs" tests-de-nuit --mesures)
248
+ code=$?
249
+ if [ "$code" -eq 75 ]; then
250
+ attend="$attend mesures"
251
+ elif [ "$code" -ne 0 ]; then
252
+ echo "✗ les mesures de temps, rejouées sur PC3, sont rouges."
253
+ etapes_pc2+=("les mesures de temps de la nuit, rejouées sur PC3")
254
+ taches_pc2+=("les mesures de temps de la nuit sur PC3 (repli)")
255
+ fi ;;
256
+ verte) ;;
257
+ *) attend="$attend mesures" ;;
258
+ esac
259
+ fi
232
260
  if [ "${#etapes_pc2[@]}" -gt 0 ]; then
233
261
  code_pc2=1
234
262
  elif [ -n "${attend// /}" ]; then
@@ -365,8 +393,11 @@ process.exit(paquets(process.argv[2]).some(p => p.pkg.name === "@roomi-fields/gr
365
393
  fi
366
394
  fi
367
395
  # A project whose Nuit flow plays on PC2 (its runner label `pc2`) leaves PC2 the night tests that
368
- # do not need the poste: PC3 plays the tests tagged @poste alone, then the tranches PC2 did not
369
- # play (the fallback, scripts/repli-de-la-nuit.mjs); the measures of time play on PC2.
396
+ # do not need the poste: PC3 plays the tests tagged @poste, then the tranches PC2 did not play
397
+ # (the fallback, scripts/repli-de-la-nuit.mjs). The measures of time play on PC3 too, unless the
398
+ # flow declares a job that plays them (`tests-de-nuit --mesures`, scripts/flux-de-la-nuit.mjs,
399
+ # the flow of Grillhouse): then the verdict of its job, read for the commit of the night, counts.
400
+ # The last green is set only when the measures were played and are green, by PC3 or by that job.
370
401
  local sur_pc2=0 tranches=
371
402
  if grep -q "\bpc2\b" "$copie/.github/workflows/nuit.yml" 2>/dev/null; then
372
403
  sur_pc2=1
@@ -8,8 +8,13 @@
8
8
  // started) counts as not played and plays whole again.
9
9
  // - A tranche that runs, or waits for less than 60 minutes, stays at PC2.
10
10
  // - The statement says which tranches played where: `pc2` the finished ones, `pc3` the replayed.
11
+ // - The measures of time: when the project's flow declares a job that plays them (`mesures`, see
12
+ // scripts/flux-de-la-nuit.mjs), the statement says its state (`mesures`: `verte`, `rouge`, `en-cours`,
13
+ // or `a-rejouer` when the job was interrupted or never came and the flow is over: PC3 plays them).
14
+ // - The flow read is the one of the commit the night plays: a run of another commit counts for none,
15
+ // and with no run of that commit every tranche, and the measures, play on PC3.
11
16
  //
12
- // node repli-de-la-nuit.mjs <dépôt owner/nom> <nombre de tranches> [<identifiant du flux>] the
17
+ // node repli-de-la-nuit.mjs <dépôt owner/nom> <nombre de tranches> [<identifiant du flux>] [<commit>] the
13
18
  // decision as JSON, the run cancelled (`gh run cancel`) when a tranche waited too long; a run that
14
19
  // waits for its group of concurrence, with no job yet, counts every tranche as not started
15
20
  import { spawnSync } from 'node:child_process';
@@ -19,20 +24,29 @@ import path from 'node:path';
19
24
  /** The minutes a tranche may wait for its job to start before PC3 plays it. */
20
25
  export const ATTENTE_MAX_MINUTES = 60;
21
26
 
27
+ const MESURES = /^mesures\b/;
22
28
  const TRANCHE = /^tranches\b.*?(\d+)\)\s*$/;
23
29
  // The conclusions of a job that started or was cancelled without finishing its tranche.
24
30
  const INTERROMPUES = new Set(['cancelled', 'skipped', 'startup_failure']);
25
31
 
26
32
  /**
27
33
  * The decision on the tranches of a Nuit flow.
28
- * @param {{ jobs: { name: string, status: string, conclusion: string | null, startedAt: string | null }[], heureDuFlux: string, maintenant: string }} o
34
+ * @param {{ jobs: { name: string, status: string, conclusion: string | null, startedAt: string | null }[], heureDuFlux: string, maintenant: string, fluxTermine?: boolean }} o
29
35
  * `jobs` the jobs of the run as `gh run view --json jobs` gives them, `heureDuFlux` the hour the
30
- * flow was created, `maintenant` the present hour, both ISO.
31
- * @returns {{ aRejouer: number[], aAnnuler: number[], enAttente: number[], pc2: number[], pc3: number[] }}
36
+ * flow was created, `maintenant` the present hour, both ISO, `fluxTermine` whether the run is over.
37
+ * @returns {{ aRejouer: number[], aAnnuler: number[], enAttente: number[], pc2: number[], pc3: number[], mesures: 'verte' | 'rouge' | 'en-cours' | 'a-rejouer' }}
32
38
  */
33
- export function choisirLeRepli({ jobs, heureDuFlux, maintenant }) {
39
+ export function choisirLeRepli({ jobs, heureDuFlux, maintenant, fluxTermine = false }) {
34
40
  const attente = Date.parse(maintenant) - Date.parse(heureDuFlux);
35
- const d = { aRejouer: [], aAnnuler: [], enAttente: [], enCours: [], rouges: [], pc2: [], pc3: [] };
41
+ const d = {
42
+ aRejouer: [],
43
+ aAnnuler: [],
44
+ enAttente: [],
45
+ enCours: [],
46
+ rouges: [],
47
+ pc2: [],
48
+ pc3: [],
49
+ };
36
50
  const tranches = jobs
37
51
  .map(j => ({ j, n: Number(TRANCHE.exec(j.name)?.[1]) }))
38
52
  .filter(({ n }) => Number.isInteger(n) && n > 0)
@@ -58,9 +72,29 @@ export function choisirLeRepli({ jobs, heureDuFlux, maintenant }) {
58
72
  }
59
73
  }
60
74
  d.pc3 = [...d.aRejouer];
75
+ d.mesures = etatDesMesures(
76
+ jobs.find(j => MESURES.test(j.name)),
77
+ d.aAnnuler.length > 0 || fluxTermine
78
+ );
61
79
  return d;
62
80
  }
63
81
 
82
+ // The state of the measures job <j> of the flow: its verdict once finished, `en-cours` while it
83
+ // waits or runs, `a-rejouer` when it was interrupted, or never came and <termine> (the flow is over
84
+ // or cancelled).
85
+ function etatDesMesures(j, termine) {
86
+ if (!j) {
87
+ return termine ? 'a-rejouer' : 'en-cours';
88
+ }
89
+ if (j.status !== 'completed') {
90
+ return termine ? 'a-rejouer' : 'en-cours';
91
+ }
92
+ if (INTERROMPUES.has(j.conclusion ?? '')) {
93
+ return 'a-rejouer';
94
+ }
95
+ return j.conclusion === 'success' ? 'verte' : 'rouge';
96
+ }
97
+
64
98
  function gh(args) {
65
99
  const r = spawnSync('gh', args, { encoding: 'utf8' });
66
100
  if (r.status !== 0) {
@@ -69,41 +103,78 @@ function gh(args) {
69
103
  return r.stdout;
70
104
  }
71
105
 
106
+ /**
107
+ * The id of the latest Nuit run of <commit> (any latest run when <commit> is empty), undefined when
108
+ * the flow has none for it.
109
+ */
110
+ function fluxDuCommit(depot, commit) {
111
+ const runs = JSON.parse(
112
+ gh([
113
+ 'run',
114
+ 'list',
115
+ '-R',
116
+ depot,
117
+ '--workflow',
118
+ 'nuit.yml',
119
+ '--limit',
120
+ '20',
121
+ '--json',
122
+ 'databaseId,headSha',
123
+ ])
124
+ );
125
+ return runs.find(r => !commit || r.headSha === commit)?.databaseId;
126
+ }
127
+
72
128
  if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
73
- const [depot, tranches, identifiant] = process.argv.slice(2);
74
- const vide = { aRejouer: [], aAnnuler: [], enAttente: [], enCours: [], rouges: [], pc2: [], pc3: [] };
129
+ const [depot, tranches, identifiant, commit] = process.argv.slice(2);
130
+ const n = Number(tranches) || 0;
131
+ // No run of the commit the night plays: the flow played none of it, PC3 plays every tranche.
132
+ const rien = () => {
133
+ const toutes = Array.from({ length: n }, (_, i) => i + 1);
134
+ return {
135
+ aRejouer: toutes,
136
+ aAnnuler: [],
137
+ enAttente: [],
138
+ enCours: [],
139
+ rouges: [],
140
+ pc2: [],
141
+ pc3: toutes,
142
+ mesures: 'a-rejouer',
143
+ };
144
+ };
75
145
  try {
76
- const id =
77
- identifiant ||
78
- JSON.parse(
79
- gh(['run', 'list', '-R', depot, '--workflow', 'nuit.yml', '--limit', '1', '--json', 'databaseId'])
80
- )[0]?.databaseId;
146
+ const id = identifiant || fluxDuCommit(depot, commit);
81
147
  if (!id) {
82
- process.stdout.write(`${JSON.stringify(vide)}\n`);
148
+ process.stdout.write(`${JSON.stringify({ ...rien(), flux: null })}\n`);
83
149
  } else {
84
150
  const run = JSON.parse(
85
- gh(['run', 'view', String(id), '-R', depot, '--json', 'jobs,createdAt,status'])
151
+ gh(['run', 'view', String(id), '-R', depot, '--json', 'jobs,createdAt,status,headSha'])
86
152
  );
87
- // A run that waits for the group of concurrence has no job yet: each of its tranches is
88
- // a job not started.
89
- const jobs =
90
- run.jobs.length === 0 && run.status !== 'completed'
91
- ? Array.from({ length: Number(tranches) || 0 }, (_, i) => ({
92
- name: `tranches (26.x, ${i + 1})`,
93
- status: 'queued',
94
- conclusion: null,
95
- startedAt: null,
96
- }))
97
- : run.jobs;
98
- const d = choisirLeRepli({
99
- jobs,
100
- heureDuFlux: run.createdAt,
101
- maintenant: new Date().toISOString(),
102
- });
103
- if (d.aAnnuler.length > 0) {
104
- gh(['run', 'cancel', String(id), '-R', depot]);
153
+ if (commit && run.headSha !== commit) {
154
+ process.stdout.write(`${JSON.stringify({ ...rien(), flux: null })}\n`);
155
+ } else {
156
+ // A run that waits for the group of concurrence has no job yet: each of its tranches is
157
+ // a job not started.
158
+ const jobs =
159
+ run.jobs.length === 0 && run.status !== 'completed'
160
+ ? Array.from({ length: Number(tranches) || 0 }, (_, i) => ({
161
+ name: `tranches (26.x, ${i + 1})`,
162
+ status: 'queued',
163
+ conclusion: null,
164
+ startedAt: null,
165
+ }))
166
+ : run.jobs;
167
+ const d = choisirLeRepli({
168
+ jobs,
169
+ heureDuFlux: run.createdAt,
170
+ maintenant: new Date().toISOString(),
171
+ fluxTermine: run.status === 'completed',
172
+ });
173
+ if (d.aAnnuler.length > 0) {
174
+ gh(['run', 'cancel', String(id), '-R', depot]);
175
+ }
176
+ process.stdout.write(`${JSON.stringify({ ...d, flux: id })}\n`);
105
177
  }
106
- process.stdout.write(`${JSON.stringify({ ...d, flux: id })}\n`);
107
178
  }
108
179
  } catch (e) {
109
180
  process.stderr.write(`⛔ repli de la nuit : ${e.message}\n`);
@@ -45,6 +45,7 @@ export {
45
45
  } from './taches-du-graphe.mjs';
46
46
  export { luUneFois } from './lecture-unique.mjs';
47
47
  export { avecLeFichierDuPoste } from './fichier-du-poste.mjs';
48
+ export { fluxDuProjetJoueLesMesures } from './flux-de-la-nuit.mjs';
48
49
  export { BASE_DU_LOT, CHANGEMENTS, DEPUIS_LE_VERT, garderLeVert, mesure } from './dernier-vert.mjs';
49
50
  export {
50
51
  consignerLesRegressions,
@@ -3241,6 +3241,11 @@ export async function tableau(
3241
3241
  };
3242
3242
  }
3243
3243
 
3244
+ // The output of the command for a board: the texts of its lines, one per line (--texte), or its JSON.
3245
+ export function sortieDeLaCommande(t, enTexte) {
3246
+ return enTexte ? `${t.lignes.map(l => l.texte).join('\n')}\n` : JSON.stringify(t);
3247
+ }
3248
+
3244
3249
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
3245
3250
  // The arguments other than --texte and --suivre are the folders of the other projects.
3246
3251
  const projets = process.argv
@@ -3272,11 +3277,7 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
3272
3277
  process.stdout.on('error', fin);
3273
3278
  } else {
3274
3279
  void tableau(process.cwd(), { projets }).then(t =>
3275
- process.stdout.write(
3276
- process.argv.includes('--texte')
3277
- ? `${t.lignes.map(l => l.texte).join('\n')}\n`
3278
- : JSON.stringify(t)
3279
- )
3280
+ process.stdout.write(sortieDeLaCommande(t, process.argv.includes('--texte')))
3280
3281
  );
3281
3282
  }
3282
3283
  }
@@ -94,6 +94,9 @@ export function lancerBd(args, cwd) {
94
94
  const enfant = spawn('bd', args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
95
95
  let stdout = '';
96
96
  let stderr = '';
97
+ // Decoded as a stream: a character cut between two chunks stays whole.
98
+ enfant.stdout.setEncoding('utf8');
99
+ enfant.stderr.setEncoding('utf8');
97
100
  enfant.stdout.on('data', d => (stdout += d));
98
101
  enfant.stderr.on('data', d => (stderr += d));
99
102
  enfant.on('error', e => resolve({ status: 127, stdout, stderr: e.message }));
@@ -596,6 +596,11 @@ function decider({ etat, memoire = {}, ticket, reprend = false, marqueurs = {} }
596
596
  return true;
597
597
  };
598
598
  const plan = ticket.paquets.join(', ');
599
+ // The plan skips the testwriter (« comportement inchangé » he was not asked for, or no package
600
+ // playing tests): a sending of the red to him leads nowhere, whatever the checks between two.
601
+ const inchangeSansTestwriter = () =>
602
+ ticket.sorte?.comportement === 'inchangé' && !m('testwriterDemande');
603
+ const testwriterSaute = () => inchangeSansTestwriter() || Boolean(lire('sansTests'));
599
604
 
600
605
  // After the plan: the gesture of a mechanical ticket, the developpeur of a plan without tests,
601
606
  // else the testwriter.
@@ -883,7 +888,8 @@ function decider({ etat, memoire = {}, ticket, reprend = false, marqueurs = {} }
883
888
  // carried ('' for none), null after green checks: the same output twice in a row is a
884
889
  // round trip without a new fact.
885
890
  const sortie = m('controlesRouges') ?? '';
886
- if (m('renvoiAuTestwriter') === sortie) {
891
+ const dejaRenvoye = m('renvoiAuTestwriter') !== null;
892
+ if (m('renvoiAuTestwriter') === sortie || (dejaRenvoye && testwriterSaute())) {
887
893
  if (lire('empreinte') === avant) {
888
894
  inscrire({ etape: CODE, inchange: true }, 'inchange');
889
895
  }
@@ -1105,7 +1111,9 @@ function decider({ etat, memoire = {}, ticket, reprend = false, marqueurs = {} }
1105
1111
  if (meles) {
1106
1112
  maj.rienALivrer = rien;
1107
1113
  } else {
1108
- maj.renvoiAuTestwriter = null;
1114
+ if (!inchangeSansTestwriter()) {
1115
+ maj.renvoiAuTestwriter = null;
1116
+ }
1109
1117
  tentative = 0;
1110
1118
  }
1111
1119
  // The report of the reds of the plan, which go to the developpeur when a command of the
@@ -1241,8 +1249,11 @@ function decider({ etat, memoire = {}, ticket, reprend = false, marqueurs = {} }
1241
1249
  return arret('a-repasser', null);
1242
1250
  }
1243
1251
  ecrireRapport('controles', `${k.resume}.`, resultat('vert'), `${k.resume}.${k.avertissements}`);
1244
- // Green checks: a sending of the developpeur to the testwriter may come again.
1245
- maj.renvoiAuTestwriter = null;
1252
+ // Green checks: a sending of the developpeur to the testwriter may come again, unless the
1253
+ // plan skips the testwriter.
1254
+ if (!inchangeSansTestwriter()) {
1255
+ maj.renvoiAuTestwriter = null;
1256
+ }
1246
1257
  const entierement = !reprise && !regeneration;
1247
1258
  if (!passeFinale) {
1248
1259
  if (entierement && k.empreinte) {