5
0
mirror of https://github.com/odoo/runbot.git synced 2025-03-16 16:05:42 +07:00

[IMP] runbot_merge: delete repos being created in remote tests

In remote tests, if the deletion of a test repository fails (because
gh glitch) or the repo creation succeeded but reported a failure (for
some reason) the entire run is hosed because every test trying to
create a similarly named repository will explode.

Alter repomaker to just try to delete the repo, unless --no-delete
mode in which case just skip any further test trying to use the same
repository (not deleting the repo is the entire point of --no-delete,
as its purpose is the ability to do post-mortem debugging on
repository state).

closes 
This commit is contained in:
Xavier Morel 2019-02-28 16:28:08 +01:00
parent 79b03a6995
commit 55ece42d8f

View File

@ -245,6 +245,17 @@ def make_repo(request, config, project, github, tunnel, users, owner):
repos = []
def repomaker(name):
fullname = '{}/{}'.format(owner, name)
repo_url = 'https://api.github.com/repos/{}'.format(fullname)
if request.config.getoption('--no-delete'):
if github.head(repo_url).ok:
pytest.skip("Repository {} already exists".format(fullname))
else:
# just try to delete the repo, we don't really care
if github.delete(repo_url).ok:
# if we did delete a repo, wait a bit as gh might need to
# propagate the thing?
time.sleep(30)
# create repo
r = github.post(endpoint, json={
'name': name,
@ -260,12 +271,12 @@ def make_repo(request, config, project, github, tunnel, users, owner):
r.raise_for_status()
repos.append(fullname)
# unwatch repo
github.put('https://api.github.com/repos/{}/subscription'.format(fullname), json={
github.put('{}/subscription'.format(repo_url), json={
'subscribed': False,
'ignored': True,
})
# create webhook
github.post('https://api.github.com/repos/{}/hooks'.format(fullname), json={
github.post('{}/hooks'.format(repo_url), json={
'name': 'web',
'config': {
'url': '{}/runbot_merge/hooks'.format(tunnel),