Require CI checks on GitHub repos via per-repo required_checks
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful

This commit is contained in:
2026-11-21 12:42:08 +11:00
parent 22554e237b
commit d741fea740
21 changed files with 130 additions and 16 deletions
+28 -4
View File
@@ -484,17 +484,41 @@ run "tag_ruleset_status_checks_rejected" {
expect_failures = [var.ruleset]
}
run "empty_status_check_contexts_rejected" {
run "per_repo_required_checks" {
command = plan
variables {
ruleset = {
noci = { name = "noci", rules = { required_status_checks = { contexts = [] } } }
ci = { name = "ci", all_repos = true, rules = { required_status_checks = { integration_id = 15368 } } }
shared = { name = "shared", rules = { required_status_checks = { contexts = ["ci/woodpecker"] } } }
plain = { name = "plain", all_repos = true, rules = { deletion = true } }
}
repository = {
checked = { name = "checked", rulesets = ["shared"], required_checks = ["lint", "test"] }
unchecked = { name = "unchecked" }
}
repository = {}
}
expect_failures = [var.ruleset]
assert {
condition = (
[for c in module.ruleset["checked/ci"].ruleset.rules[0].required_status_checks[0].required_check : "${c.context}/${c.integration_id}"] == ["lint/15368", "test/15368"] &&
!module.ruleset["checked/ci"].ruleset.rules[0].required_status_checks[0].strict_required_status_checks_policy
)
error_message = "repo required_checks must fill the opted-in ruleset, pinned to its integration_id"
}
assert {
condition = toset([for c in module.ruleset["checked/shared"].ruleset.rules[0].required_status_checks[0].required_check : c.context]) == toset(["ci/woodpecker", "lint", "test"])
error_message = "repo required_checks must add to the ruleset's own contexts"
}
assert {
condition = (
length(module.ruleset["unchecked/ci"].ruleset.rules[0].required_status_checks) == 0 &&
length(module.ruleset["checked/plain"].ruleset.rules[0].required_status_checks) == 0
)
error_message = "status check rule must be omitted without contexts or when the ruleset does not opt in"
}
}
run "org_settings_unmanaged_without_config" {