generate tag-protection ruleset for release tags
This commit is contained in:
@@ -34,8 +34,19 @@ run "public_repo_defaults" {
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = keys(github_repository_ruleset.this) == [".github/branch-protection"] && length(github_team_membership.this) == 2
|
||||
error_message = "public repo must get only the generated branch-protection ruleset"
|
||||
condition = keys(github_repository_ruleset.this) == [".github/branch-protection", ".github/tag-protection"] && length(github_team_membership.this) == 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
|
||||
)
|
||||
error_message = "tag-protection ruleset must make refs/tags/v* undeletable and immutable"
|
||||
}
|
||||
|
||||
assert {
|
||||
@@ -99,13 +110,13 @@ run "generated_and_custom_rulesets" {
|
||||
|
||||
variables {
|
||||
repository = {
|
||||
checked = { name = "checked", private = false, branch_protection = false, required_checks = ["ci/woodpecker"], rulesets = ["signed"] }
|
||||
checked = { name = "checked", private = false, branch_protection = false, tag_protection = false, required_checks = ["ci/woodpecker"], rulesets = ["signed"] }
|
||||
}
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = toset(keys(github_repository_ruleset.this)) == toset(["checked/required-checks", "checked/signed"])
|
||||
error_message = "required_checks without branch_protection yields only required-checks plus custom rulesets"
|
||||
error_message = "required_checks with protections off yields only required-checks plus custom rulesets"
|
||||
}
|
||||
|
||||
assert {
|
||||
@@ -131,6 +142,46 @@ run "private_branch_protection_rejected" {
|
||||
expect_failures = [var.repository]
|
||||
}
|
||||
|
||||
run "public_tag_protection_only" {
|
||||
command = plan
|
||||
|
||||
variables {
|
||||
repository = {
|
||||
tags = { name = "tags", private = false, branch_protection = false }
|
||||
}
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = keys(github_repository_ruleset.this) == ["tags/tag-protection"]
|
||||
error_message = "tag_protection defaults on for public repos independently of branch_protection"
|
||||
}
|
||||
}
|
||||
|
||||
run "private_tag_protection_rejected" {
|
||||
command = plan
|
||||
|
||||
variables {
|
||||
repository = {
|
||||
secret = { name = "secret", tag_protection = true }
|
||||
}
|
||||
}
|
||||
|
||||
expect_failures = [var.repository]
|
||||
}
|
||||
|
||||
run "reserved_tag_protection_name_rejected" {
|
||||
command = plan
|
||||
|
||||
variables {
|
||||
ruleset = {
|
||||
tag-protection = { name = "tag-protection", target = "tag", rules = { deletion = true } }
|
||||
}
|
||||
repository = {}
|
||||
}
|
||||
|
||||
expect_failures = [var.ruleset]
|
||||
}
|
||||
|
||||
run "private_required_checks_rejected" {
|
||||
command = plan
|
||||
|
||||
|
||||
Reference in New Issue
Block a user