mirror of
https://github.com/odoo/runbot.git
synced 2025-04-13 22:00:55 +07:00

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
69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
import pytest
|
|
import requests
|
|
|
|
@pytest.fixture()
|
|
def module():
|
|
return 'runbot_merge'
|
|
|
|
@pytest.fixture
|
|
def page(port):
|
|
s = requests.Session()
|
|
def get(url):
|
|
r = s.get('http://localhost:{}{}'.format(port, url))
|
|
r.raise_for_status()
|
|
return r.content
|
|
return get
|
|
|
|
@pytest.fixture
|
|
def default_crons():
|
|
return [
|
|
# env['runbot_merge.project']._check_fetch()
|
|
'runbot_merge.fetch_prs_cron',
|
|
# env['runbot_merge.commit']._notify()
|
|
'runbot_merge.process_updated_commits',
|
|
# env['runbot_merge.project']._check_stagings()
|
|
'runbot_merge.merge_cron',
|
|
# env['runbot_merge.project']._create_stagings()
|
|
'runbot_merge.staging_cron',
|
|
# env['runbot_merge.pull_requests']._check_linked_prs_statuses()
|
|
'runbot_merge.check_linked_prs_status',
|
|
# env['runbot_merge.pull_requests.feedback']._send()
|
|
'runbot_merge.feedback_cron',
|
|
]
|
|
|
|
@pytest.fixture
|
|
def project(env, config):
|
|
return env['runbot_merge.project'].create({
|
|
'name': 'odoo',
|
|
'github_token': config['github']['token'],
|
|
'github_prefix': 'hansen',
|
|
'branch_ids': [(0, 0, {'name': 'master'})],
|
|
})
|
|
|
|
|
|
@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')
|