chore: import upstream snapshot with attribution
cffconvert / validate (push) Has been skipped
License Check / license-check (push) Failing after 2s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:14:16 +08:00
commit 8a852e4b4e
36502 changed files with 9277225 additions and 0 deletions
+142
View File
@@ -0,0 +1,142 @@
# Copyright 2024 The OpenXLA Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
# copybara:comment_begin(oss-only)
load("@llvm_linux_x86_64//:version.bzl", _llvm_version = "VERSION")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("@xla//third_party/rules_python/python:py_test.bzl", "py_test")
load("//xla:pytype.bzl", "pytype_strict_binary", "pytype_strict_library")
load("//xla/tsl:tsl.bzl", "if_oss")
_LLVM_REPO_NAME = "llvm{}_linux_x86_64".format(_llvm_version)
# copybara:comment_end_and_uncomment_begin
# _LLVM_REPO_NAME = ""
# copybara:uncomment_end
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
licenses = ["notice"],
)
pytype_strict_binary(
name = "build",
srcs = ["build.py"],
)
pytype_strict_library(
name = "clang_tidy_diff_lib",
srcs = ["clang_tidy_diff.py"],
deps = [
"//build_tools/lint:diff_parser",
],
)
pytype_strict_binary(
name = "clang_tidy_diff",
srcs = ["clang_tidy_diff.py"],
data = if_oss([
":clang_apply_replacements_bin",
]),
main = "clang_tidy_diff.py",
deps = [
":clang_tidy_diff_lib",
],
)
py_test(
name = "clang_tidy_diff_test",
srcs = ["clang_tidy_diff_test.py"],
deps = [
":clang_tidy_diff_lib",
"@absl_py//absl/testing:absltest",
"@absl_py//absl/testing:parameterized",
],
)
genrule(
name = "generated_build_commands",
outs = ["generated_commands.txt"],
cmd = "$(location //build_tools/ci:build) --dump_commands > $(OUTS)",
tags = ["not_run:arm"],
tools = [":build"],
)
diff_test(
name = "build_command_golden_test",
failure_message = """Regenerate with `PYTHONDONTWRITEBYTECODE=1 python3 build.py --dump_commands > golden_commands.txt`.""",
file1 = "golden_commands.txt",
file2 = ":generated_build_commands",
tags = ["not_run:arm"],
)
sh_binary(
name = "parallel_gpu_execute",
srcs = ["parallel_gpu_execute.sh"],
)
# TODO: When upstream rules expose clang-tidy use that instead of explicitly creating one.
expand_template(
name = "generate_wrapper_script",
out = "clang_tidy_wrapper.sh",
substitutions = {
"%LLVM_REPO_NAME%": _LLVM_REPO_NAME,
},
template = "clang_tidy_wrapper.sh.tpl",
)
sh_binary(
name = "clang_tidy_bin",
srcs = [":generate_wrapper_script"],
data = [
# This not for g3. Only for running clang-tidy on CI/locally for OSS workflows.
"@{}//:all".format(_LLVM_REPO_NAME), # buildifier: disable=platform-specific-binaries
],
tags = [
"manual", # This binary only runs via explicit targeting.
"notap", # Not for g3.
],
visibility = ["//visibility:public"],
)
expand_template(
name = "generate_apply_replacements_wrapper_script",
out = "clang_apply_replacements_wrapper.sh",
substitutions = {
"%LLVM_REPO_NAME%": _LLVM_REPO_NAME,
},
template = "clang_apply_replacements_wrapper.sh.tpl",
)
sh_binary(
name = "clang_apply_replacements_bin",
srcs = [":generate_apply_replacements_wrapper_script"],
data = [
# This not for g3. Only for running clang-tidy on CI/locally for OSS workflows.
"@{}//:all".format(_LLVM_REPO_NAME), # buildifier: disable=platform-specific-binaries
],
tags = [
"manual", # This binary only runs via explicit targeting.
"notap", # Not for g3.
],
visibility = ["//visibility:public"],
)
sh_binary(
name = "run_clang_tidy",
srcs = ["run_clang_tidy.sh"],
)
+1021
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,18 @@
#!/bin/bash
set -e
echoerr() {
RED='\033[1;31m'
NOCOLOR='\033[0m'
printf "${RED}ERROR:${NOCOLOR} %s\n" "$*" >&2
}
REAL_BIN="$PWD/external/%LLVM_REPO_NAME%/bin/clang-apply-replacements"
if [ ! -f "$REAL_BIN" ]; then
echoerr "Failed to locate clang-apply-replacements binary at: $REAL_BIN"
exit 1
fi
echo "Using clang-apply-replacements at: " $REAL_BIN
REAL_LIB_DIR="$(dirname "$REAL_BIN")/../lib"
export LD_LIBRARY_PATH="${REAL_LIB_DIR}:${LD_LIBRARY_PATH}"
exec "$REAL_BIN" "$@"
+804
View File
@@ -0,0 +1,804 @@
# Copyright 2026 The OpenXLA Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Filters Clang-Tidy errors based on modified lines in a Git patch.
This script reads a unified diff (patch file) to determine which lines of which
files have been modified. It then parses the Bazel Build Event Protocol (BEP)
JSON file to find the paths of all generated Clang-Tidy YAML reports. For each
report, it checks if any reported errors fall within the modified line ranges
and prints the matching errors.
"""
from __future__ import annotations
import argparse
import bisect
import collections
from collections.abc import Callable, Sequence
import dataclasses
import functools
import itertools
import json
import logging
import os
import pathlib
import subprocess
import sys
import tempfile
from typing import IO, Protocol, TypedDict
from build_tools.lint import diff_parser
@dataclasses.dataclass(frozen=True)
class AppConfig:
"""Configuration for the ClangTidyDiffFilter application.
Attributes:
patch: Path to the patch file containing the diff or None if no diff
filtering should be applied.
repo_root: Absolute path to the repository root.
bep_file: Path to the Bazel Build Event Protocol JSON file.
warnings_as_errors: If True, treat Clang-Tidy warnings as errors.
fix: If True, apply fixes to the source files.
"""
patch: str | None
repo_root: str
bep_file: str
warnings_as_errors: bool
fix: bool = False
@dataclasses.dataclass(frozen=True)
class Diagnostic:
"""Represents a single Clang-Tidy diagnostic.
Attributes:
file_path: The path to the file where the diagnostic was found, relative to
the repo root.
line_num: The 1-based line number of the diagnostic.
col_num: The 1-based column number of the diagnostic.
level: The severity level of the diagnostic (e.g., "warning", "error").
name: The name of the Clang-Tidy check (e.g., "clang-diagnostic-error").
message: The diagnostic message.
yaml_file: The path to the .clang-tidy.yaml file where this diagnostic was
reported.
has_replacements: Whether the diagnostic has replacements available. For
some diagnostics, clang-tidy can automatically fix the issue, and this
attribute will be True if there are one or more replacements available.
"""
file_path: str
line_num: int
col_num: int
level: str
name: str
message: str
yaml_file: str
has_replacements: bool
@dataclasses.dataclass(frozen=True, kw_only=True)
class DiagnosticSummary:
"""Summary for all Clang-Tidy diagnostics for a file.
Attributes:
file_path: The path to the file where the diagnostics were found, relative
to the repo root.
was_skipped: Whether the file was skipped due to not being in the git diff.
total: The total number of diagnostics found in the report.
matched: The number of diagnostics that matched the diff.
"""
file_path: str
was_skipped: bool
total: int
matched: int
# Can't use TypedDict with classes because linting will complain about fields
# starting with capital letters.
ClangTidyDiagnostic = TypedDict(
"ClangTidyDiagnostic",
{
"DiagnosticName": str,
"Message": str,
"FilePath": str,
"FileOffset": int,
"Level": str,
"HasReplacements": bool,
},
total=False,
)
ClangTidyReport = TypedDict(
"ClangTidyReport",
{
"MainSourceFile": str,
"Diagnostics": list[ClangTidyDiagnostic],
},
total=False,
)
class ApplyFixes(Protocol):
"""A callable for applying fixes from clang-tidy diagnostics."""
def __call__(self, temp_dir: pathlib.Path) -> None:
"""Applies fixes to the source files in the given temporary directory.
Args:
temp_dir: The temporary directory containing the source files to apply
fixes to.
"""
...
def clang_apply_fixes(bin_path: pathlib.Path, temp_dir: pathlib.Path) -> None:
"""Applies fixes to the source files in the given temporary directory.
Args:
bin_path: Path to the clang-apply-replacements binary.
temp_dir: The temporary directory containing the source files to apply fixes
to.
"""
cmd = [
bin_path.as_posix(),
"-remove-change-desc-files",
temp_dir.as_posix(),
]
_logger().info("Running command: %r", " ".join(cmd))
subprocess.check_output(cmd)
def _logger() -> logging.Logger:
"""Returns the logger for this module."""
return logging.getLogger(__name__)
def _set_log_level(log_level: str) -> None:
"""Sets the log level for the application."""
logging.basicConfig(
format=(
"[%(asctime)s] [%(levelname)s][%(filename)s:%(funcName)s:%(lineno)d]"
" %(message)s"
),
datefmt="%H:%M:%S",
)
def _set_level(level: int) -> None:
_logger().setLevel(level)
match log_level:
case "DEBUG":
_set_level(logging.DEBUG)
case "INFO":
_set_level(logging.INFO)
case "WARNING":
_set_level(logging.WARNING)
case "ERROR":
_set_level(logging.ERROR)
case _:
raise ValueError(f"Unsupported log level: {log_level}")
def _resolve_clang_apply_replacements(
clang_apply_replacements_bin: pathlib.Path | None,
) -> pathlib.Path | None:
"""Resolve path to the clang-apply-replacements binary.
If the path is explicitly provided, use that. Otherwise, try to find it using
bazel-runfiles.
Args:
clang_apply_replacements_bin: The path to the clang-apply-replacements
binary, or None if it should be resolved from the environment.
Returns:
The path to the clang-apply-replacements binary, or None if it could not be
resolved.
"""
if clang_apply_replacements_bin:
return clang_apply_replacements_bin
runfiles_dir = os.environ.get("RUNFILES_DIR")
if not runfiles_dir:
return None
runfiles_path = (
pathlib.Path(runfiles_dir)
/ "xla/build_tools/ci/clang_apply_replacements_bin"
)
if runfiles_path.exists():
return runfiles_path
_logger().warning(
"clang-apply-replacements binary not found in RUNFILES_DIR: %s",
runfiles_path,
)
return None
def parse_diff(diff_path: str) -> dict[str, set[int]]:
"""Parses a unified diff file using diff_parser and returns a dictionary mapping filenames to a set of modified line numbers."""
with open(diff_path, "r") as f:
diff_str = f.read()
hunks = diff_parser.parse_hunks(diff_str)
file_to_lines: dict[str, set[int]] = collections.defaultdict(set)
for hunk in hunks:
for line_no, _ in hunk.added_lines():
file_to_lines[hunk.file].add(line_no)
return file_to_lines
def get_line_offsets(file_path: str) -> tuple[int, ...]:
"""Returns a list of byte offsets for the start of each line in the file."""
offsets = [0]
with open(file_path, "rb") as f:
while f.readline():
offsets.append(f.tell())
return tuple(offsets)
def offset_to_line(offsets: Sequence[int], offset: int) -> int:
"""Converts a byte offset to a 1-based line number using binary search."""
if not offsets:
return -1
# bisect_right returns the index where the offset would be inserted after
# existing entries. Since offsets contains start of lines, bisect_right - 1
# gives the line index (0-based).
return bisect.bisect_right(offsets, offset)
def normalize_path(path: str, repo_root: str) -> str:
"""Normalizes a path to be relative to the repo root.
This is not foolproof for all possible path formats,
but it handles common cases seen locally and in CI.
Args:
path: The path to normalize.
repo_root: The absolute path to the repository root.
Returns:
The normalized path as a string.
"""
if not path:
return ""
p = pathlib.Path(path)
# Handle local absolute paths under repo_root (CI Runner paths)
# This handles /__w/xla/xla by removing the prefix.
if p.is_absolute() and p.is_relative_to(repo_root):
return p.relative_to(repo_root).as_posix()
# Handle bazel execroot paths
if "execroot" in p.parts:
idx = p.parts.index("execroot")
if idx + 2 < len(p.parts):
return pathlib.Path(*p.parts[idx + 2 :]).as_posix()
# Handle remote execution paths
# p is like "/b/f/w/xla/..."
# NB: We don't quite know the top level directory to look for in the remote
# path, but since all CPP sources live mostly under "xla/" we use it as the
# anchor. We also include "third_party" as an anchor since some files may
# be under that directory.
_top_level_pkgs = ("xla", "third_party")
for pkg in _top_level_pkgs:
if pkg in p.parts:
parts = list(p.parts)
idx = parts.index(pkg) # Find FIRST occurrence in remote path
return pathlib.Path(*parts[idx:]).as_posix()
return path
def parse_bep(bep_path: str, repo_root: str) -> list[str]:
"""Parses a Bazel BEP JSON file and returns a list of paths to .clang-tidy.yaml files.
Args:
bep_path: Path to the Bazel BEP JSON file.
repo_root: Absolute path to the repository root.
Returns:
A list of paths to .clang-tidy.yaml files.
Raises:
ValueError: If a file entry in the BEP is missing 'name' or 'pathPrefix'
fields.
"""
yaml_files: list[str] = []
with open(bep_path, "r") as f:
for line in f:
try:
event = json.loads(line)
if "namedSetOfFiles" not in event:
continue
files = event["namedSetOfFiles"].get("files", [])
for file_info in files:
name = file_info.get("name")
prefix = file_info.get("pathPrefix")
if name is None:
raise ValueError("File entry in BEP is missing 'name' field.")
if not name.endswith(".clang-tidy.yaml"):
continue
if prefix is None:
raise ValueError("File entry in BEP is missing 'pathPrefix' field.")
path = (
pathlib.Path(repo_root) / pathlib.Path(*prefix) / name
).as_posix()
yaml_files.append(path)
except json.JSONDecodeError:
_logger().warning(
"Skipping invalid JSON line in BEP file: %s", line.strip()
)
continue
return yaml_files
def parse_clang_tidy_yaml(yaml_path: str) -> ClangTidyReport:
"""A simple, specialized parser for clang-tidy YAML reports to avoid PyYAML dependency."""
def extract(s: str) -> str:
_, value = s.split(":", 1)
return value.strip().strip("'\"")
result: ClangTidyReport = {"Diagnostics": []}
current_diag: ClangTidyDiagnostic | None = None
in_diag_message = False
with open(yaml_path, "r") as f:
for line in f:
stripped = line.strip()
if stripped.startswith("MainSourceFile:"):
result["MainSourceFile"] = extract(stripped)
elif stripped.startswith("- DiagnosticName:"):
current_diag = {"DiagnosticName": extract(stripped)}
result["Diagnostics"].append(current_diag)
in_diag_message = False
elif stripped.startswith("DiagnosticMessage:"):
in_diag_message = True
elif in_diag_message and stripped.startswith("Message:"):
if current_diag is not None:
current_diag["Message"] = extract(stripped)
elif in_diag_message and stripped.startswith("FilePath:"):
if current_diag is not None:
current_diag["FilePath"] = extract(stripped)
elif in_diag_message and stripped.startswith("FileOffset:"):
if current_diag is not None:
current_diag["FileOffset"] = int(extract(stripped))
elif stripped.startswith("Level:"):
if current_diag is not None:
current_diag["Level"] = extract(stripped)
elif stripped.startswith("Replacements:"):
in_diag_message = False
if current_diag is not None:
current_diag["HasReplacements"] = not stripped.endswith("[]")
return result
RESET = "\033[0m"
BOLD = "\033[1m"
RED = "\033[31m"
YELLOW = "\033[33m"
GREEN = "\033[32m"
CYAN = "\033[36m"
def ansiformat(text: str, color: str = "", bold: bool = False) -> str:
"""Returns text wrapped in ANSI color codes."""
bold_str = BOLD if bold else ""
return f"{bold_str}{color}{text}{RESET}"
def print_diagnostic(
diag: Diagnostic,
repo_root: str,
*,
warnings_as_errors: bool = False,
stream: IO[str] = sys.stderr,
) -> None:
"""Prints a diagnostic message with code snippet and color."""
# Clang-tidy format: file:line:col: level: message [name]
def get_level_str() -> str:
level_str = diag.level.lower() if diag.level else "warning"
if warnings_as_errors and level_str == "warning":
return "error"
return level_str
level_str = get_level_str()
diag_line = " ".join((
ansiformat(
":".join((diag.file_path, str(diag.line_num), str(diag.col_num))),
bold=True,
),
ansiformat(
f"{level_str}:",
color=RED if level_str == "error" else YELLOW,
bold=True,
),
ansiformat(diag.message, bold=True),
ansiformat(f"[{diag.name}]", color=CYAN, bold=True),
))
stream.write(f"{diag_line}\n")
abs_path = pathlib.Path(repo_root) / diag.file_path
try:
with open(abs_path, "r") as f:
lines = f.readlines()
except FileNotFoundError:
_logger().warning(
"Could not read file %r to print diagnostic snippet.",
abs_path.as_posix(),
)
return
context_lines = 5
start = max(0, diag.line_num - context_lines - 1)
end = min(len(lines), diag.line_num + context_lines)
for linenum, line in enumerate(lines[start:end], start=start + 1):
line_content = line.rstrip("\n")
prefix = f"{linenum:5d} | "
if linenum == diag.line_num:
stream.write(f"{ansiformat(prefix, bold=True)}{line_content}\n")
# Print caret
spaces = "".join(
"\t" if ch == "\t" else " " for ch in line_content[: diag.col_num - 1]
)
stream.write(
f"{' ' * len(prefix)}{spaces}{ansiformat('^', color=GREEN, bold=True)}\n"
)
else:
stream.write(f"{prefix}{line_content}\n")
def _find_with_prefix(
parts: Sequence[str], prefix: str
) -> tuple[int, str | None]:
"""Finds the index and value of the first part starting with the prefix.
Args:
parts: The path parts to search.
prefix: The prefix to search for.
Returns:
A tuple of (index, dir) where dir is the directory starting with the
prefix or None if not found.
"""
for idx, part in enumerate(parts):
if part.startswith(prefix):
return idx, part
return 0, None
def _get_report_source(yaml_file_path: pathlib.Path, repo_root: str) -> str:
"""Returns the source file path for a Clang-Tidy YAML report file."""
# yaml_path looks like:
# x/y/z/bazel_clang_tidy/path/to/file.cc.<target>.clang-tidy.yml.
expected_prefix = "bazel_clang_tidy_"
idx, aspect_dir = _find_with_prefix(yaml_file_path.parts, expected_prefix)
if aspect_dir is not None:
toplevel = [aspect_dir.removeprefix(expected_prefix)]
rel_parts = yaml_file_path.parts[idx + 1 :]
# Remove <target>.clang-tidy.yml suffix.
filename = rel_parts[-1].rsplit(".", 3)[0]
else:
toplevel = []
rel_parts = yaml_file_path.parts
# Remove .clang-tidy.yml without the <target>.
filename = rel_parts[-1].rsplit(".", 2)[0]
return normalize_path(
pathlib.Path(*toplevel, *rel_parts[:-1], filename).as_posix(),
repo_root,
)
class ClangTidyDiffFilter:
"""Filters Clang-Tidy diagnostics based on a diff."""
def __init__(
self,
config: AppConfig,
*,
offset_provider: Callable[[str], Sequence[int]] = get_line_offsets,
apply_fixes_fn: ApplyFixes | None = None,
):
"""Initializes the ClangTidyDiffFilter.
Args:
config: An AppConfig object containing the application configuration.
offset_provider: A callable that takes a file path and returns a list of
byte offsets for the start of each line in the file. Defaults to
`get_line_offsets`.
apply_fixes_fn: Method to call to apply fixes, if --fix is enabled. It
will be called with the path to the temp directory where the relevant
YAML files have been staged. If None, fixes will not be applied.
"""
self.has_diff = config.patch is not None
self.diff_ranges = parse_diff(config.patch) if config.patch else {}
self.yaml_files = parse_bep(config.bep_file, config.repo_root)
self.repo_root = config.repo_root
self.warnings_as_errors = config.warnings_as_errors
self.offset_provider = offset_provider
self.file_offsets_cache: dict[str, Sequence[int]] = {}
self.seen_files: set[str] = set()
self.apply_fixes_fn = apply_fixes_fn
def process_file(
self, yaml_file: str
) -> tuple[Sequence[Diagnostic], DiagnosticSummary]:
"""Processes a single Clang-Tidy YAML report file.
Args:
yaml_file: The path to the Clang-Tidy YAML report file.
Returns:
A tuple of (matched_diagnostics, summary).
"""
matched_diagnostics: list[Diagnostic] = []
data = parse_clang_tidy_yaml(yaml_file)
_logger().debug(
"Processing clang-tidy report file: %s with content:\n%s",
yaml_file,
data,
)
yaml_file_path = pathlib.Path(yaml_file)
report_source = _get_report_source(yaml_file_path, self.repo_root)
if not data:
return [], DiagnosticSummary(
file_path=report_source,
was_skipped=self.has_diff,
total=0,
matched=0,
)
main_source = data.get("MainSourceFile")
if main_source:
norm_main_source = normalize_path(main_source, self.repo_root)
self.seen_files.add(norm_main_source)
if self.has_diff and report_source in self.diff_ranges:
self.seen_files.add(report_source)
if "Diagnostics" not in data:
return [], DiagnosticSummary(
file_path=report_source,
was_skipped=self.has_diff,
total=0,
matched=0,
)
for diag in data["Diagnostics"]:
file_path = diag.get("FilePath")
offset = diag.get("FileOffset")
if not file_path or offset is None:
continue
norm_path = normalize_path(file_path, self.repo_root)
if self.has_diff and norm_path not in self.diff_ranges:
continue
abs_path = pathlib.Path(self.repo_root) / norm_path
if norm_path not in self.file_offsets_cache:
self.file_offsets_cache[norm_path] = self.offset_provider(
abs_path.as_posix()
)
offsets = self.file_offsets_cache[norm_path]
if not offsets:
_logger().warning(
"Could not read file %r to calculate line number.",
abs_path.as_posix(),
)
continue
line_num = offset_to_line(offsets, offset)
line_start_offset = offsets[line_num - 1]
col_num = offset - line_start_offset + 1
lines = self.diff_ranges[norm_path] if self.has_diff else set()
if not self.has_diff or line_num in lines:
matched_diagnostics.append(
Diagnostic(
file_path=norm_path,
line_num=line_num,
col_num=col_num,
level=diag.get("Level") or "",
name=diag.get("DiagnosticName") or "",
message=diag.get("Message") or "",
yaml_file=yaml_file,
has_replacements=diag.get("HasReplacements", False),
)
)
return matched_diagnostics, DiagnosticSummary(
file_path=report_source,
was_skipped=self.has_diff and report_source not in self.diff_ranges,
total=len(data["Diagnostics"]),
matched=len(matched_diagnostics),
)
def report_missing(self) -> None:
"""Reports any touched files that were not processed using the logger."""
if not self.has_diff:
return
touched_files = set(self.diff_ranges.keys())
missing_files = [
f for f in touched_files - self.seen_files if f.endswith((".h", ".cc"))
]
if missing_files:
_logger().warning(
"No Clang-Tidy reports were processed for the following modified"
" files:"
)
for f in sorted(missing_files):
_logger().warning(" - %s", f)
def _copy_and_normalize_yaml(
self, src: pathlib.Path, dest: pathlib.Path
) -> None:
"""Copies a YAML report and normalizes all remote paths to local absolute paths."""
with src.open("r") as f_source, dest.open("w") as f_dest:
for line in f_source:
stripped = line.strip()
# Paths in clang-tidy YAMLs only appear in these two fields.
if not stripped.startswith(("MainSourceFile:", "FilePath:")):
f_dest.write(line)
continue
_, val = line.split(":", 1)
raw_path = val.strip()
if not raw_path:
continue
norm_rel_path = normalize_path(raw_path, self.repo_root)
local_abs_path = (
pathlib.Path(self.repo_root) / norm_rel_path
).as_posix()
line = line.replace(raw_path, local_abs_path)
f_dest.write(line)
def apply_fixes(self, yaml_files: Sequence[str]) -> None:
"""Stages YAML files in temp directory and calls apply_fixes_fn."""
if not self.apply_fixes_fn or not yaml_files:
return
_logger().info("Applying fixes automatically.")
with tempfile.TemporaryDirectory() as temp_dir_str:
temp_dir = pathlib.Path(temp_dir_str)
counter = itertools.count()
for y in yaml_files:
dest_path = (
pathlib.Path(temp_dir) / f"{next(counter)}_{pathlib.Path(y).name}"
)
self._copy_and_normalize_yaml(pathlib.Path(y), dest_path)
_logger().info(
"Copied YAML report to temp dir for fixes: %s", dest_path
)
self.apply_fixes_fn(temp_dir)
def run(self) -> bool:
"""Runs the Clang-Tidy diff filter.
Returns:
True if the check was successful (no errors found), False if errors were
found or running the check failed.
"""
if self.has_diff and not self.diff_ranges:
_logger().error("No modified files found in patch.")
return False
if not self.yaml_files:
_logger().error("No YAML files provided or found in BEP.")
return False
found_diagnostics = False
yaml_files_to_fix: set[str] = set()
for y in self.yaml_files:
diagnostics, summary = self.process_file(y)
if summary.was_skipped and summary.total > 0:
_logger().info(
"Skipping %r with %d diagnostics because it is not in the diff.",
summary.file_path,
summary.total,
)
if summary.total > summary.matched and not summary.was_skipped:
_logger().info(
"Not all diagnostics will be reported for %r because they are not"
" part of the diff. Found %d diagnostics but reported %d.",
summary.file_path,
summary.total,
summary.matched,
)
for d in diagnostics:
if d.has_replacements and self.apply_fixes_fn is not None:
yaml_files_to_fix.add(y)
else:
print_diagnostic(
d, self.repo_root, warnings_as_errors=self.warnings_as_errors
)
found_diagnostics = True
self.report_missing()
self.apply_fixes(sorted(yaml_files_to_fix))
return not found_diagnostics
def main() -> None:
"""Main entry point for the Clang-Tidy diff filter."""
parser = argparse.ArgumentParser(
description="Filter Clang-Tidy errors by Git diff."
)
parser.add_argument("--patch", default=None, help="Path to the patch file.")
parser.add_argument(
"--repo-root", required=True, help="Absolute path to the repo root."
)
parser.add_argument(
"--bep-file",
required=True,
help="Path to Bazel Build Event Protocol JSON file.",
)
parser.add_argument(
"--warnings-as-errors",
default="true",
choices=["true", "false"],
help="Treat warnings as errors.",
)
parser.add_argument(
"--log-level",
default="INFO",
choices=["DEBUG", "INFO", "WARNING", "ERROR"],
help="Set the log level.",
)
parser.add_argument(
"--fix",
action="store_true",
help="Apply automatic fixes to touched files.",
)
parser.add_argument(
"--clang-apply-replacements",
type=pathlib.Path,
default=None,
help="Path to clang-apply-replacements binary.",
)
args = parser.parse_args()
_set_log_level(args.log_level)
config = AppConfig(
patch=args.patch,
repo_root=args.repo_root,
bep_file=args.bep_file,
warnings_as_errors=args.warnings_as_errors == "true",
fix=args.fix,
)
apply_replacements_bin_path = (
_resolve_clang_apply_replacements(args.clang_apply_replacements)
if args.fix
else None
)
if args.fix and apply_replacements_bin_path is None:
_logger().error(
"--clang-apply-replacements is required when --fix is enabled "
"and the binary could not be resolved automatically in runfiles."
)
sys.exit(1)
apply_fixes_fn = (
functools.partial(clang_apply_fixes, apply_replacements_bin_path)
if apply_replacements_bin_path
else None
)
filterer = ClangTidyDiffFilter(config, apply_fixes_fn=apply_fixes_fn)
if not filterer.run():
sys.exit(1)
if __name__ == "__main__":
main()
+649
View File
@@ -0,0 +1,649 @@
# Copyright 2026 The OpenXLA Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
from collections.abc import Sequence
import io
import json
import pathlib
import tempfile
import textwrap
from absl.testing import absltest
from absl.testing import parameterized
from build_tools.ci import clang_tidy_diff
class TestClangTidyDiff(parameterized.TestCase):
@parameterized.parameters(
(0, 1),
(5, 1),
(10, 2),
(15, 2),
(20, 3),
(25, 3),
(30, 4),
(35, 4),
)
def test_offset_to_line(self, offset, expected_line):
offsets = [0, 10, 20, 30]
self.assertEqual(
clang_tidy_diff.offset_to_line(offsets, offset), expected_line
)
def test_offset_to_line_empty(self):
self.assertEqual(clang_tidy_diff.offset_to_line([], 10), -1)
def test_normalize_path_relative(self):
self.assertEqual(
clang_tidy_diff.normalize_path("foo/bar.cc", "/root"), "foo/bar.cc"
)
def test_normalize_path_absolute_in_repo(self):
self.assertEqual(
clang_tidy_diff.normalize_path("/root/foo/bar.cc", "/root"),
"foo/bar.cc",
)
def test_normalize_path_absolute_outside_repo(self):
self.assertEqual(
clang_tidy_diff.normalize_path("/other/foo/bar.cc", "/root"),
"/other/foo/bar.cc",
)
def test_normalize_path_execroot(self):
path = "/usr/local/google/home/user/.cache/bazel/_bazel_user/a708d4fc59660ccd295a76cce84d113c/execroot/xla/xla/stream_executor/cuda/cuda_status.h"
self.assertEqual(
clang_tidy_diff.normalize_path(path, "/root"),
"xla/stream_executor/cuda/cuda_status.h",
)
def test_normalize_path_remote_worker(self):
path = "/b/f/w/xla/backends/gpu/codegen/triton/transforms/lowering_utils.h"
# repo_root is /__w/xla/xla, so workspace name is 'xla'
self.assertEqual(
clang_tidy_diff.normalize_path(path, "/__w/xla/xla"),
"xla/backends/gpu/codegen/triton/transforms/lowering_utils.h",
)
def test_normalize_path_local_ci_runner(self):
path = "/__w/xla/xla/xla/backends/gpu/codegen/triton/transforms/lowering_utils.h"
self.assertEqual(
clang_tidy_diff.normalize_path(path, "/__w/xla/xla"),
"xla/backends/gpu/codegen/triton/transforms/lowering_utils.h",
)
def test_normalize_path_remote_worker_third_party(self):
path = "/b/f/w/third_party/gpus/cuda/include/cuda.h"
self.assertEqual(
clang_tidy_diff.normalize_path(path, "/__w/xla/xla"),
"third_party/gpus/cuda/include/cuda.h",
)
def test_parse_diff(self):
tmpdir = self.create_tempdir().full_path
diff_path = pathlib.Path(tmpdir) / "test.diff"
with open(diff_path, "w") as f:
f.write(textwrap.dedent("""\
diff --git a/file1.cc b/file1.cc
index 123456..789012 100644
--- a/file1.cc
+++ b/file1.cc
@@ -1,2 +1,3 @@
line1
+line2
line3
"""))
ranges = clang_tidy_diff.parse_diff(str(diff_path))
self.assertEqual(ranges, {"file1.cc": {2}})
def test_parse_bep(self):
with tempfile.TemporaryDirectory() as tmpdir:
bep_path = pathlib.Path(tmpdir) / "test.bep"
with open(bep_path, "w") as f:
f.write(
'{"namedSetOfFiles": {"files": [{"name": "file1.clang-tidy.yaml",'
' "pathPrefix": ["bazel-out", "k8-opt", "bin"]}]}}\n'
)
yaml_files = clang_tidy_diff.parse_bep(str(bep_path), "/root")
self.assertEqual(
yaml_files, ["/root/bazel-out/k8-opt/bin/file1.clang-tidy.yaml"]
)
def test_parse_clang_tidy_yaml(self):
with tempfile.TemporaryDirectory() as tmpdir:
yaml_path = pathlib.Path(tmpdir) / "test.yaml"
with open(yaml_path, "w") as f:
f.write(textwrap.dedent("""\
---
MainSourceFile: '/root/file1.cc'
Diagnostics:
- DiagnosticName: misc-unused
DiagnosticMessage:
Message: 'unused variable'
FilePath: '/root/file1.cc'
FileOffset: 15
...
"""))
data = clang_tidy_diff.parse_clang_tidy_yaml(str(yaml_path))
self.assertEqual(data.get("MainSourceFile"), "/root/file1.cc")
diagnostics = data.get("Diagnostics", [])
with self.subTest("Diagnostics"):
self.assertLen(diagnostics, 1)
self.assertEqual(diagnostics[0].get("DiagnosticName"), "misc-unused")
self.assertEqual(diagnostics[0].get("Message"), "unused variable")
self.assertEqual(diagnostics[0].get("FilePath"), "/root/file1.cc")
self.assertEqual(diagnostics[0].get("FileOffset"), 15)
def test_process_file(self):
with tempfile.TemporaryDirectory() as tmpdir:
yaml_path = pathlib.Path(tmpdir) / "file1.cc.clang-tidy.yaml"
with open(yaml_path, "w") as f:
f.write(textwrap.dedent(f"""\
---
MainSourceFile: '{tmpdir}/file1.cc'
Diagnostics:
- DiagnosticName: misc-unused
DiagnosticMessage:
Message: 'unused variable'
FilePath: '{tmpdir}/file1.cc'
FileOffset: 15
Level: Error
...
"""))
diff_path = pathlib.Path(tmpdir) / "test.diff"
with open(diff_path, "w") as f:
f.write(textwrap.dedent("""\
diff --git a/file1.cc b/file1.cc
index 123456..789012 100644
--- a/file1.cc
+++ b/file1.cc
@@ -1,2 +1,3 @@
line1
+line2
line3
"""))
bep_path = pathlib.Path(tmpdir) / "test.bep"
with open(bep_path, "w") as f:
f.write(
json.dumps({
"namedSetOfFiles": {
"files": [{
"name": "file1.cc.clang-tidy.yaml",
"pathPrefix": [],
}]
}
})
+ "\n"
)
config = clang_tidy_diff.AppConfig(
patch=str(diff_path),
repo_root=str(tmpdir),
bep_file=str(bep_path),
warnings_as_errors=True,
)
def mock_offset_provider(_: str) -> list[int]:
return [0, 10, 20, 30]
filterer = clang_tidy_diff.ClangTidyDiffFilter(
config, offset_provider=mock_offset_provider
)
diagnostics, summary = filterer.process_file(str(yaml_path))
with self.subTest("Diagnostics"):
self.assertLen(diagnostics, 1)
self.assertEqual(diagnostics[0].file_path, "file1.cc")
self.assertEqual(diagnostics[0].line_num, 2)
self.assertEqual(
diagnostics[0].col_num, 6
) # Offset 15 - Line 2 start 10 + 1 = 6
self.assertEqual(diagnostics[0].level, "Error")
self.assertEqual(diagnostics[0].name, "misc-unused")
self.assertEqual(diagnostics[0].message, "unused variable")
with self.subTest("DiagnosticSummary"):
self.assertEqual(
summary,
clang_tidy_diff.DiagnosticSummary(
file_path="file1.cc",
was_skipped=False,
total=1,
matched=1,
),
)
def test_process_file_no_substring_false_positives(self):
"""Tests that we don't get false positives from diff file paths being substrings of other file paths."""
tmpdir = self.create_tempdir().full_path
yaml_path = pathlib.Path(tmpdir) / "xla/long_util.cc.clang-tidy.yaml"
yaml_path.parent.mkdir(parents=True, exist_ok=True)
with open(yaml_path, "w") as f:
f.write(textwrap.dedent(f"""\
---
MainSourceFile: '{tmpdir}/xla/long_util.cc'
Diagnostics: []
"""))
# util and long_util are both in the diff but only long_util has a report.
diff_path = pathlib.Path(tmpdir) / "test.diff"
with open(diff_path, "w") as f:
f.write(textwrap.dedent("""\
diff --git a/util.cc b/util.cc
index 123456..789012 100644
--- a/util.cc
+++ b/util.cc
@@ -1,1 +1,2 @@
line1
+line2
diff --git a/xla/long_util.cc b/xla/long_util.cc
index 123456..789012 100644
--- a/xla/long_util.cc
+++ b/xla/long_util.cc
@@ -1,1 +1,2 @@
line1
+line2
"""))
bep_path = pathlib.Path(tmpdir) / "test.bep"
with open(bep_path, "w") as f:
f.write(
json.dumps({
"namedSetOfFiles": {
"files": [{
"name": "xla/long_util.cc.clang-tidy.yaml",
"pathPrefix": [],
}]
}
})
+ "\n"
)
config = clang_tidy_diff.AppConfig(
patch=diff_path.as_posix(),
repo_root=tmpdir,
bep_file=bep_path.as_posix(),
warnings_as_errors=True,
)
filterer = clang_tidy_diff.ClangTidyDiffFilter(config)
_, summary = filterer.process_file(str(yaml_path))
self.assertIn("xla/long_util.cc", filterer.seen_files)
self.assertFalse(summary.was_skipped)
self.assertNotIn("util.cc", filterer.seen_files)
def test_process_file_empty_yaml_aspect_path(self):
tmpdir = self.create_tempdir().full_path
yaml_path = pathlib.Path(tmpdir) / (
"bazel-out/k8-opt/bin/xla/backends/bazel_clang_tidy_xla/"
"backends/source.cc.target.clang-tidy.yaml"
)
yaml_path.parent.mkdir(parents=True, exist_ok=True)
self.create_tempfile(yaml_path.as_posix(), content="")
diff_path = pathlib.Path(tmpdir) / "test.diff"
self.create_tempfile(
diff_path.as_posix(),
content=textwrap.dedent("""\
diff --git a/xla/backends/source.cc b/xla/backends/source.cc
index 123456..789012 100644
--- a/xla/backends/source.cc
+++ b/xla/backends/source.cc
@@ -1,1 +1,2 @@
line1
+line2
"""),
)
bep_path = pathlib.Path(tmpdir) / "test.bep"
self.create_tempfile(
bep_path.as_posix(),
content=json.dumps({
"namedSetOfFiles": {
"files": [{
"name": "xla/backends/source.cc.target.clang-tidy.yaml",
"pathPrefix": [
"bazel-out",
"k8-opt",
"bin",
"xla",
"backends",
"bazel_clang_tidy_xla",
],
}]
}
})
+ "\n",
)
config = clang_tidy_diff.AppConfig(
patch=diff_path.as_posix(),
repo_root=tmpdir,
bep_file=bep_path.as_posix(),
warnings_as_errors=False,
)
filterer = clang_tidy_diff.ClangTidyDiffFilter(config)
_, summary = filterer.process_file(str(yaml_path))
# File should be marked as seen despite the empty YAML.
self.assertIn(
"xla/backends/source.cc",
filterer.seen_files,
)
with self.subTest("DiagnosticSummary"):
self.assertEqual(
summary,
clang_tidy_diff.DiagnosticSummary(
file_path="xla/backends/source.cc",
was_skipped=False,
total=0,
matched=0,
),
)
def test_run(self):
with tempfile.TemporaryDirectory() as tmpdir:
yaml_path = pathlib.Path(tmpdir) / "test.clang-tidy.yaml"
with open(yaml_path, "w") as f:
f.write(textwrap.dedent(f"""\
---
MainSourceFile: '{tmpdir}/file1.cc'
Diagnostics:
- DiagnosticName: misc-unused
DiagnosticMessage:
Message: 'unused variable'
FilePath: '{tmpdir}/file1.cc'
FileOffset: 15
Level: Error
...
"""))
diff_path = pathlib.Path(tmpdir) / "test.diff"
with open(diff_path, "w") as f:
f.write(textwrap.dedent("""\
diff --git a/file1.cc b/file1.cc
index 123456..789012 100644
--- a/file1.cc
+++ b/file1.cc
@@ -1,2 +1,3 @@
line1
+line2
line3
"""))
bep_path = pathlib.Path(tmpdir) / "test.bep"
with open(bep_path, "w") as f:
f.write(
json.dumps({
"namedSetOfFiles": {
"files": [{
"name": "test.clang-tidy.yaml",
"pathPrefix": [],
}]
}
})
+ "\n"
)
config = clang_tidy_diff.AppConfig(
patch=str(diff_path),
repo_root=str(tmpdir),
bep_file=str(bep_path),
warnings_as_errors=True,
)
def mock_offset_provider(_: str) -> list[int]:
return [0, 10, 20, 30]
filterer = clang_tidy_diff.ClangTidyDiffFilter(
config, offset_provider=mock_offset_provider
)
self.assertFalse(filterer.run())
def test_print_diagnostic_sanity(self):
diag = clang_tidy_diff.Diagnostic(
file_path="file1.cc",
line_num=2,
col_num=3,
level="warning",
name="misc-unused",
message="unused variable",
yaml_file="test.clang-tidy.yaml",
has_replacements=False,
)
with tempfile.TemporaryDirectory() as tmpdir:
src_file = pathlib.Path(tmpdir) / "file1.cc"
with open(src_file, "w") as f:
f.write("line1\nline2\nline3\n")
captured_stderr = io.StringIO()
# Run it with warnings_as_errors=True to test that path too
clang_tidy_diff.print_diagnostic(
diag,
repo_root=tmpdir,
warnings_as_errors=True,
stream=captured_stderr,
)
output = captured_stderr.getvalue()
with self.subTest("diagnostic_string_sanity"):
self.assertIn("file1.cc:2:3", output)
self.assertIn("error:", output)
self.assertIn("unused variable", output)
self.assertIn("[misc-unused]", output)
self.assertIn(" 2 |", output) # Snippet line
self.assertIn("line2", output)
self.assertIn("^", output) # Caret
@parameterized.parameters(
dict(replacement_text="", expected=None),
dict(replacement_text="Replacements: []", expected=False),
dict(
replacement_text=textwrap.dedent("""\
Replacements:
- FilePath: '/root/file1.cc'
Offset: 15
Length: 6
ReplacementText: 'blehblehbleh'
"""),
expected=True,
),
)
def test_parse_clang_tidy_yaml_with_replacements(
self, replacement_text: str, expected: bool | None
):
tmpdir = self.create_tempdir().full_path
yaml_path = pathlib.Path(tmpdir) / "test.yaml"
self.create_tempfile(
yaml_path.as_posix(),
content=textwrap.dedent(f"""\
---
MainSourceFile: '/root/file1.cc'
Diagnostics:
- DiagnosticName: misc-unused
DiagnosticMessage:
Message: 'unused variable'
FilePath: '/root/file1.cc'
FileOffset: 15
{replacement_text}
...
"""),
)
data = clang_tidy_diff.parse_clang_tidy_yaml(str(yaml_path))
diagnostics = data.get("Diagnostics", [])
self.assertLen(diagnostics, 1)
self.assertEqual(diagnostics[0].get("HasReplacements"), expected)
def _setup_temp_files(
self,
) -> tuple[str, pathlib.Path, pathlib.Path, pathlib.Path]:
"""Setup for a simple yaml, diff, and BEP file in a temporary directory.
Returns:
A tuple of (tmpdir, yaml_path, diff_path, bep_path).
"""
tmpdir = self.create_tempdir().full_path
yaml_path = pathlib.Path(tmpdir) / "file1.cc.clang-tidy.yaml"
self.create_tempfile(
yaml_path.as_posix(),
content=textwrap.dedent(f"""\
---
MainSourceFile: '{tmpdir}/file1.cc'
Diagnostics:
- DiagnosticName: misc-unused
DiagnosticMessage:
Message: 'unused variable'
FilePath: '{tmpdir}/file1.cc'
FileOffset: 15
Level: Warning
Replacements:
- FilePath: '{tmpdir}/file1.cc'
Offset: 15
Length: 6
ReplacementText: ''
...
"""),
)
diff_path = pathlib.Path(tmpdir) / "test.diff"
self.create_tempfile(
diff_path.as_posix(),
content=textwrap.dedent("""\
diff --git a/file1.cc b/file1.cc
index 123456..789012 100644
--- a/file1.cc
+++ b/file1.cc
@@ -1,2 +1,3 @@
line1
+line2
line3
"""),
)
bep_path = pathlib.Path(tmpdir) / "test.bep"
self.create_tempfile(
bep_path.as_posix(),
content=json.dumps({
"namedSetOfFiles": {
"files": [{
"name": "file1.cc.clang-tidy.yaml",
"pathPrefix": [],
}]
}
})
+ "\n",
)
return tmpdir, yaml_path, diff_path, bep_path
def test_process_file_detects_replacements(self):
tmpdir, yaml_path, diff_path, bep_path = self._setup_temp_files()
config = clang_tidy_diff.AppConfig(
patch=str(diff_path),
repo_root=tmpdir,
bep_file=str(bep_path),
warnings_as_errors=False,
fix=False,
)
def mock_offset_provider(_: str) -> Sequence[int]:
return [0, 10, 20, 30]
filterer = clang_tidy_diff.ClangTidyDiffFilter(
config, offset_provider=mock_offset_provider
)
diagnostics, _ = filterer.process_file(yaml_path.as_posix())
self.assertLen(diagnostics, 1)
self.assertTrue(diagnostics[0].has_replacements)
def test_run_collects_files_to_fix(self):
tmpdir, _, diff_path, bep_path = self._setup_temp_files()
config = clang_tidy_diff.AppConfig(
patch=str(diff_path),
repo_root=tmpdir,
bep_file=str(bep_path),
warnings_as_errors=False,
fix=True,
)
staged_dirs = []
def fake_apply_fixes(temp_dir: pathlib.Path):
staged_dirs.append(temp_dir)
copied_files = list(
pathlib.Path(temp_dir).glob("*_file1.cc.clang-tidy.yaml")
)
self.assertLen(copied_files, 1)
self.assertTrue(copied_files[0].exists())
def mock_offset_provider(_: str) -> Sequence[int]:
return [0, 10, 20, 30]
filterer = clang_tidy_diff.ClangTidyDiffFilter(
config,
offset_provider=mock_offset_provider,
apply_fixes_fn=fake_apply_fixes,
)
filterer.run()
self.assertLen(staged_dirs, 1)
def test_apply_fixes_stages_files_correctly(self):
staged_dirs = []
def fake_apply_fixes(temp_dir: pathlib.Path) -> None:
staged_dirs.append(temp_dir.as_posix())
copied_files = list(pathlib.Path(temp_dir).glob("*_file1.yaml"))
self.assertLen(copied_files, 1)
copied_file = copied_files[0]
self.assertTrue(copied_file.exists())
expected_normalized = textwrap.dedent(f"""\
MainSourceFile: {tmpdir}/xla/file1.cc
SomeOtherField: some_value
FilePath: {tmpdir}/third_party/file1.cc
""")
self.assertEqual(copied_file.read_text(), expected_normalized)
tmpdir = self.create_tempdir().full_path
src_yaml = pathlib.Path(tmpdir) / "file1.yaml"
src_yaml_content = textwrap.dedent("""\
MainSourceFile: /b/f/w/xla/file1.cc
SomeOtherField: some_value
FilePath: /somepath/_bazel_user/1234/execroot/xla/third_party/file1.cc
""")
self.create_tempfile(src_yaml.as_posix(), content=src_yaml_content)
diff_path = pathlib.Path(tmpdir) / "test.diff"
self.create_tempfile(diff_path.as_posix(), content="")
bep_path = pathlib.Path(tmpdir) / "test.bep"
self.create_tempfile(bep_path.as_posix(), content="")
config = clang_tidy_diff.AppConfig(
patch=str(diff_path),
repo_root=tmpdir,
bep_file=str(bep_path),
warnings_as_errors=False,
fix=True,
)
filterer = clang_tidy_diff.ClangTidyDiffFilter(
config,
apply_fixes_fn=fake_apply_fixes,
)
filterer.apply_fixes([src_yaml])
self.assertLen(staged_dirs, 1)
if __name__ == "__main__":
absltest.main()
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
set -e
echoerr() {
RED='\033[1;31m'
NOCOLOR='\033[0m'
printf "${RED}ERROR:${NOCOLOR} %s\n" "$*" >&2
}
REAL_BIN="$PWD/external/%LLVM_REPO_NAME%/bin/clang-tidy"
if [ ! -f "$REAL_BIN" ]; then
echoerr "Failed to locate clang-tidy binary at: $REAL_BIN"
exit 1
fi
echo "Using clang-tidy at: " $REAL_BIN
REAL_LIB_DIR="$(dirname "$REAL_BIN")/../lib"
export LD_LIBRARY_PATH="${REAL_LIB_DIR}:${LD_LIBRARY_PATH}"
# Intentional unquoted $@ expansion.
# Word-splitting is required here to resolve composite tokens passed by Bazel
# (e.g., "-include file.h" -> "-include" "file.h").
exec "$REAL_BIN" $@
+128
View File
@@ -0,0 +1,128 @@
# BEGIN BuildType.JAX_LINUX_X86_CPU_BZLMOD_GITHUB_ACTIONS
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters= --test_tag_filters= --config=rbe_linux_x86_64 --config=bzlmod --test_env=JAX_NUM_GENERATED_CASES=25 --test_env=JAX_SKIP_SLOW_TESTS=1 --repo_env=HERMETIC_PYTHON_VERSION=3.12 --override_module=xla=$GITHUB_WORKSPACE/openxla/xla --override_module=rules_ml_toolchain=$GITHUB_WORKSPACE/openxla/rules_ml_toolchain --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --nobuild -- //tests:cpu_tests //tests:backend_independent_tests //jax/experimental/jax2tf/tests:jax2tf_test_cpu //tests/multiprocess:cpu_tests //jax/experimental/jax2tf/tests/multiprocess:cpu_tests //jaxlib/tools:check_cpu_wheel_sources_test //jaxlib/tools:jaxlib_wheel_size_test //:jax_wheel_size_test
bazel test --build_tag_filters= --test_tag_filters= --config=rbe_linux_x86_64 --config=bzlmod --test_env=JAX_NUM_GENERATED_CASES=25 --test_env=JAX_SKIP_SLOW_TESTS=1 --repo_env=HERMETIC_PYTHON_VERSION=3.12 --override_module=xla=$GITHUB_WORKSPACE/openxla/xla --override_module=rules_ml_toolchain=$GITHUB_WORKSPACE/openxla/rules_ml_toolchain --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async -- //tests:cpu_tests //tests:backend_independent_tests //jax/experimental/jax2tf/tests:jax2tf_test_cpu //tests/multiprocess:cpu_tests //jax/experimental/jax2tf/tests/multiprocess:cpu_tests //jaxlib/tools:check_cpu_wheel_sources_test //jaxlib/tools:jaxlib_wheel_size_test //:jax_wheel_size_test
bazel analyze-profile profile.json.gz
# END BuildType.JAX_LINUX_X86_CPU_BZLMOD_GITHUB_ACTIONS
# BEGIN BuildType.JAX_LINUX_X86_GPU_L4_GITHUB_ACTIONS
nvidia-smi
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-multiaccelerator --test_tag_filters=-multiaccelerator --config=rbe_linux_x86_64_cuda --test_env=JAX_SKIP_SLOW_TESTS=1 --test_env=TF_CPP_MIN_LOG_LEVEL=0 --test_env=JAX_EXCLUDE_TEST_TARGETS=PmapTest.testSizeOverflow --repo_env=HERMETIC_PYTHON_VERSION=3.12 --override_repository=xla=$GITHUB_WORKSPACE/openxla/xla --override_module=xla=$GITHUB_WORKSPACE/openxla/xla --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --@local_config_cuda//cuda:override_include_cuda_libs --nobuild -- //tests:gpu_tests //tests:backend_independent_tests //tests/pallas:gpu_tests //tests/pallas:backend_independent_tests //jaxlib/tools:check_gpu_wheel_sources_test //jaxlib/tools:jax_cuda_plugin_wheel_size_test //jaxlib/tools:jax_cuda_pjrt_wheel_size_test //jaxlib/tools:jaxlib_wheel_size_test //:jax_wheel_size_test
bazel test --build_tag_filters=-multiaccelerator --test_tag_filters=-multiaccelerator --config=rbe_linux_x86_64_cuda --test_env=JAX_SKIP_SLOW_TESTS=1 --test_env=TF_CPP_MIN_LOG_LEVEL=0 --test_env=JAX_EXCLUDE_TEST_TARGETS=PmapTest.testSizeOverflow --repo_env=HERMETIC_PYTHON_VERSION=3.12 --override_repository=xla=$GITHUB_WORKSPACE/openxla/xla --override_module=xla=$GITHUB_WORKSPACE/openxla/xla --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --@local_config_cuda//cuda:override_include_cuda_libs -- //tests:gpu_tests //tests:backend_independent_tests //tests/pallas:gpu_tests //tests/pallas:backend_independent_tests //jaxlib/tools:check_gpu_wheel_sources_test //jaxlib/tools:jax_cuda_plugin_wheel_size_test //jaxlib/tools:jax_cuda_pjrt_wheel_size_test //jaxlib/tools:jaxlib_wheel_size_test //:jax_wheel_size_test
bazel analyze-profile profile.json.gz
# END BuildType.JAX_LINUX_X86_GPU_L4_GITHUB_ACTIONS
# BEGIN BuildType.JAX_WINDOWS_X86_CPU_GITHUB_ACTIONS
bazel --output_base=$GITHUB_WORKSPACE\bazel_output_base build --build_tag_filters= --test_tag_filters= --config=rbe_windows_amd64 --test_env=JAX_NUM_GENERATED_CASES=25 --test_env=JAX_SKIP_SLOW_TESTS=1 --repo_env=HERMETIC_PYTHON_VERSION=3.12 --override_repository=xla=$GITHUB_WORKSPACE\openxla\xla --override_module=xla=$GITHUB_WORKSPACE\openxla\xla --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --build_runfile_links=False -- //tests:cpu_tests //tests:backend_independent_tests //jax/experimental/jax2tf/tests:jax2tf_test_cpu //tests/multiprocess:cpu_tests //jax/experimental/jax2tf/tests/multiprocess:cpu_tests //jaxlib/tools:check_cpu_wheel_sources_test //jaxlib/tools:jaxlib_wheel_size_test //:jax_wheel_size_test
bazel analyze-profile profile.json.gz
# END BuildType.JAX_WINDOWS_X86_CPU_GITHUB_ACTIONS
# BEGIN BuildType.TENSORFLOW_LINUX_X86_CPU_GITHUB_ACTIONS
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,-tf_tosa,-oss_excluded,-oss_serial,-tpu,-benchmark-test,-v1only,-gpu --test_tag_filters=-no_oss,-tf_tosa,-oss_excluded,-oss_serial,-tpu,-benchmark-test,-v1only,-gpu --config=release_cpu_linux --config=rbe_linux_cpu --repo_env=USE_PYWRAP_RULES=True --override_repository=xla=$GITHUB_WORKSPACE/openxla/xla --override_module=xla=$GITHUB_WORKSPACE/openxla/xla --verbose_failures --test_output=errors --profile=profile.json.gz --test_lang_filters=cc,py --color=yes --nobuild -- //tensorflow/compiler/... -//tensorflow/compiler/tf2tensorrt/... //tensorflow/python/... -//tensorflow/python/distribute/... -//tensorflow/python/kernel_tests/... -//tensorflow/python/data/... -//tensorflow/python/compiler/tensorrt/...
bazel test --build_tag_filters=-no_oss,-tf_tosa,-oss_excluded,-oss_serial,-tpu,-benchmark-test,-v1only,-gpu --test_tag_filters=-no_oss,-tf_tosa,-oss_excluded,-oss_serial,-tpu,-benchmark-test,-v1only,-gpu --config=release_cpu_linux --config=rbe_linux_cpu --repo_env=USE_PYWRAP_RULES=True --override_repository=xla=$GITHUB_WORKSPACE/openxla/xla --override_module=xla=$GITHUB_WORKSPACE/openxla/xla --verbose_failures --test_output=errors --profile=profile.json.gz --test_lang_filters=cc,py --color=yes -- //tensorflow/compiler/... -//tensorflow/compiler/tf2tensorrt/... //tensorflow/python/... -//tensorflow/python/distribute/... -//tensorflow/python/kernel_tests/... -//tensorflow/python/data/... -//tensorflow/python/compiler/tensorrt/...
bazel analyze-profile profile.json.gz
# END BuildType.TENSORFLOW_LINUX_X86_CPU_GITHUB_ACTIONS
# BEGIN BuildType.TENSORFLOW_LINUX_X86_GPU_L4_GITHUB_ACTIONS
nvidia-smi
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,-tf_tosa,-oss_excluded,-oss_serial,-tpu,-benchmark-test,-v1only,-no_gpu,-no_gpu_presubmit,-no_cuda11,+gpu --test_tag_filters=-no_oss,-tf_tosa,-oss_excluded,-oss_serial,-tpu,-benchmark-test,-v1only,-no_gpu,-no_gpu_presubmit,-no_cuda11,+gpu --config=release_gpu_linux --config=rbe_linux_cuda --config=hermetic_cuda_umd --repo_env=USE_PYWRAP_RULES=True --override_repository=xla=$GITHUB_WORKSPACE/openxla/xla --override_module=xla=$GITHUB_WORKSPACE/openxla/xla --verbose_failures --test_output=errors --profile=profile.json.gz --test_lang_filters=cc,py --color=yes --nobuild -- //tensorflow/compiler/... -//tensorflow/compiler/tf2tensorrt/... //tensorflow/python/... -//tensorflow/python/distribute/... -//tensorflow/python/kernel_tests/... -//tensorflow/python/data/... -//tensorflow/python/compiler/tensorrt/...
bazel test --build_tag_filters=-no_oss,-tf_tosa,-oss_excluded,-oss_serial,-tpu,-benchmark-test,-v1only,-no_gpu,-no_gpu_presubmit,-no_cuda11,+gpu --test_tag_filters=-no_oss,-tf_tosa,-oss_excluded,-oss_serial,-tpu,-benchmark-test,-v1only,-no_gpu,-no_gpu_presubmit,-no_cuda11,+gpu --config=release_gpu_linux --config=rbe_linux_cuda --config=hermetic_cuda_umd --repo_env=USE_PYWRAP_RULES=True --override_repository=xla=$GITHUB_WORKSPACE/openxla/xla --override_module=xla=$GITHUB_WORKSPACE/openxla/xla --verbose_failures --test_output=errors --profile=profile.json.gz --test_lang_filters=cc,py --color=yes -- //tensorflow/compiler/... -//tensorflow/compiler/tf2tensorrt/... //tensorflow/python/... -//tensorflow/python/distribute/... -//tensorflow/python/kernel_tests/... -//tensorflow/python/data/... -//tensorflow/python/compiler/tensorrt/...
bazel analyze-profile profile.json.gz
# END BuildType.TENSORFLOW_LINUX_X86_GPU_L4_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_ARM64_CPU_48_VCPU_PRESUBMIT_GITHUB_ACTIONS
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel,-not_run:arm --test_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel,-not_run:arm --config=warnings --config=rbe_cross_compile_linux_arm64 --config=nonccl --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --build_tests_only=False --//xla/tsl:ci_build --nobuild -- //xla/tools/multihost_hlo_runner:hlo_runner_main //xla/tools:compute_xspace_stats_main
bazel build --build_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel,-not_run:arm --test_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel,-not_run:arm --config=warnings --config=rbe_cross_compile_linux_arm64 --config=nonccl --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --build_tests_only=False --//xla/tsl:ci_build -- //xla/tools/multihost_hlo_runner:hlo_runner_main //xla/tools:compute_xspace_stats_main
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_ARM64_CPU_48_VCPU_PRESUBMIT_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_ARM64_CPU_GITHUB_ACTIONS
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel,-not_run:arm --test_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel,-not_run:arm --config=warnings --config=rbe_cross_compile_linux_arm64 --config=nonccl --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --build_tests_only --//xla/tsl:ci_build --nobuild -- //xla/... //build_tools/... @tsl//tsl/...
bazel test --build_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel,-not_run:arm --test_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel,-not_run:arm --config=warnings --config=rbe_cross_compile_linux_arm64 --config=nonccl --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --build_tests_only --//xla/tsl:ci_build -- //xla/... //build_tools/... @tsl//tsl/...
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_ARM64_CPU_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_CPU_128_VCPU_PRESUBMIT_GITHUB_ACTIONS
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --test_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=nonccl --config=rbe_linux_cpu --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build --nobuild -- //xla/tools/multihost_hlo_runner:hlo_runner_main //xla/tools:compute_xspace_stats_main
bazel build --build_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --test_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=nonccl --config=rbe_linux_cpu --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build -- //xla/tools/multihost_hlo_runner:hlo_runner_main //xla/tools:compute_xspace_stats_main
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_CPU_128_VCPU_PRESUBMIT_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_CPU_BZLMOD_GITHUB_ACTIONS
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --test_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=nonccl --config=rbe_linux_cpu --config=bzlmod --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build --nobuild -- //xla/... //build_tools/... @tsl//tsl/...
bazel test --build_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --test_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=nonccl --config=rbe_linux_cpu --config=bzlmod --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build -- //xla/... //build_tools/... @tsl//tsl/...
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_CPU_BZLMOD_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_CPU_GITHUB_ACTIONS
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --test_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=nonccl --config=rbe_linux_cpu --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build --nobuild -- //xla/... //build_tools/... @tsl//tsl/...
bazel test --build_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --test_tag_filters=-no_oss,-gpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=nonccl --config=rbe_linux_cpu --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build -- //xla/... //build_tools/... @tsl//tsl/...
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_CPU_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_GPU_8X_H100_GITHUB_ACTIONS
nvidia-smi
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,-rocm-only,-oneapi-only,multi_gpu,-xla_nvgpu_any --test_tag_filters=-no_oss,-rocm-only,-oneapi-only,multi_gpu,-xla_nvgpu_any,-requires-gpu-sm60,-requires-gpu-sm60-only,-requires-gpu-sm70,-requires-gpu-sm70-only,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=9.0 --repo_env=REMOTE_GPU_TESTING=0 --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --test_sharding_strategy=disabled --test_strategy=exclusive --nobuild -- //xla/... //build_tools/... @tsl//tsl/...
bazel test --build_tag_filters=-no_oss,-rocm-only,-oneapi-only,multi_gpu,-xla_nvgpu_any --test_tag_filters=-no_oss,-rocm-only,-oneapi-only,multi_gpu,-xla_nvgpu_any,-requires-gpu-sm60,-requires-gpu-sm60-only,-requires-gpu-sm70,-requires-gpu-sm70-only,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=9.0 --repo_env=REMOTE_GPU_TESTING=0 --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --test_sharding_strategy=disabled --test_strategy=exclusive -- //xla/... //build_tools/... @tsl//tsl/...
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_GPU_8X_H100_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_GPU_A4_224_VCPU_BENCHMARK_PRESUBMIT_GITHUB_ACTIONS
nvidia-smi
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm100-only,requires-gpu-sm60,requires-gpu-sm70,requires-gpu-sm80,requires-gpu-sm90,requires-gpu-sm100,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=cuda_libraries_from_stubs --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=10 --repo_env=HERMETIC_CUDA_VERSION=12.8.0 --repo_env=HERMETIC_CUDNN_VERSION=9.8.0 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --nobuild -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm100-only,requires-gpu-sm60,requires-gpu-sm70,requires-gpu-sm80,requires-gpu-sm90,requires-gpu-sm100,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=cuda_libraries_from_stubs --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=10 --repo_env=HERMETIC_CUDA_VERSION=12.8.0 --repo_env=HERMETIC_CUDNN_VERSION=9.8.0 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_GPU_A4_224_VCPU_BENCHMARK_PRESUBMIT_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_GPU_A4_224_VCPU_PRESUBMIT_GITHUB_ACTIONS
nvidia-smi
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm100-only,requires-gpu-sm60,requires-gpu-sm70,requires-gpu-sm80,requires-gpu-sm90,requires-gpu-sm100,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=10 --repo_env=HERMETIC_CUDA_VERSION=12.8.0 --repo_env=HERMETIC_CUDNN_VERSION=9.8.0 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --nobuild -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm100-only,requires-gpu-sm60,requires-gpu-sm70,requires-gpu-sm80,requires-gpu-sm90,requires-gpu-sm100,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=10 --repo_env=HERMETIC_CUDA_VERSION=12.8.0 --repo_env=HERMETIC_CUDNN_VERSION=9.8.0 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_GPU_A4_224_VCPU_PRESUBMIT_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_GPU_HERMETIC_ROCM_GITHUB_ACTIONS
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_gpu,-requires-gpu-intel,-requires-gpu-nvidia,-cuda-only,-oneapi-only,-requires-gpu-sm60,-requires-gpu-sm60-only,-requires-gpu-sm70,-requires-gpu-sm70-only,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm86,-requires-gpu-sm86-only,-requires-gpu-sm89,-requires-gpu-sm89-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-skip_rocprofiler_sdk,-no_oss,-oss_excluded,-oss_serial,gpu --test_tag_filters=-no_gpu,-requires-gpu-intel,-requires-gpu-nvidia,-cuda-only,-oneapi-only,-requires-gpu-sm60,-requires-gpu-sm60-only,-requires-gpu-sm70,-requires-gpu-sm70-only,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm86,-requires-gpu-sm86-only,-requires-gpu-sm89,-requires-gpu-sm89-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-skip_rocprofiler_sdk,-no_oss,-oss_excluded,-oss_serial,gpu --config=warnings --config=rbe_linux_cpu --config=rocm_clang_hermetic --config=rocm_ci_hermetic --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build --nobuild -- //xla/... //build_tools/... @tsl//tsl/...
bazel build --build_tag_filters=-no_gpu,-requires-gpu-intel,-requires-gpu-nvidia,-cuda-only,-oneapi-only,-requires-gpu-sm60,-requires-gpu-sm60-only,-requires-gpu-sm70,-requires-gpu-sm70-only,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm86,-requires-gpu-sm86-only,-requires-gpu-sm89,-requires-gpu-sm89-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-skip_rocprofiler_sdk,-no_oss,-oss_excluded,-oss_serial,gpu --test_tag_filters=-no_gpu,-requires-gpu-intel,-requires-gpu-nvidia,-cuda-only,-oneapi-only,-requires-gpu-sm60,-requires-gpu-sm60-only,-requires-gpu-sm70,-requires-gpu-sm70-only,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm86,-requires-gpu-sm86-only,-requires-gpu-sm89,-requires-gpu-sm89-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-skip_rocprofiler_sdk,-no_oss,-oss_excluded,-oss_serial,gpu --config=warnings --config=rbe_linux_cpu --config=rocm_clang_hermetic --config=rocm_ci_hermetic --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build -- //xla/... //build_tools/... @tsl//tsl/...
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_GPU_HERMETIC_ROCM_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_GPU_L4_16_VCPU_BENCHMARK_PRESUBMIT_GITHUB_ACTIONS
nvidia-smi
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm75-only,requires-gpu-sm60,requires-gpu-sm70,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --config=cuda_libraries_from_stubs --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=7.5 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --nobuild -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm75-only,requires-gpu-sm60,requires-gpu-sm70,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --config=cuda_libraries_from_stubs --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=7.5 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_GPU_L4_16_VCPU_BENCHMARK_PRESUBMIT_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_GPU_L4_16_VCPU_PRESUBMIT_GITHUB_ACTIONS
nvidia-smi
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm75-only,requires-gpu-sm60,requires-gpu-sm70,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=7.5 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --nobuild -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm75-only,requires-gpu-sm60,requires-gpu-sm70,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=7.5 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_GPU_L4_16_VCPU_PRESUBMIT_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_GPU_L4_48_VCPU_BENCHMARK_PRESUBMIT_GITHUB_ACTIONS
nvidia-smi
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm75-only,requires-gpu-sm60,requires-gpu-sm70,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --config=cuda_libraries_from_stubs --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=7.5 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --nobuild -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm75-only,requires-gpu-sm60,requires-gpu-sm70,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --config=cuda_libraries_from_stubs --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=7.5 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_GPU_L4_48_VCPU_BENCHMARK_PRESUBMIT_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_GPU_L4_48_VCPU_PRESUBMIT_GITHUB_ACTIONS
nvidia-smi
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm75-only,requires-gpu-sm60,requires-gpu-sm70,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=7.5 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --nobuild -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm75-only,requires-gpu-sm60,requires-gpu-sm70,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=7.5 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async -- //xla/tools/multihost_hlo_runner:hlo_runner_main_gpu //xla/tools:compute_xspace_stats_main_gpu
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_GPU_L4_48_VCPU_PRESUBMIT_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_GPU_L4_GITHUB_ACTIONS
nvidia-smi
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm75-only,requires-gpu-sm60,requires-gpu-sm70,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=7.5 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --nobuild -- //xla/... //build_tools/... @tsl//tsl/...
bazel test --build_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu --test_tag_filters=-no_oss,requires-gpu-nvidia,-rocm-only,-oneapi-only,gpu,-multi_gpu,requires-gpu-sm75-only,requires-gpu-sm60,requires-gpu-sm70,-requires-gpu-sm80,-requires-gpu-sm80-only,-requires-gpu-sm90,-requires-gpu-sm90-only,-requires-gpu-sm100,-requires-gpu-sm100-only,-requires-gpu-sm103,-requires-gpu-sm103-only,-requires-gpu-sm120,-requires-gpu-sm120-only,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=rbe_linux_cuda_nvcc --config=hermetic_cuda_umd --repo_env=TF_CUDA_COMPUTE_CAPABILITIES=7.5 --run_under=//build_tools/ci:parallel_gpu_execute --//xla/tsl:ci_build --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async -- //xla/... //build_tools/... @tsl//tsl/...
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_GPU_L4_GITHUB_ACTIONS
# BEGIN BuildType.XLA_LINUX_X86_GPU_ONEAPI_GITHUB_ACTIONS
parallel --ungroup --retries 3 --delay 15 --nonall -- bazel build --build_tag_filters=oneapi-only,requires-gpu-intel,-requires-gpu-amd,-requires-gpu-nvidia,-no_oss,-cuda-only,-rocm-only,-no-oneapi,gpu --test_tag_filters=oneapi-only,-requires-gpu-intel,-requires-gpu-amd,-requires-gpu-nvidia,-no_oss,-cuda-only,-rocm-only,-no-oneapi,gpu --config=nonccl --config=rbe_linux_cpu --config=sycl --config=sycl_hermetic --config=icpx_clang --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build --nobuild -- //xla/... //build_tools/... @tsl//tsl/...
bazel build --build_tag_filters=oneapi-only,requires-gpu-intel,-requires-gpu-amd,-requires-gpu-nvidia,-no_oss,-cuda-only,-rocm-only,-no-oneapi,gpu --test_tag_filters=oneapi-only,-requires-gpu-intel,-requires-gpu-amd,-requires-gpu-nvidia,-no_oss,-cuda-only,-rocm-only,-no-oneapi,gpu --config=nonccl --config=rbe_linux_cpu --config=sycl --config=sycl_hermetic --config=icpx_clang --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build -- //xla/... //build_tools/... @tsl//tsl/...
bazel analyze-profile profile.json.gz
# END BuildType.XLA_LINUX_X86_GPU_ONEAPI_GITHUB_ACTIONS
# BEGIN BuildType.XLA_MACOS_ARM64_CPU_KOKORO
df -h
bazel --version
mkdir -p /tmpfs/bazel_output
bazel test --build_tag_filters=-no_oss,-gpu,-no_mac,-mac_excluded,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --test_tag_filters=-no_oss,-gpu,-no_mac,-mac_excluded,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --config=nonccl --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --macos_minimum_os=10.15 --test_tmpdir=/tmpfs/bazel_output --test_size_filters=small,medium --//xla/tsl:ci_build -- //xla/... -//xla/python_api/... -//xla/python/... -//xla/service/gpu/...
bazel analyze-profile profile.json.gz
# END BuildType.XLA_MACOS_ARM64_CPU_KOKORO
# BEGIN BuildType.XLA_MACOS_X86_CPU_KOKORO
sudo wget --no-verbose -O /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.11.0/bazelisk-darwin-amd64
chmod +x /usr/local/bin/bazel
bazel --version
mkdir -p /Volumes/BuildData/bazel_output
bazel test --build_tag_filters=-no_oss,-gpu,-no_mac,-mac_excluded,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --test_tag_filters=-no_oss,-gpu,-no_mac,-mac_excluded,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --config=nonccl --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --macos_minimum_os=10.15 --test_tmpdir=/Volumes/BuildData/bazel_output --//xla/tsl:ci_build -- //xla/... -//xla/python_api/... -//xla/python/... -//xla/service/gpu/...
bazel analyze-profile profile.json.gz
# END BuildType.XLA_MACOS_X86_CPU_KOKORO
# BEGIN BuildType.XLA_WINDOWS_X86_CPU_GITHUB_ACTIONS
bazel --output_user_root=C:/x build --build_tag_filters=-no_windows,-no_oss,-gpu,-tpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --test_tag_filters=-no_windows,-no_oss,-gpu,-tpu,-requires-gpu-nvidia,-requires-gpu-amd,-requires-gpu-intel --config=warnings --config=nonccl --config=rbe_xla_windows_x86_cpu_2022 --color=yes --test_output=errors --verbose_failures --keep_going --nobuild_tests_only --profile=profile.json.gz --flaky_test_attempts=3 --jobs=150 --bes_upload_mode=fully_async --//xla/tsl:ci_build -- //xla/... //build_tools/... @tsl//tsl/... -//xla/tpu/... -//xla/backends/cpu/collectives:gloo_collectives_test -//xla/backends/cpu/collectives:mpi_collectives -//xla/backends/cpu/collectives:mpi_communicator -//xla/python/transfer/... -//xla/backends/profiler/subprocess:subprocess_profiling_session -//xla/backends/profiler/subprocess:subprocess_profiling_session_test -//xla/backends/profiler/subprocess:subprocess_registry -//xla/backends/profiler/subprocess:subprocess_registry_test -//xla/tools/benchmarks/utils:generate_benchmark_matrices_cc -//xla/tools/benchmarks/utils:generate_benchmark_matrices_main -//xla/tools/benchmarks/utils:generate_benchmark_matrices_test -//xla/backends/cpu/runtime/ynnpack:ynn_fusion_thunk -//xla/backends/cpu/runtime/ynnpack:ynn_interop -//xla/backends/cpu/runtime/ynnpack:ynn_threadpool -//xla/backends/gpu/... -//xla/codegen/emitters/tests/... -//xla/service/gpu/... -//xla/codegen/intrinsic/cpp:eigen_unary_test
bazel analyze-profile profile.json.gz
# END BuildType.XLA_WINDOWS_X86_CPU_GITHUB_ACTIONS
+83
View File
@@ -0,0 +1,83 @@
#!/usr/bin/env bash
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
#
# A script to run multiple GPU tests in parallel controlled with an environment
# variable.
#
# Required environment variables:
# TF_GPU_COUNT = Number of GPUs available.
TF_GPU_COUNT=${TF_GPU_COUNT:-4}
TF_TESTS_PER_GPU=${TF_TESTS_PER_GPU:-8}
# This function is used below in rlocation to check that a path is absolute
function is_absolute {
[[ "$1" = /* ]] || [[ "$1" =~ ^[a-zA-Z]:[/\\].* ]]
}
export TF_PER_DEVICE_MEMORY_LIMIT_MB=${TF_PER_DEVICE_MEMORY_LIMIT_MB:-4096}
# *******************************************************************
# This section of the script is needed to
# make things work on windows under msys.
# *******************************************************************
RUNFILES_MANIFEST_FILE="${TEST_SRCDIR}/MANIFEST"
function rlocation() {
if is_absolute "$1" ; then
# If the file path is already fully specified, simply return it.
echo "$1"
elif [[ -e "$TEST_SRCDIR/$1" ]]; then
# If the file exists in the $TEST_SRCDIR then just use it.
echo "$TEST_SRCDIR/$1"
elif [[ -e "$RUNFILES_MANIFEST_FILE" ]]; then
# If a runfiles manifest file exists then use it.
echo "$(grep "^$1 " "$RUNFILES_MANIFEST_FILE" | sed 's/[^ ]* //')"
fi
}
TEST_BINARY="$(rlocation $TEST_WORKSPACE/${1#./})"
shift
# *******************************************************************
mkdir -p /var/lock
# Try to acquire any of the TF_GPU_COUNT * TF_TESTS_PER_GPU
# slots to run a test at.
#
# Prefer to allocate 1 test per GPU over 4 tests on 1 GPU.
# So, we iterate over TF_TESTS_PER_GPU first.
for j in `seq 0 $((TF_TESTS_PER_GPU-1))`; do
for i in `seq 0 $((TF_GPU_COUNT-1))`; do
exec {lock_fd}>/var/lock/gpulock${i}_${j} || exit 1
if flock -n "$lock_fd";
then
(
# This export only works within the brackets, so it is isolated to one
# single command.
export CUDA_VISIBLE_DEVICES=$i
export HIP_VISIBLE_DEVICES=$i
echo "Running test $TEST_BINARY $* on GPU $CUDA_VISIBLE_DEVICES"
"$TEST_BINARY" $@
)
return_code=$?
flock -u "$lock_fd"
exit $return_code
fi
done
done
echo "Cannot find a free GPU to run the test $* on, exiting with failure..."
exit 1
+39
View File
@@ -0,0 +1,39 @@
This folder contains scripts and commands executed by GitHub actions in OpenXLA,
TensorFlow and JAX OSS repos. The GitHub actions replaced
KokoroPresubmit-tensorflow* workflows. They run under
`Copybara_XLA{Presubmit,Submit}` presubmit chip (category) at Google internally.
The tests run on several target OS configurations/GCP containers such as Linux
x86 with GPU or Linux ARM64. They assure that XLA/Tensor Flow/JAX compiles and
runs on those platforms. The tests uses released OSS c++ clang compiler which
has some differences in supporting c++ standards compared Google's internal
version.
#### How it works
Repo specific GitHub actions call `build.py --build="build_name"`. E.g. OpenXLA
uses https://github.com/openxla/xla/blob/main/.github/workflows/ci.yml
The build here is a set of shell script commands executing the test targets or
doing compile only testing. Each GitHub action call translates into compile only
test:
1. dryrun `bazel build --nobuild ... test_targets`
1. actual compile `bazel build ... test_targets`
1. analyse results `bazel analyze-profile ...`
or compile and run test commands:
1. dry run `bazel build --nobuild ... test_targets`
1. actual test `bazel test ... test_targets`
1. analyse results `bazel analyze-profile profile.json.gz`
Checking in changes to `build.py` regenerates `golden_commands.txt` which lets
us see how commands are changing. `golden_commands.txt` are not called as part
of the continuous integration process.
#### When does it run?
The GitHub actions are automatically called as part of Google presubmit. The
GitHub actions are automatically called on GitHub PR commit if the committer is
part of OpenXLA GitHub org. Committer which are not part of OpenXLA org need an
approval from OpenXLA org member to run the actions.
+94
View File
@@ -0,0 +1,94 @@
#!/bin/bash
# Copyright 2026 The OpenXLA Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
set -xe
source "$(dirname "${BASH_SOURCE[0]}")/shell_common.sh"
CLANG_FORMAT_VERSION="${CLANG_FORMAT_VERSION:-17.0.6}"
CLANG_FORMAT_PKG="clang-format==${CLANG_FORMAT_VERSION}"
BUILD_WORKSPACE_DIRECTORY="${BUILD_WORKSPACE_DIRECTORY:-$(pwd)}"
cd "$BUILD_WORKSPACE_DIRECTORY"
if ! command -v uv >/dev/null 2>&1; then
echoerr "uv is required to run the clang-format check."
echoerr "Install uv from https://docs.astral.sh/uv/"
exit 1
fi
FIX=false
while [[ $# -gt 0 ]]; do
case $1 in
--fix)
FIX=true
shift
;;
*)
set +x
echo "Unknown option: $1" >&2
echo "Usage: $0 [--fix]" >&2
exit 1
;;
esac
done
get_merge_base() {
local REFERENCE
local REMOTE="${REMOTE:-$(git remote -v | awk '/openxla\/xla/ { print $1; exit }')}"
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echoerr "This script must be run inside a Git repository."
exit 1
fi
if [ -n "${TARGET_REF}" ]; then
REFERENCE="$TARGET_REF"
else
if [ -z "$REMOTE" ]; then
echoerr "Could not find a git remote pointing to openxla/xla. Please add it as a remote."
echoerr "Example: git remote add upstream https://github.com/openxla/xla.git"
exit 1
fi
REFERENCE="${REMOTE}/main"
fi
MERGE_BASE=$(git merge-base "$REFERENCE" HEAD || true)
if [ -z "$MERGE_BASE" ]; then
echoerr "Could not find a common ancestor with $REFERENCE. Please fetch and rebase on main."
echoerr "Example: git fetch ${REMOTE:-origin} main && git rebase ${REMOTE:-origin}/main"
exit 1
fi
}
get_merge_base
EXTRA_ARGS=(-p1 -style=file)
if [ "$FIX" = true ]; then
EXTRA_ARGS+=(-i)
fi
# Run diff against the merge base.
# -U0: Context of 0 lines (ignore surrounding code)
# clang-format-diff: Checks only lines present in the diff
DIFF=$(git diff -U0 --no-color "$MERGE_BASE" -- '*.cc' '*.h' |
uvx --from "$CLANG_FORMAT_PKG" clang-format-diff.py "${EXTRA_ARGS[@]}")
if [ -n "$DIFF" ]; then
echoerr "Clang-format failed on the following changes:"
echo "$DIFF"
exit 1
fi
+125
View File
@@ -0,0 +1,125 @@
#!/bin/bash
# Copyright 2026 The OpenXLA Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
set -xe
# Get targets from git diff if not specified on the command nline.
get_targets_from_diff() {
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
set +x
echo "Error: This script must be run inside a Git repository." >&2
exit 1
fi
REMOTE=${REMOTE:-$(git remote -v | awk '/openxla\/xla/ { print $1; exit }')}
if [ -z "$REMOTE" ]; then
set +x
echo "Could not find a git remote pointing to openxla/xla. Please add it as a remote." >&2
echo "Example: git remote add upstream https://github.com/openxla/xla.git" >&2
exit 1
fi
TARGET_REF=${TARGET_REF:-${REMOTE}/main}
MERGE_BASE=$(git merge-base "$TARGET_REF" HEAD || true)
if [ -z "$MERGE_BASE" ]; then
set +x
echo "Could not find a common ancestor with $TARGET_REF. Please rebase on $REMOTE main." >&2
echo "Example: git pull --rebase $REMOTE main" >&2
exit 1
fi
CHANGED_FILES=$(git diff --name-only --diff-filter=d "$MERGE_BASE" |
grep -E '\.(cc|h)$' || true)
if [ -z "$CHANGED_FILES" ]; then
set +x
echo "No C++ files changed."
exit 0
fi
PACKAGES=$(echo "$CHANGED_FILES" | while read -r file; do
echo "//$(dirname "$file"):all"
done | sort -u | tr '\n' ' ')
BASE_QUERY="kind('cc_(library|binary|test)', rdeps(set($PACKAGES), set($CHANGED_FILES), 1))"
if [ -n "$TAGS_TO_IGNORE" ]; then
QUERY="(${BASE_QUERY} except attr('tags', '${TAGS_TO_IGNORE}', (${BASE_QUERY})))"
else
QUERY="${BASE_QUERY}"
fi
# Populate global TARGETS variable
# We use readarray to handle multi-line output from bazel cquery
readarray -t TARGETS < <($BAZEL_CMD cquery --output=starlark --starlark:expr="target.label" --config="$CONFIG" "$QUERY")
if [ ${#TARGETS[@]} -eq 0 ]; then
set +x
echo "No relevant targets found for changed files."
exit 0
fi
}
BUILD_WORKSPACE_DIRECTORY=${BUILD_WORKSPACE_DIRECTORY:-$(pwd)}
cd "$BUILD_WORKSPACE_DIRECTORY"
BAZEL_CMD=${BAZEL_CMD:-bazelisk}
CONFIG="clang-tidy-noerrors"
FIX=false
# Explicitly specify targets to run clang-tidy on.
# TODO(sohaibiftikhar): Move the bash orchestration to python.
TARGETS=()
while [[ $# -gt 0 ]]; do
case $1 in
--fix)
FIX=true
shift
;;
--target)
TARGETS+=("$2")
shift 2
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--fix] [--target <target> ...]"
exit 1
;;
esac
done
if [ ${#TARGETS[@]} -eq 0 ]; then
USE_DIFF=true
get_targets_from_diff
else
USE_DIFF=false
fi
# Create temporary files for the patch and BEP
PATCH_FILE=$(mktemp)
BEP_FILE=$(mktemp)
# Ensure cleanup on exit
trap 'rm -f "$PATCH_FILE" "$BEP_FILE"' EXIT
$BAZEL_CMD build --config="$CONFIG" --build_event_json_file="$BEP_FILE" --keep_going \
"${TARGETS[@]}"
EXTRA_ARGS=()
if [ "$FIX" = true ]; then
EXTRA_ARGS+=("--fix")
fi
if [ "$USE_DIFF" = true ]; then
# Generate the patch file for changed lines
git diff "$MERGE_BASE" > "$PATCH_FILE"
EXTRA_ARGS+=("--patch" "$PATCH_FILE")
fi
$BAZEL_CMD run //build_tools/ci:clang_tidy_diff -- \
--repo-root "$BUILD_WORKSPACE_DIRECTORY" \
--bep-file "$BEP_FILE" \
"${EXTRA_ARGS[@]}"
+21
View File
@@ -0,0 +1,21 @@
# Copyright 2026 The OpenXLA Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
echoerr() {
set +x
RED='\033[1;31m'
NOCOLOR='\033[0m'
printf "${RED}ERROR:${NOCOLOR} %s\n" "$*" >&2
}