in buildkite/bazel_auto_sheriff.py [0:0]
def _analyze(self):
# Main build: PASSED; Downstream build: PASSED
if self.main_result["state"] == "passed" and self.downstream_result["state"] == "passed":
self._log_success("Main build: PASSED; Downstream build: PASSED")
return
# Main build: FAILED; Downstream build: PASSED
if self.main_result["state"] == "failed" and self.downstream_result["state"] == "passed":
self._log("FAIL", "Main build: FAILED")
self._log("PASSED", "Downstream build: PASSED")
self._analyze_main_pipeline_result()
self._log("HEADER", "Analyzing finished.")
return
# Main build: PASSED; Downstream build: FAILED
if self.main_result["state"] == "passed" and self.downstream_result["state"] == "failed":
self._log("PASSED", "Main build: PASSED")
self._log("FAIL", "Downstream build: FAILED")
self._analyze_for_downstream_pipeline_result()
self._log("HEADER", "Analyzing finished.")
return
# Main build: FAILED; Downstream build: FAILED
if self.main_result["state"] == "failed" and self.downstream_result["state"] == "failed":
self._log("FAIL", "Main build: FAILED")
self._log("FAIL", "Downstream build: FAILED")
last_green_commit = self.main_result["last_green_commit"]
# If the lastest build is the last green commit, that means some infra change has caused the breakage.
if last_green_commit == self.main_result["commit"]:
self.broken_by_infra = True
self._log("SERIOUS", f"Project failed at last green commit. This is probably caused by an infra change, please ping philwo@ or pcloudy@.")
self._log("HEADER", "Analyzing finished.")
return
# Rebuild the project at last green commit, check if the failure is caused by infra change.
self._log("PASSED", f"Rebuild at last green commit {last_green_commit}...")
build_info = self.client.trigger_new_build(last_green_commit, "Trigger build at last green commit.")
build_info = self.client.wait_build_to_finish(build_number = build_info["number"], logger = self)
if build_info["state"] == "failed":
self.broken_by_infra = True
self._log("SERIOUS", f"Project failed at last green commit. This is probably caused by an infra change, please ping philwo@ or pcloudy@.")
elif build_info["state"] == "passed":
self._log("PASSED", f"Project succeeded at last green commit. Maybe main pipeline and downstream pipeline are broken for different reasons.")
self._analyze_main_pipeline_result()
self._analyze_for_downstream_pipeline_result()
else:
self._log("SERIOUS", f"Rebuilding project at last green commit failed with unknown reason. Please check " + build_info["web_url"])
self._log("HEADER", "Analyzing finished.")
return