Skip to content

Commit 7165916

Browse files
Test Userclaude
andcommitted
ci(4311): list fmt-affected files in job summary on drift
The cargo fmt gate already existed in ci-pr.yml, ci-main.yml, and .gitea/workflows/native-ci.yml and was correctly wired into the merge gate (ci-pr.yml:636). The one unmet AC of #4311 was 'lists the affected files in the job summary' -- previously the step dumped only a raw unified diff. Replace the bare one-line Rustfmt Check with a step that captures the diff, preserves the exit code (any non-zero cargo fmt exit propagates), and on failure writes a deduplicated, repo-relative affected-files list to $GITHUB_STEP_SUMMARY. Behaviour-preserving: still fails on drift, still passes when clean (no summary written on the clean path). Mirrored identically into ci-main.yml. The native .gitea workflow is left untouched (Gitea Actions syntax, no step-summary support; its gate goal of failing on drift is already met). Verification (this session): - drift path: exit 1, summary lists 4 files (deduped from 13 hunks), no stray commas (rendered output cat -A checked) - clean path: exit 0, no summary written - bash -n on extracted shipped body: SYNTAX OK - python3 yaml.safe_load on both files: VALID - rch exec exit-code propagation verified (true->0, false->1, fmt drift->1) Out of scope (surgical): pre-existing fmt drift (#3013, owned by open PR #3018) is NOT reformatted -- only the gate UX is changed. Refs #4311 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bb8062a commit 7165916

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

.github/workflows/ci-main.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,28 @@ jobs:
127127
/home/alex/.local/bin/sccache --zero-stats
128128
129129
- name: Rustfmt Check
130-
run: /home/alex/.local/bin/rch exec -- cargo fmt --all -- --check
130+
# Fail on drift (#4311) and list affected files in the job summary.
131+
# Exit code is preserved: any non-zero cargo fmt exit propagates.
132+
run: |
133+
set +e
134+
diff_output="$(/home/alex/.local/bin/rch exec -- cargo fmt --all -- --check 2>&1)"
135+
fmt_exit=$?
136+
if [ "$fmt_exit" -ne 0 ]; then
137+
affected="$(printf '%s\n' "$diff_output" | grep '^Diff in ' | sed -E 's|^Diff in ||; s|:[0-9]+: *$||' | sort -u)"
138+
rel="$(printf '%s\n' "$affected" | sed "s|^${GITHUB_WORKSPACE:-$PWD}/||")"
139+
{
140+
echo "## 🎨 cargo fmt drift detected"
141+
echo ""
142+
echo "Run \`cargo fmt --all\` locally and commit the result."
143+
echo ""
144+
echo "**Affected files ($(printf '%s\n' "$rel" | grep -c .)):**"
145+
echo ""
146+
printf -- '- \`%s\`\n' $rel
147+
echo ""
148+
} >> "$GITHUB_STEP_SUMMARY"
149+
printf '%s\n' "$diff_output"
150+
exit "$fmt_exit"
151+
fi
131152
132153
- name: Clippy Check
133154
# Soft-fail: terraphim_service registry crate has known compilation errors

.github/workflows/ci-pr.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,28 @@ jobs:
199199
/home/alex/.local/bin/sccache --zero-stats
200200
201201
- name: Rustfmt Check
202-
run: /home/alex/.local/bin/rch exec -- cargo fmt --all -- --check
202+
# Fail on drift (#4311) and list affected files in the job summary.
203+
# Exit code is preserved: any non-zero cargo fmt exit propagates.
204+
run: |
205+
set +e
206+
diff_output="$(/home/alex/.local/bin/rch exec -- cargo fmt --all -- --check 2>&1)"
207+
fmt_exit=$?
208+
if [ "$fmt_exit" -ne 0 ]; then
209+
affected="$(printf '%s\n' "$diff_output" | grep '^Diff in ' | sed -E 's|^Diff in ||; s|:[0-9]+: *$||' | sort -u)"
210+
rel="$(printf '%s\n' "$affected" | sed "s|^${GITHUB_WORKSPACE:-$PWD}/||")"
211+
{
212+
echo "## 🎨 cargo fmt drift detected"
213+
echo ""
214+
echo "Run \`cargo fmt --all\` locally and commit the result."
215+
echo ""
216+
echo "**Affected files ($(printf '%s\n' "$rel" | grep -c .)):**"
217+
echo ""
218+
printf -- '- \`%s\`\n' $rel
219+
echo ""
220+
} >> "$GITHUB_STEP_SUMMARY"
221+
printf '%s\n' "$diff_output"
222+
exit "$fmt_exit"
223+
fi
203224
204225
- name: Clippy Check
205226
run: /home/alex/.local/bin/rch exec -- cargo clippy --workspace --all-targets --features zlob -- -D warnings

0 commit comments

Comments
 (0)