mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] repo creation error handling + warnings
* The repo would only be registered at the very end of the creation, meaning an error *during* the repo creation (e.g. while uploading the first blob or setting up webhooks) would leave the repository undeleted. Register the repository as soon as we know it was created, in order to correctly dispose of it afterwards. * Migrate logging.warning call to warnings.warn on repository deletion failure: pytest will print warnings during its reporting, not so for log warnings (?)
This commit is contained in:
parent
b55e38ae2d
commit
e542dfc852
12
conftest.py
12
conftest.py
@ -54,6 +54,7 @@ import subprocess
|
||||
import sys
|
||||
import time
|
||||
import uuid
|
||||
import warnings
|
||||
import xmlrpc.client
|
||||
from contextlib import closing
|
||||
|
||||
@ -383,6 +384,7 @@ def make_repo(capsys, request, config, tunnel, users):
|
||||
'allow_rebase_merge': False,
|
||||
})
|
||||
r.raise_for_status()
|
||||
repo = Repo(github, fullname, repos)
|
||||
|
||||
# create webhook
|
||||
github.post('{}/hooks'.format(repo_url), json={
|
||||
@ -401,8 +403,9 @@ def make_repo(capsys, request, config, tunnel, users):
|
||||
'content': base64.b64encode(b'whee').decode('ascii'),
|
||||
'branch': 'garbage_%s' % uuid.uuid4()
|
||||
}).raise_for_status()
|
||||
|
||||
return Repo(github, fullname, repos)
|
||||
# try to unwatch repo, doesn't actually work
|
||||
repo.unsubscribe()
|
||||
return repo
|
||||
|
||||
yield repomaker
|
||||
|
||||
@ -433,9 +436,6 @@ class Repo:
|
||||
self.hook = False
|
||||
repos.append(self)
|
||||
|
||||
# unwatch repo
|
||||
self.unsubscribe()
|
||||
|
||||
@property
|
||||
def owner(self):
|
||||
return self.name.split('/')[0]
|
||||
@ -470,7 +470,7 @@ class Repo:
|
||||
def delete(self):
|
||||
r = self._session.delete('https://api.github.com/repos/{}'.format(self.name))
|
||||
if r.status_code != 204:
|
||||
logging.getLogger(__name__).warning("Unable to delete repository %s", self.name)
|
||||
warnings.warn("Unable to delete repository %s (HTTP %s)" % (self.name, r.status_code))
|
||||
|
||||
def set_secret(self, secret):
|
||||
assert self.hook
|
||||
|
Loading…
Reference in New Issue
Block a user