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