[Qa-jenkins-scm] [jenkins.debian.net] 08/10: reproducible debian: create arch specific history pages for packages

Holger Levsen holger at layer-acht.org
Thu Jul 28 18:14:13 UTC 2016


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 d605e52ca7b4f5d47820751e7ae9a3e4f2864e6f
Author: Valerie R Young <spectranaut at riseup.net>
Date:   Wed Jul 27 13:00:40 2016 -0400

    reproducible debian: create arch specific history pages for packages
    
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 bin/reproducible_html_packages.py                  | 59 +++++++++++++++-------
 .../reproducible/package_history.mustache          | 17 +++++++
 .../reproducible/package_navigation.mustache       |  8 ++-
 3 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/bin/reproducible_html_packages.py b/bin/reproducible_html_packages.py
index 2270ef9..118edb8 100755
--- a/bin/reproducible_html_packages.py
+++ b/bin/reproducible_html_packages.py
@@ -26,6 +26,9 @@ suitearch_details_template = renderer.load_template(
     os.path.join(TEMPLATE_PATH, 'package_suitearch_details'))
 project_links_template = renderer.load_template(
     os.path.join(TEMPLATE_PATH, 'project_links'))
+package_history_template = renderer.load_template(
+    os.path.join(TEMPLATE_PATH, 'package_history'))
+
 
 def sizeof_fmt(num):
     for unit in ['B','KB','MB','GB']:
@@ -274,19 +277,24 @@ def shorten_if_debiannet(hostname):
         hostname = hostname[:-11]
     return hostname
 
-def gen_history_page(package):
-    keys = ('build date', 'version', 'suite', 'architecture', 'result',
-        'build duration', 'node1', 'node2', 'job')
+def gen_history_page(package, arch=None):
+    keys = ['build date', 'version', 'suite', 'architecture', 'result',
+        'build duration', 'node1', 'node2', 'job']
+
+    context = {}
     try:
         head = package.history[0]
     except IndexError:
-        html = '<p>No historical data available for this package.</p>'
+        context['arch'] = arch
     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:
+        context['keys'] = [{'key': key} for key in keys]
+        rows = []
+        for r in package.history:
+            # make a copy, since we modify in place
+            record = dict(r)
+            # skip records for other archs if we care about arch
+            if arch and record['architecture'] != arch:
+                continue
             # remove trailing .debian.net from hostnames
             record['node1'] = shorten_if_debiannet(record['node1'])
             record['node2'] = shorten_if_debiannet(record['node2'])
@@ -297,17 +305,22 @@ def gen_history_page(package):
             # human 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')
+            row_items = [{'item': record[key]} for key in keys]
+            rows.append({'row_items': row_items})
+        context['rows'] = rows
+
+    html = renderer.render(package_history_template, context)
+    if arch:
+        destfile = os.path.join(HISTORY_PATH, arch, package.name+'.html')
+    else:
+        destfile = os.path.join(HISTORY_PATH, package.name+'.html')
     title = 'build history of {}'.format(package.name)
+    print(arch)
+    if arch:
+        title += ' on {}'.format(arch)
     write_html_page(title=title, body=html, destfile=destfile,
                     noendpage=True)
 
-
 def gen_packages_html(packages, no_clean=False):
     """
     generate the /rb-pkg/package.html pages.
@@ -318,6 +331,9 @@ def gen_packages_html(packages, no_clean=False):
     for package in sorted(packages, key=lambda x: x.name):
         assert isinstance(package, Package)
         gen_history_page(package)
+        for arch in ARCHS:
+            gen_history_page(package, arch)
+
         pkg = package.name
 
         notes_uri = ''
@@ -339,7 +355,13 @@ def gen_packages_html(packages, no_clean=False):
                 suitearch_section_html, default_view, reproducible = \
                     gen_suitearch_section(package, suite, arch)
 
-                history = '{}/{}.html'.format(HISTORY_URI, pkg)
+                history_uri = '{}/{}.html'.format(HISTORY_URI, pkg)
+                history_archs = []
+                for a in ARCHS:
+                    history_archs.append({
+                        'history_arch': a,
+                        'history_arch_uri': '{}/{}/{}.html'.format(HISTORY_URI, a, pkg)
+                    })
                 project_links = renderer.render(project_links_template)
 
                 navigation_html = renderer.render(package_navigation_template, {
@@ -347,7 +369,8 @@ def gen_packages_html(packages, no_clean=False):
                     'suite': suite,
                     'arch': arch,
                     'version': version,
-                    'history': history,
+                    'history_uri': history_uri,
+                    'history_archs': history_archs,
                     'notes_uri': notes_uri,
                     'notify_maintainer': package.notify_maint,
                     'suitearch_section_html': suitearch_section_html,
diff --git a/mustache-templates/reproducible/package_history.mustache b/mustache-templates/reproducible/package_history.mustache
new file mode 100644
index 0000000..8326e8d
--- /dev/null
+++ b/mustache-templates/reproducible/package_history.mustache
@@ -0,0 +1,17 @@
+{{^rows}}
+<p>No historical data available for this package{{#arch}} on architecture: {{arch}}{{/arch}}.</p>
+{{/rows}}
+<table>
+  <tr>
+    {{#keys}}
+    <th>{{key}}</th>
+    {{/keys}}
+  </tr>
+  {{#rows}}
+  <tr>
+    {{#row_items}}
+    <td>{{{item}}}</td>
+    {{/row_items}}
+  </tr>
+  {{/rows}}
+</table>
diff --git a/mustache-templates/reproducible/package_navigation.mustache b/mustache-templates/reproducible/package_navigation.mustache
index 0d579b7..e90d261 100644
--- a/mustache-templates/reproducible/package_navigation.mustache
+++ b/mustache-templates/reproducible/package_navigation.mustache
@@ -17,7 +17,13 @@
   {{/reproducible}}
   {{/notes_uri}}
   <li>
-    <a href="{{history}}" target="main">test history</a>
+    <a href="{{history_uri}}" target="main">test history</a>
+    <ul class="children"><li>
+    Filter by:
+    {{#history_archs}}
+       <a href="{{history_arch_uri}}" target="main"><span class="filter-history">{{history_arch}}<span></a>
+    {{/history_archs}}
+    </li></ul>
   </li>
   <h4>Suite and Architecture</h4>
   {{{suitearch_section_html}}}

-- 
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