mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] various improvements
This commit is contained in:
parent
12bb6d05a1
commit
019cee7f54
@ -127,6 +127,12 @@ def s2human(time):
|
|||||||
def flatten(list_of_lists):
|
def flatten(list_of_lists):
|
||||||
return itertools.chain.from_iterable(list_of_lists)
|
return itertools.chain.from_iterable(list_of_lists)
|
||||||
|
|
||||||
|
def decode_utf(field):
|
||||||
|
try:
|
||||||
|
return field.decode('utf-8')
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
return ''
|
||||||
|
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# RunBot Models
|
# RunBot Models
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
@ -236,16 +242,11 @@ class runbot_repo(osv.osv):
|
|||||||
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/*/head:refs/pull/*'])
|
repo.git(['fetch', '-p', 'origin', '+refs/pull/*/head:refs/pull/*'])
|
||||||
|
|
||||||
fields = ['refname','objectname','authordate:iso8601','authorname','subject']
|
fields = ['refname','objectname','committerdate:iso8601','authorname','subject']
|
||||||
fmt = "%00".join(["%("+field+")" for field in fields])
|
fmt = "%00".join(["%("+field+")" for field in fields])
|
||||||
git_refs = repo.git(['for-each-ref', '--format', fmt, '--sort=-committerdate', 'refs/heads', 'refs/pull'])
|
git_refs = repo.git(['for-each-ref', '--format', fmt, '--sort=-committerdate', 'refs/heads', 'refs/pull'])
|
||||||
git_refs = git_refs.strip()
|
git_refs = git_refs.strip()
|
||||||
|
|
||||||
def decode_utf(string):
|
|
||||||
try:
|
|
||||||
return field.decode('utf-8')
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
return ''
|
|
||||||
refs = [[decode_utf(field) for field in line.split('\x00')] for line in git_refs.split('\n')]
|
refs = [[decode_utf(field) for field in line.split('\x00')] for line in git_refs.split('\n')]
|
||||||
|
|
||||||
for name, sha, date, author, subject in refs:
|
for name, sha, date, author, subject in refs:
|
||||||
@ -738,15 +739,20 @@ class runbot_build(osv.osv):
|
|||||||
def force(self, cr, uid, ids, context=None):
|
def force(self, cr, uid, ids, context=None):
|
||||||
"""Force a rebuild"""
|
"""Force a rebuild"""
|
||||||
for build in self.browse(cr, uid, ids, context=context):
|
for build in self.browse(cr, uid, ids, context=context):
|
||||||
domain = [('repo_id','=',build.repo_id.id), ('state', '=', 'pending')]
|
domain = [('state', '=', 'pending')]
|
||||||
new_id = self.search(cr, uid, domain, order='id', limit=1)[0]
|
pending_ids = self.search(cr, uid, domain, order='id', limit=1)
|
||||||
|
if len(pending_ids):
|
||||||
|
sequence = pending_ids[0]
|
||||||
|
else:
|
||||||
|
sequence = self.search(cr, uid, [], order='id desc', limit=1)[0]
|
||||||
|
|
||||||
# Force it now
|
# Force it now
|
||||||
if build.state == 'done' and build.result == 'skipped':
|
if build.state == 'done' and build.result == 'skipped':
|
||||||
build.write({'state': 'pending', 'sequence':new_id, 'result': '' })
|
build.write({'state': 'pending', 'sequence':sequence, 'result': '' })
|
||||||
# or duplicate it
|
# or duplicate it
|
||||||
elif build.state in ['running','done']:
|
elif build.state in ['running', 'done', 'duplicate']:
|
||||||
new_build = {
|
new_build = {
|
||||||
'sequence': new_id,
|
'sequence': sequence,
|
||||||
'branch_id': build.branch_id.id,
|
'branch_id': build.branch_id.id,
|
||||||
'name': build.name,
|
'name': build.name,
|
||||||
'author': build.author,
|
'author': build.author,
|
||||||
@ -926,29 +932,10 @@ class RunbotController(http.Controller):
|
|||||||
build_ids = flatten(build_by_branch_ids.values())
|
build_ids = flatten(build_by_branch_ids.values())
|
||||||
build_dict = {build.id: build for build in build_obj.browse(cr, uid, build_ids, context=request.context) }
|
build_dict = {build.id: build for build in build_obj.browse(cr, uid, build_ids, context=request.context) }
|
||||||
|
|
||||||
def build_info(build):
|
|
||||||
real_build = build.duplicate_id if build.state == 'duplicate' else build
|
|
||||||
return {
|
|
||||||
'id': build.id,
|
|
||||||
'name': build.name,
|
|
||||||
'state': real_build.state,
|
|
||||||
'result': real_build.result,
|
|
||||||
'subject': build.subject,
|
|
||||||
'author': build.author,
|
|
||||||
'dest': build.dest,
|
|
||||||
'real_dest': real_build.dest,
|
|
||||||
'job_age': s2human(real_build.job_age),
|
|
||||||
'job_time': s2human(real_build.job_time),
|
|
||||||
'job': real_build.job,
|
|
||||||
'domain': real_build.domain,
|
|
||||||
'port': real_build.port,
|
|
||||||
'subject': build.subject,
|
|
||||||
}
|
|
||||||
|
|
||||||
def branch_info(branch):
|
def branch_info(branch):
|
||||||
return {
|
return {
|
||||||
'branch': branch,
|
'branch': branch,
|
||||||
'builds': [build_info(build_dict[build_id]) for build_id in build_by_branch_ids[branch.id]]
|
'builds': [self.build_info(build_dict[build_id]) for build_id in build_by_branch_ids[branch.id]]
|
||||||
}
|
}
|
||||||
|
|
||||||
context.update({
|
context.update({
|
||||||
@ -962,32 +949,58 @@ class RunbotController(http.Controller):
|
|||||||
|
|
||||||
return request.render("runbot.repo", context)
|
return request.render("runbot.repo", context)
|
||||||
|
|
||||||
|
def build_info(self, build):
|
||||||
|
real_build = build.duplicate_id if build.state == 'duplicate' else build
|
||||||
|
return {
|
||||||
|
'id': build.id,
|
||||||
|
'name': build.name,
|
||||||
|
'state': real_build.state,
|
||||||
|
'result': real_build.result,
|
||||||
|
'subject': build.subject,
|
||||||
|
'author': build.author,
|
||||||
|
'dest': build.dest,
|
||||||
|
'real_dest': real_build.dest,
|
||||||
|
'job_age': s2human(real_build.job_age),
|
||||||
|
'job_time': s2human(real_build.job_time),
|
||||||
|
'job': real_build.job,
|
||||||
|
'domain': real_build.domain,
|
||||||
|
'port': real_build.port,
|
||||||
|
'subject': build.subject,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@http.route(['/runbot/build/<build_id>'], type='http', auth="public", website=True)
|
@http.route(['/runbot/build/<build_id>'], type='http', auth="public", website=True)
|
||||||
def build(self, build_id=None, search=None, **post):
|
def build(self, build_id=None, search=None, **post):
|
||||||
registry, cr, uid, context = request.registry, request.cr, 1, request.context
|
registry, cr, uid, context = request.registry, request.cr, 1, request.context
|
||||||
|
|
||||||
build = registry['runbot.build'].browse(cr, uid, [int(build_id)])[0]
|
Build = registry['runbot.build']
|
||||||
|
Logging = registry['ir.logging']
|
||||||
|
|
||||||
|
build = Build.browse(cr, uid, [int(build_id)])[0]
|
||||||
|
real_build = build.duplicate_id if build.state == 'duplicate' else build
|
||||||
|
|
||||||
# other builds
|
# other builds
|
||||||
build_ids = registry['runbot.build'].search(cr, uid, [('branch_id', '=', build.branch_id.id)])
|
build_ids = Build.search(cr, uid, [('branch_id', '=', build.branch_id.id)])
|
||||||
other_builds = registry['runbot.build'].browse(cr, uid, build_ids)
|
other_builds = Build.browse(cr, uid, build_ids)
|
||||||
|
|
||||||
domain = ['|', ('dbname', '=like', '%s-%%' % build.dest), ('build_id', '=', build.id)]
|
domain = ['|', ('dbname', '=like', '%s-%%' % real_build.dest), ('build_id', '=', real_build.id)]
|
||||||
#if type:
|
#if type:
|
||||||
# domain.append(('type', '=', type))
|
# domain.append(('type', '=', type))
|
||||||
#if level:
|
#if level:
|
||||||
# domain.append(('level', '=', level))
|
# domain.append(('level', '=', level))
|
||||||
if search:
|
if search:
|
||||||
domain.append(('name', 'ilike', search))
|
domain.append(('name', 'ilike', search))
|
||||||
logging_ids = registry['ir.logging'].search(cr, uid, domain)
|
logging_ids = Logging.search(cr, uid, domain)
|
||||||
logs = registry['ir.logging'].browse(cr, uid, logging_ids)
|
|
||||||
|
|
||||||
context = self.common(cr, uid)
|
context = {
|
||||||
|
'repo': build.repo_id,
|
||||||
|
'build': self.build_info(build),
|
||||||
|
'br': {'branch': build.branch_id},
|
||||||
|
'logs': Logging.browse(cr, uid, logging_ids),
|
||||||
|
'other_builds': other_builds
|
||||||
|
}
|
||||||
#context['type'] = type
|
#context['type'] = type
|
||||||
#context['level'] = level
|
#context['level'] = level
|
||||||
context['build'] = build
|
|
||||||
context['other_builds'] = other_builds
|
|
||||||
context['logs'] = logs
|
|
||||||
return request.render("runbot.build", context)
|
return request.render("runbot.build", context)
|
||||||
|
|
||||||
@http.route(['/runbot/build/<build_id>/force'], type='http', auth="public", website=True)
|
@http.route(['/runbot/build/<build_id>/force'], type='http', auth="public", website=True)
|
||||||
|
@ -401,9 +401,9 @@
|
|||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" t-attf-href="/runbot/repo/#{ slug(build.repo_id) }"><b><t t-esc="build.repo_id.base"/></b></a>
|
<a class="navbar-brand" t-attf-href="/runbot/repo/#{ slug(repo) }"><b><t t-esc="repo.base"/></b></a>
|
||||||
<a class="navbar-brand" t-attf-href="/runbot/build/{{build.id}}">
|
<a class="navbar-brand" t-attf-href="/runbot/build/{{build['id']}}">
|
||||||
<t t-esc="build.dest"/>
|
<t t-esc="build['dest']"/>
|
||||||
<t t-call="runbot.build_name">
|
<t t-call="runbot.build_name">
|
||||||
<t t-set="bu" t-value="build"/>
|
<t t-set="bu" t-value="build"/>
|
||||||
<t t-set="klass" t-value="''"/>
|
<t t-set="klass" t-value="''"/>
|
||||||
@ -453,7 +453,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<form class="navbar-form navbar-right" role="search" t-attf-action="/runbot/build/{{build.id}}" method="get">
|
<form class="navbar-form navbar-right" role="search" t-attf-action="/runbot/build/{{build['id']}}" method="get">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="search" name="search" class="form-control" placeholder="Search" t-att-value="search or ''"/>
|
<input type="search" name="search" class="form-control" placeholder="Search" t-att-value="search or ''"/>
|
||||||
<button type="submit" class="btn btn-default">Search</button>
|
<button type="submit" class="btn btn-default">Search</button>
|
||||||
@ -463,8 +463,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<p>
|
<p>
|
||||||
Subject: <t t-esc="build.subject"/><br/>
|
Subject: <t t-esc="build['subject']"/><br/>
|
||||||
Author: <t t-esc="build.author"/><br/>
|
Author: <t t-esc="build['author']"/><br/>
|
||||||
</p>
|
</p>
|
||||||
<table class="table table-condensed table-striped">
|
<table class="table table-condensed table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
@ -479,7 +479,7 @@
|
|||||||
<td><b t-esc="l.level"/></td>
|
<td><b t-esc="l.level"/></td>
|
||||||
<td><t t-esc="l.type"/></td>
|
<td><t t-esc="l.type"/></td>
|
||||||
<td>
|
<td>
|
||||||
<a t-attf-href="https://{{build.repo_id.base}}/blob/{{build.name}}/{{l.path}}#L{{l.line}}"><t t-esc="l.name"/>:<t t-esc="l.line"/></a> <t t-esc="l.func"/>
|
<a t-attf-href="https://{{repo.base}}/blob/{{build['name']}}/{{l.path}}#L{{l.line}}"><t t-esc="l.name"/>:<t t-esc="l.line"/></a> <t t-esc="l.func"/>
|
||||||
<t t-if="'\n' not in l.message"><t t-esc="l.message"/></t>
|
<t t-if="'\n' not in l.message"><t t-esc="l.message"/></t>
|
||||||
<pre t-if="'\n' in l.message" style="margin:0;padding:0; border: none;"><t t-esc="l.message"/></pre>
|
<pre t-if="'\n' in l.message" style="margin:0;padding:0; border: none;"><t t-esc="l.message"/></pre>
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user