Run every step under -EUTF-8, so the image's locale cannot clear the labels
What does this MR do and why?
Each project's Duo session image decides the locale. An image that sets none, such as debian:bookworm-slim, has Ruby read files as US-ASCII. The MR Risk Labeler's decide_labels reads answer.txt with a bare File.read, so an answer holding a non-ASCII character, as in docs: low — only a README typo, routes to clear. The run takes the labels off instead of applying them.
bin/compile now passes -EUTF-8 to every ruby step it emits, in every flow it compiles: nine in flows/mr-risk.yml and five in flows/flow.yml. Each step reads files as UTF-8 whatever the image sets, so a project's setup script no longer has to export LANG=C.UTF-8 for the flow. flows/deps.yml, which bin/compile no longer renders and the sync deletes at the next tag, stays as it is.
-EUTF-8 sets the external encoding alone, which is what a UTF-8 locale already gives, so the steps behave in every image as they do in one with a UTF-8 locale. -EUTF-8:UTF-8 would set an internal encoding as well, and then every write transcodes and a write of binary bytes raises. The integration suites pass under either flag; -EUTF-8 is the one that changes nothing for an image that already has a UTF-8 locale.
Also in this MR:
docs/specs/mr-risk.mdgains the platform constraint: the image decides the locale and may set none. The upstream check's code keeps its ASCII-only rule, now because every release runs the copy at HEAD, and one without the flag still reads it under the image's locale.README.mdsays the image needs no locale.- The comments in the shared
decide_labelsandbuild_notethat said a bare read in the runner is US-ASCII are gone, since under the flag it is not. The explicitencoding: "UTF-8"reads stay.bin/compilestrips comments, so this changes nothing inflows/.
How to check
make check, run with LANG=C.UTF-8 LC_ALL=C.UTF-8.
- The new example in
spec/mr-risk/integrationruns the compileddecide_labelsunderLC_ALL=C, withLANG,LC_CTYPEandRUBYOPTcleared. Againstmain'sflows/mr-risk.ymlit fails, writingclear. Against this branch it writesapplyand keeps the reason, em dash included. spec/support/flow.rbnow matches the packed command with the flag in it, sospec/flow's pass over every embedded script fails if a step loses it.- Outside the suite, every step the two integration suites run was forced under
LC_ALL=C. All 22 mr-risk and 16 flow examples pass on this branch.
On main |
With this MR | |
|---|---|---|
flows/mr-risk.yml |
38668 bytes, 2292 under the cap | 38740 bytes, 2220 under the cap |
flows/flow.yml |
38430 bytes, 2530 under the cap | 38470 bytes, 2490 under the cap |
That is eight bytes, -EUTF-8, per step. The packed scripts are byte for byte the same.
Relation to !101 (closed)
!101 (closed) reads the inputs of classify_change, choose_thread and extract_iid as UTF-8, one read at a time. Its three new spec/flow examples fail against main's flows and pass against this branch's with none of its src/ changes, so once this merges its per-read encodings are redundant. Its two spec/deps examples no longer apply, since !119 (merged) removed the deps flow.
Notes
- Not changed:
UPSTREAM_STAND_INinevals/lib/eval_flow.rbrunsruby -rfileutils -eand stripstier_model.txtfrom a bare read.bin/compiledoes not emit it. It replaces a flow'sfetch_upstreamin an eval run, and no flow an eval suite runs has one yet. - The pre-commit
prettierhook passes on the two flows, and the other hooks pass.