Skip to content

Commit

Permalink
Merge pull request #235 from stackhpc/branch-status-checks
Browse files Browse the repository at this point in the history
Support branch-specific branch protection rules
  • Loading branch information
Alex-Welsh authored Sep 4, 2023
2 parents 33f2a3a + 2795a27 commit 778ab14
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 57 deletions.
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"
]
}
}
}

0 comments on commit 778ab14

Please sign in to comment.