发版检查

如何在发布前生成 diff、执行 policy check,并读懂 SARIF 结果。

发版检查

这一页属于 #strong[How-to]:当你要发布时,按这里的步骤做。

目标

在发布前回答三个问题:

  1. 这次变了什么?
  2. 哪些变化值得警惕?
  3. 是否违反了本地 policy?

步骤

codeiq build ./sdk
codeiq diff ./sdk --since <last-release-commit> --test-changes true
codeiq check ./sdk/dist/diff.json --policy ./policy/dist/bundle.ciq.tgz

这里的关键点有两个:

  • 当前 check 仍然要求显式传入一个本地 policy bundle;
  • 如果 policy repo 使用 profile: policy-bundle 构建,实际可传入的产物通常是 dist/bundle.ciq.tgz

先看哪些结果?

dist/diff.json

优先看:

  • summary
  • changes[*].kind
  • changes[*].level
  • changes[*].semanticCategory
  • changes[*].semanticDiff
  • changes[*].beforeRecord / changes[*].afterRecord
  • componentChanges

当前 repo 已经为很多 change 做了 richer semantic shaping。例如:

  • Go:receiver、pointer receiver、method set、signature 变化
  • Rust:unsafe、extern ABI、where clause、signature 变化
  • Terraform:provider ref、lifecycle、meta-argument 变化
  • OpenAPI:HTTP method、requiredness、status code、media type 变化

dist/check.sarif.json

优先看:

  • level = error:通常意味着高风险
  • level = warning:值得重点确认
  • level = note:补充信息

当前最小 SARIF 会把 policy decision 映射成:

  • ruleId
  • level
  • message.text
  • locations[].physicalLocation.artifactLocation.uri
  • tool.driver.rules[].helpUri

因此,在看 SARIF 时,优先确认:

  • 是哪条 policy rule 触发了结果;
  • 结果落在哪个源文件 / 契约文件;
  • helpUri 是否指向了你团队约定的 policy 文档。

适合谁?

  • SDK / Library 维护者
  • OpenAPI / Terraform 维护者
  • 要做发布前门禁的团队

相关输入长什么样?

  • 代码 / 规格 repo 先生成 CIQ Bundle
  • policy repo 生成 CIQ OPA Bundle
  • check 消费的是 CIQ Diff + local policy bundle

如果你想精确查 bundle、diff、policy-bundle 和 SARIF 的文件结构,请看:/docs/indexing

下一步