Skip to content

Commit 6f29e52

Browse files
committed
package in pipe html report generator
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent c8a6eb8 commit 6f29e52

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

scripts/pkg_in_pipe/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
report.html

scripts/pkg_in_pipe/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Packages in pipe report generator
2+
3+
Generates an html report with the packages in the current tags.
4+
5+
# Requirements
6+
7+
An environmnt variable `PLANE_TOKEN` must be defined when running the generator.

scripts/pkg_in_pipe/pkg_in_pipe.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
5+
import koji
6+
import requests
7+
8+
def print_header(out):
9+
print('''
10+
<!DOCTYPE html>
11+
<html lang="en">
12+
<head>
13+
<meta charset="UTF-8">
14+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
15+
<title>XCP-ng Package Update</title>
16+
<script src="https://cdn.tailwindcss.com"></script>
17+
</head>
18+
<body class="bg-gray-400 text-center">
19+
''', file=out)
20+
21+
def print_footer(out):
22+
print('''
23+
</body>
24+
</html>
25+
''', file=out)
26+
27+
def print_table_header(out, tag):
28+
print(f'''
29+
<div class="px-3 py-3">
30+
<div class="relative overflow-x-auto shadow-md sm:rounded-lg">
31+
<table class="table-fixed w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
32+
<caption class="p-5 text-lg font-semibold text-left rtl:text-right text-gray-900 bg-white dark:text-white dark:bg-gray-800">
33+
{tag}
34+
</caption>
35+
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
36+
<tr>
37+
<th scope="col" class="px-6 py-3">
38+
Build
39+
</th>
40+
<th scope="col" class="px-6 py-3">
41+
Cards
42+
</th>
43+
<th scope="col" class="px-6 py-3">
44+
By
45+
</th>
46+
</tr>
47+
</thead>
48+
<tbody>
49+
''', file=out)
50+
51+
def print_table_footer(out):
52+
print('''
53+
</tbody>
54+
</table>
55+
</div>
56+
</div>
57+
''', file=out)
58+
59+
def print_table_line(out, build, link, issues, by):
60+
issues_content = '\n'.join([f'<li><a class="font-medium text-blue-600 dark:text-blue-500 hover:underline" href="https://project.vates.tech/vates-global/browse/XCPNG-{i['sequence_id']}/">XCPNG-{i['sequence_id']}</a></li>' for i in issues])
61+
print(f'''
62+
<tr class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700 border-gray-200">
63+
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
64+
<a class="font-medium text-blue-600 dark:text-blue-500 hover:underline" href="{link}">{build}</a>
65+
</th>
66+
<td class="px-6 py-4">
67+
<ul>
68+
{issues_content}
69+
</ul>
70+
</td>
71+
<td class="px-6 py-4">
72+
{by}
73+
</td>
74+
</tr>
75+
''', file=out)
76+
77+
# open koji session
78+
config = koji.read_config("koji")
79+
session = koji.ClientSession('https://kojihub.xcp-ng.org', config)
80+
session.ssl_login(config['cert'], None, config['serverca'])
81+
82+
# load the issues from plane, so we can search for the plane card related to a build
83+
resp = requests.get('https://project.vates.tech/api/v1/workspaces/vates-global/projects/43438eec-1335-4fc2-8804-5a4c32f4932d/issues/',
84+
headers={'x-api-key': os.environ['PLANE_TOKEN']})
85+
project_issues = resp.json()
86+
87+
with open('report.html', 'w') as out:
88+
print_header(out)
89+
tags = [f'v{v}-{p}' for v in ['8.2', '8.3'] for p in ['incoming', 'ci', 'testing', 'candidates', 'lab']]
90+
for tag in tags:
91+
print_table_header(out, tag)
92+
for build in session.listTagged(tag):
93+
build_url = f'https://koji.xcp-ng.org/buildinfo?buildID={build['build_id']}'
94+
build_issues = [i for i in project_issues['results'] if f'href="{build_url}"' in i['description_html']]
95+
print_table_line(out, build['nvr'], build_url, build_issues, build['owner_name'])
96+
print_table_footer(out)
97+
print_footer(out)

0 commit comments

Comments
 (0)