Skip to content

Commit c6967f0

Browse files
committed
CI: always write bugfix-validation JSON (fix artifact-upload failure)
The per-arch Bugfix validation jobs declare `bugfix_validate_result.json` in `provides=[...]`, so the praktika runner unconditionally tries to upload that artifact during the post-run step. Previously the JSON was only written for actual bugfix PRs (those with the `pr-bugfix` / `pr-critical-bugfix` label). On non-bugfix PRs that exercise these jobs (e.g. when the test-runner script itself is modified), the file was never written, and the artifact-upload step failed with `ls: cannot access '...bugfix_validate_result.json': No such file`, which caused the entire job to report `FAILURE` to GitHub. This was exactly the latent bug that `force_success=True` was masking before commit `517801bc446`. After dropping `force_success`, the failure surfaced on PR #103541 itself: 4/4 per-arch jobs failed at the artifact-upload step even though the inner praktika test results were all green (sanity test `00001_select_1` passed on every arch). Fix: - `ci/jobs/functional_tests.py` and `ci/jobs/integration_test_job.py` now ALWAYS write `bugfix_validate_result.json` whenever the job is a bugfix-validation job, regardless of PR labels. Two new fields are recorded: * `is_bugfix_pr` — whether the PR has a `pr-bugfix` / `pr-critical-bugfix` label. * `skipped` — set to `true` for non-bugfix PRs and for bugfix PRs that hit an infrastructure error during validation. Excludes the arch from the aggregator's validation decision. - `ci/jobs/bugfix_validation_aggregate.py` recognises both fields and reports SUCCESS in the new "all archs skipped because not a bugfix PR" case, so the aggregator does not block PRs that merely modify the bugfix-validation runner. The default `is_bugfix_pr=true` preserves back-compat with older per-arch JSONs. The `set_success()` semantics for actual bugfix PRs are unchanged: result inversion (XFAIL semantics) and natural OK status without `force_success=True`. The integration-test runner now also writes a `skipped=true` JSON when `has_error` is set during bugfix validation, so an infra-error arch propagates as a real job failure on GitHub while still emitting the artifact for the aggregator to consume. CI report: #103541
1 parent 517801b commit c6967f0

3 files changed

Lines changed: 203 additions & 87 deletions

File tree

‎ci/jobs/bugfix_validation_aggregate.py‎

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,32 @@
1919
"validated": true | false,
2020
"info": "<human-readable description>",
2121
"arch": "amd64" | "aarch64",
22-
"kind": "functional tests" | "integration tests"
22+
"kind": "functional tests" | "integration tests",
23+
"is_bugfix_pr": true | false, # whether the PR actually has a
24+
# `pr-bugfix` / `pr-critical-bugfix`
25+
# label
26+
"skipped": true | false # set on infra error or on
27+
# non-bugfix PRs; the aggregator
28+
# excludes this arch from the
29+
# validation decision
2330
}
2431
2532
The aggregator combines all four results and reports SUCCESS to GitHub iff
2633
at least one arch validated the bug. This is the only bugfix-validation
2734
check that blocks PR merge.
2835
29-
Artifact-not-found is treated as `validated == false` with a SKIPPED
30-
sub-result, so an aggregator failure cannot be silently masked by the
31-
absence of a per-arch JSON. Per-arch jobs that genuinely failed (e.g. due
32-
to a sanitizer report or server crash) deliberately do not write the JSON
33-
in that case, so the aggregator naturally falls back to SKIPPED for that
34-
arch and the other arch can still validate the bug.
36+
Special cases:
37+
38+
- If all per-arch results have `is_bugfix_pr=false`, the per-arch jobs
39+
ran on a non-bugfix PR (because the bugfix-validation runner script
40+
was modified in this PR). There is nothing to validate; the aggregator
41+
reports SUCCESS so the merge gate doesn't block the CI-infrastructure
42+
PR.
43+
- If a per-arch result has `skipped=true` (set on infra error or for
44+
non-bugfix PRs), that arch does NOT count toward the validation
45+
decision; the other arch can still validate the bug.
46+
- Artifact-not-found is treated identically to `skipped=true` — the arch
47+
is excluded from the decision.
3548
"""
3649
import json
3750
from pathlib import Path
@@ -85,6 +98,7 @@ def main() -> int:
8598
sub_results = []
8699
any_validated = False
87100
any_present = False
101+
bugfix_pr_archs_present = False
88102

89103
for artifact_name, label in PER_ARCH_RESULTS:
90104
data = _load_per_arch_result(artifact_name)
@@ -101,7 +115,25 @@ def main() -> int:
101115

102116
any_present = True
103117
validated = bool(data.get("validated", False))
118+
# Default `is_bugfix_pr` to True for back-compat with older per-arch
119+
# JSONs that did not include this field; in that case the JSON is
120+
# only emitted on actual bugfix PRs anyway.
121+
is_bugfix_pr = bool(data.get("is_bugfix_pr", True))
122+
skipped = bool(data.get("skipped", False))
104123
msg = str(data.get("info", ""))
124+
125+
if not is_bugfix_pr or skipped:
126+
# Don't count this arch toward the validation decision. The arch
127+
# either ran on a non-bugfix PR (sanity test only) or hit an
128+
# infrastructure error. Either way, the OTHER arch can still
129+
# validate the bug; this arch is just excluded.
130+
sub_results.append(
131+
Result(name=label, status=Result.Status.SKIPPED, info=msg)
132+
)
133+
print(f"[{label}] SKIPPED: {msg}")
134+
continue
135+
136+
bugfix_pr_archs_present = True
105137
sub_results.append(
106138
Result(
107139
name=label,
@@ -113,10 +145,27 @@ def main() -> int:
113145
if validated:
114146
any_validated = True
115147

148+
# Decide overall status:
149+
# - All per-arch jobs ran on a non-bugfix PR (e.g., this PR modifies the
150+
# bugfix-validation runner itself) -> SUCCESS, nothing to validate.
151+
# - At least one bugfix-PR arch validated the bug -> SUCCESS.
152+
# - At least one bugfix-PR arch ran but none validated -> FAIL (the
153+
# new/modified regression test does not actually catch the bug it is
154+
# supposed to catch).
155+
# - All artifacts missing -> SKIPPED with explanation.
156+
if not any_present:
157+
overall_status = Result.Status.SKIPPED
158+
elif not bugfix_pr_archs_present:
159+
# All per-arch results came from non-bugfix PRs (or all were
160+
# skipped). Nothing to validate; aggregator must not block merge.
161+
overall_status = Result.Status.OK
162+
else:
163+
overall_status = Result.Status.OK if any_validated else Result.Status.FAIL
164+
116165
overall = Result(
117166
name="Bugfix validation (final)",
118167
results=sub_results,
119-
status=Result.Status.OK if any_validated else Result.Status.FAIL,
168+
status=overall_status,
120169
)
121170

122171
if not any_present:
@@ -125,6 +174,12 @@ def main() -> int:
125174
"This usually means all four per-arch jobs were skipped or did not "
126175
"emit their result file."
127176
)
177+
elif not bugfix_pr_archs_present:
178+
overall.set_info(
179+
"Not a bugfix PR — all per-arch jobs ran sanity tests only. "
180+
"The bugfix-validation infrastructure is being verified by this "
181+
"PR; nothing to validate against a real bug."
182+
)
128183
elif not any_validated:
129184
overall.set_info(
130185
"Bugfix validation could not be confirmed on any architecture. "

‎ci/jobs/functional_tests.py‎

Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -755,52 +755,79 @@ def start():
755755
test_result.extend_sub_results(results[-1].results)
756756
results[-1].results = []
757757

758-
# invert result status for bugfix validation
759-
if is_bugfix_validation and test_result and (Labels.PR_BUGFIX in info.pr_labels or Labels.PR_CRITICAL_BUGFIX in info.pr_labels):
758+
# Bugfix validation: invert the result status (only for actual bugfix PRs)
759+
# and always write the JSON artifact (for both bugfix and non-bugfix PRs).
760+
if is_bugfix_validation and test_result:
761+
is_bugfix_pr = (
762+
Labels.PR_BUGFIX in info.pr_labels
763+
or Labels.PR_CRITICAL_BUGFIX in info.pr_labels
764+
)
760765
has_failure = False
761-
for r in test_result.results:
762-
r.set_label(Result.Label.XFAIL)
763-
if r.status == Result.Status.FAIL:
764-
r.status = Result.Status.OK
765-
has_failure = True
766-
elif r.status == Result.Status.OK:
767-
r.status = Result.Status.FAIL
768-
769-
# Per-arch bugfix-validation contract:
770-
# The job's *status* reflects "did the test run and produce a result?"
771-
# — NOT "was the bug validated?". The validation outcome is data
772-
# (recorded in the JSON artifact below) that the `Bugfix validation
773-
# (final)` aggregator consumes to decide the merge-blocking status.
774-
#
775-
# We deliberately exit with the natural OK status here (no
776-
# `force_success=True` flag is used at the job level) so that real
777-
# infrastructure errors (server crash, sanitizer assert) still
778-
# propagate as failures.
779-
if has_failure:
780-
test_result.set_info("Bug reproduced on master HEAD; PR validates the fix on this arch")
781-
else:
782-
print("Failed to reproduce the bug on this arch")
783-
test_result.set_info(
784-
"Failed to reproduce the bug on this arch; "
785-
"see Bugfix validation (final) aggregator for the merge-blocking decision"
786-
)
787-
test_result.set_success()
788766

789-
# Each per-arch JSON is uploaded as a separate S3 artifact and consumed
790-
# by the `Bugfix validation (final)` aggregator job, which OR's the
791-
# `validated` fields across all four per-arch results.
767+
if is_bugfix_pr:
768+
for r in test_result.results:
769+
r.set_label(Result.Label.XFAIL)
770+
if r.status == Result.Status.FAIL:
771+
r.status = Result.Status.OK
772+
has_failure = True
773+
elif r.status == Result.Status.OK:
774+
r.status = Result.Status.FAIL
775+
776+
# Per-arch bugfix-validation contract:
777+
# The job's *status* reflects "did the test run and produce a
778+
# result?" — NOT "was the bug validated?". The validation outcome
779+
# is data (recorded in the JSON artifact below) that the `Bugfix
780+
# validation (final)` aggregator consumes to decide the
781+
# merge-blocking status.
782+
#
783+
# We deliberately exit with the natural OK status here (no
784+
# `force_success=True` flag is used at the job level) so that
785+
# real infrastructure errors (server crash, sanitizer assert)
786+
# still propagate as failures.
787+
if has_failure:
788+
test_result.set_info(
789+
"Bug reproduced on master HEAD; PR validates the fix on this arch"
790+
)
791+
else:
792+
print("Failed to reproduce the bug on this arch")
793+
test_result.set_info(
794+
"Failed to reproduce the bug on this arch; "
795+
"see Bugfix validation (final) aggregator for the merge-blocking decision"
796+
)
797+
test_result.set_success()
798+
# else: non-bugfix PR running this job because the test runner script
799+
# was modified in this PR. The sanity test (`00001_select_1`) ran;
800+
# the natural test_result is sufficient.
801+
802+
# Always write the JSON artifact when this is a bugfix-validation job.
803+
# The praktika runner declares this artifact in `provides=[...]`, so
804+
# the file MUST exist for artifact upload to succeed — even on
805+
# non-bugfix PRs that exercise this job (e.g., when the test-runner
806+
# script was modified). For non-bugfix PRs the JSON records that
807+
# fact, and the `Bugfix validation (final)` aggregator treats
808+
# `is_bugfix_pr=false` as "nothing to validate" (does not block
809+
# merge).
792810
result_path = Path(temp_dir) / "bugfix_validate_result.json"
793811
try:
794812
arch = "aarch64" if Utils.is_arm() else "amd64"
795-
payload = {
796-
"validated": bool(has_failure),
797-
"info": (
813+
if is_bugfix_pr:
814+
info_msg = (
798815
f"Bug reproduced on master HEAD ({arch}) and fixed on PR"
799816
if has_failure
800817
else f"Failed to reproduce the bug on master HEAD ({arch})"
801-
),
818+
)
819+
else:
820+
info_msg = (
821+
f"Not a bugfix PR ({arch}); job ran sanity test only "
822+
"because the bugfix-validation runner was modified in "
823+
"this PR"
824+
)
825+
payload = {
826+
"validated": bool(has_failure) and is_bugfix_pr,
827+
"info": info_msg,
802828
"arch": arch,
803829
"kind": "functional tests",
830+
"is_bugfix_pr": is_bugfix_pr,
804831
}
805832
with result_path.open("w") as f:
806833
json.dump(payload, f)

‎ci/jobs/integration_test_job.py‎

Lines changed: 77 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,25 +1042,22 @@ def main():
10421042
if has_error:
10431043
R.set_error().set_info("\n".join(error_info))
10441044

1045-
if is_bugfix_validation and (Labels.PR_BUGFIX in info.pr_labels or Labels.PR_CRITICAL_BUGFIX in info.pr_labels):
1046-
assert (
1047-
is_llvm_coverage is False
1048-
), "Bugfix validation with LLVM coverage is not supported"
1049-
1050-
# Real infrastructure errors (sanitizer assert, OOM, etc.) are kept
1051-
# as a hard failure of the per-arch job. We do NOT mask them via
1052-
# `set_success()` and we do NOT write the JSON artifact, so the
1053-
# aggregator treats this arch as SKIPPED (validated=false). This
1054-
# keeps `force_success=True` unnecessary at the job-config level
1055-
# while still letting the other arch validate the bug.
1056-
if has_error:
1057-
print(
1058-
"WARN: Skipping bugfix-validation result write due to "
1059-
"infrastructure error; aggregator will treat this arch as "
1060-
"validated=false (SKIPPED)"
1061-
)
1062-
else:
1063-
has_failure = False
1045+
# Bugfix validation: invert the result status (only for actual bugfix PRs
1046+
# without infrastructure errors) and always write the JSON artifact (for
1047+
# both bugfix and non-bugfix PRs, so the artifact-upload step succeeds).
1048+
if is_bugfix_validation:
1049+
is_bugfix_pr = (
1050+
Labels.PR_BUGFIX in info.pr_labels
1051+
or Labels.PR_CRITICAL_BUGFIX in info.pr_labels
1052+
)
1053+
if is_bugfix_pr:
1054+
assert (
1055+
is_llvm_coverage is False
1056+
), "Bugfix validation with LLVM coverage is not supported"
1057+
1058+
has_failure = False
1059+
1060+
if is_bugfix_pr and not has_error:
10641061
for r in R.results:
10651062
# invert statuses
10661063
r.set_label(Result.Label.XFAIL)
@@ -1079,7 +1076,9 @@ def main():
10791076
# We deliberately set the natural OK status here (no
10801077
# `force_success=True` flag at the job level) so genuine
10811078
# infrastructure failures still propagate as failures (handled
1082-
# by the `if has_error:` branch above).
1079+
# by the `if has_error:` branch below — we still write the JSON
1080+
# but mark it `skipped=true` so the aggregator excludes this
1081+
# arch from the validation decision).
10831082
if has_failure:
10841083
R.set_info(
10851084
"Bug reproduced on master HEAD; PR validates the fix on this arch"
@@ -1091,29 +1090,64 @@ def main():
10911090
"see Bugfix validation (final) aggregator for the merge-blocking decision"
10921091
)
10931092
R.set_success()
1094-
1095-
# Each per-arch JSON is uploaded as a separate S3 artifact and
1096-
# consumed by the `Bugfix validation (final)` aggregator job,
1097-
# which OR's the `validated` fields across all four per-arch
1098-
# results.
1099-
result_path = Path(temp_path) / "bugfix_validate_result.json"
1100-
try:
1101-
arch = "aarch64" if Utils.is_arm() else "amd64"
1102-
payload = {
1103-
"validated": bool(has_failure),
1104-
"info": (
1105-
f"Bug reproduced on master HEAD ({arch}) and fixed on PR"
1106-
if has_failure
1107-
else f"Failed to reproduce the bug on master HEAD ({arch})"
1108-
),
1109-
"arch": arch,
1110-
"kind": "integration tests",
1111-
}
1112-
with result_path.open("w") as f:
1113-
json.dump(payload, f)
1114-
print(f"Wrote bugfix-validation result to {result_path}: {payload}")
1115-
except OSError as e:
1116-
print(f"WARN: failed to write {result_path}: {e}")
1093+
elif is_bugfix_pr and has_error:
1094+
# Real infrastructure error during bugfix validation. Don't mask
1095+
# via `set_success()` — let it propagate as a job failure. We
1096+
# still write the JSON below (skipped=true) so the artifact
1097+
# upload doesn't fail and the aggregator can see this arch
1098+
# was unable to validate.
1099+
print(
1100+
"WARN: Bugfix validation arch had infrastructure error; "
1101+
"recording skipped=true in JSON; aggregator will treat this "
1102+
"arch as SKIPPED (validated=false)"
1103+
)
1104+
# else: non-bugfix PR running this job because the test runner script
1105+
# was modified in this PR. The sanity test (`00001_select_1`) ran;
1106+
# we keep the natural test_result.
1107+
1108+
# Always write the JSON artifact when this is a bugfix-validation
1109+
# job. The praktika runner declares this artifact in `provides=[...]`,
1110+
# so the file MUST exist for artifact upload to succeed — even on
1111+
# non-bugfix PRs and even when the bugfix-validation arch hit an
1112+
# infrastructure error. For non-bugfix PRs and infra-error cases the
1113+
# JSON records that fact, and the aggregator treats
1114+
# `is_bugfix_pr=false` or `skipped=true` as "nothing to validate on
1115+
# this arch".
1116+
result_path = Path(temp_path) / "bugfix_validate_result.json"
1117+
try:
1118+
arch = "aarch64" if Utils.is_arm() else "amd64"
1119+
if not is_bugfix_pr:
1120+
info_msg = (
1121+
f"Not a bugfix PR ({arch}); job ran sanity test only "
1122+
"because the bugfix-validation runner was modified in "
1123+
"this PR"
1124+
)
1125+
skipped = True
1126+
elif has_error:
1127+
info_msg = (
1128+
f"Skipped on {arch} due to infrastructure error during "
1129+
"bugfix validation"
1130+
)
1131+
skipped = True
1132+
elif has_failure:
1133+
info_msg = f"Bug reproduced on master HEAD ({arch}) and fixed on PR"
1134+
skipped = False
1135+
else:
1136+
info_msg = f"Failed to reproduce the bug on master HEAD ({arch})"
1137+
skipped = False
1138+
payload = {
1139+
"validated": bool(has_failure) and is_bugfix_pr and not has_error,
1140+
"info": info_msg,
1141+
"arch": arch,
1142+
"kind": "integration tests",
1143+
"is_bugfix_pr": is_bugfix_pr,
1144+
"skipped": skipped,
1145+
}
1146+
with result_path.open("w") as f:
1147+
json.dump(payload, f)
1148+
print(f"Wrote bugfix-validation result to {result_path}: {payload}")
1149+
except OSError as e:
1150+
print(f"WARN: failed to write {result_path}: {e}")
11171151

11181152
force_ok_exit = False
11191153
if is_llvm_coverage and llvm_profdata_cmd:

0 commit comments

Comments
 (0)