Skip to content

Commit cae7bfe

Browse files
committed
ci: the packed-manifest check pins stand-in Lambda assets, like the publish job
The publish job adds prebuilt/handler-zip.json and prebuilt/video-image.json before verify:packed-manifests; the PR check did not, so a package could pass on the PR and fail at publish. The verifier now runs the same pin script on sparse stand-ins of release size when no pins exist, and removes them afterwards. It lives in the verifier, not a Build step, so the edit-accuracy input closure stays unchanged.
1 parent 1f7e346 commit cae7bfe

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎scripts/verify-packed-manifests.mjs‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
readFileSync,
1313
rmSync,
1414
statSync,
15+
truncateSync,
1516
writeFileSync,
1617
} from "node:fs";
1718
import { extname, join, posix } from "node:path";
@@ -605,15 +606,46 @@ function packAndVerifyWorkspace(workspace, packDir) {
605606
return { workspace, filename, packedPackage };
606607
}
607608

609+
const LAMBDA_PIN_ASSETS = [
610+
{ asset: "hyperframes-lambda-handler.zip", flags: [] },
611+
{ asset: "hyperframes-lambda-video-arm64.oci.tar", flags: ["--video-image"] },
612+
];
613+
614+
// The publish job pins the Lambda release assets before this check. Anywhere else, sparse stand-ins of release
615+
// size go through the same pin script, so the size check packs the file list a release publishes. Returns the cleanup.
616+
function pinStandInLambdaAssets() {
617+
const lambda = join(PACKAGES_DIR, "aws-lambda");
618+
if (existsSync(join(lambda, "prebuilt", "handler-zip.json"))) return () => {};
619+
mkdirSync(join(ROOT, "dist"), { recursive: true });
620+
const written = [];
621+
for (const { asset, flags } of LAMBDA_PIN_ASSETS) {
622+
const path = join(ROOT, "dist", asset);
623+
writeFileSync(path, "");
624+
truncateSync(path, 150_000_000);
625+
execFileSync("bun", [join(lambda, "scripts", "pin-handler-zip.ts"), ...flags], {
626+
cwd: ROOT,
627+
stdio: "ignore",
628+
});
629+
written.push(path, path.replace(/\.[^/]*$/, ".sha256"));
630+
}
631+
written.push(
632+
join(lambda, "prebuilt", "handler-zip.json"),
633+
join(lambda, "prebuilt", "video-image.json"),
634+
);
635+
return () => written.forEach((path) => rmSync(path, { force: true }));
636+
}
637+
608638
function main() {
609639
const packDir = mkdtempSync(join(tmpdir(), "hyperframes-pack-"));
640+
const unpinLambda = pinStandInLambdaAssets();
610641
try {
611642
const packedWorkspaces = listWorkspacePackageDirs()
612643
.map((workspace) => packAndVerifyWorkspace(workspace, packDir))
613644
.filter(Boolean);
614645
verifyPackedConsumer(packDir, packedWorkspaces);
615646
verifyPackageSizes(packedWorkspaces);
616647
} finally {
648+
unpinLambda();
617649
rmSync(packDir, { force: true, recursive: true });
618650
}
619651
}

0 commit comments

Comments
 (0)