fix: 稳定 PaC source artifact YAML 空白
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# R1.1 报告
|
||||
|
||||
- 复现输入包含空 `metadata`、空数组和嵌套空数组。
|
||||
- Bun YAML 输出 `metadata: `、`spec: ` 和 `items: ` 等尾随空格。
|
||||
- `git diff --no-index --check` 稳定以非零状态报告 trailing whitespace。
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# R1.2 报告
|
||||
|
||||
- 在通用 `pacSourceArtifactYaml()` 中逐行移除水平尾随空白。
|
||||
- 未修改 AgentRun 或 HWLAB consumer 文件及渲染职责。
|
||||
- 序列化后重新解析与原对象完全相等。
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# R1.3 报告
|
||||
|
||||
- 定向测试:24 项通过,0 项失败,共 287 个断言。
|
||||
- AgentRun 与 HWLAB 首次生成均成功,第二次写入均为 `mutation=false`。
|
||||
- 三个真实生成文件均可解析、无行尾空格、EOF 恰好一个换行。
|
||||
- 两个 consumer 的 `source-artifact check` 均返回 aligned。
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# R1.4 报告
|
||||
|
||||
- 交付分支:`fix/1753-pac-yaml-trailing-space`。
|
||||
- 关联 issue:https://github.com/pikasTech/unidesk/issues/1753
|
||||
- PR:https://github.com/pikasTech/unidesk/pull/1754
|
||||
- 受控 preflight:`MERGEABLE`、`CLEAN`、`readyForCommanderMerge=true`。
|
||||
- 不执行合并或部署。
|
||||
@@ -0,0 +1,6 @@
|
||||
# R1 总报告
|
||||
|
||||
- 通用 PaC source artifact YAML serializer 已消除 Bun 空 mapping/sequence 产生的行尾空格。
|
||||
- YAML 结构、一个 EOF 换行和重复生成幂等均已验证。
|
||||
- AgentRun 与 HWLAB consumer 无需手工修补。
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# PaC Source Artifact YAML 空白稳定性
|
||||
|
||||
- 来源:https://github.com/pikasTech/unidesk/issues/1753
|
||||
- 范围:通用 PaC source artifact serializer;禁止 consumer 手工修补。
|
||||
|
||||
|
||||
## R1 [completed]
|
||||
|
||||
修复 PaC source artifact YAML serializer 的行尾空格,关联 https://github.com/pikasTech/unidesk/issues/1753,完成任务后将详细报告写入[任务报告](./details/pac-source-artifact-yaml-whitespace/R1_Task_Report.md)。
|
||||
|
||||
### R1.1 [completed]
|
||||
|
||||
复现空 mapping 行尾空格和 git diff --check 失败,关联 https://github.com/pikasTech/unidesk/issues/1753,完成任务后将详细报告写入[任务报告](./details/pac-source-artifact-yaml-whitespace/R1.1_Task_Report.md)。
|
||||
|
||||
### R1.2 [completed]
|
||||
|
||||
在通用 serializer 修复稳定 YAML 输出并保持结构不变,完成任务后将详细报告写入[任务报告](./details/pac-source-artifact-yaml-whitespace/R1.2_Task_Report.md)。
|
||||
|
||||
### R1.3 [completed]
|
||||
|
||||
验证 AgentRun/HWLAB 生成、EOF 和二次写入幂等,完成任务后将详细报告写入[任务报告](./details/pac-source-artifact-yaml-whitespace/R1.3_Task_Report.md)。
|
||||
|
||||
### R1.4 [completed]
|
||||
|
||||
提交非 draft PR、运行受控 preflight 并留下审查证据,完成任务后将详细报告写入[任务报告](./details/pac-source-artifact-yaml-whitespace/R1.4_Task_Report.md)。
|
||||
@@ -270,6 +270,20 @@ describe("source artifact serialization", () => {
|
||||
expect(first).toContain("apiVersion: tekton.dev/v1\nkind: Pipeline\n");
|
||||
expect(Bun.YAML.parse(first)).toEqual(manifest);
|
||||
});
|
||||
|
||||
test("empty mappings and sequences have stable whitespace without changing structure", () => {
|
||||
const manifest = {
|
||||
apiVersion: "tekton.dev/v1",
|
||||
kind: "PipelineRun",
|
||||
metadata: {},
|
||||
spec: { params: [], workspaces: [], pipelineSpec: { tasks: [] } },
|
||||
};
|
||||
const serialized = pacSourceArtifactYaml(manifest);
|
||||
expect(serialized).not.toMatch(/[\t ]+$/m);
|
||||
expect(serialized.endsWith("\n")).toBe(true);
|
||||
expect(serialized.endsWith("\n\n")).toBe(false);
|
||||
expect(Bun.YAML.parse(serialized)).toEqual(manifest);
|
||||
});
|
||||
});
|
||||
|
||||
describe("runtime source-commit selection", () => {
|
||||
|
||||
@@ -1032,7 +1032,12 @@ function parseYamlRecord(text: string, label: string): Record<string, unknown> {
|
||||
}
|
||||
|
||||
export function pacSourceArtifactYaml(value: Record<string, unknown>): string {
|
||||
return `${Bun.YAML.stringify(value, null, 2).trim()}\n`;
|
||||
const serialized = Bun.YAML.stringify(value, null, 2)
|
||||
.split("\n")
|
||||
.map((line) => line.replace(/[\t ]+$/u, ""))
|
||||
.join("\n")
|
||||
.trim();
|
||||
return `${serialized}\n`;
|
||||
}
|
||||
|
||||
function requiredParam(binding: PacSourceArtifactBinding, key: string): string {
|
||||
|
||||
Reference in New Issue
Block a user