Skip to content

Commit

Permalink
fix github disk full by cleaning intermediate build steps
Browse files Browse the repository at this point in the history
Local build was fixed in previous change but disk space usage is too large for github actions runner so I see build fail on sapling PRs.   Fix it by cleaning up intermediate state.

Test Plan:

Build locally, raise  PR to check github actions

```
  • Loading branch information
ahornby committed Jul 12, 2023
1 parent 1686dc0 commit eb240d2
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 45 deletions.
88 changes: 44 additions & 44 deletions .github/workflows/edenfs_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,93 +110,93 @@ jobs:
- name: Fetch edencommon
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests edencommon
- name: Build ninja
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests ninja
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests ninja
- name: Build cmake
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests cmake
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests cmake
- name: Build blake3
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests blake3
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests blake3
- name: Build cpptoml
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests cpptoml
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests cpptoml
- name: Build gflags
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests gflags
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests gflags
- name: Build glog
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests glog
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests glog
- name: Build fmt
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests fmt
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests fmt
- name: Build googletest
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests googletest
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests googletest
- name: Build python-six
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests python-six
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests python-six
- name: Build zstd
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests zstd
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests zstd
- name: Build boost
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests boost
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests boost
- name: Build double-conversion
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests double-conversion
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests double-conversion
- name: Build libevent
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests libevent
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests libevent
- name: Build lz4
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests lz4
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests lz4
- name: Build snappy
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests snappy
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests snappy
- name: Build libgit2
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests libgit2
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests libgit2
- name: Build python-ptyprocess
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests python-ptyprocess
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests python-ptyprocess
- name: Build pexpect
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests pexpect
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests pexpect
- name: Build bz2
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests bz2
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests bz2
- name: Build python-filelock
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests python-filelock
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests python-filelock
- name: Build python-toml
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests python-toml
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests python-toml
- name: Build re2
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests re2
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests re2
- name: Build rocksdb
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests rocksdb
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests rocksdb
- name: Build sqlite3
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests sqlite3
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests sqlite3
- name: Build zlib
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests zlib
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests zlib
- name: Build autoconf
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests autoconf
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests autoconf
- name: Build automake
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests automake
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests automake
- name: Build libtool
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests libtool
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests libtool
- name: Build nghttp2
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests nghttp2
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests nghttp2
- name: Build libcurl
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests libcurl
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests libcurl
- name: Build libsodium
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests libsodium
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests libsodium
- name: Build xz
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests xz
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests xz
- name: Build folly
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests folly
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests folly
- name: Build fizz
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests fizz
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests fizz
- name: Build mvfst
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests mvfst
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests mvfst
- name: Build libffi
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests libffi
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests libffi
- name: Build ncurses
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests ncurses
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests ncurses
- name: Build python
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests python
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests python
- name: Build wangle
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests wangle
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests wangle
- name: Build fbthrift
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests fbthrift
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests fbthrift
- name: Build fb303
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests fb303
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests fb303
- name: Build rust-shed
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests rust-shed
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests rust-shed
- name: Build sapling
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests sapling
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests sapling
- name: Build edencommon
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --no-tests edencommon
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --clean-intermediate --no-tests edencommon
- name: Build eden
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --src-dir=. eden --project-install-prefix eden:/usr/local
- name: Copy artifacts
Expand Down
23 changes: 22 additions & 1 deletion build/fbcode_builder/getdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,12 @@ def setup_project_cmd_parser(self, parser):
action="store_true",
default=False,
)
parser.add_argument(
"--clean-intermediate",
help="Clean up intermediate files if possible to reduce disk usage",
action="store_true",
default=False,
)


@cmd("fixup-dyn-deps", "Adjusts dynamic dependencies for packaging purposes")
Expand Down Expand Up @@ -1052,6 +1058,15 @@ def write_job_for_platform(self, platform, args): # noqa: C901
f" run: {getdepscmd}{allow_sys_arg} fetch --no-tests {m.name}\n"
)

if build_opts.clean_intermediate:
# Strip debug info from the binaries, but only on linux.
# While the `strip` utility is also available on macOS,
# attempting to strip there results in an error.
# The `strip` utility is not available on Windows.
clean_intermediate = "--clean-intermediate "
else:
clean_intermediate = ""

for m in projects:
if m != manifest:
if m.name == "rust":
Expand All @@ -1065,7 +1080,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}--no-tests {m.name}\n"
f" run: {getdepscmd}{allow_sys_arg} build {src_dir_arg}{clean_intermediate}--no-tests {m.name}\n"
)

out.write(" - name: Build %s\n" % manifest.name)
Expand Down Expand Up @@ -1155,6 +1170,12 @@ def setup_project_cmd_parser(self, parser):
help="add a prefix to all job names",
default=None,
)
parser.add_argument(
"--clean-intermediate",
help="Clean up intermediate files if possible to reduce disk usage",
action="store_true",
default=False,
)


def get_arg_var_name(args):
Expand Down
5 changes: 5 additions & 0 deletions build/fbcode_builder/getdeps/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ def build(self, install_dirs, reconfigure: bool) -> None:
self._prepare(install_dirs=install_dirs, reconfigure=reconfigure)
self._build(install_dirs=install_dirs, reconfigure=reconfigure)

if self.build_opts.clean_intermediate:
# don't clean --src-dir=. case as user may want to build again or run tests on the build
if self.src_dir.startswith(self.build_opts.scratch_dir) and os.path.isdir(self.build_dir):
shutil.rmtree(self.build_dir)

# On Windows, emit a wrapper script that can be used to run build artifacts
# directly from the build directory, without installing them. On Windows $PATH
# needs to be updated to include all of the directories containing the runtime
Expand Down
4 changes: 4 additions & 0 deletions build/fbcode_builder/getdeps/buildopts.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(
lfs_path=None,
shared_libs: bool = False,
facebook_internal=None,
clean_intermediate: bool = False,
) -> 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 @@ -65,6 +66,7 @@ def __init__(
use_shipit - use real shipit instead of the simple shipit transformer
vcvars_path - Path to external VS toolchain's vsvarsall.bat
shared_libs - whether to build shared libraries
clean_intermediate - whether to clean up intermediate build files to save runner disk space
"""

if not install_dir:
Expand Down Expand Up @@ -103,6 +105,7 @@ def __init__(
self.allow_system_packages = allow_system_packages
self.lfs_path = lfs_path
self.shared_libs = shared_libs
self.clean_intermediate = clean_intermediate

lib_path = None
if self.is_darwin():
Expand Down Expand Up @@ -602,6 +605,7 @@ def setup_build_options(args, host_type=None) -> BuildOptions:
"allow_system_packages",
"lfs_path",
"shared_libs",
"clean_intermediate"
}
}

Expand Down

0 comments on commit eb240d2

Please sign in to comment.