Skip to content

Commit 3efd15f

Browse files
committed
feat: support disabling serving
This is useful when environments don't have a server ready (or are targeting other languages without a web UI).
1 parent 9cfd7f5 commit 3efd15f

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

runner/orchestration/executors/executor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const executorSchema = z.object({
7272
)
7373
.describe('Call this function while the server is running'),
7474
]),
75-
z.promise(z.custom<ServeTestingResult>()),
75+
z.promise(z.union([z.custom<ServeTestingResult>(), z.null()])),
7676
)
7777
.nullable(),
7878
executeProjectTests: z.function(

runner/orchestration/executors/local-executor-config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ export const localExecutorConfigSchema = z.strictObject({
2121
buildCommand: z.string().optional(),
2222
/**
2323
* Command to run when starting a development server inside the app.
24-
* Defaults to `<package manager> run start --port 0`.
24+
*
25+
* When `undefined`, defaults to `<package manager> run start --port 0`.
26+
* When `null`, the app has no server and no runtime testing will occur.
2527
*/
26-
serveCommand: z.string().optional(),
28+
serveCommand: z.string().optional().nullable(),
2729
/**
2830
* Optional command for executing project tests.
2931
*/

runner/orchestration/executors/local-executor.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {callWithTimeout} from '../../utils/timeout.js';
2727
import {executeCommand} from '../../utils/exec.js';
2828
import {cleanupBuildMessage} from '../../workers/builder/worker.js';
2929
import {combineAbortSignals} from '../../utils/abort-signal.js';
30+
import {ServeTestingResult} from '../../workers/serve-testing/worker-types.js';
3031

3132
let uniqueIDs = 0;
3233

@@ -172,13 +173,18 @@ export class LocalExecutor implements Executor {
172173
} satisfies TestExecutionResult;
173174
}
174175

175-
async serveWebApplication<T>(
176+
async serveWebApplication(
176177
_id: EvalID,
177178
appDirectoryPath: string,
178179
rootPromptDef: RootPromptDefinition,
179180
progress: ProgressLogger,
180-
logicWhileServing: (serveUrl: string) => Promise<T>,
181-
): Promise<T> {
181+
logicWhileServing: (serveUrl: string) => Promise<ServeTestingResult>,
182+
): Promise<ServeTestingResult | null> {
183+
// Serve testing is explicitly disabled.
184+
if (this.config.serveCommand === null) {
185+
return null;
186+
}
187+
182188
return await serveApp(
183189
this.getServeCommand(),
184190
rootPromptDef,
@@ -207,7 +213,7 @@ export class LocalExecutor implements Executor {
207213
}
208214

209215
getServeCommand(): string {
210-
if (this.config.serveCommand !== undefined) {
216+
if (this.config.serveCommand != null) {
211217
return this.config.serveCommand;
212218
}
213219

runner/orchestration/serve-testing-worker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ export async function serveAndTestApp(
8787
},
8888
);
8989

90+
// An executor might define `serveWebApplication` but conditionally decide
91+
// that no web application can be started/served.
92+
if (result === null) {
93+
return null;
94+
}
95+
9096
if (result.errorMessage === undefined) {
9197
progress.log(rootPromptDef, 'success', 'Validation of running app is successful');
9298
} else {

0 commit comments

Comments
 (0)