-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
114 lines (90 loc) · 3.72 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import sys
from flask import Flask, render_template
from scripts.loaders import load_data, load_json, load_monitor_report
app = Flask("python_rebuild_status")
REPORT_STATES = {
"success": "🟢",
"once_succeeded_last_failed": "🟠",
"waiting": "⚪",
"failed": "🔴",
}
ALL_TO_BUILD = sorted(load_data("data/python312.pkgs"))
HISTORICALLY_SUCCESSFUL = load_data("data/python313.pkgs")
FAILED = load_data("data/failed.pkgs")
WAITING = load_data("data/waiting.pkgs")
ALL_IN_COPR = load_monitor_report("data/copr.pkgs")
BUGZILLAS = load_json("data/bzurls.json")
def count_pkgs_with_state(build_status, looked_for):
return sum(1 for state in build_status.values() if state == looked_for)
def assign_build_status():
build_status = {}
for pkg in ALL_TO_BUILD:
# python3.12 has been rebuilt but it doesn't require 'python(abi) = 3.13'
if pkg == "python3.12":
status = REPORT_STATES["success"]
# pkg can build once and never again, so let's look at the last
# build to determine if we need to take a look at it anyways
elif pkg in HISTORICALLY_SUCCESSFUL:
last_build_state = ALL_IN_COPR[pkg]
if last_build_state == "failed":
status = REPORT_STATES["once_succeeded_last_failed"]
elif last_build_state == "succeeded":
status = REPORT_STATES["success"]
else:
# package is waiting in build queue, we don't know its status yet
status = REPORT_STATES["waiting"]
elif pkg in FAILED:
status = REPORT_STATES["failed"]
elif pkg in WAITING:
status = REPORT_STATES["waiting"]
build_status[pkg] = status
return build_status
def find_maintainers():
# bits borrowed from: https://pagure.io/fedora-misc-package-utilities/blob/master/f/find-package-maintainers
maintainers = load_json('data/pagure_owner_alias.json')
return {pkg: maintainers["rpms"][pkg] for pkg in ALL_TO_BUILD}
def sort_by_maintainers(packages_with_maintainers, build_status):
# get maintainer, their pkgs and build statuses
by_maintainers = {}
for pkg, maints in packages_with_maintainers.items():
for maint in maints:
by_maintainers.setdefault(maint, []).append(f"{pkg} {build_status[pkg]}")
return sorted(by_maintainers.items())
def create_failed_report(build_status):
failure_report = {}
for pkg, bzurls in BUGZILLAS.items():
if (state := build_status.get(pkg)) is not None:
failure_report[pkg] = {"bzurls": bzurls, "state": state}
return failure_report
build_status = assign_build_status()
packages_with_maintainers = find_maintainers()
status_by_packages = [(pkg, build_status[pkg], packages_with_maintainers[pkg]) for pkg in ALL_TO_BUILD]
status_by_maintainers = sort_by_maintainers(packages_with_maintainers, build_status)
@app.route('/')
def index():
return render_template(
'index.html',
number_pkgs_to_rebuild=len(ALL_TO_BUILD),
number_pkgs_success=count_pkgs_with_state(build_status, REPORT_STATES["success"]),
number_pkgs_flaky=count_pkgs_with_state(build_status, REPORT_STATES["once_succeeded_last_failed"]),
number_pkgs_failed=len(FAILED),
number_pkgs_waiting=len(WAITING),
)
@app.route('/packages/')
def packages():
return render_template(
'packages.html',
status_by_packages=status_by_packages,
)
@app.route('/maintainers/')
def maintainers():
return render_template(
'maintainers.html',
status_by_maintainers=status_by_maintainers,
)
@app.route('/failures/')
def failures():
return render_template(
'failures.html',
status_failed=create_failed_report(build_status),
)