Skip to content

Commit 0c7d6eb

Browse files
committed
Add ZuulOnly branch protection
stackhpc/neutron is a first example of a Zuul only CI repo, stackhpc/2025.1 and stackhpc/2026.1 only run Zuul jobs and we can use ``gate`` label to gate the patches for Zuul to merge them. Disable the permission for regular human users to merge patches in these repositories.
1 parent 8d6e4fc commit 0c7d6eb

3 files changed

Lines changed: 75 additions & 2 deletions

File tree

‎terraform/github/branches.tf‎

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ resource "github_branch_protection" "openstack_branch_protection_caracal" {
523523
}
524524

525525
resource "github_branch_protection" "openstack_branch_protection_epoxy" {
526-
for_each = toset(var.repositories["OpenStack"])
526+
for_each = toset([for r in var.repositories["OpenStack"] : r if !contains(var.repositories["ZuulOnly"], r)])
527527
repository_id = data.github_repository.repositories[each.key].node_id
528528

529529
pattern = "stackhpc/2025.1"
@@ -562,7 +562,7 @@ resource "github_branch_protection" "openstack_branch_protection_epoxy" {
562562
}
563563

564564
resource "github_branch_protection" "openstack_branch_protection_gazpacho" {
565-
for_each = toset(var.repositories["OpenStack"])
565+
for_each = toset([for r in var.repositories["OpenStack"] : r if !contains(var.repositories["ZuulOnly"], r)])
566566
repository_id = data.github_repository.repositories[each.key].node_id
567567

568568
pattern = "stackhpc/2026.1"
@@ -637,6 +637,75 @@ resource "github_branch_protection" "openstack_branch_protection_master" {
637637
}
638638
}
639639

640+
# ZuulOnly: push_allowances contains only the Zuul GitHub App, so PRs can only be
641+
# merged by Zuul (typically after the "gate" label enqueues the change into its gate
642+
# pipeline). Neither the Developers team nor the owning team can merge directly.
643+
# Only the stackhpc/2025.1 and stackhpc/2026.1 branches are gated this way for now;
644+
# neutron's other branches keep normal OpenStack-group protection (see openstack_branch_protection_*).
645+
resource "github_branch_protection" "zuulonly_branch_protection_epoxy" {
646+
for_each = toset(var.repositories["ZuulOnly"])
647+
repository_id = data.github_repository.repositories[each.key].node_id
648+
649+
pattern = "stackhpc/2025.1"
650+
require_conversation_resolution = true
651+
allows_deletions = false
652+
allows_force_pushes = false
653+
654+
restrict_pushes {
655+
blocks_creations = false
656+
push_allowances = [
657+
local.zuul_app_node_id
658+
]
659+
}
660+
661+
required_pull_request_reviews {
662+
dismiss_stale_reviews = true
663+
require_code_owner_reviews = true
664+
required_approving_review_count = 1
665+
}
666+
667+
required_status_checks {
668+
contexts = ["stackhpc/check"]
669+
strict = false
670+
}
671+
672+
lifecycle {
673+
prevent_destroy = true
674+
}
675+
}
676+
677+
resource "github_branch_protection" "zuulonly_branch_protection_gazpacho" {
678+
for_each = toset(var.repositories["ZuulOnly"])
679+
repository_id = data.github_repository.repositories[each.key].node_id
680+
681+
pattern = "stackhpc/2026.1"
682+
require_conversation_resolution = true
683+
allows_deletions = false
684+
allows_force_pushes = false
685+
686+
restrict_pushes {
687+
blocks_creations = false
688+
push_allowances = [
689+
local.zuul_app_node_id
690+
]
691+
}
692+
693+
required_pull_request_reviews {
694+
dismiss_stale_reviews = true
695+
require_code_owner_reviews = true
696+
required_approving_review_count = 1
697+
}
698+
699+
required_status_checks {
700+
contexts = ["stackhpc/check"]
701+
strict = false
702+
}
703+
704+
lifecycle {
705+
prevent_destroy = true
706+
}
707+
}
708+
640709
resource "github_branch_protection" "platform_branch_protection" {
641710
for_each = toset(var.repositories["Platform"])
642711
repository_id = data.github_repository.repositories[each.key].node_id

‎terraform/github/terraform.tfvars.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
"stackhpc-inspector-plugins"
8585
],
8686
"Platform": [],
87+
"ZuulOnly": [
88+
"neutron"
89+
],
8790
"ReleaseTrain": [
8891
".github",
8992
"ARC-Installer",

‎terraform/github/variables.tf‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ variable "repositories" {
2727
"Platform" = [],
2828
"ReleaseTrain" = [],
2929
"SMSLab" = [],
30+
"ZuulOnly" = [],
3031
}
3132
}
3233

0 commit comments

Comments
 (0)