-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/PTFE-583-prevent-creation-integration-branches'…
… into q/3.9
- Loading branch information
Showing
12 changed files
with
312 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% extends "message.md" %} | ||
|
||
{% block title -%} | ||
Request integration branches | ||
{% endblock %} | ||
|
||
{% block message %} | ||
Waiting for integration branch creation to be requested by the user. | ||
|
||
To request integration branches, please comment on this pull request with the following command: | ||
|
||
``` | ||
/create_integration_branches | ||
``` | ||
|
||
Alternatively, the `/approve` and `/create_pull_requests` commands will automatically | ||
create the integration branches. | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1159,6 +1159,210 @@ def test_comments_without_integration_pull_requests(self): | |
self.assertIn('Hello %s' % self.args.contributor_username, | ||
self.get_last_pr_comment(pr)) | ||
|
||
def test_request_integration_branch_creation(self): | ||
"""Test comments to request integration branches creation. | ||
1. Create a PR and ensure the proper message is sent regarding | ||
the creation of integration branches. | ||
2. Request the creation of integration branches and ensure the | ||
branches are created. | ||
3. Once the integration branches are created, | ||
ensure the bot is able to merge the PR. | ||
""" | ||
settings = """ | ||
repository_owner: {owner} | ||
repository_slug: {slug} | ||
repository_host: {host} | ||
robot: {robot} | ||
robot_email: [email protected] | ||
pull_request_base_url: https://bitbucket.org/{owner}/{slug}/bar/pull-requests/{{pr_id}} | ||
commit_base_url: https://bitbucket.org/{owner}/{slug}/commits/{{commit_id}} | ||
build_key: pre-merge | ||
required_leader_approvals: 0 | ||
required_peer_approvals: 1 | ||
always_create_integration_branches: false | ||
always_create_integration_pull_requests: false | ||
admins: | ||
- {admin} | ||
""" # noqa | ||
options = self.bypass_all_but(['bypass_build_status']) | ||
pr = self.create_pr('feature/TEST-0069', 'development/4.3') | ||
with self.assertRaises(exns.RequestIntegrationBranches): | ||
self.handle( | ||
pr.id, settings=settings, options=options, backtrace=True) | ||
self.assertEqual(len(list(pr.get_comments())), 2) | ||
self.assertIn( | ||
'Request integration branches', self.get_last_pr_comment(pr)) | ||
self.assertIn( | ||
'/create_integration_branches', self.get_last_pr_comment(pr)) | ||
|
||
pr.add_comment('/create_integration_branches') | ||
with self.assertRaises(exns.BuildNotStarted): | ||
self.handle( | ||
pr.id, settings=settings, options=options, backtrace=True) | ||
self.assertEqual(len(list(pr.get_comments())), 4) | ||
self.assertIn('Integration data created', self.get_last_pr_comment(pr)) | ||
self.assertIn( | ||
'create_integration_branches', self.get_last_pr_comment(pr)) | ||
|
||
options = self.bypass_all | ||
with self.assertRaises(exns.SuccessMessage): | ||
self.handle( | ||
pr.id, settings=settings, options=options, backtrace=True) | ||
|
||
def test_request_integration_branch_by_creating_pull_requests(self): | ||
"""Test creating integration branches by creating pull requests | ||
1. Create a PR and verify that the appropriate message is sent | ||
regarding its creation | ||
2. Type `/create_integration_branches` and ensure the | ||
branches are created. | ||
3. Once the integration branches are created, | ||
ensure the bot is able to merge the PR. | ||
""" | ||
settings = """ | ||
repository_owner: {owner} | ||
repository_slug: {slug} | ||
repository_host: {host} | ||
robot: {robot} | ||
robot_email: [email protected] | ||
pull_request_base_url: https://bitbucket.org/{owner}/{slug}/bar/pull-requests/{{pr_id}} | ||
commit_base_url: https://bitbucket.org/{owner}/{slug}/commits/{{commit_id}} | ||
build_key: pre-merge | ||
required_leader_approvals: 0 | ||
required_peer_approvals: 1 | ||
always_create_integration_branches: false | ||
always_create_integration_pull_requests: false | ||
admins: | ||
- {admin} | ||
""" # noqa | ||
options = self.bypass_all_but(['bypass_build_status']) | ||
pr = self.create_pr('feature/TEST-0069', 'development/4.3') | ||
with self.assertRaises(exns.RequestIntegrationBranches): | ||
self.handle( | ||
pr.id, settings=settings, options=options, backtrace=True) | ||
|
||
pr.add_comment('/create_pull_requests') | ||
with self.assertRaises(exns.BuildNotStarted): | ||
self.handle( | ||
pr.id, settings=settings, options=options, backtrace=True) | ||
self.assertEqual(len(list(pr.get_comments())), 4) | ||
self.assertIn('Integration data created', self.get_last_pr_comment(pr)) | ||
|
||
options = self.bypass_all | ||
with self.assertRaises(exns.SuccessMessage): | ||
self.handle( | ||
pr.id, settings=settings, options=options, backtrace=True) | ||
|
||
self.assertIn( | ||
'I have successfully merged the changeset', | ||
self.get_last_pr_comment(pr)) | ||
|
||
def test_creation_integration_branch_by_approve(self): | ||
"""Test pr.approve() to request integration branches creation. | ||
1. Create a PR and verify that the appropriate message is sent | ||
regarding its creation | ||
2. Ensure that author approval is required for the PR | ||
3. Approve the PR from the author's perspective and check if | ||
the integration branches are created. | ||
4. Once the integration branches are created, | ||
ensure the bot is able to merge the PR. | ||
""" | ||
settings = """ | ||
repository_owner: {owner} | ||
repository_slug: {slug} | ||
repository_host: {host} | ||
robot: {robot} | ||
robot_email: [email protected] | ||
pull_request_base_url: https://bitbucket.org/{owner}/{slug}/bar/pull-requests/{{pr_id}} | ||
commit_base_url: https://bitbucket.org/{owner}/{slug}/commits/{{commit_id}} | ||
build_key: pre-merge | ||
required_leader_approvals: 0 | ||
required_peer_approvals: 0 | ||
always_create_integration_branches: false | ||
admins: | ||
- {admin} | ||
""" # noqa | ||
pr_1 = self.create_pr('feature/TEST-0069', 'development/4.3') | ||
pr_2 = self.create_pr('feature/TEST-0070', 'development/4.3') | ||
prs = [pr_1, pr_2] | ||
|
||
for pr in prs: | ||
options = self.bypass_all_but(['bypass_build_status', | ||
'bypass_author_approval']) | ||
with self.assertRaises(exns.ApprovalRequired): | ||
self.handle(pr.id, options=options, backtrace=True) | ||
|
||
self.assertEqual(len(list(pr.get_comments())), 3) | ||
|
||
self.assertIn( | ||
'Integration data created', list(pr.get_comments())[-2].text) | ||
|
||
self.assertIn( | ||
'Waiting for approval', self.get_last_pr_comment(pr)) | ||
self.assertIn( | ||
'The following approvals are needed', | ||
self.get_last_pr_comment(pr)) | ||
|
||
if pr.src_branch == "feature/TEST-0069": | ||
pr.approve() | ||
elif pr.src_branch == "feature/TEST-0070": | ||
pr.add_comment('/approve') | ||
|
||
with self.assertRaises(exns.BuildNotStarted): | ||
self.handle( | ||
pr.id, settings=settings, options=options, backtrace=True) | ||
|
||
options = self.bypass_all | ||
with self.assertRaises(exns.SuccessMessage): | ||
self.handle( | ||
pr.id, settings=settings, options=options, backtrace=True) | ||
|
||
self.assertIn( | ||
'I have successfully merged the changeset', | ||
self.get_last_pr_comment(pr)) | ||
|
||
def test_integration_branch_creation_latest_branch(self): | ||
"""Test there is no comment to request integration branches creation. | ||
1. Create a PR with the latest branch and check if there is no comment | ||
to request integration branches creation. | ||
2. Then, ensure the bot is able to merge the PR. | ||
""" | ||
settings = """ | ||
repository_owner: {owner} | ||
repository_slug: {slug} | ||
repository_host: {host} | ||
robot: {robot} | ||
robot_email: [email protected] | ||
pull_request_base_url: https://bitbucket.org/{owner}/{slug}/bar/pull-requests/{{pr_id}} | ||
commit_base_url: https://bitbucket.org/{owner}/{slug}/commits/{{commit_id}} | ||
build_key: pre-merge | ||
required_leader_approvals: 0 | ||
required_peer_approvals: 1 | ||
always_create_integration_branches: false | ||
admins: | ||
- {admin} | ||
""" # noqa | ||
options = self.bypass_all_but(['bypass_build_status']) | ||
pr = self.create_pr('feature/TEST-0069', 'development/10.0') | ||
self.handle(pr.id, settings=settings, options=options) | ||
self.assertEqual(len(list(pr.get_comments())), 1) | ||
|
||
with self.assertRaises(exns.BuildNotStarted): | ||
self.handle( | ||
pr.id, settings=settings, options=options, backtrace=True) | ||
|
||
options = self.bypass_all | ||
with self.assertRaises(exns.SuccessMessage): | ||
self.handle( | ||
pr.id, settings=settings, options=options, backtrace=True) | ||
|
||
def test_comments_for_manual_integration_pr_creation(self): | ||
"""Test comments when integration data is created. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.