用途:该技能面向 openshift/hypershift 仓库的 Go 与 Markdown 代码质量,规定格式、Lint 与测试约定的强制规则。
主要能力与规则: 格式化与 Lint:写完 Go 代码后用 make lint-fix 自动修复大部分 lint 问题;提交前运行 make verify 验证 lint 与测试通过;Markdown 文件用 make verify-codespell 检查拼写错误。 测试命名(强制):每个 Go 测试名必须采用 name: "When <条件>, it should <期望行为>" 格式,例如 name: "When NodePool has valid image ID, it should create Azure machine template"。禁止使用 "nominal case without managed identity"、"basic Azure machine template with ImageID"、"error case - invalid subnet ID" 等泛化名称。 单元测试函数命名:单元测试函数必须以其被测函数命名,采用标准 Go 的 Test<FunctionName> 约定,如测试 ReconcileNodePool 用 func TestReconcileNodePool(t *testing.T)。禁止 TestNodePoolFeatures、TestAzureIntegration、TestVariousCases 等不与具体函数对应的名称;函数复杂时在单一 Test<FunctionName> 内用表驱动测试,每个用例仍用 When...it should... 命名。 单元测试放置:新增或修改函数时始终包含单元测试,测试放在被测代码同包目录的 _test.go 文件中;不要放到 test/integration/(历史目录);需要集群的新集成式测试应使用 test/e2e/ 或 test/envtest/。
使用方式:按上述命令与命名规则执行,提交前对照检查清单:运行 make lint-fix、运行 make verify 并通过、测试采用 When...it should... 命名、新函数有单元测试、Markdown 经 make verify-codespell 检查。
限制:资料仅涉及该仓库的具体命令与约定,未提供适用范围之外的更多信息;是否自动执行依赖项目工具链。