mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot_merge: PR source branch/label handling
Remote's labels are not entirely under our control as the part before ":" is the *owner* of the source repo => introduce additional "owned" fixture to handle this case, as it may diverge from the "user" role if running the tests against an organisation.
This commit is contained in:
parent
0725c77323
commit
7451a94358
@ -104,7 +104,7 @@ class Repo(object):
|
||||
|
||||
def make_pr(self, title, body, target, ctid, user, label=None):
|
||||
assert 'heads/%s' % target in self.refs
|
||||
return PR(self, title, body, target, ctid, user=user, label=label or '{}:{}'.format(user, target))
|
||||
return PR(self, title, body, target, ctid, user=user, label='{}:{}'.format(user, label or target))
|
||||
|
||||
def make_ref(self, name, commit, force=False):
|
||||
assert isinstance(self.objects[commit], Commit)
|
||||
|
@ -44,6 +44,10 @@ def env(registry):
|
||||
|
||||
cr.rollback()
|
||||
|
||||
@pytest.fixture
|
||||
def owner():
|
||||
return 'user'
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def users(env):
|
||||
env['res.partner'].create({
|
||||
|
@ -886,7 +886,7 @@ class TestBatching(object):
|
||||
for i, t in enumerate(trees):
|
||||
tree.update(t)
|
||||
c = repo.make_commit(c, 'commit_{}_{:02}'.format(prefix, i), None, tree=dict(tree))
|
||||
pr = repo.make_pr('title {}'.format(prefix), 'body {}'.format(prefix), target=target, ctid=c, user=user, label='{}:{}'.format(user, prefix))
|
||||
pr = repo.make_pr('title {}'.format(prefix), 'body {}'.format(prefix), target=target, ctid=c, user=user, label=prefix)
|
||||
|
||||
for context, result in statuses:
|
||||
repo.post_status(c, result, context)
|
||||
@ -927,8 +927,8 @@ class TestBatching(object):
|
||||
pr21 = self._pr(repo, 'PR1', [{'a': 'AAA'}, {'b': 'BBB'}])
|
||||
pr22 = self._pr(repo, 'PR2', [{'c': 'CCC'}, {'d': 'DDD'}])
|
||||
|
||||
pr11 = self._pr(repo, 'Pressing 1', [{'x': 'x'}, {'y': 'y'}])
|
||||
pr12 = self._pr(repo, 'Pressing 2', [{'z': 'z'}, {'zz': 'zz'}])
|
||||
pr11 = self._pr(repo, 'Pressing1', [{'x': 'x'}, {'y': 'y'}])
|
||||
pr12 = self._pr(repo, 'Pressing2', [{'z': 'z'}, {'zz': 'zz'}])
|
||||
pr11.post_comment('hansen priority=1', 'reviewer')
|
||||
pr12.post_comment('hansen priority=1', 'reviewer')
|
||||
|
||||
@ -952,8 +952,8 @@ class TestBatching(object):
|
||||
pr21 = self._pr(repo, 'PR1', [{'a': 'AAA'}, {'b': 'BBB'}])
|
||||
pr22 = self._pr(repo, 'PR2', [{'c': 'CCC'}, {'d': 'DDD'}])
|
||||
|
||||
pr11 = self._pr(repo, 'Pressing 1', [{'x': 'x'}, {'y': 'y'}])
|
||||
pr12 = self._pr(repo, 'Pressing 2', [{'z': 'z'}, {'zz': 'zz'}])
|
||||
pr11 = self._pr(repo, 'Pressing1', [{'x': 'x'}, {'y': 'y'}])
|
||||
pr12 = self._pr(repo, 'Pressing2', [{'z': 'z'}, {'zz': 'zz'}])
|
||||
pr11.post_comment('hansen priority=1', 'reviewer')
|
||||
pr12.post_comment('hansen priority=1', 'reviewer')
|
||||
|
||||
@ -967,7 +967,7 @@ class TestBatching(object):
|
||||
staging_1 = p_11.staging_id
|
||||
|
||||
# no statuses run on PR0s
|
||||
pr01 = self._pr(repo, 'Urgent 1', [{'n': 'n'}, {'o': 'o'}], reviewer=None, statuses=[])
|
||||
pr01 = self._pr(repo, 'Urgent1', [{'n': 'n'}, {'o': 'o'}], reviewer=None, statuses=[])
|
||||
pr01.post_comment('hansen priority=0', 'reviewer')
|
||||
p_01 = self._get(env, repo, pr01.number)
|
||||
assert p_01.state == 'opened'
|
||||
@ -1025,7 +1025,7 @@ class TestBatching(object):
|
||||
p_21 = self._get(env, repo, pr21.number)
|
||||
|
||||
# no statuses run on PR0s
|
||||
pr01 = self._pr(repo, 'Urgent 1', [{'n': 'n'}, {'o': 'o'}], reviewer=None, statuses=[])
|
||||
pr01 = self._pr(repo, 'Urgent1', [{'n': 'n'}, {'o': 'o'}], reviewer=None, statuses=[])
|
||||
pr01.post_comment('hansen priority=0', 'reviewer')
|
||||
p_01 = self._get(env, repo, pr01.number)
|
||||
p_01.state = 'error'
|
||||
|
@ -42,8 +42,7 @@ def make_pr(repo, prefix, trees, *, target='master', user='user', label=None,
|
||||
tree.update(t)
|
||||
c = repo.make_commit(c, 'commit_{}_{:02}'.format(prefix, i), None,
|
||||
tree=dict(tree))
|
||||
pr = repo.make_pr('title {}'.format(prefix), 'body {}'.format(prefix), target=target,
|
||||
ctid=c, user=user, label=label and '{}:{}'.format(user, label))
|
||||
pr = repo.make_pr('title {}'.format(prefix), 'body {}'.format(prefix), target=target, ctid=c, user=user, label=label)
|
||||
for context, result in statuses:
|
||||
repo.post_status(c, result, context)
|
||||
if reviewer:
|
||||
@ -221,7 +220,7 @@ def test_ff_fail(env, project, repo_a, repo_b):
|
||||
assert len(st) == 1
|
||||
assert len(st.batch_ids.prs) == 2
|
||||
|
||||
def test_one_failed(env, project, repo_a, repo_b):
|
||||
def test_one_failed(env, project, repo_a, repo_b, owner):
|
||||
""" If the companion of a ready branch-matched PR is not ready,
|
||||
they should not get staged
|
||||
"""
|
||||
@ -236,7 +235,7 @@ def test_one_failed(env, project, repo_a, repo_b):
|
||||
c_pr = repo_b.make_commit(c_b, 'pr', None, tree={'a': 'b_1'})
|
||||
pr_b = repo_b.make_pr(
|
||||
'title', 'body', target='master', ctid=c_pr,
|
||||
user='user', label='user:do-a-thing',
|
||||
user='user', label='do-a-thing',
|
||||
)
|
||||
repo_b.post_status(c_pr, 'success', 'ci/runbot')
|
||||
repo_b.post_status(c_pr, 'success', 'legal/cla')
|
||||
@ -245,7 +244,7 @@ def test_one_failed(env, project, repo_a, repo_b):
|
||||
pr_b = to_pr(env, pr_b)
|
||||
assert pr_a.state == 'ready'
|
||||
assert pr_b.state == 'validated'
|
||||
assert pr_a.label == pr_b.label == 'user:do-a-thing'
|
||||
assert pr_a.label == pr_b.label == '{}:do-a-thing'.format(owner)
|
||||
|
||||
env['runbot_merge.project']._check_progress()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user