mirror of https://github.com/mongodb/mongo
SERVER-108478 Move lint_large_files_check to bazel run lint (#39413)
GitOrigin-RevId: e6ff6a58c1b1fe83644e859bdfb4e240c6528112
This commit is contained in:
parent
ec20d12864
commit
caa07aac4e
|
|
@ -10,6 +10,7 @@ from typing import List
|
|||
REPO_ROOT = pathlib.Path(__file__).parent.parent.parent
|
||||
sys.path.append(str(REPO_ROOT))
|
||||
|
||||
LARGE_FILE_THRESHOLD = 10 * 1024 * 1024 #10MiB
|
||||
|
||||
def create_build_files_in_new_js_dirs() -> None:
|
||||
base_dirs = ["src/mongo/db/modules/enterprise/jstests", "jstests"]
|
||||
|
|
@ -207,7 +208,7 @@ def get_parsed_args(args):
|
|||
)
|
||||
parser.add_argument(
|
||||
"--fail-on-validation",
|
||||
type=bool,
|
||||
action="store_true",
|
||||
default=False,
|
||||
)
|
||||
parser.add_argument(
|
||||
|
|
@ -216,6 +217,11 @@ def get_parsed_args(args):
|
|||
default="origin/master",
|
||||
help="Base branch to compare changes against",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--large-files",
|
||||
action="store_true",
|
||||
default=False
|
||||
)
|
||||
return parser.parse_known_args(args)
|
||||
|
||||
def run_rules_lint(bazel_bin: str, args: List[str]) -> bool:
|
||||
|
|
@ -282,6 +288,15 @@ def run_rules_lint(bazel_bin: str, args: List[str]) -> bool:
|
|||
if lint_all or any(file.endswith(".yml") for file in files_to_lint):
|
||||
subprocess.run([bazel_bin, "run", "//buildscripts:validate_evg_project_config", "--", f"--evg-project-name={parsed_args.lint_yaml_project}", "--evg-auth-config=.evergreen.yml"], check=True)
|
||||
|
||||
if lint_all or parsed_args.large_files:
|
||||
subprocess.run([bazel_bin, "run", "//buildscripts:large_file_check", "--", "--exclude", "src/third_party/*"], check=True)
|
||||
else:
|
||||
# simple check
|
||||
for file in files_to_lint:
|
||||
if os.path.getsize(file) > LARGE_FILE_THRESHOLD:
|
||||
print(f"File {file} exceeds large file threshold of {LARGE_FILE_THRESHOLD}")
|
||||
return False
|
||||
|
||||
# Default to linting everything in rules_lint if no path was passed in.
|
||||
if len([arg for arg in args if not arg.startswith("--")]) == 0:
|
||||
args = ["//..."] + args
|
||||
|
|
|
|||
|
|
@ -306,6 +306,23 @@ py_binary(
|
|||
],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
name = "large_file_check",
|
||||
srcs = ["large_file_check.py"],
|
||||
deps = [
|
||||
"//buildscripts/linter",
|
||||
"//buildscripts/patch_builds",
|
||||
dependency(
|
||||
"structlog",
|
||||
group = "evergreen",
|
||||
),
|
||||
dependency(
|
||||
"gitpython",
|
||||
group = "evergreen",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets
|
||||
py_library(
|
||||
name = "all_python_files",
|
||||
|
|
|
|||
|
|
@ -57,7 +57,11 @@ MONGO_REVISION_ENV_VAR = "REVISION"
|
|||
def _get_repos_and_revisions() -> Tuple[List[Repo], RevisionMap]:
|
||||
"""Get the repo object and a map of revisions to compare against."""
|
||||
|
||||
repos = [Repo(git.get_base_dir())]
|
||||
repo_dir = os.environ.get("BUILD_WORKSPACE_DIRECTORY", None)
|
||||
if repo_dir:
|
||||
repos = [Repo(repo_dir)]
|
||||
else:
|
||||
repos = [Repo(git.get_base_dir())]
|
||||
|
||||
revision_map = generate_revision_map(repos, {"mongo": os.environ.get(MONGO_REVISION_ENV_VAR)})
|
||||
return repos, revision_map
|
||||
|
|
|
|||
|
|
@ -734,7 +734,7 @@ tasks:
|
|||
- func: "bazel run"
|
||||
vars:
|
||||
target: >-
|
||||
lint //... --lint-yaml=${project}
|
||||
lint //... --lint-yaml=${project} --large-files
|
||||
|
||||
# Check that the mutational fuzzer can parse all JS filess.
|
||||
- name: lint_fuzzer_sanity_all
|
||||
|
|
@ -767,33 +767,6 @@ tasks:
|
|||
- func: "setup jstestfuzz"
|
||||
- func: "lint fuzzer sanity patch"
|
||||
|
||||
- name: lint_large_files_check
|
||||
tags:
|
||||
[
|
||||
"assigned_to_jira_team_devprod_build",
|
||||
"development_critical_single_variant",
|
||||
]
|
||||
exec_timeout_secs: 600 # 10 minute timeout
|
||||
commands:
|
||||
- command: manifest.load
|
||||
- func: "git get project and add git tag"
|
||||
- func: "f_expansions_write"
|
||||
- func: "kill processes"
|
||||
- func: "cleanup environment"
|
||||
- func: "set up venv"
|
||||
- func: "upload pip requirements"
|
||||
- func: "configure evergreen api credentials"
|
||||
- command: subprocess.exec
|
||||
type: test
|
||||
params:
|
||||
binary: bash
|
||||
args:
|
||||
- "./src/evergreen/run_python_script_with_report.sh"
|
||||
- "lint-large-files-check"
|
||||
- "buildscripts/large_file_check.py"
|
||||
- "--exclude"
|
||||
- "src/third_party/*"
|
||||
|
||||
- name: lint_pyright
|
||||
tags:
|
||||
[
|
||||
|
|
|
|||
Loading…
Reference in New Issue