mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
runbot fixes
- rebuild create a new build - test pull head instead of merge - move commit status to a function, to add support for pending
This commit is contained in:
parent
5423ea2394
commit
c2ca8aeed9
@ -207,7 +207,7 @@ class runbot_repo(osv.osv):
|
|||||||
run(['git', 'clone', '--bare', repo.name, repo.path])
|
run(['git', 'clone', '--bare', repo.name, repo.path])
|
||||||
else:
|
else:
|
||||||
repo.git(['fetch', '-p', 'origin', '+refs/heads/*:refs/heads/*'])
|
repo.git(['fetch', '-p', 'origin', '+refs/heads/*:refs/heads/*'])
|
||||||
repo.git(['fetch', '-p', 'origin', '+refs/pull/*/merge:refs/pull/*'])
|
repo.git(['fetch', '-p', 'origin', '+refs/pull/*/head:refs/pull/*'])
|
||||||
out = repo.git(['for-each-ref', '--format', '["%(refname)","%(objectname)","%(authordate:iso8601)"]', '--sort=-committerdate', 'refs/heads'])
|
out = repo.git(['for-each-ref', '--format', '["%(refname)","%(objectname)","%(authordate:iso8601)"]', '--sort=-committerdate', 'refs/heads'])
|
||||||
refs = [simplejson.loads(i) for i in out.split('\n') if i]
|
refs = [simplejson.loads(i) for i in out.split('\n') if i]
|
||||||
out = repo.git(['for-each-ref', '--format', '["%(refname)","%(objectname)","%(authordate:iso8601)"]', '--sort=-committerdate', 'refs/pull'])
|
out = repo.git(['for-each-ref', '--format', '["%(refname)","%(objectname)","%(authordate:iso8601)"]', '--sort=-committerdate', 'refs/pull'])
|
||||||
@ -458,6 +458,8 @@ class runbot_build(osv.osv):
|
|||||||
# checkout branch
|
# checkout branch
|
||||||
build.branch_id.repo_id.git_export(build.name, build.path())
|
build.branch_id.repo_id.git_export(build.name, build.path())
|
||||||
|
|
||||||
|
# TODO use git log to get commit message date and author
|
||||||
|
|
||||||
# v6 rename bin -> openerp
|
# v6 rename bin -> openerp
|
||||||
if os.path.isdir(build.path('bin/addons')):
|
if os.path.isdir(build.path('bin/addons')):
|
||||||
shutil.move(build.path('bin'), build.path('openerp'))
|
shutil.move(build.path('bin'), build.path('openerp'))
|
||||||
@ -533,6 +535,7 @@ class runbot_build(osv.osv):
|
|||||||
|
|
||||||
def spawn(self, cmd, lock_path, log_path, cpu_limit=None, shell=False):
|
def spawn(self, cmd, lock_path, log_path, cpu_limit=None, shell=False):
|
||||||
def preexec_fn():
|
def preexec_fn():
|
||||||
|
os.setsid()
|
||||||
if cpu_limit:
|
if cpu_limit:
|
||||||
# set soft cpulimit
|
# set soft cpulimit
|
||||||
soft, hard = resource.getrlimit(resource.RLIMIT_CPU)
|
soft, hard = resource.getrlimit(resource.RLIMIT_CPU)
|
||||||
@ -547,6 +550,22 @@ class runbot_build(osv.osv):
|
|||||||
p=subprocess.Popen(cmd, stdout=out, stderr=out, preexec_fn=preexec_fn, shell=shell)
|
p=subprocess.Popen(cmd, stdout=out, stderr=out, preexec_fn=preexec_fn, shell=shell)
|
||||||
return p.pid
|
return p.pid
|
||||||
|
|
||||||
|
def github_status(self, cr, uid, ids, context=None):
|
||||||
|
for build in self.browse(cr, uid, ids, context=context):
|
||||||
|
# try to update github
|
||||||
|
try:
|
||||||
|
state = "success" if build.result == 'ok' else "failure"
|
||||||
|
status = {
|
||||||
|
"state": state,
|
||||||
|
"target_url": "http://runbot.odoo.com/runbot/build/%s" % build.id,
|
||||||
|
"description": "runbot build %s (runtime %ss)" % (build.dest, build.job_time),
|
||||||
|
"context": "continuous-integration/runbot"
|
||||||
|
}
|
||||||
|
build.repo_id.github('/repos/:owner/:repo/statuses/%s' % build.name, status)
|
||||||
|
_logger.debug("github status %s update to %s", build.name, state)
|
||||||
|
except Exception, e:
|
||||||
|
_logger.exception("github status error")
|
||||||
|
|
||||||
def job_10_test_base(self, cr, uid, build, lock_path, log_path):
|
def job_10_test_base(self, cr, uid, build, lock_path, log_path):
|
||||||
# checkout source
|
# checkout source
|
||||||
build.checkout()
|
build.checkout()
|
||||||
@ -576,25 +595,12 @@ class runbot_build(osv.osv):
|
|||||||
'job_end': time.strftime(openerp.tools.DEFAULT_SERVER_DATETIME_FORMAT, log_time),
|
'job_end': time.strftime(openerp.tools.DEFAULT_SERVER_DATETIME_FORMAT, log_time),
|
||||||
'result': 'ko',
|
'result': 'ko',
|
||||||
}
|
}
|
||||||
# TODO mark as failed too long post_install (after Modules loaded.)
|
|
||||||
if grep(log_all, "openerp.modules.loading: Modules loaded."):
|
if grep(log_all, "openerp.modules.loading: Modules loaded."):
|
||||||
if not grep(log_all, "FAIL"):
|
if not grep(log_all, "FAIL"):
|
||||||
v['result'] = "ok"
|
if not grep(build.path("openerp/test/common.py"), "post_install") or grep(log_all, "Initiating shutdown."):
|
||||||
|
v['result'] = "ok"
|
||||||
build.write(v)
|
build.write(v)
|
||||||
|
build.github_status()
|
||||||
# try to update github
|
|
||||||
try:
|
|
||||||
state = "success" if v['result'] == 'ok' else "failure"
|
|
||||||
status = {
|
|
||||||
"state": state,
|
|
||||||
"target_url": "http://runbot.odoo.com/runbot/build/%s" % build.name,
|
|
||||||
"description": "runbot build %s (runtime %ss)" % (build.dest, build.job_time),
|
|
||||||
"context": "continuous-integration/runbot"
|
|
||||||
}
|
|
||||||
build.repo_id.github('/repos/:owner/:repo/statuses/%s' % build.name, status)
|
|
||||||
_logger.debug("github status %s update to %s", build.name, state)
|
|
||||||
except Exception, e:
|
|
||||||
_logger.exception("github status error")
|
|
||||||
|
|
||||||
# run server
|
# run server
|
||||||
cmd, mods = build.cmd()
|
cmd, mods = build.cmd()
|
||||||
@ -631,14 +637,18 @@ class runbot_build(osv.osv):
|
|||||||
|
|
||||||
def force(self, cr, uid, ids, context=None):
|
def force(self, cr, uid, ids, context=None):
|
||||||
for build in self.browse(cr, uid, ids, context=context):
|
for build in self.browse(cr, uid, ids, context=context):
|
||||||
if build.state in ['running']:
|
max_id = self.search(cr, uid, [('repo_id','=',build.repo_id.id)], order='id desc', limit=1)[0]
|
||||||
build.kill()
|
# Force it now
|
||||||
max_ids = self.search(cr, uid, [('repo_id','=',build.repo_id.id)], order='id desc', limit=1)
|
if build.state in ['pending']:
|
||||||
build.write({
|
build.write({ 'sequence':max_id })
|
||||||
'sequence':max_ids[0],
|
# or duplicate it
|
||||||
'state':'pending',
|
elif build.state in ['running']:
|
||||||
'result':'',
|
d = {
|
||||||
})
|
'branch_id': build.branch_id.id,
|
||||||
|
'name': build.name,
|
||||||
|
'sequence': max_id,
|
||||||
|
}
|
||||||
|
self.create(cr, 1, d)
|
||||||
return build.repo_id.id
|
return build.repo_id.id
|
||||||
|
|
||||||
def schedule(self, cr, uid, ids, context=None):
|
def schedule(self, cr, uid, ids, context=None):
|
||||||
@ -828,8 +838,17 @@ class RunbotController(http.Controller):
|
|||||||
return werkzeug.utils.redirect('/runbot/repo/%s' % repo_id)
|
return werkzeug.utils.redirect('/runbot/repo/%s' % repo_id)
|
||||||
|
|
||||||
# kill ` ps faux | grep ./static | awk '{print $2}' `
|
# kill ` ps faux | grep ./static | awk '{print $2}' `
|
||||||
# ps faux| grep Cron | grep -v '_' | awk '{print $2}' | xargs kill
|
# ps faux| grep Cron | grep -- '-all' | awk '{print $2}' | xargs kill
|
||||||
# psql -l | grep " 000" | awk '{print $1}' | xargs -n1 dropdb
|
# psql -l | grep " 000" | awk '{print $1}' | xargs -n1 dropdb
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
# - cannibal branch
|
||||||
|
# - commit/pull more info
|
||||||
|
# - v6 support
|
||||||
|
|
||||||
# - host field in build
|
# - host field in build
|
||||||
|
# - unlink build to remove ir_logging entires # ondelete=cascade
|
||||||
|
# - gc either build or only old ir_logging
|
||||||
|
# - if nginx server logfiles via each virtual server or map /runbot/static to root
|
||||||
|
|
||||||
# vim:
|
# vim:
|
||||||
|
@ -215,6 +215,7 @@
|
|||||||
<div t-attf-class="btn-group {{klass}} pull-right">
|
<div t-attf-class="btn-group {{klass}} pull-right">
|
||||||
<div t-attf-class="btn-group {{klass}}">
|
<div t-attf-class="btn-group {{klass}}">
|
||||||
<a t-if="bu.state=='running'" t-attf-href="http://{{bu.domain}}/?db={{bu.dest}}-all" class="btn btn-primary"><i class="fa fa-sign-in"/></a>
|
<a t-if="bu.state=='running'" t-attf-href="http://{{bu.domain}}/?db={{bu.dest}}-all" class="btn btn-primary"><i class="fa fa-sign-in"/></a>
|
||||||
|
<a t-attf-href="/runbot/build/{{bu.name}}" class="btn btn-default"><i class="fa fa-file-text-o"/></a>
|
||||||
<a t-attf-href="https://#{bu.repo_id.base}/commit/#{bu.name}" class="btn btn-default"><i class="fa fa-github"/></a>
|
<a t-attf-href="https://#{bu.repo_id.base}/commit/#{bu.name}" class="btn btn-default"><i class="fa fa-github"/></a>
|
||||||
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-cog"/><span class="caret"></span></button>
|
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-cog"/><span class="caret"></span></button>
|
||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
|
Loading…
Reference in New Issue
Block a user