Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support branch-specific branch protection rules #235

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 33 additions & 25 deletions terraform/github/branches.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "github_branch_protection" "ansible_branch_protection" {
]

required_status_checks {
contexts = lookup(var.required_status_checks, each.key, [])
contexts = lookup(var.required_status_checks, each.key, { "default" : [] }).default
strict = false
}

Expand Down Expand Up @@ -52,7 +52,7 @@ resource "github_branch_protection" "batch_branch_protection" {
]

required_status_checks {
contexts = lookup(var.required_status_checks, each.key, [])
contexts = lookup(var.required_status_checks, each.key, { "default" : [] }).default
strict = false
}

Expand Down Expand Up @@ -84,11 +84,13 @@ resource "github_branch_protection" "kayobe_branch_protection_py_3-6" {
]

required_status_checks {
contexts = lookup(var.required_status_checks, each.key, [
"tox / Tox pep8 with Python 3.8",
"tox / Tox py3 with Python 3.6",
"tox / Tox py3 with Python 3.8",
])
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/[vwxy]*", lookup(var.required_status_checks, each.key, {
"default" : [
"tox / Tox pep8 with Python 3.8",
"tox / Tox py3 with Python 3.8",
"tox / Tox py3 with Python 3.6"
]
}).default)
strict = false
}

Expand Down Expand Up @@ -117,11 +119,13 @@ resource "github_branch_protection" "kayobe_branch_protection_py_3-10" {
]

required_status_checks {
contexts = lookup(var.required_status_checks, each.key, [
"tox / Tox pep8 with Python 3.10",
"tox / Tox py3 with Python 3.10",
"tox / Tox py3 with Python 3.8",
])
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/[z,2]*", lookup(var.required_status_checks, each.key, {
"default" : [
"tox / Tox pep8 with Python 3.10",
"tox / Tox py3 with Python 3.10",
"tox / Tox py3 with Python 3.8"
]
}).default)
strict = false
}

Expand Down Expand Up @@ -153,11 +157,13 @@ resource "github_branch_protection" "openstack_branch_protection_py_3-6" {
}

required_status_checks {
contexts = lookup(var.required_status_checks, each.key, [
"tox / Tox pep8 with Python 3.8",
"tox / Tox py3 with Python 3.6",
"tox / Tox py3 with Python 3.8",
])
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/[vwxy]*", lookup(var.required_status_checks, each.key, {
"default" : [
"tox / Tox pep8 with Python 3.8",
"tox / Tox py3 with Python 3.8",
"tox / Tox py3 with Python 3.6"
]
}).default)
strict = false
}
lifecycle {
Expand Down Expand Up @@ -185,11 +191,13 @@ resource "github_branch_protection" "openstack_branch_protection_py_3-10" {
}

required_status_checks {
contexts = lookup(var.required_status_checks, each.key, [
"tox / Tox pep8 with Python 3.10",
"tox / Tox py3 with Python 3.10",
"tox / Tox py3 with Python 3.8",
])
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/[z,2]*", lookup(var.required_status_checks, each.key, {
"default" : [
"tox / Tox pep8 with Python 3.10",
"tox / Tox py3 with Python 3.10",
"tox / Tox py3 with Python 3.8"
]
}).default)
strict = false
}

Expand Down Expand Up @@ -218,7 +226,7 @@ resource "github_branch_protection" "platform_branch_protection" {
]

required_status_checks {
contexts = lookup(var.required_status_checks, each.key, [])
contexts = lookup(var.required_status_checks, each.key, { "default" : [] }).default
strict = false
}

Expand Down Expand Up @@ -247,7 +255,7 @@ resource "github_branch_protection" "releasetrain_branch_protection" {
]

required_status_checks {
contexts = lookup(var.required_status_checks, each.key, [])
contexts = lookup(var.required_status_checks, each.key, { "default" : [] }).default
strict = false
}

Expand Down Expand Up @@ -276,7 +284,7 @@ resource "github_branch_protection" "smslab_branch_protection" {
]

required_status_checks {
contexts = lookup(var.required_status_checks, each.key, [])
contexts = lookup(var.required_status_checks, each.key, { "default" : [] }).default
strict = false
}

Expand Down
94 changes: 62 additions & 32 deletions terraform/github/terraform.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,37 +296,67 @@
"community_files"
],
"required_status_checks": {
"ansible-collection-pulp": [
"integration (3.16)",
"integration (3.21)",
"lint (2.10)",
"lint (2.12)",
"lint (2.9)"
],
"designate-dashboard": [],
"horizon": [],
"ironic-ui": [],
"magnum-ui": [],
"neutron": [],
"octavia-dashboard": [],
"openstack-admin-guide": [
"Build OpenStack admin guide"
],
"stackhpc-kayobe-config": [
"Tox pep8 with Python 3.8",
"Tox releasenotes with Python 3.8",
"Build Kayobe Image / Build kayobe image",
"aio (CentOS OVS) / All in one",
"aio (CentOS OVN) / All in one",
"aio (Rocky OVS) / All in one",
"aio (Rocky OVN) / All in one",
"aio (Ubuntu OVS) / All in one",
"aio (Ubuntu OVN) / All in one"
],
"stackhpc-release-train": [
"Ansible Lint",
"Ansible Validations",
"Build documentation"
]
"ansible-collection-pulp": {
"default": [
"integration (3.16)",
"integration (3.21)",
"lint (2.10)",
"lint (2.12)",
"lint (2.9)"
]
},
"designate-dashboard": {
"default": []
},
"horizon": {
"default": []
},
"ironic-ui": {
"default": []
},
"magnum-ui": {
"default": []
},
"neutron": {
"default": []
},
"octavia-dashboard": {
"default": []
},
"openstack-admin-guide": {
"default": [
"Build OpenStack admin guide"
]
},
"stackhpc-kayobe-config": {
"default": ["none"],
"stackhpc/[vwxy]*": [
"Tox pep8 with Python 3.8",
"Tox releasenotes with Python 3.8",
"Build Kayobe Image / Build kayobe image",
"aio (CentOS OVS) / All in one",
"aio (CentOS OVN) / All in one",
"aio (Rocky OVS) / All in one",
"aio (Rocky OVN) / All in one",
"aio (Ubuntu OVS) / All in one",
"aio (Ubuntu OVN) / All in one"
],
"stackhpc/[z,2]*": [
"Tox pep8 with Python 3.10",
"Tox releasenotes with Python 3.10",
"Build Kayobe Image / Build kayobe image",
"aio (Rocky 9 OVS) / All in one",
"aio (Rocky 9 OVN) / All in one",
"aio (Ubuntu Jammy OVS) / All in one",
"aio (Ubuntu Jammy OVN) / All in one"
]
},
"stackhpc-release-train": {
"default": [
"Ansible Lint",
"Ansible Validations",
"Build documentation"
]
}
}
}