2019-09-23 18:54:42 +07:00
|
|
|
import pytest
|
2018-03-14 16:37:46 +07:00
|
|
|
|
2020-01-21 20:56:57 +07:00
|
|
|
@pytest.fixture()
|
2019-09-23 18:54:42 +07:00
|
|
|
def module():
|
|
|
|
return 'runbot_merge'
|
2019-10-10 14:22:12 +07:00
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def project(env, config):
|
|
|
|
return env['runbot_merge.project'].create({
|
|
|
|
'name': 'odoo',
|
|
|
|
'github_token': config['github']['token'],
|
|
|
|
'github_prefix': 'hansen',
|
2024-11-29 15:04:06 +07:00
|
|
|
'github_name': config['github']['name'],
|
|
|
|
'github_email': "foo@example.org",
|
2019-10-10 14:22:12 +07:00
|
|
|
'branch_ids': [(0, 0, {'name': 'master'})],
|
2019-11-20 20:57:40 +07:00
|
|
|
})
|
[ADD] *: per-repository webhook secret
Currently webhook secrets are configured per *project* which is an
issue both because different repositories may have different
administrators and thus creates safety concerns, and because multiple
repositories can feed into different projects (e.g. on mergebot,
odoo-dev/odoo is both an ancillary repository to the main RD project,
and the main repository to the minor / legacy master-wowl
project). This means it can be necessary to have multiple projects
share the same secret as well, this then mandates the secret for more
repositories per (1).
This is a pain in the ass, so just detach secrets from projects and
link them *only* to repositories, it's cleaner and easier to manage
and set up progressively.
This requires a lot of changes to the tests, as they all need to
correctly configure the signaling.
For `runbot_merge` there was *some* setup sharing already via the
module-level `repo` fixtures`, those were merged into a conftest-level
fixture which could handle the signaling setup. A few tests which
unnecessarily set up repositories ad-hoc were also moved to the
fixture. But for most of the ad-hoc setup in `runbot_merge`, as well
as `forwardport` where it's all ad-hoc, events sources setup was just
appended as is. This should probably be cleaned up at one point, with
the various requirements collected and organised into a small set of
fixtures doing the job more uniformly.
Fixes #887
2024-06-06 16:07:57 +07:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def make_repo2(env, project, make_repo, users, setreviewers):
|
|
|
|
"""Layer over ``make_repo`` which also:
|
|
|
|
|
|
|
|
- adds the new repo to ``project`` (with no group and the ``'default'`` status required)
|
|
|
|
- sets the standard reviewers on the repo
|
|
|
|
- and creates an event source for the repo
|
|
|
|
"""
|
|
|
|
def mr(name):
|
|
|
|
r = make_repo(name)
|
|
|
|
rr = env['runbot_merge.repository'].create({
|
|
|
|
'project_id': project.id,
|
|
|
|
'name': r.name,
|
|
|
|
'group_id': False,
|
|
|
|
'required_statuses': 'default',
|
|
|
|
})
|
|
|
|
setreviewers(rr)
|
|
|
|
env['runbot_merge.events_sources'].create({'repository': r.name})
|
|
|
|
return r
|
|
|
|
return mr
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def repo(make_repo2):
|
|
|
|
return make_repo2('repo')
|