in buildkite/incompatible_flag_verbose_failures.py [0:0]
def get_failing_jobs(build_info):
failing_jobs = []
for job in build_info["jobs"]:
if "state" in job and job["state"] == "failed":
command = job["command"]
if not command:
bazelci.eprint("'command' field not found in the job: " + str(job))
continue
# Skip if the job is not a runner job
if command.find("bazelci.py runner") == -1:
continue
# Get rid of the incompatible flags in the command line because we are going to test them individually
command_without_incompatible_flags = " ".join(
[i for i in command.split(" ") if not i.startswith("--incompatible_flag")]
)
# Recover the task name from job command
flags = get_flags_from_command(command)
task = flags.get("task")
if not task:
raise BuildkiteException(
"The following command has no --task argument: %s." % command
)
# Fetch the original job config to retrieve the platform name.
job_config = bazelci.load_config(
http_url=flags.get("http_config"), file_config=flags.get("file_config")
)
# The config can either contain a "tasks" dict (new format) or a "platforms" dict (legacy format).
all_tasks = job_config.get("tasks", job_config.get("platforms"))
if not all_tasks:
raise BuildkiteException(
"Malformed configuration: No 'tasks' or 'platforms' entry found."
)
task_config = all_tasks.get(task)
if not task_config:
raise BuildkiteException(
"Configuration does not contain an entry for task '%s'" % task
)
# Shortcut: Users can skip the "platform" field if its value equals the task name.
platform = task_config.get("platform") or task
failing_jobs.append(
{
"name": job["name"],
"command": command_without_incompatible_flags.split("\n"),
"platform": platform,
}
)
return failing_jobs