diff options
author | Yongqin Liu <yongqin.liu@linaro.org> | 2020-02-28 18:51:15 +0800 |
---|---|---|
committer | Yongqin Liu <yongqin.liu@linaro.org> | 2020-02-28 18:53:44 +0800 |
commit | 62f54c1a6a630daba4238e3d72176703a268ddd8 (patch) | |
tree | 5c52366a8d5e297ff035d606a12e3370aed93adf | |
parent | 81711fdfba2df3da1cfbf084fd8fa042eee294c7 (diff) |
lkft: add pages for describe information
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rw-r--r-- | lkft/models.py | 8 | ||||
-rw-r--r-- | lkft/templates/lkft-describe.html | 85 | ||||
-rw-r--r-- | lkft/templates/lkft-kernelchanges.html | 24 | ||||
-rw-r--r-- | lkft/urls.py | 6 | ||||
-rw-r--r-- | lkft/views.py | 84 |
5 files changed, 181 insertions, 26 deletions
diff --git a/lkft/models.py b/lkft/models.py index 67665be..f43200f 100644 --- a/lkft/models.py +++ b/lkft/models.py @@ -43,7 +43,7 @@ class CiBuildKernelChangeManager(models.Manager): class CiBuild(models.Model): name = models.CharField(max_length=255) number = models.IntegerField() - kernel_change = models.ForeignKey(KernelChange, null=True, on_delete=None) + kernel_change = models.ForeignKey(KernelChange, null=True, on_delete=models.CASCADE) timestamp = models.DateTimeField(null=True) duration = models.IntegerField(default=0) # total_seconds result = models.CharField(max_length=100, null=True, default="NOINFO") @@ -66,9 +66,9 @@ class ReportBuild(models.Model): # the version of the qareport build version = models.CharField(max_length=100) - kernel_change = models.ForeignKey(KernelChange, on_delete=None) - ci_build = models.ForeignKey(CiBuild, on_delete=None, related_name="ci_build") - ci_trigger_build = models.ForeignKey(CiBuild, on_delete=None, related_name='trigger_build') + kernel_change = models.ForeignKey(KernelChange, on_delete=models.CASCADE) + ci_build = models.ForeignKey(CiBuild, on_delete=models.CASCADE, related_name="ci_build") + ci_trigger_build = models.ForeignKey(CiBuild, on_delete=models.CASCADE, related_name='trigger_build') number_passed = models.IntegerField(default=0) number_failed = models.IntegerField(default=0) diff --git a/lkft/templates/lkft-describe.html b/lkft/templates/lkft-describe.html new file mode 100644 index 0000000..826f48e --- /dev/null +++ b/lkft/templates/lkft-describe.html @@ -0,0 +1,85 @@ +{% extends '_layouts/base.html' %} + +{% block title %} {{kernel_change.describe}} {% endblock %} + +{% block headline %}<h1>Kernel Change: {{kernel_change.describe}}</a></h1>{% endblock %} + +{% block content %} +<div> +<h1>Trigger Build</h1> +<table border="1"> + <tr> + <th>Name</th> + <th>Number</th> + <th>Status</th> + <th>StartedAt</th> + <th>Duration</th> +</tr> +<tr> + <td><a href="https://ci.linaro.org/job/{{trigger_build.name}}/">{{trigger_build.name}}</a></td> + <td align='right'><a href="https://ci.linaro.org/job/{{trigger_build.name}}/{{trigger_build.number}}/">{{trigger_build.number}}</a></td> + <td>{{trigger_build.result}}</td> + <td><p>Started at {{ trigger_build.timestamp|date:'M. d, Y, H:i'}}, <br/>{{ trigger_build.timestamp|timesince}} ago</p></td> + <td align='right'>{{trigger_build.duration}}</td> +</tr> +</table> +</div> + +<div> +<h1>CI Builds</h1> +<table border="1"> + <tr> + <th>Index</th> + <th>Name</th> + <th>Number</th> + <th>Status</th> + <th>QueuedTime</th> + <th>StartedAt</th> + <th>Duration</th> +</tr> +{% for cibuild in ci_builds %} +<tr> + <td>{{ forloop.counter }}</td> + <td><a href="https://ci.linaro.org/job/{{cibuild.name}}/">{{cibuild.name}}</a></td> + <td align='right'><a href="https://ci.linaro.org/job/{{cibuild.name}}/{{cibuild.number}}/">{{cibuild.number}}</a></td> + <td>{{cibuild.result}}</td> + <td align='right'>{{cibuild.queued_duration}}</td> + <td><p>Started at {{ cibuild.timestamp|date:'M. d, Y, H:i'}}, <br/>{{ cibuild.timestamp|timesince}} ago</p></td> + <td align='right'>{{cibuild.duration}}</td> +</tr> +{% endfor %} +</table> +</div> + +<div> +<h1>Test Results</h1> +<table border="1"> + <tr> + <th>Index</th> + <th>Group</th> + <th>Name</th> + <th>StartedAt</th> + <th>Duration</th> + <th>Pass</th> + <th>Fail</th> + <th>Total</th> + <th>Modules Done</th> + <th>Modules Total</th> +</tr> +{% for report_build in report_builds %} +<tr> + <td>{{ forloop.counter }}</td> + <td><a href="https://qa-reports.linaro.org/{{report_build.group}}/">{{report_build.group}}</a></td> + <td><a href="https://qa-reports.linaro.org/{{report_build.group}}/{{report_build.name}}/">{{report_build.name}}</a></td> + <td><p>Started at {{ report_build.started_at|date:'M. d, Y, H:i'}},<br/>{{ report_build.started_at|timesince}} ago</p></td> + <td align='right'>{{report_build.duration}}</td> + <td align='right'>{{report_build.number_passed}}</td> + <td align='right'>{{report_build.number_failed}}</td> + <td align='right'>{{report_build.number_total}}</td> + <td align='right'>{{report_build.modules_done}}</td> + <td align='right'>{{report_build.modules_total}}</td> +</tr> +{% endfor %} +</table> +</div> +{% endblock %} diff --git a/lkft/templates/lkft-kernelchanges.html b/lkft/templates/lkft-kernelchanges.html index 9dc0704..344b1bc 100644 --- a/lkft/templates/lkft-kernelchanges.html +++ b/lkft/templates/lkft-kernelchanges.html @@ -1,8 +1,8 @@ {% extends '_layouts/base.html' %} -{% block title %} Summary for Kernel Changes {% endblock %} +{% block title %} Kernel Changes {% endblock %} -{% block headline %}<h1>Summary for Kernel Changes</a></h1>{% endblock %} +{% block headline %}<h1>Kernel Changes</a></h1>{% endblock %} {% block content %} <div> @@ -24,21 +24,21 @@ {% for kernelchange in kernelchanges %} <tr> <td>{{ forloop.counter }}</td> - <td>{{kernelchange.branch}}</td> - <td>{{kernelchange.describe}}</td> + <td><a href="/lkft/kernel-changes/{{kernelchange.branch}}/">{{kernelchange.branch}}</a></td> + <td><a href="/lkft/kernel-changes/{{kernelchange.branch}}/{{kernelchange.describe}}/">{{kernelchange.describe}}</a></td> <td>{{kernelchange.status}}</td> <td><p>Started at {{ kernelchange.start_timestamp|date:'M. d, Y, H:i'}}, {{ kernelchange.start_timestamp|timesince}} ago</p></td> {% if kernelchange.status == 'ALL_COMPLETED' %} - <td>Took {{kernelchange.duration}} to finish</td> + <td align='right'>Took {{kernelchange.duration}} to finish</td> {% else %} - <td>--</td> + <td align='right'>--</td> {% endif %} - <td><a href="https://ci.linaro.org/job/{{kernelchange.trigger_name}}/{{kernelchange.trigger_number}}">{{kernelchange.trigger_name}}#{{kernelchange.trigger_number}}</td> - <td>{{kernelchange.number_passed}}</td> - <td>{{kernelchange.number_failed}}</td> - <td>{{kernelchange.number_total}}</td> - <td>{{kernelchange.modules_done}}</td> - <td>{{kernelchange.modules_total}}</td> + <td><a href="https://ci.linaro.org/job/{{kernelchange.trigger_name}}/{{kernelchange.trigger_number}}">{{kernelchange.trigger_name}}#{{kernelchange.trigger_number}}</a></td> + <td align='right'>{{kernelchange.number_passed}}</td> + <td align='right'>{{kernelchange.number_failed}}</td> + <td align='right'>{{kernelchange.number_total}}</td> + <td align='right'>{{kernelchange.modules_done}}</td> + <td align='right'>{{kernelchange.modules_total}}</td> </tr> {% endfor %} </table> diff --git a/lkft/urls.py b/lkft/urls.py index 7416e8a..e244394 100644 --- a/lkft/urls.py +++ b/lkft/urls.py @@ -7,7 +7,11 @@ urlpatterns = [ url(r'^$', views.list_projects, name='home'), url(r'^rc-projects/.*$', views.list_rc_projects, name='list_rc_projects'), url(r'^projects/.*$', views.list_projects, name='list_projects'), - url(r'^kernel-changes/.*$', views.list_kernel_changes, name='list_kernel_changes'), + url(r'^kernel-changes/$', views.list_kernel_changes, name='list_kernel_changes'), + # newchanges/$branch/ + url(r'^kernel-changes/(%s)/$' % (basic_pat), views.list_branch_kernel_changes, name='list_branch_kernel_changes'), + # newchanges/$branch/$describe/ + url(r'^kernel-changes/(%s)/(%s)/$' % (basic_pat, basic_pat), views.list_describe_kernel_changes, name='list_describe_kernel_changes'), url(r'^builds/.*$', views.list_builds, name='list_builds'), url(r'^jobs/.*$', views.list_jobs, name='list_jobs'), url(r'^file-bug/.*$', views.file_bug, name='file_bug'), diff --git a/lkft/views.py b/lkft/views.py index a96b4ca..5f667fc 100644 --- a/lkft/views.py +++ b/lkft/views.py @@ -31,7 +31,7 @@ from lkft.lkft_config import find_citrigger, find_cibuild, get_hardware_from_pna from lkft.lkft_config import find_expect_cibuilds from lkft.lkft_config import get_configs, get_qa_server_project -from .models import KernelChange, CiBuild +from .models import KernelChange, CiBuild, ReportBuild qa_report_def = QA_REPORT[QA_REPORT_DEFAULT] qa_report_api = qa_report.QAReportApi(qa_report_def.get('domain'), qa_report_def.get('token')) @@ -1117,20 +1117,13 @@ def new_build(request, branch, describe, name, number): return HttpResponse("ERROR:%s" % err_msg, status=200) - -def list_kernel_changes(request): +def get_kernel_changes_info(db_kernelchanges=[]): queued_ci_items = jenkins_api.get_queued_items() lkft_projects = qa_report_api.get_lkft_qa_report_projects() - db_kernelchanges = KernelChange.objects.all().order_by('branch', '-describe') kernelchanges = [] - check_branches = [] for db_kernelchange in db_kernelchanges: - if db_kernelchange.branch in check_branches: - continue - else: - check_branches.append(db_kernelchange.branch) kernelchange = {} if db_kernelchange.reported and db_kernelchange.result == 'ALL_COMPLETED': kernelchange['branch'] = db_kernelchange.branch @@ -1309,8 +1302,81 @@ def list_kernel_changes(request): kernelchanges.append(kernelchange) + return kernelchanges + + +@login_required +def list_kernel_changes(request): + db_kernelchanges = KernelChange.objects.all().order_by('branch', '-describe') + check_branches = [] + for db_kernelchange in db_kernelchanges: + if db_kernelchange.branch in check_branches: + continue + else: + check_branches.append(db_kernelchange.branch) + + kernelchanges = get_kernel_changes_info(db_kernelchanges=check_branches) + return render(request, 'lkft-kernelchanges.html', { "kernelchanges": kernelchanges, } + ) + +@login_required +def list_branch_kernel_changes(request, branch): + db_kernelchanges = KernelChange.objects.all().filter(branch=branch).order_by('-describe') + kernelchanges = get_kernel_changes_info(db_kernelchanges=db_kernelchanges) + + return render(request, 'lkft-kernelchanges.html', + { + "kernelchanges": kernelchanges, + } + ) +@login_required +def list_describe_kernel_changes(request, branch, describe): + db_kernel_change = KernelChange.objects.get(branch=branch, describe=describe) + db_report_builds = ReportBuild.objects.filter(kernel_change=db_kernel_change).order_by('group', 'name') + db_ci_builds = CiBuild.objects.filter(kernel_change=db_kernel_change).exclude(name=db_kernel_change.trigger_name).order_by('name', 'number') + db_trigger_build = CiBuild.objects.get(name=db_kernel_change.trigger_name, kernel_change=db_kernel_change) + + trigger_build = {} + trigger_build['name'] = db_trigger_build.name + trigger_build['number'] = db_trigger_build.number + trigger_build['timestamp'] = db_trigger_build.timestamp + trigger_build['result'] = db_trigger_build.result + trigger_build['duration'] = datetime.timedelta(seconds=db_trigger_build.duration) + + ci_builds = [] + for db_ci_build in db_ci_builds: + ci_build = {} + ci_build['name'] = db_ci_build.name + ci_build['number'] = db_ci_build.number + ci_build['timestamp'] = db_ci_build.timestamp + ci_build['result'] = db_ci_build.result + ci_build['duration'] = datetime.timedelta(seconds=db_ci_build.duration) + ci_build['queued_duration'] = db_ci_build.timestamp - db_trigger_build.timestamp + ci_builds.append(ci_build) + + report_builds = [] + for db_report_build in db_report_builds: + report_build = {} + report_build['group'] = db_report_build.group + report_build['name'] = db_report_build.name + report_build['started_at'] = db_report_build.started_at + report_build['number_passed'] = db_report_build.number_passed + report_build['number_failed'] = db_report_build.number_failed + report_build['number_total'] = db_report_build.number_total + report_build['modules_done'] = db_report_build.modules_done + report_build['modules_total'] = db_report_build.modules_total + report_build['duration'] = db_report_build.fetched_at - db_report_build.started_at + report_builds.append(report_build) + + return render(request, 'lkft-describe.html', + { + "kernel_change": db_kernel_change, + 'report_builds': report_builds, + 'trigger_build': trigger_build, + 'ci_builds': ci_builds, + } )
\ No newline at end of file |