mirror of https://github.com/mongodb/mongo
SERVER-107602 Move lint poetry lock to bazel run lint (#38999)
GitOrigin-RevId: 8cb267d093a5e92b07e91a6176d39f2deab41c0b
This commit is contained in:
parent
531c9cabf6
commit
0f12f16e00
|
|
@ -202,7 +202,7 @@ def run_rules_lint(bazel_bin: str, args: List[str]) -> bool:
|
|||
return False
|
||||
|
||||
lint_all = "..." in args or "--all" in args or "//..." in args
|
||||
files_to_format = args
|
||||
files_to_lint = args
|
||||
if not lint_all and len([arg for arg in args if not arg.startswith("--")]) == 0:
|
||||
origin_branch = "origin/master"
|
||||
for arg in args:
|
||||
|
|
@ -221,34 +221,33 @@ def run_rules_lint(bazel_bin: str, args: List[str]) -> bool:
|
|||
)
|
||||
lint_all = True
|
||||
else:
|
||||
files_to_format = [
|
||||
files_to_lint = [
|
||||
file
|
||||
for file in _get_files_changed_since_fork_point(origin_branch)
|
||||
if file.endswith((".cpp", ".c", ".h", ".py", ".js", ".mjs", ".json"))
|
||||
if file.endswith((".cpp", ".c", ".h", ".py", ".js", ".mjs", ".json", ".lock", ".toml"))
|
||||
]
|
||||
|
||||
# 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
|
||||
|
||||
if lint_all or "sbom.json" in files_to_format:
|
||||
if lint_all or "sbom.json" in files_to_lint:
|
||||
subprocess.run([bazel_bin, "run", "//buildscripts:sbom_linter"], check=True)
|
||||
|
||||
if lint_all or any(file.endswith(".h") or file.endswith(".cpp") for file in files_to_format):
|
||||
if lint_all or any(file.endswith((".h", ".cpp")) for file in files_to_lint):
|
||||
subprocess.run(
|
||||
[bazel_bin, "run", "//buildscripts:quickmongolint", "--", "lint"], check=True
|
||||
)
|
||||
|
||||
if lint_all or any(
|
||||
file.endswith(".cpp")
|
||||
or file.endswith(".c")
|
||||
or file.endswith(".h")
|
||||
or file.endswith(".py")
|
||||
or file.endswith(".idl")
|
||||
for file in files_to_format
|
||||
file.endswith((".cpp", ".c", ".h", ".py", ".idl"))
|
||||
for file in files_to_lint
|
||||
):
|
||||
subprocess.run([bazel_bin, "run", "//buildscripts:errorcodes", "--", "--quiet"], check=True)
|
||||
|
||||
if lint_all or "poetry.lock" in files_to_lint or "pyproject.toml" in files_to_lint:
|
||||
subprocess.run([bazel_bin, "run", "//buildscripts:poetry_lock_check"], check=True)
|
||||
|
||||
fix = ""
|
||||
with tempfile.NamedTemporaryFile(delete=False) as buildevents:
|
||||
buildevents_path = buildevents.name
|
||||
|
|
|
|||
|
|
@ -270,6 +270,18 @@ py_binary(
|
|||
)],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
name = "poetry_lock_check",
|
||||
srcs = ["poetry_lock_check.py"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
dependency(
|
||||
"poetry",
|
||||
group = "export",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets
|
||||
py_library(
|
||||
name = "all_python_files",
|
||||
|
|
|
|||
|
|
@ -5,17 +5,20 @@ Check to make sure poetry.lock is synced with pyproject.toml.
|
|||
Returns nonzero if poetry.lock and pyproject.toml are not synced
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
POETRY_LOCK_V200 = (
|
||||
"""# This file is automatically @generated by Poetry 2.0.0 and should not be changed by hand."""
|
||||
)
|
||||
|
||||
|
||||
REPO_ROOT = os.environ.get("BUILD_WORKSPACE_DIRECTORY", ".")
|
||||
# This has a great error message as part of the failure case
|
||||
subprocess.run(["poetry", "check", "--lock"], check=True)
|
||||
subprocess.run(["python", "-m", "poetry", "check", "--lock"], check=True, cwd=REPO_ROOT)
|
||||
|
||||
# Check if the poetry lock file was generated with poetry 2.0.0
|
||||
with open("poetry.lock", "r") as poetry_lock:
|
||||
with open(f"{REPO_ROOT}/poetry.lock", "r") as poetry_lock:
|
||||
if POETRY_LOCK_V200 not in poetry_lock.read(len(POETRY_LOCK_V200)):
|
||||
raise Exception("""Poetry lockfile was not generated by poetry 2.0.0.
|
||||
Make sure to have poetry 2.0.0 installed when running poetry lock.
|
||||
|
|
@ -824,36 +824,6 @@ tasks:
|
|||
- "--exclude"
|
||||
- "src/third_party/*"
|
||||
|
||||
# Confirm that the poetry.lock file is up to date with pyproject.toml
|
||||
- name: lint_poetry_lock
|
||||
tags:
|
||||
[
|
||||
"assigned_to_jira_team_devprod_build",
|
||||
"development_critical_single_variant",
|
||||
"lint",
|
||||
]
|
||||
commands:
|
||||
- command: timeout.update
|
||||
params:
|
||||
# 20 mins
|
||||
exec_timeout_secs: 1200
|
||||
- func: "f_expansions_write"
|
||||
- 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"
|
||||
- command: subprocess.exec
|
||||
type: test
|
||||
params:
|
||||
binary: bash
|
||||
args:
|
||||
- "src/evergreen/run_python_script_with_report.sh"
|
||||
- "lint-poetry-lock"
|
||||
- "evergreen/functions/poetry_lock_check.py"
|
||||
|
||||
- name: lint_pyright
|
||||
tags:
|
||||
[
|
||||
|
|
|
|||
Loading…
Reference in New Issue