@@ -118,24 +118,27 @@ export async function attemptBuild(
118
118
lastAttempt = attempt ;
119
119
}
120
120
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
+ }
137
139
138
140
// Attempt to repair axe testing.
141
+ // This only runs when the last build completed & serving did run.
139
142
let axeRepairAttempts = 0 ;
140
143
while (
141
144
lastAttempt . serveTestingResult &&
@@ -174,6 +177,15 @@ export async function attemptBuild(
174
177
progress
175
178
) ;
176
179
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
+
177
189
// Re-run serving & tests after Axe repair.
178
190
// This allows us to check if we fixed the violations.
179
191
attempt . serveTestingResult = await serveAndTestApp (
@@ -191,9 +203,6 @@ export async function attemptBuild(
191
203
userJourneyAgentTaskInput
192
204
) ;
193
205
194
- attemptDetails . push ( attempt ) ;
195
- lastAttempt = attempt ;
196
-
197
206
if ( attempt . serveTestingResult . axeViolations ?. length === 0 ) {
198
207
progress . log (
199
208
rootPromptDef ,
0 commit comments