diff options
author | Yongqin Liu <yongqin.liu@linaro.org> | 2019-12-30 19:50:28 +0800 |
---|---|---|
committer | Yongqin Liu <yongqin.liu@linaro.org> | 2019-12-30 19:50:28 +0800 |
commit | 41c94e5c99d795fd29ddf64d8dffe477a580ba83 (patch) | |
tree | 636cabf1e484d129b7834b350822135005299bb6 /lkft/management | |
parent | 9215bf5f76611cff1447c87f6b5d3f4a83ca74e0 (diff) |
lkft: add lkftreport tool
for lkft reporting
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Diffstat (limited to 'lkft/management')
-rw-r--r-- | lkft/management/__init__.py | 0 | ||||
-rw-r--r-- | lkft/management/commands/__init__.py | 0 | ||||
-rw-r--r-- | lkft/management/commands/lkftreport.py | 45 |
3 files changed, 45 insertions, 0 deletions
diff --git a/lkft/management/__init__.py b/lkft/management/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lkft/management/__init__.py diff --git a/lkft/management/commands/__init__.py b/lkft/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lkft/management/commands/__init__.py diff --git a/lkft/management/commands/lkftreport.py b/lkft/management/commands/lkftreport.py new file mode 100644 index 0000000..0a5042d --- /dev/null +++ b/lkft/management/commands/lkftreport.py @@ -0,0 +1,45 @@ +## https://docs.djangoproject.com/en/1.11/topics/db/managers/ +## https://docs.djangoproject.com/en/dev/howto/custom-management-commands/#howto-custom-management-commands +## https://medium.com/@bencleary/django-scheduled-tasks-queues-part-1-62d6b6dc24f8 +## https://medium.com/@bencleary/django-scheduled-tasks-queues-part-2-fc1fb810b81d +## https://medium.com/@kevin.michael.horan/scheduling-tasks-in-django-with-the-advanced-python-scheduler-663f17e868e6 +## https://django-background-tasks.readthedocs.io/en/latest/ + + +import datetime + +from django.core.management.base import BaseCommand, CommandError +from lkft.models import KernelChange, CiBuild + +from lcr import qa_report + +jenkins_api = qa_report.JenkinsApi('ci.linaro.org', None) + +class Command(BaseCommand): + help = 'Check the build and test results for kernel changes, and send report if the jobs finished' + +# def add_arguments(self, parser): +# parser.add_argument('git_describes', nargs='+', type=str) + + def handle(self, *args, **options): + kernel_changes = KernelChange.objects_needs_report.all() + for kernel_change in kernel_changes: + trigger_url = jenkins_api.get_job_url(name=kernel_change.trigger_name, number=kernel_change.trigger_number) + trigger_build = jenkins_api.get_build_details_with_full_url(build_url=trigger_url) + trigger_build['start_timestamp'] = datetime.datetime.fromtimestamp(int(trigger_build['timestamp'])/1000) + trigger_build['duration'] = datetime.timedelta(milliseconds=trigger_build['duration']) + + print "%s started at %s, took %s" % (kernel_change, trigger_build['start_timestamp'], trigger_build['duration']) + ci_builds = CiBuild.objects_kernel_change.get_builds_per_kernel_change(kernel_change=kernel_change) + for ci_build in ci_builds: + build_url = jenkins_api.get_job_url(name=ci_build.name, number=ci_build.number) + build = jenkins_api.get_build_details_with_full_url(build_url=build_url) + build['start_timestamp'] = datetime.datetime.fromtimestamp(int(build['timestamp'])/1000) + + if build.get('building'): + build_status = 'INPROGRESS' + else: + build_status = build.get('result') # null or SUCCESS, FAILURE, ABORTED + build['duration'] = datetime.timedelta(milliseconds=build['duration']) + + print "\t %s %s started at %s, took %s" % (ci_build, build_status, build['start_timestamp'], build['duration']) |