You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(workflows): add integrity heuristic and per-file compile loop to recompile-safe-output-fixtures (#868)
The previous iteration of the workflow silently no-op'd on release v0.31.1
because `ado-aw compile tests/safe-outputs/` exits 0 with "0 compiled,
N skipped" when given a directory argument (issue #867). It also did not
catch the case where the on-disk lock files were stamped by a non-release
build, which is what triggered the manual recompile in the first place.
This change:
- Replaces `ado-aw compile tests/safe-outputs/` with a per-file loop
`for md in tests/safe-outputs/*.md; do ado-aw compile --force "$md"; done`
run from the repo root. `--force` is required to bypass the GitHub-remote
guard inside this repo.
- Adds Step 2.5 (pre-flight `ado-aw check`) to detect drift between the
released binary and the committed lock files independent of any version
string comparison.
- Adds Step 3.5 (post-compile sanity) that re-runs `ado-aw check` against
every recompiled lock file and hard-fails with `report-incomplete` if
any still report drift.
- Updates the no-op decision logic so the agent only emits `noop` when both
the git diff is empty AND pre-flight integrity passed for every file.
An empty diff plus failed integrity now emits `report-incomplete`.
- Updates the PR body and "When NOT to open a PR" guidance to reference
the new integrity signals.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: .github/workflows/recompile-safe-output-fixtures.md
+65-5Lines changed: 65 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,17 +125,63 @@ chmod +x ado-aw
125
125
126
126
If the version printed by `./ado-aw --version` does not contain `BARE`, abort with `missing-data` describing the mismatch — you have downloaded the wrong asset.
127
127
128
+
## Step 2.5 — Pre-flight integrity check on the existing lock files
129
+
130
+
Before recompiling, run `ado-aw check` against every existing `tests/safe-outputs/*.lock.yml` using the **released** binary. The `check` subcommand recompiles each pipeline from its source `.md` and compares against the committed lock file; a non-zero exit means the on-disk lock file does **not** match what the released compiler would produce — i.e. it drifted (for example because someone recompiled with a dev build off `main` and merged that, or because a release shipped output changes that were never propagated). This is a primary signal that we need to recompile, independent of whether the source `.md` changed.
131
+
132
+
```bash
133
+
set -euo pipefail
134
+
cd"$GITHUB_WORKSPACE"
135
+
mkdir -p /tmp/gh-aw/agent
136
+
:> /tmp/gh-aw/agent/integrity-failures.txt
137
+
INTEGRITY_FAIL_COUNT=0
138
+
forlockin tests/safe-outputs/*.lock.yml;do
139
+
if /tmp/gh-aw/agent/ado-aw-bin/ado-aw check "$lock" \
Record the failure count and the failing-file list — both go in the PR body (Step 6) when a PR is opened. Do **not** abort on integrity failure here; this step is diagnostic only. Recompilation in Step 3 is what fixes the drift. If a single per-file check log shows an error other than a content mismatch (for example a missing source file, a codemod-required source, or an internal compiler error), include the relevant log excerpt in the PR body or — if recompile in Step 3 cannot succeed either — fall back to `report-incomplete` from Step 3.
152
+
128
153
## Step 3 — Recompile every fixture in `tests/safe-outputs/`
129
154
130
-
The `tests/safe-outputs/README.md`documents the idempotent recompile command. Run it under strict shell mode so a single fixture failure aborts the whole run instead of leaving partial output on disk:
155
+
`ado-aw compile` accepts a single `.md`path or no arguments (cwd autodiscovery). It does **not** accept a directory argument — passing one silently produces `0 compiled, N skipped`, which is exactly the failure mode that took down [run 27020309715](https://github.com/githubnext/ado-aw/actions/runs/27020309715) and is tracked in [issue #867](https://github.com/githubnext/ado-aw/issues/867). Loop per-file from the repo root instead, and pass `--force` to bypass the GitHub-remote guard (required when running inside `githubnext/ado-aw` itself):
131
156
132
157
```bash
133
158
set -euo pipefail
134
159
cd"$GITHUB_WORKSPACE"
135
-
/tmp/gh-aw/agent/ado-aw-bin/ado-aw compile tests/safe-outputs/ 2>&1| tee /tmp/gh-aw/agent/recompile.log
160
+
:> /tmp/gh-aw/agent/recompile.log
161
+
formdin tests/safe-outputs/*.md;do
162
+
echo">>> compiling $md"| tee -a /tmp/gh-aw/agent/recompile.log
163
+
/tmp/gh-aw/agent/ado-aw-bin/ado-aw compile --force "$md"2>&1| tee -a /tmp/gh-aw/agent/recompile.log
164
+
done
136
165
```
137
166
138
-
If the compile exits non-zero, do **not** open a PR with partial output. Emit `report-incomplete` with the last ~80 lines of `/tmp/gh-aw/agent/recompile.log` so a maintainer can investigate. Stop.
167
+
If any per-file compile exits non-zero, the script aborts via `set -euo pipefail` and partial output is left on disk. Do **not** open a PR in that state — emit `report-incomplete` with the last ~80 lines of `/tmp/gh-aw/agent/recompile.log` so a maintainer can investigate. Stop.
168
+
169
+
## Step 3.5 — Post-compile sanity check
170
+
171
+
After recompiling, re-run `ado-aw check` against every lock file using the same released binary. Every check **must** now pass — if any still fails, our just-produced output disagrees with itself, which means the compile silently mis-handled something. That is a hard failure:
|| { echo"post-compile integrity STILL failing for $lock"; cat "/tmp/gh-aw/agent/postcheck-$(basename "$lock").log";exit 1; }
180
+
done
181
+
echo"all lock files pass integrity check against ado-aw ${TAG}"
182
+
```
183
+
184
+
If this step fails, emit `report-incomplete` with the offending file name and the tail of its postcheck log; do **not** open a PR with broken integrity.
If `/tmp/gh-aw/agent/recompile-status.txt` is empty, the fixtures already match the released version — emit `noop` with the message `"tests/safe-outputs/ already compiled against ado-aw ${TAG}"` and stop. Do **not** open an empty PR.
195
+
If `/tmp/gh-aw/agent/recompile-status.txt` is empty **and**`INTEGRITY_FAIL_COUNT` from Step 2.5 was `0`, the fixtures already match the released version — emit `noop` with the message `"tests/safe-outputs/ already compiled against ado-aw ${TAG} and all integrity checks pass"` and stop. Do **not** open an empty PR.
196
+
197
+
If `/tmp/gh-aw/agent/recompile-status.txt` is empty **but**`INTEGRITY_FAIL_COUNT > 0`, this is contradictory — recompile produced no diff yet `check` reported drift. That should not happen in practice (a passing `check` and a no-op `compile` against the same source and binary must agree). Emit `report-incomplete` with the contents of `/tmp/gh-aw/agent/integrity-failures.txt` and the relevant `check-*.log` files so a maintainer can investigate. Stop.
150
198
151
199
If non-empty, inspect the diff briefly to make sure only `.lock.yml` files under `tests/safe-outputs/` changed:
152
200
@@ -183,14 +231,24 @@ The `safe-outputs.create-pull-request.title-prefix` is configured to `chore(work
183
231
184
232
Bumps the `version` field in every `tests/safe-outputs/*.lock.yml` metadata marker from `${OLD_VER}` to `${NEW_VER}`, picking up any compile-output changes shipped in [`ado-aw ${TAG}`](https://github.com/githubnext/ado-aw/releases/tag/${TAG}).
185
233
234
+
### Pre-flight integrity check
235
+
236
+
Before recompiling, `ado-aw check` was run against every existing lock file using the released `${TAG}` binary:
237
+
238
+
-**Integrity failures**: `${INTEGRITY_FAIL_COUNT}` of N files
239
+
240
+
<ifINTEGRITY_FAIL_COUNT > 0, include a fenced block listing the contents of `/tmp/gh-aw/agent/integrity-failures.txt`>
241
+
186
242
### Files updated
187
243
188
244
<list of files from `git diff --name-only -- tests/safe-outputs/`, one per line in a fenced block>
189
245
190
246
### How this was produced
191
247
192
248
- Downloaded `ado-aw-linux-x64` from the `${TAG}` release and verified its SHA256 against `checksums.txt`.
249
+
- Ran `ado-aw check tests/safe-outputs/*.lock.yml` against the released binary to detect drift (see counts above).
193
250
- Ran `ado-aw compile tests/safe-outputs/` from the repo root.
251
+
- Re-ran `ado-aw check` against every regenerated lock file; all passed.
194
252
- The `allowed-files` glob in this workflow restricts the diff to `tests/safe-outputs/**/*.lock.yml`.
195
253
196
254
### Reviewer checklist
@@ -212,7 +270,9 @@ The `safe-outputs.close-pull-request` configuration on this workflow targets any
212
270
- Release assets never appear within the bounded retry window (Step 2) — emit `report-incomplete`.
213
271
-`ado-aw --version` does not contain `BARE` (Step 2) — emit `missing-data`.
0 commit comments