fix: 收敛 NC01 Tekton 服务构建为矩阵任务
This commit is contained in:
@@ -355,20 +355,17 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
|
||||
"hwlab-edge-proxy",
|
||||
"hwlab-agent-skills"
|
||||
];
|
||||
for (let index = 0; index < retainedServiceIds.length; index += 1) {
|
||||
const serviceId = retainedServiceIds[index];
|
||||
const task = taskByName(pipelineJson, `build-${serviceId}`);
|
||||
assert.deepEqual(task.runAfter, ["plan-artifacts"]);
|
||||
assert.deepEqual(task.when, [{ input: `$(tasks.plan-artifacts.results.build-${serviceId})`, operator: "in", values: ["true"] }]);
|
||||
}
|
||||
const buildServices = taskByName(pipelineJson, "build-services");
|
||||
assert.deepEqual(buildServices.runAfter, ["plan-artifacts"]);
|
||||
assert.deepEqual(buildServices.matrix, { params: [{ name: "service-id", value: retainedServiceIds.map((id) => `hwlab-${id.replace(/^hwlab-/u, "")}`) }] });
|
||||
|
||||
const collectScript = collectArtifacts.taskSpec.steps[0].script;
|
||||
assert.match(collectScript, /--external-service-report-dir \/workspace\/source\/service-results/u);
|
||||
assert.ok(
|
||||
taskByName(pipelineJson, "build-hwlab-cloud-web").taskSpec.results.some((result) => result.name === "go-base-image-status"),
|
||||
buildServices.taskSpec.results.some((result) => result.name === "go-base-image-status"),
|
||||
"build task should declare Go base evidence Tekton results so artifact-publish result files are collected"
|
||||
);
|
||||
const cloudWebBuildScript = taskByName(pipelineJson, "build-hwlab-cloud-web").taskSpec.steps.find((step) => step.name === "publish")?.script ?? "";
|
||||
const cloudWebBuildScript = buildServices.taskSpec.steps.find((step) => step.name === "publish")?.script ?? "";
|
||||
assert.match(cloudWebBuildScript, /node scripts\/artifact-publish\.mjs --publish/u);
|
||||
|
||||
const artifactPublishSource = await readFile("scripts/artifact-publish.mjs", "utf8");
|
||||
|
||||
@@ -391,10 +391,19 @@ function perServiceBuildTask(serviceId, { runAfter = ["plan-artifacts"] } = {})
|
||||
};
|
||||
}
|
||||
|
||||
function perServiceBuildMatrixTask(serviceIds, { runAfter = ["plan-artifacts"] } = {}) {
|
||||
const task = perServiceBuildTask(serviceIds[0], { runAfter });
|
||||
task.name = "build-services";
|
||||
delete task.when;
|
||||
task.params = task.params.map((param) => param.name === "service-id" ? { name: "service-id", value: "$(matrix.params.service-id)" } : param);
|
||||
task.matrix = { params: [{ name: "service-id", value: serviceIds }] };
|
||||
return task;
|
||||
}
|
||||
|
||||
function collectArtifactsTask({ serviceIds = defaultServiceIds } = {}) {
|
||||
return {
|
||||
name: "collect-artifacts",
|
||||
runAfter: serviceIds.map(buildTaskName),
|
||||
runAfter: ["build-services"],
|
||||
workspaces: [{ name: "source", workspace: "source" }],
|
||||
taskSpec: {
|
||||
params: [
|
||||
@@ -467,12 +476,10 @@ function runtimeReadyTask({ profile = "dev" } = {}) {
|
||||
|
||||
function imagePublishTaskSet(args = { lane: "node" }, deploy = null) {
|
||||
const serviceIds = serviceIdsForLane(args.lane, deploy);
|
||||
const buildTasks = serviceIds.map((serviceId) => perServiceBuildTask(serviceId, {
|
||||
runAfter: ["plan-artifacts"]
|
||||
}));
|
||||
const buildTask = perServiceBuildMatrixTask(serviceIds, { runAfter: ["plan-artifacts"] });
|
||||
return [
|
||||
planArtifactsTask({ serviceIds }),
|
||||
...buildTasks,
|
||||
buildTask,
|
||||
collectArtifactsTask({ serviceIds })
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user