split github_org into team, repository and ruleset submodules
This commit is contained in:
@@ -24,36 +24,36 @@ run "public_repo_defaults" {
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = github_repository_file.codeowners[".github"].content == "* @IUCLabs/maintainers-slug @carol\n"
|
||||
condition = module.repository[".github"].codeowners.content == "* @IUCLabs/maintainers-slug @carol\n"
|
||||
error_message = "CODEOWNERS must list maintainers, teams by owner-qualified slug"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = local.repository_access[".github"] == { "@maintainers" = "maintain", carol = "maintain", dave = "push" }
|
||||
condition = module.repository[".github"].access == { "@maintainers" = "maintain", carol = "maintain", dave = "push" }
|
||||
error_message = "maintainers get maintain (winning over codeowners), codeowners get push"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = keys(github_repository_ruleset.this) == [".github/branch-protection", ".github/tag-protection"] && length(github_team_membership.this) == 2
|
||||
condition = keys(module.repository[".github"].rulesets) == ["branch-protection", "tag-protection"] && length(module.team["maintainers"].membership) == 2
|
||||
error_message = "public repo must get only the generated branch-protection and tag-protection rulesets"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
github_repository_ruleset.this[".github/tag-protection"].target == "tag" &&
|
||||
github_repository_ruleset.this[".github/tag-protection"].enforcement == "active" &&
|
||||
github_repository_ruleset.this[".github/tag-protection"].conditions[0].ref_name[0].include == tolist(["refs/tags/v*"]) &&
|
||||
github_repository_ruleset.this[".github/tag-protection"].rules[0].deletion &&
|
||||
github_repository_ruleset.this[".github/tag-protection"].rules[0].non_fast_forward
|
||||
module.repository[".github"].rulesets["tag-protection"].target == "tag" &&
|
||||
module.repository[".github"].rulesets["tag-protection"].enforcement == "active" &&
|
||||
module.repository[".github"].rulesets["tag-protection"].conditions[0].ref_name[0].include == tolist(["refs/tags/v*"]) &&
|
||||
module.repository[".github"].rulesets["tag-protection"].rules[0].deletion &&
|
||||
module.repository[".github"].rulesets["tag-protection"].rules[0].non_fast_forward
|
||||
)
|
||||
error_message = "tag-protection ruleset must make refs/tags/v* undeletable and immutable"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
github_repository.this[".github"].allow_squash_merge &&
|
||||
!github_repository.this[".github"].allow_merge_commit &&
|
||||
!github_repository.this[".github"].allow_rebase_merge
|
||||
module.repository[".github"].repository.allow_squash_merge &&
|
||||
!module.repository[".github"].repository.allow_merge_commit &&
|
||||
!module.repository[".github"].repository.allow_rebase_merge
|
||||
)
|
||||
error_message = "merge_type defaults to squash only"
|
||||
}
|
||||
@@ -69,7 +69,7 @@ run "private_repo_defaults" {
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = length(github_repository_ruleset.this) == 0 && length(github_repository_file.codeowners) == 1
|
||||
condition = length(module.repository["secret"].rulesets) == 0 && module.repository["secret"].codeowners != null
|
||||
error_message = "private repo defaults to no rulesets but still gets CODEOWNERS"
|
||||
}
|
||||
}
|
||||
@@ -86,8 +86,8 @@ run "merge_type_rebase" {
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
github_repository.this["r"].allow_rebase_merge && !github_repository.this["r"].allow_squash_merge && !github_repository.this["r"].allow_merge_commit &&
|
||||
github_repository.this["m"].allow_merge_commit && !github_repository.this["m"].allow_squash_merge && !github_repository.this["m"].allow_rebase_merge
|
||||
module.repository["r"].repository.allow_rebase_merge && !module.repository["r"].repository.allow_squash_merge && !module.repository["r"].repository.allow_merge_commit &&
|
||||
module.repository["m"].repository.allow_merge_commit && !module.repository["m"].repository.allow_squash_merge && !module.repository["m"].repository.allow_rebase_merge
|
||||
)
|
||||
error_message = "merge_type must enable exactly the matching allow_* flag"
|
||||
}
|
||||
@@ -115,17 +115,17 @@ run "generated_and_custom_rulesets" {
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = toset(keys(github_repository_ruleset.this)) == toset(["checked/required-checks", "checked/signed"])
|
||||
condition = toset(keys(module.repository["checked"].rulesets)) == toset(["required-checks", "signed"])
|
||||
error_message = "required_checks with protections off yields only required-checks plus custom rulesets"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = github_repository_ruleset.this["checked/required-checks"].rules[0].required_status_checks[0].strict_required_status_checks_policy
|
||||
condition = module.repository["checked"].rulesets["required-checks"].rules[0].required_status_checks[0].strict_required_status_checks_policy
|
||||
error_message = "required-checks ruleset must be strict"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = length(github_repository_ruleset.this["checked/required-checks"].rules[0].pull_request) == 0
|
||||
condition = length(module.repository["checked"].rulesets["required-checks"].rules[0].pull_request) == 0
|
||||
error_message = "required-checks ruleset must not carry pull_request rules"
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ run "public_tag_protection_only" {
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = keys(github_repository_ruleset.this) == ["tags/tag-protection"]
|
||||
condition = keys(module.repository["tags"].rulesets) == ["tag-protection"]
|
||||
error_message = "tag_protection defaults on for public repos independently of branch_protection"
|
||||
}
|
||||
}
|
||||
@@ -242,15 +242,15 @@ run "non_main_default_branch_renamed" {
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
github_branch_default.this["legacy"].branch == "master" &&
|
||||
github_branch_default.this["legacy"].rename &&
|
||||
github_branch_default.this["legacy"].wait_for_rename
|
||||
module.repository["legacy"].branch_default.branch == "master" &&
|
||||
module.repository["legacy"].branch_default.rename &&
|
||||
module.repository["legacy"].branch_default.wait_for_rename
|
||||
)
|
||||
error_message = "default_branch must rename the auto-init main and wait for it to propagate"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = github_repository_file.codeowners["legacy"].branch == "master"
|
||||
condition = module.repository["legacy"].codeowners.branch == "master"
|
||||
error_message = "CODEOWNERS must be committed to the renamed default branch"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user