Skip to content

Commit 914c8fc

Browse files
committed
fix: ensure Axe attempts do not override build result
1 parent 6134260 commit 914c8fc

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

runner/orchestration/build-serve-loop.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,27 @@ export async function attemptBuild(
118118
lastAttempt = attempt;
119119
}
120120

121-
// Now that we got a working app, try to serve it and collect
122-
// findings from the running app.
123-
lastAttempt.serveTestingResult = await serveAndTestApp(
124-
evalID,
125-
gateway,
126-
directory,
127-
env,
128-
rootPromptDef,
129-
workerConcurrencyQueue,
130-
abortSignal,
131-
progress,
132-
skipScreenshots,
133-
skipAxeTesting,
134-
enableAutoCsp,
135-
userJourneyAgentTaskInput
136-
);
121+
if (lastAttempt.buildResult.status === BuildResultStatus.SUCCESS) {
122+
// Now that we got a working app, try to serve it and collect
123+
// findings from the running app.
124+
lastAttempt.serveTestingResult = await serveAndTestApp(
125+
evalID,
126+
gateway,
127+
directory,
128+
env,
129+
rootPromptDef,
130+
workerConcurrencyQueue,
131+
abortSignal,
132+
progress,
133+
skipScreenshots,
134+
skipAxeTesting,
135+
enableAutoCsp,
136+
userJourneyAgentTaskInput
137+
);
138+
}
137139

138140
// Attempt to repair axe testing.
141+
// This only runs when the last build completed & serving did run.
139142
let axeRepairAttempts = 0;
140143
while (
141144
lastAttempt.serveTestingResult &&
@@ -174,6 +177,15 @@ export async function attemptBuild(
174177
progress
175178
);
176179

180+
attemptDetails.push(attempt);
181+
lastAttempt = attempt;
182+
183+
// If we somehow introduced build errors via the Axe repair loop,
184+
// then we should abort and let that last attempt have "build errors".
185+
if (attempt.buildResult.status !== BuildResultStatus.SUCCESS) {
186+
break;
187+
}
188+
177189
// Re-run serving & tests after Axe repair.
178190
// This allows us to check if we fixed the violations.
179191
attempt.serveTestingResult = await serveAndTestApp(
@@ -191,9 +203,6 @@ export async function attemptBuild(
191203
userJourneyAgentTaskInput
192204
);
193205

194-
attemptDetails.push(attempt);
195-
lastAttempt = attempt;
196-
197206
if (attempt.serveTestingResult.axeViolations?.length === 0) {
198207
progress.log(
199208
rootPromptDef,

0 commit comments

Comments
 (0)