Public release release-f70e47af061d
Source commit: f70e47af061d8f7ba27cd769c8cd2e2f8707dc72 Public tree identity: sha256:03a43db60d295811688bedaa5ad6460df0dbde27fbf37033997f4d8100f83ab2
This commit is contained in:
commit
b23e4e5bff
210 changed files with 78295 additions and 0 deletions
148
scripts/flagship-demo-smoke.js
Normal file
148
scripts/flagship-demo-smoke.js
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const assert = require("assert");
|
||||
const cp = require("child_process");
|
||||
const crypto = require("crypto");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const extension = require("../vscode-extension/extension");
|
||||
|
||||
const repo = path.resolve(__dirname, "..");
|
||||
const project = path.join(repo, "examples/launch-build-demo");
|
||||
const source = fs.readFileSync(path.join(project, "src/build.rs"), "utf8");
|
||||
const forbiddenSourceAssumptions =
|
||||
/\b(?:std::fs|std::process|git|podman|docker|localhost|127\.0\.0\.1)|\/home\/|\/Users\/|C:\\Users\\/i;
|
||||
|
||||
const envs = extension.discoverEnvironmentNames(project);
|
||||
assert.deepStrictEqual(envs, ["linux", "windows"]);
|
||||
assert.deepStrictEqual(extension.diagnoseEnvReferences(source, envs), []);
|
||||
assert.doesNotMatch(
|
||||
source,
|
||||
forbiddenSourceAssumptions,
|
||||
"flagship build source must not bypass Clusterflux host capabilities or rely on coordinator-side filesystem, Git, container, or machine-local assumptions"
|
||||
);
|
||||
|
||||
const inspection = JSON.parse(
|
||||
cp.execFileSync(
|
||||
"cargo",
|
||||
[
|
||||
"run",
|
||||
"-q",
|
||||
"-p",
|
||||
"clusterflux-cli",
|
||||
"--bin",
|
||||
"clusterflux",
|
||||
"--",
|
||||
"bundle",
|
||||
"inspect",
|
||||
"--project",
|
||||
project,
|
||||
"--json"
|
||||
],
|
||||
{ cwd: repo, encoding: "utf8" }
|
||||
)
|
||||
);
|
||||
|
||||
assert.strictEqual(inspection.project, project);
|
||||
assert.strictEqual(
|
||||
inspection.source_provider_manifest.coordinator_requires_checkout_access,
|
||||
false
|
||||
);
|
||||
assert.strictEqual(
|
||||
inspection.source_provider_manifest.transfer_policy.local_source_bytes_remain_node_local,
|
||||
true
|
||||
);
|
||||
assert.strictEqual(
|
||||
inspection.source_provider_manifest.transfer_policy.coordinator_receives_source_bytes_by_default,
|
||||
false
|
||||
);
|
||||
assert.strictEqual(
|
||||
inspection.source_provider_manifest.transfer_policy.default_full_repo_tarball,
|
||||
false
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
inspection.source_provider_manifest.transfer_policy.allowed_remote_transfer.sort(),
|
||||
["ExplicitSnapshotChunks", "RequiredContent"]
|
||||
);
|
||||
assert.strictEqual(inspection.metadata.embeds_full_container_images, false);
|
||||
assert(inspection.metadata.environments.some((env) => env.name === "linux"));
|
||||
assert(inspection.metadata.environments.some((env) => env.name === "windows"));
|
||||
assert(inspection.metadata.selected_inputs.some((input) => input.path === "src/build.rs"));
|
||||
|
||||
const bundleDirectory = path.join(repo, "target/acceptance/flagship-bundle");
|
||||
const build = JSON.parse(
|
||||
cp.execFileSync(
|
||||
"cargo",
|
||||
[
|
||||
"run",
|
||||
"-q",
|
||||
"-p",
|
||||
"clusterflux-cli",
|
||||
"--bin",
|
||||
"clusterflux",
|
||||
"--",
|
||||
"build",
|
||||
"--project",
|
||||
project,
|
||||
"--output",
|
||||
bundleDirectory,
|
||||
"--json",
|
||||
],
|
||||
{ cwd: repo, encoding: "utf8" }
|
||||
)
|
||||
);
|
||||
assert.strictEqual(build.status, "built");
|
||||
assert.strictEqual(build.bundle_artifact.task_descriptor_count, 11);
|
||||
assert.strictEqual(build.bundle_artifact.entrypoint_count, 6);
|
||||
assert.deepStrictEqual(build.bundle_artifact.files.sort(), [
|
||||
"debug-metadata.json",
|
||||
"entrypoints.json",
|
||||
"environments.json",
|
||||
"manifest.json",
|
||||
"module.wasm",
|
||||
"source-provider.json",
|
||||
"task-descriptors.json",
|
||||
"vfs-seed.json",
|
||||
]);
|
||||
const bundleManifest = JSON.parse(
|
||||
fs.readFileSync(path.join(bundleDirectory, "manifest.json"), "utf8")
|
||||
);
|
||||
const bundleEntrypoints = JSON.parse(
|
||||
fs.readFileSync(path.join(bundleDirectory, "entrypoints.json"), "utf8")
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
bundleEntrypoints.map((entrypoint) => entrypoint.name).sort(),
|
||||
["build", "fail", "identity", "long-join", "park-wake", "restart"]
|
||||
);
|
||||
const bundleModule = fs.readFileSync(path.join(bundleDirectory, "module.wasm"));
|
||||
assert.strictEqual(bundleManifest.kind, "clusterflux-bundle");
|
||||
assert.strictEqual(
|
||||
bundleManifest.bundle_digest,
|
||||
`sha256:${crypto.createHash("sha256").update(bundleModule).digest("hex")}`
|
||||
);
|
||||
assert.strictEqual(bundleManifest.embeds_full_repository, false);
|
||||
assert.strictEqual(
|
||||
bundleManifest.coordinator_receives_source_bytes_by_default,
|
||||
false
|
||||
);
|
||||
const taskDescriptors = JSON.parse(
|
||||
fs.readFileSync(path.join(bundleDirectory, "task-descriptors.json"), "utf8")
|
||||
);
|
||||
assert(
|
||||
taskDescriptors.some(
|
||||
(task) =>
|
||||
task.name === "task_add_one" &&
|
||||
task.argument_schema === "input : i32" &&
|
||||
task.result_schema === "i32" &&
|
||||
task.restart_compatibility_hash.startsWith("sha256:") &&
|
||||
task.probe_symbol === "clusterflux.probe.task_add_one"
|
||||
)
|
||||
);
|
||||
|
||||
cp.execFileSync("cargo", ["test", "-p", "launch-build-demo"], {
|
||||
cwd: repo,
|
||||
stdio: "inherit"
|
||||
});
|
||||
|
||||
console.log("Flagship demo smoke passed");
|
||||
Loading…
Add table
Add a link
Reference in a new issue