Skip to content

Commit 3766d03

Browse files
committed
V2
1 parent 6e9886d commit 3766d03

2 files changed

Lines changed: 35 additions & 22 deletions

File tree

pr_testing/test_multiple_prs.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,9 @@ if [ "$BUILD_ONLY" = "true" ]; then
13231323
DO_ADDON_TESTS=false
13241324
DO_CRAB_TESTS=false
13251325
ENABLE_BOT_TESTS=$(echo $ENABLE_BOT_TESTS | sed -e 's/HLT_P2_TIMING//;s/HLT_P2_INTEGRATION//;s/PROFILING//')
1326+
mark_commit_status_all_prs 'build_only' 'success' -u "" -d "Only build"
1327+
else
1328+
mark_commit_status_all_prs 'build_only' 'success' -u "" -d "Build and test"
13261329
fi
13271330

13281331
DO_PROFILING=false

process_pr.py

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import collections
12
import copy
23

34
from categories import (
@@ -2104,7 +2105,8 @@ def process_pr(
21042105
if bot_status or (signatures["tests"] == "pending"):
21052106
new_bot_tests = True
21062107
trigger_test = True
2107-
signatures["tests"] = "started"
2108+
if not build_only:
2109+
signatures["tests"] = "started"
21082110
desc = "requested by %s at %s UTC." % (
21092111
ensure_ascii(test_comment.user.login),
21102112
test_comment.created_at,
@@ -2133,6 +2135,7 @@ def process_pr(
21332135
and bot_status.target_url == turl
21342136
and signatures["tests"] == "pending"
21352137
and (" requested by " in bot_status.description)
2138+
and not build_only
21362139
):
21372140
signatures["tests"] = "started"
21382141
if (
@@ -2141,26 +2144,30 @@ def process_pr(
21412144
):
21422145
signatures["tests"] = "pending"
21432146
if signatures["tests"] == "started" and new_bot_tests:
2144-
lab_stats = {}
2147+
lab_stats = collections.defaultdict(list)
2148+
reporting_build_only = False
2149+
build_only_prefixes = []
21452150
for status in commit_statuses:
21462151
if not status.context.startswith(cms_status_prefix + "/"):
21472152
continue
2148-
cdata = status.context.split("/")
2149-
if cdata[-1] not in ["optional", "required"]:
2153+
prefix, suffix = status.context.rsplit("/", 1)
2154+
if suffix == "build_only" and status.description == "Only build":
2155+
logger.info("Adding prefix %s to build_only_prefixes", prefix)
2156+
build_only_prefixes.append(prefix)
2157+
2158+
if suffix not in ["optional", "required"]:
21502159
continue
2151-
if (cdata[-1] not in lab_stats) or (cdata[-1] == "required"):
2152-
lab_stats[cdata[-1]] = []
2153-
lab_stats[cdata[-1]].append("pending")
2160+
if suffix == "required":
2161+
lab_stats[suffix] = []
2162+
lab_stats[suffix].append("pending")
21542163
if status.state == "pending":
21552164
continue
2156-
scontext = "/".join(cdata[:-1])
21572165
all_states = {}
21582166
result_url = ""
2159-
for s in [
2160-
i
2161-
for i in commit_statuses
2162-
if ((i.context == scontext) or (i.context.startswith(scontext + "/")))
2163-
]:
2167+
for s in commit_statuses:
2168+
if not ((s.context == prefix) or (s.context.startswith(prefix + "/"))):
2169+
continue
2170+
21642171
if (not result_url) and ("/jenkins-artifacts/" in s.target_url):
21652172
xdata = s.target_url.split("/")
21662173
while xdata and (not xdata[-2].startswith("PR-")):
@@ -2188,18 +2195,19 @@ def process_pr(
21882195
)
21892196
continue
21902197
if "success" in all_states:
2191-
lab_stats[cdata[-1]][-1] = "success"
2198+
lab_stats[suffix][-1] = "success"
21922199
if "error" in all_states:
21932200
if [c for c in all_states["error"] if ("/opt/" not in c)]:
2194-
lab_stats[cdata[-1]][-1] = "error"
2201+
lab_stats[suffix][-1] = "error"
21952202
logger.info(
2196-
"Final Status: status.context=%s cdata[-1]=%s lab_stats[cdata[-1]][-1]=%s status.description=%s",
2203+
"Final Status: status.context=%s suffix=%s lab_stats[%s][-1]=%s status.description=%s",
21972204
status.context,
2198-
cdata[-1],
2199-
lab_stats[cdata[-1]][-1],
2205+
suffix,
2206+
suffix,
2207+
lab_stats[suffix][-1],
22002208
status.description,
22012209
)
2202-
if (lab_stats[cdata[-1]][-1] != "pending") and (
2210+
if (lab_stats[suffix][-1] != "pending") and (
22032211
not status.description.startswith("Finished")
22042212
):
22052213
if result_url:
@@ -2217,10 +2225,11 @@ def process_pr(
22172225
raise Exception("System-error: unable to get PR result")
22182226
if o and (not dryRun):
22192227
res = "+1"
2220-
if lab_stats[cdata[-1]][-1] == "error":
2228+
if lab_stats[suffix][-1] == "error":
22212229
res = "-1"
22222230
res = "%s\n\n%s" % (res, o)
22232231
issue.create_comment(res)
2232+
reporting_build_only = prefix in build_only_prefixes
22242233
if not dryRun:
22252234
last_commit_obj.create_status(
22262235
"success",
@@ -2229,10 +2238,11 @@ def process_pr(
22292238
context=status.context,
22302239
)
22312240
logger.info("Lab Status %s", lab_stats)
2241+
# End of loop over all statuses
22322242
lab_state = "required"
22332243
if lab_state not in lab_stats:
22342244
lab_state = "optional"
2235-
if (lab_state in lab_stats) and ("pending" not in lab_stats[lab_state]):
2245+
if (lab_state in lab_stats) and ("pending" not in lab_stats[lab_state]) and not reporting_build_only:
22362246
signatures["tests"] = "approved"
22372247
if "error" in lab_stats[lab_state]:
22382248
signatures["tests"] = "rejected"
@@ -2365,7 +2375,7 @@ def process_pr(
23652375

23662376
# Keep old tests state for closed PRs (workaround for missing commit statuses in old PRs)
23672377
# Do not change tests label in build-only mode
2368-
if build_only or not create_status:
2378+
if not create_status:
23692379
labels = [l for l in labels if not l.startswith("tests-")]
23702380
labels.extend(l for l in old_labels if l.startswith("tests-"))
23712381

0 commit comments

Comments
 (0)