Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(ci): add test for module assets in self-hosted CI

Steven Enamakelda785b4e93bc
diff --git a/scripts/ci/self-hosted/test-module-assets.mjs b/scripts/ci/self-hosted/test-module-assets.mjs
new file mode 100644
index 0000000000..0ce39939c6
--- /dev/null
+++ b/scripts/ci/self-hosted/test-module-assets.mjs
@@ -0,0 +1,65 @@
+#!/usr/bin/env node
+// Resolve the native test-module release assets the Rust coverage lane needs,
+// straight from the compiled module registry (the authoritative pin).
+//
+// Usage: node scripts/ci/self-hosted/test-module-assets.mjs [host_key]
+// Prints one line per module: `<id>\t<url>\t<archive>\t<sha256>`.
+//
+// Reading the registry instead of copying version + digest into a workflow
+// keeps a single source of truth: ci-lite.yml carries its own copies, and its
+// tinyjuice copy had already drifted (0.2.2 there, 0.2.5 in the registry).
+import { readFileSync, readdirSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+
+import { parseRecords } from "../../lib/module-pins.mjs";
+
+const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
+const REGISTRY_DIR = join(ROOT, "crates/openhuman-core/src/modules");
+
+/** Test modules the core suite loads, by registry record id. */
+export const TEST_MODULE_IDS = ["tinymemory", "tinyjuice"];
+
+/** Concatenate registry.rs and its `registry/records_*.rs` fragments. */
+export function readRegistrySource(dir = REGISTRY_DIR) {
+ const fragments = readdirSync(join(dir, "registry"))
+ .filter((f) => /^records_.*\.rs$/.test(f))
+ .sort()
+ .map((f) => readFileSync(join(dir, "registry", f), "utf8"));
+ return [readFileSync(join(dir, "registry.rs"), "utf8"), ...fragments].join("\n");
+}
+
+/** `release_url` per record id, from the same source text. */
+export function parseReleaseUrls(src) {
+ const urls = new Map();
+ const re = /id: "([^"]+)",[\s\S]*?release_url: "([^"]+)"/g;
+ for (const m of src.matchAll(re)) {
+ if (!urls.has(m[1])) urls.set(m[1], m[2]);
+ }
+ return urls;
+}
+
+/** Resolve `{id, url, archive, sha256}` for each wanted module on `hostKey`. */
+export function resolveTestModuleAssets(src, hostKey, ids = TEST_MODULE_IDS) {
+ const byId = new Map([...parseRecords(src).values()].map((r) => [r.id, r]));
+ const releaseUrls = parseReleaseUrls(src);
+ return ids.map((id) => {
+ const record = byId.get(id);
+ if (!record) throw new Error(`registry has no ModuleRecord with id "${id}"`);
+ const asset = record.assets.find((a) => a.hostKey === hostKey);
+ if (!asset) throw new Error(`${id} ${record.version} has no ${hostKey} asset`);
+ const release = releaseUrls.get(id);
+ if (!release || !release.includes("/releases/tag/")) {
+ throw new Error(`${id}: release_url missing or not a /releases/tag/ URL`);
+ }
+ const url = `${release.replace("/releases/tag/", "/releases/download/")}/${asset.archive}`;
+ return { id, url, archive: asset.archive, sha256: asset.sha256 };
+ });
+}
+
+if (process.argv[1] === fileURLToPath(import.meta.url)) {
+ const hostKey = process.argv[2] ?? "ubuntu-22.04-x86_64";
+ for (const a of resolveTestModuleAssets(readRegistrySource(), hostKey)) {
+ console.log([a.id, a.url, a.archive, a.sha256].join("\t"));
+ }
+}