Skip to content

Commit

Permalink
speedup github CI a lot
Browse files Browse the repository at this point in the history
Default to Debug build on github CI

Adds a --build-type option so one can force RelWithDebInfo or Debug explicity

Also default cargo to shallow clones

Before: 2h 42m for github actions eden linux build

After: ??

Test plan:

test locally with: `./build/fbcode_builder/getdeps.py --allow-system-packages build --src-dir=. --build-type=Debug --project-install-prefix eden:/usr/local eden`

CI
  • Loading branch information
ahornby committed Oct 14, 2023
1 parent 53d570d commit 6411536
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 11 deletions.
22 changes: 20 additions & 2 deletions build/fbcode_builder/getdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,13 @@ def setup_project_cmd_parser(self, parser):
action="store_true",
default=False,
)
parser.add_argument(
"--build-type",
help="Set the build type explicitly. Cmake and cargo builders act on them. Only Debug and RelWithDebInfo widely supported.",
choices=["Debug", "Release", "RelWithDebInfo", "MinSizeRel"],
action="store",
default=None,
)


@cmd("fixup-dyn-deps", "Adjusts dynamic dependencies for packaging purposes")
Expand Down Expand Up @@ -1031,6 +1038,10 @@ def write_job_for_platform(self, platform, args): # noqa: C901

out.write(" - uses: actions/checkout@v4\n")

build_type_arg=""
if args.build_type:
build_type_arg = f"--build-type {args.build_type} "

if build_opts.free_up_disk:
free_up_disk = "--free-up-disk "
if not build_opts.is_windows():
Expand Down Expand Up @@ -1111,7 +1122,7 @@ def write_job_for_platform(self, platform, args): # noqa: C901
has_same_repo_dep = True
out.write(" - name: Build %s\n" % m.name)
out.write(
f" run: {getdepscmd}{allow_sys_arg} build {src_dir_arg}{free_up_disk}--no-tests {m.name}\n"
f" run: {getdepscmd}{allow_sys_arg} build {build_type_arg}{src_dir_arg}{free_up_disk}--no-tests {m.name}\n"
)

out.write(" - name: Build %s\n" % manifest.name)
Expand All @@ -1132,7 +1143,7 @@ def write_job_for_platform(self, platform, args): # noqa: C901
no_tests_arg = "--no-tests "

out.write(
f" run: {getdepscmd}{allow_sys_arg} build {no_tests_arg}{no_deps_arg}--src-dir=. {manifest.name} {project_prefix}\n"
f" run: {getdepscmd}{allow_sys_arg} build {build_type_arg}{no_tests_arg}{no_deps_arg}--src-dir=. {manifest.name} {project_prefix}\n"
)

out.write(" - name: Copy artifacts\n")
Expand Down Expand Up @@ -1218,6 +1229,13 @@ def setup_project_cmd_parser(self, parser):
action="store_true",
default=False,
)
parser.add_argument(
"--build-type",
help="Set the build type explicitly. Cmake and cargo builders act on them. Only Debug and RelWithDebInfo widely supported.",
choices=["Debug", "Release", "RelWithDebInfo", "MinSizeRel"],
action="store",
default=None,
)


def get_arg_var_name(args):
Expand Down
10 changes: 6 additions & 4 deletions build/fbcode_builder/getdeps/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def main():
"--target",
target,
"--config",
"Release",
{build_type},
get_jobs_argument(args.num_jobs),
] + args.cmake_args
elif args.mode == "test":
Expand Down Expand Up @@ -610,8 +610,9 @@ def _compute_cmake_define_args(self, env):
# unspecified. Some of the deps fail to compile in release mode
# due to warning->error promotion. RelWithDebInfo is the happy
# medium.
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_BUILD_TYPE": self.build_opts.build_type
}

if "SANDCASTLE" not in os.environ:
# We sometimes see intermittent ccache related breakages on some
# of the FB internal CI hosts, so we prefer to disable ccache
Expand Down Expand Up @@ -708,6 +709,7 @@ def _build(self, install_dirs, reconfigure: bool) -> None:
build_dir=self.build_dir,
install_dir=self.inst_dir,
sys=sys,
build_type=self.build_opts.build_type,
)

self._invalidate_cache()
Expand All @@ -721,7 +723,7 @@ def _build(self, install_dirs, reconfigure: bool) -> None:
"--target",
self.cmake_target,
"--config",
"Release",
self.build_opts.build_type,
"-j",
str(self.num_jobs),
],
Expand Down Expand Up @@ -1194,7 +1196,7 @@ def _build(self, install_dirs, reconfigure) -> None:
"--target",
"install",
"--config",
"Release",
self.build_opts.build_type,
"-j",
str(self.num_jobs),
],
Expand Down
12 changes: 12 additions & 0 deletions build/fbcode_builder/getdeps/buildopts.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(
shared_libs: bool = False,
facebook_internal=None,
free_up_disk: bool = False,
build_type: str = None,
) -> None:
"""fbcode_builder_dir - the path to either the in-fbsource fbcode_builder dir,
or for shipit-transformed repos, the build dir that
Expand All @@ -67,6 +68,7 @@ def __init__(
vcvars_path - Path to external VS toolchain's vsvarsall.bat
shared_libs - whether to build shared libraries
free_up_disk - take extra actions to save runner disk space
build_type - CMAKE_BUILD_TYPE, used by cmake and cargo builders
"""

if not install_dir:
Expand Down Expand Up @@ -107,6 +109,15 @@ def __init__(
self.shared_libs = shared_libs
self.free_up_disk = free_up_disk

if build_type is None:
if "GITHUB_ACTIONS" in os.environ:
# speed up CI by default
build_type = "Debug"
else:
build_type = "RelWithDebInfo"

self.build_type = build_type

lib_path = None
if self.is_darwin():
lib_path = "DYLD_LIBRARY_PATH"
Expand Down Expand Up @@ -606,6 +617,7 @@ def setup_build_options(args, host_type=None) -> BuildOptions:
"lfs_path",
"shared_libs",
"free_up_disk",
"build_type",
}
}

Expand Down
19 changes: 14 additions & 5 deletions build/fbcode_builder/getdeps/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,30 @@ def _prepare(self, install_dirs, reconfigure) -> None:
def _build(self, install_dirs, reconfigure) -> None:
# _prepare has been run already. Actually do the build
build_source_dir = self.build_source_dir()

build_args = [
"--out-dir",
os.path.join(self.inst_dir, "bin"),
"-Zunstable-options",
"-Zgitoxide=fetch,shallow-deps",
]

if self.build_opts.build_type != "Debug":
build_args.append("--release")

if self.manifests_to_build is None:
self.run_cargo(
install_dirs,
"build",
["--out-dir", os.path.join(self.inst_dir, "bin"), "-Zunstable-options"],
build_args,
)
else:
for manifest in self.manifests_to_build:
self.run_cargo(
install_dirs,
"build",
[
"--out-dir",
os.path.join(self.inst_dir, "bin"),
"-Zunstable-options",
build_args
+ [
"--manifest-path",
self.manifest_dir(manifest),
],
Expand Down
1 change: 1 addition & 0 deletions build/fbcode_builder/manifests/rocksdb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ snappy

[build]
builder = cmake
job_weight_mib = 512
subdir = rocksdb-8.6.7

[cmake.defines]
Expand Down

0 comments on commit 6411536

Please sign in to comment.