Skip to content

Commit b28627a

Browse files
[PTFE-583] ✨ Prevent creation of integration branches
1 parent d1034a2 commit b28627a

File tree

3 files changed

+37
-58
lines changed

3 files changed

+37
-58
lines changed

bert_e/templates/request_integration_branches.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ To request integration branches, please comment on this pull request with the fo
1212
```
1313
/create_integration_branches
1414
```
15+
16+
Alternatively, there's another way to accomplish this. Simply tag this PR with `/approve` or
17+
`/create_pull_requests`, and it will automatically create the integration branches
18+
1519
{% endblock %}

bert_e/tests/test_bert_e.py

Lines changed: 28 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ def test_request_integration_branch_creation(self):
11821182
required_leader_approvals: 0
11831183
required_peer_approvals: 1
11841184
always_create_integration_branches: false
1185+
always_create_integration_pull_requests: false
11851186
admins:
11861187
- {admin}
11871188
""" # noqa
@@ -1285,65 +1286,41 @@ def test_creation_integration_branch_by_approve(self):
12851286
admins:
12861287
- {admin}
12871288
""" # noqa
1288-
options = self.bypass_all_but(['bypass_build_status', 'bypass_author_approval'])
1289-
pr = self.create_pr('feature/TEST-0069', 'development/4.3')
1290-
1291-
with self.assertRaises(exns.ApprovalRequired):
1292-
self.handle(pr.id, options=options, backtrace=True)
1293-
1294-
self.assertEqual(len(list(pr.get_comments())), 3)
1295-
1296-
self.assertIn(
1297-
'Integration data created', list(pr.get_comments())[-2].text)
1298-
1299-
self.assertIn(
1300-
'Waiting for approval', self.get_last_pr_comment(pr))
1301-
self.assertIn(
1302-
'The following approvals are needed', self.get_last_pr_comment(pr))
1303-
1304-
pr.approve()
1305-
1306-
with self.assertRaises(exns.BuildNotStarted):
1307-
self.handle(
1308-
pr.id, settings=settings, options=options, backtrace=True)
1309-
1310-
options = self.bypass_all
1311-
with self.assertRaises(exns.SuccessMessage):
1312-
self.handle(
1313-
pr.id, settings=settings, options=options, backtrace=True)
1314-
1315-
self.assertIn(
1316-
'I have successfully merged the changeset', self.get_last_pr_comment(pr))
1317-
1318-
options = self.bypass_all_but(['bypass_build_status', 'bypass_author_approval'])
1319-
pr = self.create_pr('feature/TEST-0070', 'development/4.3')
1289+
pr_1 = self.create_pr('feature/TEST-0069', 'development/4.3')
1290+
pr_2 = self.create_pr('feature/TEST-0070', 'development/4.3')
1291+
prs = [pr_1, pr_2]
13201292

1321-
with self.assertRaises(exns.ApprovalRequired):
1322-
self.handle(pr.id, options=options, backtrace=True)
1293+
for pr in prs:
1294+
options = self.bypass_all_but(['bypass_build_status', 'bypass_author_approval'])
1295+
with self.assertRaises(exns.ApprovalRequired):
1296+
self.handle(pr.id, options=options, backtrace=True)
13231297

1324-
self.assertEqual(len(list(pr.get_comments())), 3)
1298+
self.assertEqual(len(list(pr.get_comments())), 3)
13251299

1326-
self.assertIn(
1300+
self.assertIn(
13271301
'Integration data created', list(pr.get_comments())[-2].text)
13281302

1329-
self.assertIn(
1330-
'Waiting for approval', self.get_last_pr_comment(pr))
1331-
self.assertIn(
1332-
'The following approvals are needed', self.get_last_pr_comment(pr))
1303+
self.assertIn(
1304+
'Waiting for approval', self.get_last_pr_comment(pr))
1305+
self.assertIn(
1306+
'The following approvals are needed', self.get_last_pr_comment(pr))
13331307

1334-
pr.add_comment('/approve')
1308+
if pr.src_branch == "feature/TEST-0069":
1309+
pr.approve()
1310+
elif pr.src_branch == "feature/TEST-0070":
1311+
pr.add_comment('/approve')
13351312

1336-
with self.assertRaises(exns.BuildNotStarted):
1337-
self.handle(
1338-
pr.id, settings=settings, options=options, backtrace=True)
1313+
with self.assertRaises(exns.BuildNotStarted):
1314+
self.handle(
1315+
pr.id, settings=settings, options=options, backtrace=True)
13391316

1340-
options = self.bypass_all
1341-
with self.assertRaises(exns.SuccessMessage):
1342-
self.handle(
1343-
pr.id, settings=settings, options=options, backtrace=True)
1344-
1345-
self.assertIn(
1346-
'I have successfully merged the changeset', self.get_last_pr_comment(pr))
1317+
options = self.bypass_all
1318+
with self.assertRaises(exns.SuccessMessage):
1319+
self.handle(
1320+
pr.id, settings=settings, options=options, backtrace=True)
1321+
1322+
self.assertIn(
1323+
'I have successfully merged the changeset', self.get_last_pr_comment(pr))
13471324

13481325
def test_integration_branch_creation_latest_branch(self):
13491326
"""Test there is no comment to request integration branches creation.

bert_e/workflow/gitwaterflow/integration.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,13 @@ def check_integration_branches(job):
144144
approvals.add(job.pull_request.author)
145145
approved_by_author = job.pull_request.author in approvals
146146

147-
always_create_integration = job.settings.always_create_integration_branches
148-
create_integration = job.settings.create_integration_branches
149-
always_create_integration_prs = job.settings.always_create_integration_pull_requests
150-
create_prs = job.settings.create_pull_requests
147+
create_integration = (job.settings.always_create_integration_branches or
148+
job.settings.create_integration_branches)
149+
create_prs = (job.settings.always_create_integration_pull_requests or
150+
job.settings.create_pull_requests)
151151
multiple_dst_branches = len(job.git.cascade.dst_branches) <= 1
152152

153-
if not (always_create_integration
154-
or create_integration
155-
or always_create_integration_prs
153+
if not (create_integration
156154
or create_prs
157155
or approved_by_author
158156
or multiple_dst_branches):

0 commit comments

Comments
 (0)