新增 release artifact URL workflow action plan API

This commit is contained in:
2026-06-16 15:01:39 +08:00
parent b7ec759645
commit e11c29533f
9 changed files with 230 additions and 4 deletions

View File

@@ -67,6 +67,8 @@ continuation records are in `../text14.txt`.
implementation, including fetch status and next-command output.
`createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel()` turns
that SDK URL workflow into stable dashboard rows and status text.
`createProjectReleaseReadinessArtifactUrlWorkflowActionPlan()` turns blocked
URL workflows into ordered input, fetch, and command actions for CI tooling.
Browser shells can also pass the JSON to
`linuxCncIniPanelWorkflowOverviewApi.validateWorkflowOverviewReleaseReadinessArtifactJson()`
through the workflow overview iframe and receive stable validation rows. They

View File

@@ -57,6 +57,7 @@ import {
createProjectReleaseGateManifest,
createProjectReleaseGateResultMatrix,
createProjectReleaseReadinessArtifactJsonWorkflow,
createProjectReleaseReadinessArtifactUrlWorkflowActionPlan,
createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel,
createProjectReleaseReadinessArtifactValidation,
createProjectReleaseReadinessArtifactValidationActionPlan,
@@ -252,10 +253,15 @@ action-plan output without executing release gates.
`createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel()` turns the
URL workflow result into stable dashboard status text and rows for ready,
missing-input, fetch-failure, and artifact-validation-blocked states.
`createProjectReleaseReadinessArtifactUrlWorkflowActionPlan()` turns the same
URL workflow into ordered workflow-level actions, distinguishing caller input,
fetch checks, and executable gate commands while preserving a shell script for
command actions.
`tests/sdk/node/verify_project_release_artifact_url_workflow.sh` is the
dedicated executable SDK gate for that URL workflow. It verifies caller-provided
fetch handling, ready summaries, missing input, HTTP failure, thrown fetch
errors, and ends with `project_release_artifact_url_workflow_node_smoke=ok`.
fetch handling, ready summaries, action plans, missing input, HTTP failure,
thrown fetch errors, and ends with
`project_release_artifact_url_workflow_node_smoke=ok`.
## OPFS/session persistence exports

View File

@@ -5,6 +5,7 @@ export {
createProjectReleaseGateManifest,
createProjectReleaseGateResultMatrix,
createProjectReleaseReadinessArtifactJsonWorkflow,
createProjectReleaseReadinessArtifactUrlWorkflowActionPlan,
createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel,
createProjectReleaseReadinessArtifactValidation,
createProjectReleaseReadinessArtifactValidationActionPlan,

View File

@@ -727,6 +727,88 @@ export function createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel
};
}
export function createProjectReleaseReadinessArtifactUrlWorkflowActionPlan(
workflow = {},
) {
const missing = arrayOrEmpty(workflow?.missing);
const ready = workflow?.ready === true;
const validationCommands = arrayOrEmpty(workflow?.actionPlan?.commands);
const inputActions = [
...(missing.includes("artifact-url")
? [{
id: "provide-artifact-url",
label: "Provide release readiness artifact URL",
kind: "input",
command: null,
expectedOutput: null,
}]
: []),
...(missing.includes("fetch")
? [{
id: "provide-fetch",
label: "Provide fetch implementation",
kind: "input",
command: null,
expectedOutput: null,
}]
: []),
...(missing.includes("artifact-fetch")
? [{
id: "verify-artifact-url-fetch",
label: "Verify release readiness artifact URL fetch",
kind: "fetch",
command: null,
expectedOutput: null,
}]
: []),
];
const commandActions = validationCommands.map((command) => ({
id: command.id ?? command.gateId ?? `command-${command.step}`,
label: command.label,
kind: "command",
command: command.command,
expectedOutput: command.expectedOutput ?? null,
}));
const actions = ready ? [] : [...inputActions, ...commandActions].map((action, index) => ({
step: index + 1,
...action,
}));
const commands = actions.filter(({ command }) => typeof command === "string" && command.length > 0);
const shellScript = commands.length > 0
? [
"#!/usr/bin/env bash",
"set -euo pipefail",
"",
...commands.map(({ command }) => command),
"",
].join("\n")
: (ready
? "# Project release readiness artifact URL workflow is already ready.\n"
: "# Project release readiness artifact URL workflow requires non-shell input.\n");
return {
apiName: "project-release-readiness-artifact-url-workflow-action-plan",
planVersion: 1,
phase: ready ? "ready" : "blocked",
ready,
missing,
actionCount: actions.length,
commandCount: commands.length,
nextActionId: actions[0]?.id ?? null,
nextCommand: commands[0]?.command ?? null,
actions,
commands,
shellScript,
rows: actions.map(({ id, label, kind, command, expectedOutput }) => ({
id,
label,
kind,
value: command ?? kind,
expectedOutput,
})),
};
}
export function createProjectReleaseReadinessArtifactValidation(artifact = {}) {
const artifactObject = objectOrEmpty(artifact);
const releaseGate = objectOrEmpty(artifactObject.releaseGate);

View File

@@ -42,6 +42,7 @@ for (const phrase of [
"createProjectReleaseReadinessArtifactValidationActionPlan()",
"createProjectReleaseReadinessArtifactValidationSummaryViewModel()",
"loadProjectReleaseReadinessArtifactUrlWorkflow()",
"createProjectReleaseReadinessArtifactUrlWorkflowActionPlan()",
"createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel()",
"embedded gate manifest, result matrix, and action plan",
"validateWorkflowOverviewReleaseReadinessArtifactJson()",
@@ -125,6 +126,7 @@ for (const phrase of [
"gateActionPlanReady",
"loadIniPanelShellWorkflowOverviewReleaseReadinessArtifactUrl()",
"loadProjectReleaseReadinessArtifactUrlWorkflow()",
"createProjectReleaseReadinessArtifactUrlWorkflowActionPlan()",
"createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel()",
"verify_project_release_artifact_url_workflow.sh",
"project_release_artifact_url_workflow_node_smoke=ok",

View File

@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
import {
createProjectReleaseGateManifest,
createProjectReleaseReadinessArtifactUrlWorkflowActionPlan,
createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel,
createProjectReleaseReadinessReport,
loadProjectReleaseReadinessArtifactUrlWorkflow,
@@ -25,6 +26,7 @@ const readyWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflow({
},
});
const readySummary = createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel(readyWorkflow);
const readyActionPlan = createProjectReleaseReadinessArtifactUrlWorkflowActionPlan(readyWorkflow);
assert.equal(fetchedUrl, "/project-release-readiness.json");
assert.equal(readyWorkflow.apiName, "project-release-readiness-artifact-url-workflow");
@@ -49,6 +51,21 @@ assert.deepEqual(
["missing", "none"],
],
);
assert.deepEqual(readyActionPlan, {
apiName: "project-release-readiness-artifact-url-workflow-action-plan",
planVersion: 1,
phase: "ready",
ready: true,
missing: [],
actionCount: 0,
commandCount: 0,
nextActionId: null,
nextCommand: null,
actions: [],
commands: [],
shellScript: "# Project release readiness artifact URL workflow is already ready.\n",
rows: [],
});
const missingInputWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflow({
artifactUrl: "",
@@ -57,11 +74,30 @@ const missingInputWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflo
const missingInputSummary = createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel(
missingInputWorkflow,
);
const missingInputActionPlan = createProjectReleaseReadinessArtifactUrlWorkflowActionPlan(
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");
assert.equal(missingInputActionPlan.phase, "blocked");
assert.equal(missingInputActionPlan.actionCount, 4);
assert.equal(missingInputActionPlan.commandCount, 2);
assert.equal(missingInputActionPlan.nextActionId, "provide-artifact-url");
assert.equal(
missingInputActionPlan.nextCommand,
"wasm-port/tests/host/verify_project_release_gate.sh",
);
assert.deepEqual(
missingInputActionPlan.actions.slice(0, 2).map(({ id, kind, command }) => [id, kind, command]),
[
["provide-artifact-url", "input", null],
["provide-fetch", "input", null],
],
);
assert.match(missingInputActionPlan.shellScript, /^#!\/usr\/bin\/env bash\nset -euo pipefail\n/);
const httpFailureWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflow({
artifactUrl: "/missing.json",
@@ -74,6 +110,9 @@ const httpFailureWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflow
const httpFailureSummary = createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel(
httpFailureWorkflow,
);
const httpFailureActionPlan = createProjectReleaseReadinessArtifactUrlWorkflowActionPlan(
httpFailureWorkflow,
);
assert.equal(httpFailureWorkflow.ready, false);
assert.equal(httpFailureWorkflow.fetched, false);
assert.equal(httpFailureWorkflow.httpStatus, 404);
@@ -85,6 +124,14 @@ assert.equal(
);
assert.match(httpFailureSummary.statusLine, /^Blocked: artifact-fetch/);
assert.equal(httpFailureSummary.rows.find(({ id }) => id === "fetch")?.value, "blocked");
assert.equal(httpFailureActionPlan.phase, "blocked");
assert.equal(httpFailureActionPlan.actionCount, 3);
assert.equal(httpFailureActionPlan.commandCount, 2);
assert.equal(httpFailureActionPlan.nextActionId, "verify-artifact-url-fetch");
assert.equal(
httpFailureActionPlan.rows[0].value,
"fetch",
);
const thrownFetchWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflow({
artifactUrl: "/throws.json",
@@ -95,11 +142,16 @@ const thrownFetchWorkflow = await loadProjectReleaseReadinessArtifactUrlWorkflow
const thrownFetchSummary = createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel(
thrownFetchWorkflow,
);
const thrownFetchActionPlan = createProjectReleaseReadinessArtifactUrlWorkflowActionPlan(
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/);
assert.equal(thrownFetchActionPlan.nextActionId, "verify-artifact-url-fetch");
assert.equal(thrownFetchActionPlan.commands.length, 2);
console.log("project_release_artifact_url_workflow_node_smoke=ok");

View File

@@ -38,6 +38,7 @@ import {
createProjectReleaseGateManifest,
createProjectReleaseGateResultMatrix,
createProjectReleaseReadinessArtifactJsonWorkflow,
createProjectReleaseReadinessArtifactUrlWorkflowActionPlan,
createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel,
createProjectReleaseReadinessArtifactValidation,
createProjectReleaseReadinessArtifactValidationActionPlan,
@@ -98,6 +99,10 @@ const requiredExports = [
["createProjectReleaseGateManifest", createProjectReleaseGateManifest],
["createProjectReleaseGateResultMatrix", createProjectReleaseGateResultMatrix],
["createProjectReleaseReadinessArtifactJsonWorkflow", createProjectReleaseReadinessArtifactJsonWorkflow],
[
"createProjectReleaseReadinessArtifactUrlWorkflowActionPlan",
createProjectReleaseReadinessArtifactUrlWorkflowActionPlan,
],
[
"createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel",
createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel,
@@ -386,6 +391,19 @@ assert.equal(
).statusLine,
"Ready: Artifact URL workflow complete",
);
assert.equal(
createProjectReleaseReadinessArtifactUrlWorkflowActionPlan(
await loadProjectReleaseReadinessArtifactUrlWorkflow({
artifactUrl: "/project-release-readiness.json",
fetchRef: async () => ({
ok: true,
status: 200,
text: async () => JSON.stringify(releaseReadinessArtifact),
}),
}),
).shellScript,
"# Project release readiness artifact URL workflow is already ready.\n",
);
assert.equal(
(await loadProjectReleaseReadinessArtifactUrlWorkflow({
artifactUrl: "/missing.json",