新增 release artifact URL workflow SDK gate

This commit is contained in:
2026-06-16 14:29:55 +08:00
parent bee05005b5
commit b7ec759645
9 changed files with 184 additions and 3 deletions

View File

@@ -0,0 +1,105 @@
import assert from "node:assert/strict";
import {
createProjectReleaseGateManifest,
createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel,
createProjectReleaseReadinessReport,
loadProjectReleaseReadinessArtifactUrlWorkflow,
} from "../../../runtime/sdk/src/index.js";
const manifest = createProjectReleaseGateManifest();
const readyArtifactJson = JSON.stringify(createProjectReleaseReadinessReport({
gateResults: Object.fromEntries(manifest.gateIds.map((id) => [id, true])),
}));
let fetchedUrl = null;
const readyWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflow({
artifactUrl: "/project-release-readiness.json",
fetchRef: async (url) => {
fetchedUrl = url;
return {
ok: true,
status: 200,
text: async () => readyArtifactJson,
};
},
});
const readySummary = createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel(readyWorkflow);
assert.equal(fetchedUrl, "/project-release-readiness.json");
assert.equal(readyWorkflow.apiName, "project-release-readiness-artifact-url-workflow");
assert.equal(readyWorkflow.workflowVersion, 1);
assert.equal(readyWorkflow.ready, true);
assert.equal(readyWorkflow.fetched, true);
assert.equal(readyWorkflow.httpStatus, 200);
assert.equal(readyWorkflow.fetchError, null);
assert.equal(readyWorkflow.jsonWorkflow.ready, true);
assert.equal(readyWorkflow.validation.ready, true);
assert.equal(readyWorkflow.actionPlan.ready, true);
assert.equal(readySummary.apiName, "project-release-readiness-artifact-url-workflow-summary-view-model");
assert.equal(readySummary.statusLine, "Ready: Artifact URL workflow complete");
assert.deepEqual(
readySummary.rows.map(({ id, value }) => [id, value]),
[
["artifact-url", "/project-release-readiness.json"],
["fetch", "ready (200)"],
["json-workflow", "ready"],
["artifact-validation", "ready"],
["next-command", "none"],
["missing", "none"],
],
);
const missingInputWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflow({
artifactUrl: "",
fetchRef: null,
});
const missingInputSummary = createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel(
missingInputWorkflow,
);
assert.equal(missingInputWorkflow.ready, false);
assert.equal(missingInputWorkflow.fetched, false);
assert.deepEqual(missingInputWorkflow.missing.slice(0, 2), ["artifact-url", "fetch"]);
assert.match(missingInputSummary.statusLine, /^Blocked: artifact-url, fetch/);
assert.equal(missingInputSummary.rows.find(({ id }) => id === "artifact-url")?.value, "missing");
const httpFailureWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflow({
artifactUrl: "/missing.json",
fetchRef: async () => ({
ok: false,
status: 404,
text: async () => "",
}),
});
const httpFailureSummary = createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel(
httpFailureWorkflow,
);
assert.equal(httpFailureWorkflow.ready, false);
assert.equal(httpFailureWorkflow.fetched, false);
assert.equal(httpFailureWorkflow.httpStatus, 404);
assert.match(httpFailureWorkflow.fetchError, /404/);
assert.equal(httpFailureWorkflow.missing[0], "artifact-fetch");
assert.equal(
httpFailureWorkflow.actionPlan.nextCommand,
"wasm-port/tests/host/verify_project_release_gate.sh",
);
assert.match(httpFailureSummary.statusLine, /^Blocked: artifact-fetch/);
assert.equal(httpFailureSummary.rows.find(({ id }) => id === "fetch")?.value, "blocked");
const thrownFetchWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflow({
artifactUrl: "/throws.json",
fetchRef: async () => {
throw new Error("network unavailable");
},
});
const thrownFetchSummary = createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel(
thrownFetchWorkflow,
);
assert.equal(thrownFetchWorkflow.ready, false);
assert.equal(thrownFetchWorkflow.fetched, false);
assert.equal(thrownFetchWorkflow.httpStatus, null);
assert.equal(thrownFetchWorkflow.fetchError, "network unavailable");
assert.equal(thrownFetchWorkflow.missing[0], "artifact-fetch");
assert.match(thrownFetchSummary.statusLine, /^Blocked: artifact-fetch/);
console.log("project_release_artifact_url_workflow_node_smoke=ok");

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
node "$ROOT_DIR/tests/sdk/node/verify_project_release_artifact_url_workflow.mjs"

View File

@@ -5,3 +5,4 @@ ROOT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
node "$ROOT_DIR/tests/sdk/node/verify_sdk_surface.mjs"
"$ROOT_DIR/tests/sdk/node/verify_project_release_gate_manifest.sh"
"$ROOT_DIR/tests/sdk/node/verify_project_release_artifact_url_workflow.sh"