[Qa-jenkins-scm] [jenkins.debian.net] 04/08: reproducible: Add a history page, with a table with all the builds done of that package. Link it in the rb-pkg pages.

Holger Levsen holger at moszumanska.debian.org
Fri Oct 9 16:03:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit 605b2b71ba35bf22f84add00dd2d11dc24783547
Author: Mattia Rizzolo <mattia at mapreri.org>
Date:   Fri Oct 9 15:24:03 2015 +0000

    reproducible: Add a history page, with a table with all the builds done of that package.  Link it in the rb-pkg pages.
---
 bin/reproducible_common.py        | 18 ++++++++++++++++++
 bin/reproducible_html_packages.py | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index 344cdc1..2322081 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -51,6 +51,7 @@ NOTES_URI = '/notes'
 ISSUES_URI = '/issues'
 RB_PKG_URI = '/rb-pkg'
 RBUILD_URI = '/rbuild'
+HISTORY_URI = '/history'
 BUILDINFO_URI = '/buildinfo'
 DBD_PATH = BASE + DBD_URI
 DBDTXT_PATH = BASE + DBDTXT_URI
@@ -60,6 +61,7 @@ NOTES_PATH = BASE + NOTES_URI
 ISSUES_PATH = BASE + ISSUES_URI
 RB_PKG_PATH = BASE + RB_PKG_URI
 RBUILD_PATH = BASE + RBUILD_URI
+HISTORY_PATH = BASE + HISTORY_URI
 BUILDINFO_PATH = BASE + BUILDINFO_URI
 
 REPRODUCIBLE_URL = 'https://reproducible.debian.net'
@@ -105,6 +107,8 @@ log.debug("RB_PKG_URI:\t" + RB_PKG_URI)
 log.debug("RB_PKG_PATH:\t" + RB_PKG_PATH)
 log.debug("RBUILD_URI:\t" + RBUILD_URI)
 log.debug("RBUILD_PATH:\t" + RBUILD_PATH)
+log.debug("HISTORY_URI:\t" + HISTORY_URI)
+log.debug("HISTORY_PATH:\t" + HISTORY_PATH)
 log.debug("BUILDINFO_URI:\t" + BUILDINFO_URI)
 log.debug("BUILDINFO_PATH:\t" + BUILDINFO_PATH)
 log.debug("REPRODUCIBLE_DB:\t" + REPRODUCIBLE_DB)
@@ -720,6 +724,20 @@ class Package:
         except IndexError:
             result = 0
         self.notify_maint = '⚑' if result == 1 else ''
+        self.history = []
+        self._load_history
+
+    def _load_history(self):
+        keys = ['build ID', 'version', 'suite', 'architecture', 'result',
+            'build date', 'build duration', 'builder']
+        query = """
+                SELECT id, version, suite, architecture, status, build_date,
+                    build_duration, builder
+                FROM stats_build WHERE name='{}' ORDER BY build_date DESC
+            """.format(self.name)
+        results = query_db(query)
+        for record in results:
+            self.history.append(dict(zip(keys, record)))
 
     def get_status(self, suite, arch):
         """ This returns False if the package does not exists in this suite """
diff --git a/bin/reproducible_html_packages.py b/bin/reproducible_html_packages.py
index c3094cf..39bbbd1 100755
--- a/bin/reproducible_html_packages.py
+++ b/bin/reproducible_html_packages.py
@@ -36,6 +36,9 @@ html_package_page = Template((tab*2).join(("""
                 <li><a href="https://sources.debian.net/src/$package/$version/debian/rules">rules</a></li>
             </ul>
         </li>
+        <li>
+          <a href=$history" target="main">Build history</a>
+        </li>
     </ul>
 
 ${suites_links}
@@ -205,6 +208,34 @@ def gen_suites_links(package, current_suite, current_arch):
     return tab*5 + (tab*7).join(html.splitlines(True))
 
 
+def gen_history_page(package):
+    keys = ('build date', 'version', 'suite', 'architecture', 'result',
+        'build duration', 'builder')
+    try:
+        head = package.history[0]
+    except IndexError:
+        html = '<p>No historical data available for this package.</p>'
+        return
+    else:
+        html = '<table>\n{tab}<tr>\n{tab}{tab}'.format(tab=tab)
+        for i in keys:
+            html += '<th>{}</th>'.format(i)
+        html += '\n{tab}</tr>'.format(tab=tab)
+        for record in package.history:
+            # huma formatting of build duration
+            record['build duration'] = convert_into_hms_string(
+                int(record['build duration']))
+            html += '\n{tab}<tr>\n{tab}{tab}'.format(tab=tab)
+            for i in keys:
+                html += '<td>{}</td>'.format(record[i])
+            html += '\n{tab}</tr>'.format(tab=tab)
+        html += '</table>'
+    destfile = os.path.join(HISTORY_PATH, package.name+'.html')
+    title = 'build history of {}'.format(package.name)
+    write_html_page(title=title, body=html, destfile=destfile,
+                    noheader=True, noendpage=True)
+
+
 def gen_packages_html(packages, no_clean=False):
     """
     generate the /rb-pkg/package.html pages.
@@ -214,6 +245,7 @@ def gen_packages_html(packages, no_clean=False):
     log.debug('Generating the pages of ' + str(total) + ' package(s)')
     for package in sorted(packages, key=lambda x: x.name):
         assert isinstance(package, Package)
+        gen_history_page(package)
         pkg = package.name
         for suite in SUITES:
             for arch in ARCHS:
@@ -236,6 +268,7 @@ def gen_packages_html(packages, no_clean=False):
                 suites_links = gen_suites_links(package, suite, arch)
                 status, icon, spokenstatus = get_status_icon(status)
                 status = gen_status_link_icon(status, spokenstatus, icon, suite, arch)
+                history = '{}/{}.html'.format(HISTORY_URI, pkg)
 
                 html = html_package_page.substitute(
                     package=pkg,
@@ -244,6 +277,7 @@ def gen_packages_html(packages, no_clean=False):
                     status=status,
                     version=version,
                     build_time=build_date,
+                    history=history,
                     links=links,
                     notify_maintainer=package.notify_maint,
                     suites_links=suites_links,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list