mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[FIX] runbot_merge: behaviour when no CI are required
If the required_statuses are empty, PRs should always be validated (and just require a review) rather than never be merge-able. Fixes #216
This commit is contained in:
parent
0152271fb8
commit
60c8f0f498
@ -812,7 +812,7 @@ class PullRequests(models.Model):
|
|||||||
# targets
|
# targets
|
||||||
failed = self.browse(())
|
failed = self.browse(())
|
||||||
for pr in self:
|
for pr in self:
|
||||||
required = pr.repository.project_id.required_statuses.split(',')
|
required = filter(None, pr.repository.project_id.required_statuses.split(','))
|
||||||
|
|
||||||
success = True
|
success = True
|
||||||
for ci in required:
|
for ci in required:
|
||||||
@ -830,7 +830,6 @@ class PullRequests(models.Model):
|
|||||||
'pull_request': pr.number,
|
'pull_request': pr.number,
|
||||||
'message': "%r failed on this reviewed PR." % ci,
|
'message': "%r failed on this reviewed PR." % ci,
|
||||||
})
|
})
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
oldstate = pr.state
|
oldstate = pr.state
|
||||||
if oldstate == 'opened':
|
if oldstate == 'opened':
|
||||||
@ -860,8 +859,7 @@ class PullRequests(models.Model):
|
|||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
pr = super().create(vals)
|
pr = super().create(vals)
|
||||||
c = self.env['runbot_merge.commit'].search([('sha', '=', pr.head)])
|
c = self.env['runbot_merge.commit'].search([('sha', '=', pr.head)])
|
||||||
if c and c.statuses:
|
pr._validate(json.loads(c.statuses or '{}'))
|
||||||
pr._validate(json.loads(c.statuses))
|
|
||||||
|
|
||||||
if pr.state not in ('closed', 'merged'):
|
if pr.state not in ('closed', 'merged'):
|
||||||
self.env['runbot_merge.pull_requests.tagging'].create({
|
self.env['runbot_merge.pull_requests.tagging'].create({
|
||||||
|
@ -871,6 +871,24 @@ def test_reopen_state(env, repo):
|
|||||||
assert pr.state == 'validated', \
|
assert pr.state == 'validated', \
|
||||||
"if a PR is reopened and had a CI'd head, it should be validated immediately"
|
"if a PR is reopened and had a CI'd head, it should be validated immediately"
|
||||||
|
|
||||||
|
def test_no_required_statuses(env, repo):
|
||||||
|
""" check that mergebot can work on a repo with no CI at all
|
||||||
|
"""
|
||||||
|
env['runbot_merge.project'].search([]).required_statuses = ''
|
||||||
|
m = repo.make_commit(None, 'initial', None, tree={'0': '0'})
|
||||||
|
repo.make_ref('heads/master', m)
|
||||||
|
|
||||||
|
c = repo.make_commit(m, 'first', None, tree={'0': '1'})
|
||||||
|
prx = repo.make_pr('title', 'body', target='master', ctid=c, user='user')
|
||||||
|
prx.post_comment('hansen r+', 'reviewer')
|
||||||
|
|
||||||
|
run_crons(env)
|
||||||
|
|
||||||
|
assert env['runbot_merge.pull_requests'].search([
|
||||||
|
('repository.name', '=', repo.name),
|
||||||
|
('number', '=', prx.number)
|
||||||
|
]).state == 'ready'
|
||||||
|
|
||||||
class TestRetry:
|
class TestRetry:
|
||||||
@pytest.mark.xfail(reason="This may not be a good idea as it could lead to tons of rebuild spam")
|
@pytest.mark.xfail(reason="This may not be a good idea as it could lead to tons of rebuild spam")
|
||||||
def test_auto_retry_push(self, env, repo):
|
def test_auto_retry_push(self, env, repo):
|
||||||
|
Loading…
Reference in New Issue
Block a user