summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lcr/qa_report.py28
-rw-r--r--lkft/lkft_config.py63
-rw-r--r--lkft/templates/lkft-projects.html11
-rw-r--r--lkft/views.py29
4 files changed, 112 insertions, 19 deletions
diff --git a/lcr/qa_report.py b/lcr/qa_report.py
index d9eb02c..a8e4b32 100644
--- a/lcr/qa_report.py
+++ b/lcr/qa_report.py
@@ -23,9 +23,11 @@ class RESTFullApi():
def call_with_full_url(self, request_url='', method='GET', returnResponse=False):
headers = {
'Content-Type': 'application/json',
- 'Authorization': 'Token %s' % self.api_token,
- 'Auth-Token': self.api_token,
}
+ if self.api_token:
+ headers['Authorization'] = 'Token %s' % self.api_token
+ headers['Auth-Token'] = self.api_token
+
if method == 'GET':
r = requests.get(request_url, headers=headers)
else:
@@ -64,6 +66,28 @@ class RESTFullApi():
raise NotImplementedError('%s.get_api_url_prefix should never be called directly' % self.__class__.__name__)
+class JenkinsApi(RESTFullApi):
+ def get_api_url_prefix(self, detail_url):
+ # https://ci.linaro.org/job/trigger-lkft-aosp-mainline/api/json
+ return 'https://%s/job/%s/api/json/' % (self.domain, detail_url)
+
+
+ def get_last_build(self, cijob_name=''):
+ if not cijob_name:
+ return None
+ full_url = self.get_api_url_prefix(detail_url=cijob_name)
+ result = self.call_with_full_url(request_url=full_url)
+ if result:
+ return result.get('lastBuild')
+ else:
+ return None
+
+
+ def get_build_details_with_full_url(self, build_url):
+ full_api_url = '%s/api/json/' % build_url
+ return self.call_with_full_url(request_url=full_api_url)
+
+
class LAVAApi(RESTFullApi):
def get_api_url_prefix(self):
return 'https://%s/api/v0.1/' % self.domain
diff --git a/lkft/lkft_config.py b/lkft/lkft_config.py
new file mode 100644
index 0000000..1456f2c
--- /dev/null
+++ b/lkft/lkft_config.py
@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+import re
+
+citrigger_lkft = {
+ 'trigger-lkft-aosp-mainline': [
+ 'mainline-9.0-hikey',
+ 'mainline-9.0-hikey-auto',
+ 'mainline-9.0-hikey960',
+ 'mainline-9.0-hikey960-auto',
+ 'mainline-9.0-x15',
+ 'mainline-9.0-x15-auto',
+ ],
+
+ 'trigger-lkft-ti-4.19': [
+ '4.19-9.0-x15',
+ '4.19-9.0-x15-auto',
+ '4.19-9.0-am65x',
+ '4.19-9.0-am65x-auto',
+ ],
+ 'trigger-lkft-hikey-4.19': [
+ '4.19-9.0-hikey',
+ '4.19-9.0-hikey-auto',
+ '4.19-9.0-hikey960',
+ '4.19-9.0-hikey960-auto',
+ ],
+
+ 'trigger-lkft-x15-4.14': [
+ '4.14-8.1-x15',
+ ],
+ 'trigger-lkft-hikey-4.14-premerge-ci': [
+ '4.14-9.0-hikey',
+ '4.14-9.0-hikey960',
+ ],
+ 'trigger-lkft-hikey-4.14': [
+ '4.14-8.1-hikey',
+ ],
+
+ 'trigger-lkft-hikey-4.9-premerge-ci': [
+ '4.9-9.0-hikey',
+ '4.9-9.0-hikey960',
+ ],
+ 'trigger-lkft-hikey-4.9': [
+ '4.9-8.1-hikey',
+ ],
+
+ 'trigger-lkft-hikey-4.4-premerge-ci': [
+ '4.4-lts-9.0-hikey',
+ ],
+ 'trigger-lkft-hikey-4.4': [
+ '4.4-8.1-hikey',
+ '4.4-9.0-hikey',
+ ],
+}
+
+def find_citrigger(lkft_pname=""):
+ if not lkft_pname:
+ return None
+ for trigger_name, lkft_pnames in citrigger_lkft.items():
+ if lkft_pname in lkft_pnames:
+ return trigger_name
+ return None
diff --git a/lkft/templates/lkft-projects.html b/lkft/templates/lkft-projects.html
index 7a601a3..f47e153 100644
--- a/lkft/templates/lkft-projects.html
+++ b/lkft/templates/lkft-projects.html
@@ -12,6 +12,7 @@
<th>Project</th>
<th>Last Build Timestamp</th>
<th>Last Build No.</th>
+ <th>Last Trigger Build No.</th>
</tr>
{% for project in projects %}
<tr>
@@ -37,6 +38,16 @@
No Build Yet
{% endif %}
</td>
+ <td>
+ {% if project.last_trigger_build %}
+ {% with project.last_trigger_build as last_trigger_build %}
+ <a href="{{last_trigger_build.url}}">{{ last_trigger_build.displayName}}</a>
+ {% endwith %}
+ {% else %}
+ No Trigger Build Setup Yet
+ {% endif %}
+ </td>
+ </td>
</tr>
{% endfor %}
</table>
diff --git a/lkft/views.py b/lkft/views.py
index d53f282..47e6897 100644
--- a/lkft/views.py
+++ b/lkft/views.py
@@ -26,9 +26,11 @@ from lcr.settings import QA_REPORT, QA_REPORT_DEFAULT
from lcr import qa_report
from lcr.qa_report import DotDict
from lcr.utils import download_urllib
+from lkft.lkft_config import find_citrigger
qa_report_def = QA_REPORT[QA_REPORT_DEFAULT]
qa_report_api = qa_report.QAReportApi(qa_report_def.get('domain'), qa_report_def.get('token'))
+jenkins_api = qa_report.JenkinsApi('ci.linaro.org', None)
DIR_ATTACHMENTS = os.path.join(FILES_DIR, 'lkft')
@@ -201,24 +203,12 @@ def extract(result_zip_path, failed_testcases_all={}, metadata={}):
'failed_number': failed_number
}
-citrigger_lkft = {
- 'trigger-lkft-aosp-mainline': [
- 'mainline-9.0-hikey',
- 'mainline-9.0-hikey-auto',
- 'mainline-9.0-hikey960',
- 'mainline-9.0-hikey960-auto',
- 'mainline-9.0-x15',
- 'mainline-9.0-x15',
- ],
-}
-
-def find_citrigger(lkft_pname=""):
- if not lkft_pname:
+
+def get_last_trigger_build(lkft_pname=''):
+ ci_trigger_name = find_citrigger(lkft_pname=lkft_pname)
+ if not ci_trigger_name:
return None
- for trigger_name, lkft_pnames in citrigger_lkft:
- if lkft_pname in lkft_pnames:
- return trigger_name
- return None
+ return jenkins_api.get_last_build(cijob_name=ci_trigger_name)
def list_projects(request):
projects = []
@@ -235,6 +225,11 @@ def list_projects(request):
last_build['created_at'] = datetime.datetime.strptime(str(created_str), '%Y-%m-%dT%H:%M:%S.%fZ')
project['last_build'] = last_build
+ last_trigger_build = get_last_trigger_build(project.get('name'))
+ if last_trigger_build:
+ last_trigger_url = last_trigger_build.get('url')
+ project['last_trigger_build'] = jenkins_api.get_build_details_with_full_url(build_url=last_trigger_url)
+
projects.append(project)
bugs = get_lkft_bugs()