Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"typecheck": "tsc --noEmit && tsc -p tsconfig.type-tests.json",
"typecheck:tests": "tsc -p tsconfig.tests.json",
"test:prep": "( cd ../kernel && sh ../ops/cargo.sh build ) && ( [ ! -d ../testdata/preflight ] || find ../testdata/preflight -name '*-cli' -type f -exec chmod +x {} + )",
"test": "npm run test:prep && npm run typecheck && npm run build && npm run typecheck:tests && vitest run",
"test": "sh scripts/test.sh",
"test:watch": "vitest"
},
"license": "UNLICENSED",
Expand Down
37 changes: 37 additions & 0 deletions sdk/scripts/prune-test-build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Drop the build outputs a test run does not need, to keep the propagated
// tree small in a cloud sandbox.
//
// Source maps only. Declaration files are deliberately NOT pruned: package.json
// declares `"types": "./dist/index.d.ts"`, so deleting them would leave the
// package's own declared type entry pointing at a file that `npm test` had just
// removed. Nothing in this repo breaks today -- every current in-repo consumer
// imports `.js` (`ops/probes/**`, `workflows/drive.yaml`,
// `workflows/drive-cloud.yaml`, `testdata/backlog-picker.flow.yaml`), and
// `surface` does not depend on the sdk -- but the next TypeScript consumer
// would hit a failure whose cause is "someone ran the tests", which is not a
// cost worth paying for the space. The file
// count that actually matters is `kernel/target/debug` at ~4900 files (see
// ops/cargo.sh); `dist` declarations are noise beside it.
import { readdir, rm } from "node:fs/promises";
import { resolve } from "node:path";

const generatedDirectories = [resolve(import.meta.dirname, "../dist")];

for (const directory of generatedDirectories) {
let entries;
try {
entries = await readdir(directory, { recursive: true, withFileTypes: true });
} catch (error) {
if (error.code === "ENOENT") continue;
throw error;
}

await Promise.all(
entries
.filter(
(entry) =>
entry.isFile() && entry.name.endsWith(".map"),
)
.map((entry) => rm(resolve(entry.parentPath, entry.name))),
);
}
10 changes: 10 additions & 0 deletions sdk/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -eu

trap 'node scripts/prune-test-build.mjs' EXIT

npm run test:prep
npm run typecheck
npm run build
npm run typecheck:tests
vitest run
Loading