-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodal.ts
More file actions
29 lines (23 loc) · 760 Bytes
/
modal.ts
File metadata and controls
29 lines (23 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { App } from "modal";
import type { TestRunner } from ".";
export class ModalHelloWorld implements TestRunner {
name = "Hello World";
provider = "modal" as const;
exec = async () => {
const app = await App.lookup("sandbench", { createIfMissing: true });
const start = Date.now();
const image = await app.imageFromRegistry("alpine:3.21");
const sb = await app.createSandbox(image);
const res = await sb.exec(["echo", "Hello World from code!"]);
const output = await res.stdout.readText();
const error = await res.stderr.readText();
const end = Date.now();
await sb.terminate();
return {
success: (await sb.wait()) === 0,
output,
error,
runningTimeMs: end - start,
};
};
}