Skip to content

Commit 4b07ea5

Browse files
committed
kci: Add tests in forecasting
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent f82aa04 commit 4b07ea5

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

kernelci/cli/config.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,54 @@ def compare_builds(merged_data):
119119
return result
120120

121121

122+
def forecast_tests(merged_data, kbuilds, checkout):
123+
tests = []
124+
for kbuild in kbuilds:
125+
kbuild_data = merged_data.get("jobs", {}).get(kbuild, {})
126+
jobs = merged_data.get("scheduler", [])
127+
for job in jobs:
128+
kind = job.get("event", {}).get("kind")
129+
if kind != "kbuild":
130+
continue
131+
scheduler_rules = job.get("rules", [])
132+
job_name = job.get("job")
133+
job_data = merged_data.get("jobs", {}).get(job_name, {})
134+
job_rules = job_data.get("rules", [])
135+
# we might have rules in scheduler entries too
136+
scheduler_rules = job.get("rules", [])
137+
node = {
138+
"kind": "kbuild",
139+
"data": {
140+
"kernel_revision": {
141+
"tree": checkout.get("tree"),
142+
"branch": checkout.get("branch"),
143+
"version": {
144+
"version": 6,
145+
"patchlevel": 16,
146+
"extra": "-rc3-973-gb7d1bbd97f77"
147+
},
148+
}
149+
},
150+
}
151+
if not validate_rules(node, job_rules) or not validate_rules(node, scheduler_rules):
152+
continue
153+
# runtime/name in scheduler
154+
runtime = job.get("runtime", {}).get("name")
155+
platforms = job.get("platforms", [])
156+
test_name = f"{job_name} ({runtime}) {platforms}"
157+
tests.append(test_name)
158+
159+
return tests
160+
161+
122162
# pylint: disable=too-many-branches disable=too-many-locals
123163
def do_forecast(merged_data):
124164
"""
125165
We will simulate checkout event on each tree/branch
126166
and try to build list of builds/tests it will run
127167
"""
128168
checkouts = []
169+
tests = []
129170
build_configs = merged_data.get("build_configs", {})
130171
for bcfg in build_configs:
131172
data = build_configs[bcfg]
@@ -182,10 +223,16 @@ def do_forecast(merged_data):
182223
print(f" Identical builds: {checkout['kbuilds_identical']}")
183224
if checkout.get("kbuilds"):
184225
num_builds = len(checkout["kbuilds"])
226+
if num_builds > 0:
227+
tests.extend(forecast_tests(merged_data, checkout["kbuilds"], checkout))
185228
print(f" Number of builds: {num_builds}")
186229
print(" Builds:")
187230
for build in checkout["kbuilds"]:
188231
print(f" - {build}")
232+
print(f" Number of tests: {len(tests)}")
233+
print(f" Tests:")
234+
for test in tests:
235+
print(f" - {test}")
189236
else:
190237
print(" No builds found for this checkout")
191238

0 commit comments

Comments
 (0)