Skip to content

Commit cbfd759

Browse files
authored
Merge pull request #310 from stackhpc/caracal-bp
Update branch protection rules for caracal
2 parents 364f7c0 + f8a308c commit cbfd759

File tree

3 files changed

+156
-10
lines changed

3 files changed

+156
-10
lines changed

docs/usage/source-code-ci.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The table below contains the different workflows with a description of each and
2727

2828
OpenStack use [Tox](https://wiki.openstack.org/wiki/Testing) to manage the unit tests and style checks for the various projects they maintain.
2929
Therefore, when a `pull request` is opened the tox workflow will automatically perform a series of unit tests and linting in order ensure correctness and style guidelines are being met.
30-
The python environment will depend on the branch pre-Zed, python 3.6 and python 3.8 will be tested. From Zed onward, python 3.8 and python 3.10 will be tested.
30+
The python environment will depend on the branch pre-Zed, python 3.6 and python 3.8 will be tested. From Zed onward, python 3.8 and python 3.10 will be tested, though only python 3.10 will be required for Caracal.
3131
This can be controlled within the strategy matrix of the workflow.
3232
The Python versions should correspond to those used in the supported OS distributions for a particular release.
3333
The source for the workflow can be found [here](https://github.com/stackhpc/.github/blob/main/.github/workflows/tox.yml).

terraform/github/branches.tf

Lines changed: 144 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ resource "github_branch_protection" "kayobe_branch_protection_py_3-6" {
100100
}
101101
}
102102

103-
resource "github_branch_protection" "kayobe_branch_protection_py_3-10" {
103+
resource "github_branch_protection" "kayobe_branch_protection_zed" {
104104
for_each = toset(var.repositories["Kayobe"])
105105
repository_id = data.github_repository.repositories[each.key].node_id
106106

107-
pattern = "stackhpc/[z,2]*"
107+
pattern = "stackhpc/zed"
108108
require_conversation_resolution = true
109109
allows_deletions = false
110110
allows_force_pushes = false
@@ -120,7 +120,7 @@ resource "github_branch_protection" "kayobe_branch_protection_py_3-10" {
120120
]
121121

122122
required_status_checks {
123-
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/[z,2]*", lookup(var.required_status_checks, each.key, {
123+
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/zed", lookup(var.required_status_checks, each.key, {
124124
"default" : [
125125
"tox / Tox pep8 with Python 3.10",
126126
"tox / Tox py3 with Python 3.10",
@@ -135,6 +135,75 @@ resource "github_branch_protection" "kayobe_branch_protection_py_3-10" {
135135
}
136136
}
137137

138+
resource "github_branch_protection" "kayobe_branch_protection_antelope" {
139+
for_each = toset(var.repositories["Kayobe"])
140+
repository_id = data.github_repository.repositories[each.key].node_id
141+
142+
pattern = "stackhpc/2023.1"
143+
require_conversation_resolution = true
144+
allows_deletions = false
145+
allows_force_pushes = false
146+
147+
required_pull_request_reviews {
148+
dismiss_stale_reviews = true
149+
require_code_owner_reviews = true
150+
required_approving_review_count = 1
151+
}
152+
153+
push_restrictions = [
154+
resource.github_team.organisation_teams["Developers"].node_id
155+
]
156+
157+
required_status_checks {
158+
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/2023.1", lookup(var.required_status_checks, each.key, {
159+
"default" : [
160+
"tox / Tox pep8 with Python 3.10",
161+
"tox / Tox py3 with Python 3.10",
162+
"tox / Tox py3 with Python 3.8"
163+
]
164+
}).default)
165+
strict = false
166+
}
167+
168+
lifecycle {
169+
prevent_destroy = true
170+
}
171+
}
172+
173+
resource "github_branch_protection" "kayobe_branch_protection_caracal" {
174+
for_each = toset(var.repositories["Kayobe"])
175+
repository_id = data.github_repository.repositories[each.key].node_id
176+
177+
pattern = "stackhpc/2024.1"
178+
require_conversation_resolution = true
179+
allows_deletions = false
180+
allows_force_pushes = false
181+
182+
required_pull_request_reviews {
183+
dismiss_stale_reviews = true
184+
require_code_owner_reviews = true
185+
required_approving_review_count = 1
186+
}
187+
188+
push_restrictions = [
189+
resource.github_team.organisation_teams["Developers"].node_id
190+
]
191+
192+
required_status_checks {
193+
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/2024.1", lookup(var.required_status_checks, each.key, {
194+
"default" : [
195+
"tox / Tox pep8 with Python 3.10",
196+
"tox / Tox py3 with Python 3.10"
197+
]
198+
}).default)
199+
strict = false
200+
}
201+
202+
lifecycle {
203+
prevent_destroy = true
204+
}
205+
}
206+
138207
resource "github_branch_protection" "openstack_branch_protection_py_3-6" {
139208
for_each = toset(var.repositories["OpenStack"])
140209
repository_id = data.github_repository.repositories[each.key].node_id
@@ -173,11 +242,11 @@ resource "github_branch_protection" "openstack_branch_protection_py_3-6" {
173242
}
174243
}
175244

176-
resource "github_branch_protection" "openstack_branch_protection_py_3-10" {
245+
resource "github_branch_protection" "openstack_branch_protection_zed" {
177246
for_each = toset(var.repositories["OpenStack"])
178247
repository_id = data.github_repository.repositories[each.key].node_id
179248

180-
pattern = "stackhpc/[z,2]*"
249+
pattern = "stackhpc/zed"
181250
require_conversation_resolution = true
182251
allows_deletions = false
183252
allows_force_pushes = false
@@ -193,7 +262,7 @@ resource "github_branch_protection" "openstack_branch_protection_py_3-10" {
193262
}
194263

195264
required_status_checks {
196-
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/[z,2]*", lookup(var.required_status_checks, each.key, {
265+
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/zed", lookup(var.required_status_checks, each.key, {
197266
"default" : [
198267
"tox / Tox pep8 with Python 3.10",
199268
"tox / Tox py3 with Python 3.10",
@@ -208,6 +277,75 @@ resource "github_branch_protection" "openstack_branch_protection_py_3-10" {
208277
}
209278
}
210279

280+
resource "github_branch_protection" "openstack_branch_protection_antelope" {
281+
for_each = toset(var.repositories["OpenStack"])
282+
repository_id = data.github_repository.repositories[each.key].node_id
283+
284+
pattern = "stackhpc/2023.1"
285+
require_conversation_resolution = true
286+
allows_deletions = false
287+
allows_force_pushes = false
288+
289+
push_restrictions = [
290+
resource.github_team.organisation_teams["Developers"].node_id
291+
]
292+
293+
required_pull_request_reviews {
294+
dismiss_stale_reviews = true
295+
require_code_owner_reviews = true
296+
required_approving_review_count = 1
297+
}
298+
299+
required_status_checks {
300+
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/2023.1", lookup(var.required_status_checks, each.key, {
301+
"default" : [
302+
"tox / Tox pep8 with Python 3.10",
303+
"tox / Tox py3 with Python 3.10",
304+
"tox / Tox py3 with Python 3.8"
305+
]
306+
}).default)
307+
strict = false
308+
}
309+
310+
lifecycle {
311+
prevent_destroy = false
312+
}
313+
}
314+
315+
resource "github_branch_protection" "openstack_branch_protection_caracal" {
316+
for_each = toset(var.repositories["OpenStack"])
317+
repository_id = data.github_repository.repositories[each.key].node_id
318+
319+
pattern = "stackhpc/2024.1"
320+
require_conversation_resolution = true
321+
allows_deletions = false
322+
allows_force_pushes = false
323+
324+
push_restrictions = [
325+
resource.github_team.organisation_teams["Developers"].node_id
326+
]
327+
328+
required_pull_request_reviews {
329+
dismiss_stale_reviews = true
330+
require_code_owner_reviews = true
331+
required_approving_review_count = 1
332+
}
333+
334+
required_status_checks {
335+
contexts = lookup(lookup(var.required_status_checks, each.key, {}), "stackhpc/2024.1", lookup(var.required_status_checks, each.key, {
336+
"default" : [
337+
"tox / Tox pep8 with Python 3.10",
338+
"tox / Tox py3 with Python 3.10"
339+
]
340+
}).default)
341+
strict = false
342+
}
343+
344+
lifecycle {
345+
prevent_destroy = false
346+
}
347+
}
348+
211349
resource "github_branch_protection" "platform_branch_protection" {
212350
for_each = toset(var.repositories["Platform"])
213351
repository_id = data.github_repository.repositories[each.key].node_id

terraform/github/import_resources.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
Import existing GitHub resources from the `stackhpc` organisation
55
so that they maybe managed by Terraform. It shall only import resources
6-
that are defined within the `terraform.tfvars.json` file nd are currently
6+
that are defined within the `terraform.tfvars.json` file and are currently
77
available on GitHub.
88
"""
99

@@ -223,9 +223,17 @@ def main() -> None:
223223
branch_protection_resource = BranchProtection(team_id.name.lower(
224224
), {f"{name}:stackhpc/[vwxy]*": name for name in team_repositories}, parsed_args.dry_run, "_py_3-6")
225225
branch_protection_resource.refresh_resource()
226-
# Post-Zed branch protection
226+
# Zed branch protection
227227
branch_protection_resource = BranchProtection(team_id.name.lower(
228-
), {f"{name}:stackhpc/[z,2]*": name for name in team_repositories}, parsed_args.dry_run, "_py_3-10")
228+
), {f"{name}:stackhpc/zed": name for name in team_repositories}, parsed_args.dry_run, "_zed")
229+
branch_protection_resource.refresh_resource()
230+
# Antelope branch protection
231+
branch_protection_resource = BranchProtection(team_id.name.lower(
232+
), {f"{name}:stackhpc/2023.1": name for name in team_repositories}, parsed_args.dry_run, "_antelope")
233+
branch_protection_resource.refresh_resource()
234+
# Caracal branch protection
235+
branch_protection_resource = BranchProtection(team_id.name.lower(
236+
), {f"{name}:stackhpc/2024.1": name for name in team_repositories}, parsed_args.dry_run, "_caracal")
229237
branch_protection_resource.refresh_resource()
230238
else:
231239
branch_protection_resource = BranchProtection(team_id.name.lower(

0 commit comments

Comments
 (0)