SERVER-111295 [v8.2] Set python as formatter in format_multirun (#41680)

GitOrigin-RevId: e47fadfd8bfc0835d7d121df0ce2073d43f2e898
This commit is contained in:
Zack Winter 2025-10-07 07:23:10 -07:00 committed by MongoDB Bot
parent 3c713fd09f
commit eb9af3a1da
13 changed files with 40 additions and 35 deletions

1
.gitattributes vendored
View File

@ -6,6 +6,7 @@
external rules-lint-ignored=true
**/*.tpl.h rules-lint-ignored=true
**/*.tpl.cpp rules-lint-ignored=true
rpm/*.spec rules-lint-ignored=true
src/mongo/bson/column/bson_column_compressed_data.inl rules-lint-ignored=true
*.idl linguist-language=yaml

View File

@ -17,11 +17,15 @@ bazel_cache = os.path.expanduser(args.bazel_cache)
# the cc_library and cc_binaries in our build. There is not a good way from
# within the build to get all those targets, so we will generate the list via query
# https://sig-product-docs.synopsys.com/bundle/coverity-docs/page/coverity-analysis/topics/building_with_bazel.html#build_with_bazel
cmd = [
cmd = (
[
bazel_executable,
bazel_cache,
"aquery",
] + bazel_cmd_args + [args.bazel_query]
]
+ bazel_cmd_args
+ [args.bazel_query]
)
print(f"Running command: {cmd}")
proc = subprocess.run(
cmd,
@ -33,9 +37,7 @@ proc = subprocess.run(
print(proc.stderr)
targets = set()
with open('coverity_targets.list', 'w') as f:
with open("coverity_targets.list", "w") as f:
for line in proc.stdout.splitlines():
if line.startswith(" Target: "):
f.write(line.split()[-1] + "\n")

View File

@ -35,6 +35,7 @@ format_multirun(
graphql = "//:prettier",
html = "//:prettier",
markdown = "//:prettier",
python = "@aspect_rules_lint//format:ruff",
shell = "@shfmt//:shfmt",
sql = "//:prettier",
starlark = "@buildifier_prebuilt//:buildifier",

View File

@ -45,7 +45,6 @@ def run_pty_command(cmd):
def generate_compiledb(bazel_bin, persistent_compdb, enterprise):
# compiledb ignores command line args so just make a version rc file in anycase
write_mongo_variables_bazelrc([])
if persistent_compdb:

View File

@ -13,6 +13,7 @@ ARCH_NORMALIZE_MAP = {
"s390x": "s390x",
}
def get_mongo_arch(args):
arch = platform.machine().lower()
if arch in ARCH_NORMALIZE_MAP:
@ -20,10 +21,12 @@ def get_mongo_arch(args):
else:
return arch
def get_mongo_version(args):
proc = subprocess.run(["git", "describe", "--abbrev=0"], capture_output=True, text=True)
return proc.stdout.strip()[1:]
def write_mongo_variables_bazelrc(args):
mongo_version = get_mongo_version(args)
mongo_arch = get_mongo_arch(args)

View File

@ -105,6 +105,7 @@ def validate_help(exe_path):
print(f"Error while calling help for {exe_path}: {e}")
sys.exit(1)
# Make sure we have a proper git version in the windows release
def validate_version(exe_path):
try:
@ -124,6 +125,7 @@ def validate_version(exe_path):
print(f"Error while calling version for {exe_path}: {e}")
sys.exit(1)
def main():
if len(sys.argv) != 2:
print("Usage: python msi_validation.py <path_to_msi>")

View File

@ -533,12 +533,16 @@ def get_edition_alias(edition_name: str) -> str:
return "org"
return edition_name
def validate_top_level_directory(tar_name: str):
command = f"tar -tf {tar_name} | head -n 1 | awk -F/ '{{print $1}}'"
proc = subprocess.run(command, capture_output=True, shell=True, text=True)
top_level_directory = proc.stdout.strip()
if all(os_arch not in top_level_directory for os_arch in VALID_TAR_DIRECTORY_ARCHITECTURES):
raise Exception(f"Found an unexpected os-arch pairing as the top level directory. Top level directory: {top_level_directory}")
raise Exception(
f"Found an unexpected os-arch pairing as the top level directory. Top level directory: {top_level_directory}"
)
arches: Set[str] = set()
oses: Set[str] = set()

View File

@ -50,6 +50,7 @@ DISTROS = ["suse", "debian", "redhat", "ubuntu", "amazon", "amazon2", "amazon202
unexpected_lts_release_series = ("8.2",)
def get_suffix(version, stable_name: str, unstable_name: str) -> str:
parts = version.split(".")
@ -59,11 +60,12 @@ def get_suffix(version, stable_name: str, unstable_name: str) -> str:
series = f"{major}.{minor}"
if major >= 5:
is_stable_version = (minor == 0 or series in unexpected_lts_release_series)
is_stable_version = minor == 0 or series in unexpected_lts_release_series
return stable_name if is_stable_version else unstable_name
else:
return stable_name if minor % 2 == 0 else unstable_name
class Spec(object):
"""Spec class."""

View File

@ -23,6 +23,7 @@ def read_sha_file(filename):
content = f.read()
return content.strip().split()[0]
def _fetch_remote_sha256_hash(s3_path: str):
downloaded = False
result = None
@ -63,6 +64,7 @@ def _verify_s3_hash(s3_path: str, local_path: str, expected_hash: str) -> None:
f"Hash mismatch for {s3_path}, expected {expected_hash} but got {hash_string}"
)
def validate_file(s3_path, output_path, remote_sha_allowed):
hexdigest = S3_SHA256_HASHES.get(s3_path)
if hexdigest:
@ -155,8 +157,6 @@ def download_s3_binary(
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Download and verify S3 binary.")
parser.add_argument("s3_path", help="S3 URL to download from")
parser.add_argument("local_path", nargs="?", help="Optional output file path")

View File

@ -12,6 +12,7 @@ def compute_sha256(file_path: str) -> str:
sha256.update(block)
return sha256.hexdigest()
def write_sha256_file(file_path: str, hash_value: str):
sha256_path = file_path + ".sha256"
file_name = os.path.basename(file_path)
@ -19,6 +20,7 @@ def write_sha256_file(file_path: str, hash_value: str):
f.write(f"{hash_value} {file_name}\n")
print(f"Wrote SHA-256 to {sha256_path}")
def main():
if len(sys.argv) != 2:
print("Usage: sha256sum.py <file>")
@ -32,5 +34,6 @@ def main():
hash_value = compute_sha256(file_path)
write_sha256_file(file_path, hash_value)
if __name__ == "__main__":
main()

View File

@ -60,21 +60,9 @@ class TestPackager(TestCase):
want: str
cases = [
Case(
name="Old unstable",
version="4.3.0",
want="-org-unstable"
),
Case(
name="Old stable 4.2",
version="4.2.0",
want="-org"
),
Case(
name="Old stable 4.4",
version="4.4.0",
want="-org"
),
Case(name="Old unstable", version="4.3.0", want="-org-unstable"),
Case(name="Old stable 4.2", version="4.2.0", want="-org"),
Case(name="Old stable 4.4", version="4.4.0", want="-org"),
Case(
name="New stable standard",
version="8.0.0",

View File

@ -13,8 +13,8 @@ def url_exists(url, timeout=5):
except requests.RequestException:
return False
if __name__ == "__main__":
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Download and verify S3 binary.")
parser.add_argument("s3_path", help="S3 URL to download from")
parser.add_argument("local_path", nargs="?", help="Optional output file path")