mirror of https://github.com/mongodb/mongo
SERVER-108655 Use our own architectures for naming the top level folder in release packages (#39602)
Co-authored-by: Daniel Moody <dmoody256@gmail.com> GitOrigin-RevId: d7644705d817516b2db60baca94af29223281a09
This commit is contained in:
parent
0be07af779
commit
a53de12948
6
.bazelrc
6
.bazelrc
|
|
@ -505,9 +505,6 @@ common:fission --remote_download_regex=.*\.dwo$
|
||||||
# Avoid failing builds when BES metadata fails to upload.
|
# Avoid failing builds when BES metadata fails to upload.
|
||||||
common --bes_upload_mode=fully_async
|
common --bes_upload_mode=fully_async
|
||||||
|
|
||||||
# Default Mongo Version if a version is not specified.
|
|
||||||
common --define=MONGO_VERSION=8.2.0-alpha
|
|
||||||
|
|
||||||
# Default distmod if not specified.
|
# Default distmod if not specified.
|
||||||
common --define=MONGO_DISTMOD=""
|
common --define=MONGO_DISTMOD=""
|
||||||
|
|
||||||
|
|
@ -523,6 +520,9 @@ try-import %workspace%/.bazelrc.evergreen
|
||||||
# local default dev settings
|
# local default dev settings
|
||||||
try-import %workspace%/.bazelrc.common_bes
|
try-import %workspace%/.bazelrc.common_bes
|
||||||
|
|
||||||
|
# local default dev settings
|
||||||
|
try-import %workspace%/.bazelrc.mongo_variables
|
||||||
|
|
||||||
# local git version info
|
# local git version info
|
||||||
try-import %workspace%/.bazelrc.git
|
try-import %workspace%/.bazelrc.git
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,8 @@ buildozer
|
||||||
.bazelrc.gitinfo
|
.bazelrc.gitinfo
|
||||||
.bazelrc.workstation
|
.bazelrc.workstation
|
||||||
.bazelrc.common_bes
|
.bazelrc.common_bes
|
||||||
|
.bazelrc.mongo_variables
|
||||||
|
.bazelrc.mongo_version
|
||||||
.bazelrc.compiledb
|
.bazelrc.compiledb
|
||||||
.bazelrc.sync
|
.bazelrc.sync
|
||||||
.compiledb
|
.compiledb
|
||||||
|
|
|
||||||
14
BUILD.bazel
14
BUILD.bazel
|
|
@ -220,13 +220,13 @@ mongo_install(
|
||||||
"//conditions:default": ["//src/mongo/db:mongod"],
|
"//conditions:default": ["//src/mongo/db:mongod"],
|
||||||
}),
|
}),
|
||||||
package_extract_name = select({
|
package_extract_name = select({
|
||||||
"//bazel/config:build_enterprise_linux_enabled": "mongodb-linux-{TARGET_CPU}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
"//bazel/config:build_enterprise_linux_enabled": "mongodb-linux-{MONGO_ARCH}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||||
"//bazel/config:build_enterprise_linux_disabled": "mongodb-linux-{TARGET_CPU}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
"//bazel/config:build_enterprise_linux_disabled": "mongodb-linux-{MONGO_ARCH}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||||
"//bazel/config:build_enterprise_windows_enabled": "mongodb-win32-{TARGET_CPU}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
"//bazel/config:build_enterprise_windows_enabled": "mongodb-win32-{MONGO_ARCH}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||||
"//bazel/config:build_enterprise_windows_disabled": "mongodb-win32-{TARGET_CPU}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
"//bazel/config:build_enterprise_windows_disabled": "mongodb-win32-{MONGO_ARCH}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||||
"//bazel/config:build_enterprise_mac_enabled": "mongodb-macos-{TARGET_CPU}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
"//bazel/config:build_enterprise_mac_enabled": "mongodb-macos-{MONGO_ARCH}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||||
"//bazel/config:build_enterprise_mac_disabled": "mongodb-macos-{TARGET_CPU}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
"//bazel/config:build_enterprise_mac_disabled": "mongodb-macos-{MONGO_ARCH}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||||
"//conditions:default": "mongodb-{TARGET_CPU}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
"//conditions:default": "mongodb-{MONGO_ARCH}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||||
}),
|
}),
|
||||||
publish_debug_in_stripped = select({
|
publish_debug_in_stripped = select({
|
||||||
"@platforms//os:windows": True,
|
"@platforms//os:windows": True,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ py_library(
|
||||||
"install_modules.py",
|
"install_modules.py",
|
||||||
"lint.py",
|
"lint.py",
|
||||||
"plus_interface.py",
|
"plus_interface.py",
|
||||||
|
"set_mongo_variables.py",
|
||||||
"wrapper_debug.py",
|
"wrapper_debug.py",
|
||||||
"wrapper_hook.py",
|
"wrapper_hook.py",
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import sys
|
||||||
REPO_ROOT = pathlib.Path(__file__).parent.parent.parent
|
REPO_ROOT = pathlib.Path(__file__).parent.parent.parent
|
||||||
sys.path.append(str(REPO_ROOT))
|
sys.path.append(str(REPO_ROOT))
|
||||||
|
|
||||||
|
from bazel.wrapper_hook.set_mongo_variables import write_mongo_variables_bazelrc
|
||||||
|
|
||||||
|
|
||||||
def run_pty_command(cmd):
|
def run_pty_command(cmd):
|
||||||
stdout = None
|
stdout = None
|
||||||
|
|
@ -43,6 +45,9 @@ def run_pty_command(cmd):
|
||||||
|
|
||||||
|
|
||||||
def generate_compiledb(bazel_bin, persistent_compdb, enterprise):
|
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:
|
if persistent_compdb:
|
||||||
info_proc = subprocess.run(
|
info_proc = subprocess.run(
|
||||||
[bazel_bin, "info", "output_base"], capture_output=True, text=True
|
[bazel_bin, "info", "output_base"], capture_output=True, text=True
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
import hashlib
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
ARCH_NORMALIZE_MAP = {
|
||||||
|
"amd64": "x86_64",
|
||||||
|
"x86_64": "x86_64",
|
||||||
|
"arm64": "aarch64",
|
||||||
|
"aarch64": "aarch64",
|
||||||
|
"ppc64le": "ppc64le",
|
||||||
|
"s390x": "s390x",
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_mongo_arch(args):
|
||||||
|
arch = platform.machine().lower()
|
||||||
|
if arch in ARCH_NORMALIZE_MAP:
|
||||||
|
return ARCH_NORMALIZE_MAP[arch]
|
||||||
|
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)
|
||||||
|
|
||||||
|
repo_root = pathlib.Path(os.path.abspath(__file__)).parent.parent.parent
|
||||||
|
version_file = os.path.join(repo_root, ".bazelrc.mongo_variables")
|
||||||
|
existing_hash = ""
|
||||||
|
if os.path.exists(version_file):
|
||||||
|
with open(version_file, encoding="utf-8") as f:
|
||||||
|
existing_hash = hashlib.md5(f.read().encode()).hexdigest()
|
||||||
|
|
||||||
|
bazelrc_contents = f"""
|
||||||
|
common --define=MONGO_ARCH={mongo_arch}
|
||||||
|
common --define=MONGO_VERSION={mongo_version}
|
||||||
|
"""
|
||||||
|
current_hash = hashlib.md5(bazelrc_contents.encode()).hexdigest()
|
||||||
|
if existing_hash != current_hash:
|
||||||
|
with open(version_file, "w", encoding="utf-8") as f:
|
||||||
|
f.write(bazelrc_contents)
|
||||||
|
|
@ -22,6 +22,7 @@ def main():
|
||||||
from bazel.wrapper_hook.engflow_check import engflow_auth
|
from bazel.wrapper_hook.engflow_check import engflow_auth
|
||||||
from bazel.wrapper_hook.generate_common_bes_bazelrc import write_workstation_bazelrc
|
from bazel.wrapper_hook.generate_common_bes_bazelrc import write_workstation_bazelrc
|
||||||
from bazel.wrapper_hook.plus_interface import check_bazel_command_type, test_runner_interface
|
from bazel.wrapper_hook.plus_interface import check_bazel_command_type, test_runner_interface
|
||||||
|
from bazel.wrapper_hook.set_mongo_variables import write_mongo_variables_bazelrc
|
||||||
|
|
||||||
# This is used to autogenerate a BUILD.bazel that creates
|
# This is used to autogenerate a BUILD.bazel that creates
|
||||||
# Filegroups for select tags - used to group targets for installing
|
# Filegroups for select tags - used to group targets for installing
|
||||||
|
|
@ -42,6 +43,8 @@ def main():
|
||||||
|
|
||||||
write_workstation_bazelrc(args)
|
write_workstation_bazelrc(args)
|
||||||
|
|
||||||
|
write_mongo_variables_bazelrc(args)
|
||||||
|
|
||||||
args = test_runner_interface(
|
args = test_runner_interface(
|
||||||
sys.argv[1:],
|
sys.argv[1:],
|
||||||
autocomplete_query=os.environ.get("MONGO_AUTOCOMPLETE_QUERY") == "1",
|
autocomplete_query=os.environ.get("MONGO_AUTOCOMPLETE_QUERY") == "1",
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,16 @@ VERSIONS_TO_SKIP: Set[str] = set(
|
||||||
)
|
)
|
||||||
DISABLED_TESTS: Set[Tuple[str, str]] = set()
|
DISABLED_TESTS: Set[Tuple[str, str]] = set()
|
||||||
|
|
||||||
|
VALID_TAR_DIRECTORY_ARCHITECTURES = [
|
||||||
|
"linux-aarch64",
|
||||||
|
"linux-x86_64",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"macos-aarch64",
|
||||||
|
"macos-x86_64",
|
||||||
|
"windows-x86_64",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class Test:
|
class Test:
|
||||||
|
|
@ -523,6 +533,12 @@ def get_edition_alias(edition_name: str) -> str:
|
||||||
return "org"
|
return "org"
|
||||||
return edition_name
|
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}")
|
||||||
|
|
||||||
arches: Set[str] = set()
|
arches: Set[str] = set()
|
||||||
oses: Set[str] = set()
|
oses: Set[str] = set()
|
||||||
|
|
@ -663,6 +679,8 @@ if args.command == "branch":
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
validate_top_level_directory("mongo-binaries.tgz")
|
||||||
|
|
||||||
if not args.skip_enterprise_check:
|
if not args.skip_enterprise_check:
|
||||||
logging.info(
|
logging.info(
|
||||||
"Checking the source files used to build the binaries, use --skip-enterprise-check to skip this check."
|
"Checking the source files used to build the binaries, use --skip-enterprise-check to skip this check."
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue