diff --git a/.ci/docker/common/install_buck.sh b/.ci/docker/common/install_buck.sh index a32f3d16af8..f8b7dcbab45 100755 --- a/.ci/docker/common/install_buck.sh +++ b/.ci/docker/common/install_buck.sh @@ -9,17 +9,23 @@ set -ex install_ubuntu() { apt-get update - apt-get install -y zstd + apt-get install -y zstd python3-certifi + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)" + + # Create a cache directory for buck2 + CACHE_DIR="/tmp/buck2_cache" + mkdir -p "${CACHE_DIR}" - BUCK2=buck2-x86_64-unknown-linux-gnu.zst - wget -q "https://github.com/facebook/buck2/releases/download/${BUCK2_VERSION}/${BUCK2}" - zstd -d "${BUCK2}" -o buck2 + # Run resolve_buck.py to get the buck2 binary + BUCK2_PATH=$(python "${REPO_ROOT}/tools/cmake/resolve_buck.py" --cache_dir "${CACHE_DIR}") - chmod +x buck2 - mv buck2 /usr/bin/ + # Move buck2 to /usr/bin/ + mv "${BUCK2_PATH}" /usr/bin/buck2 + chmod +x /usr/bin/buck2 - rm "${BUCK2}" - # Cleanup package manager + # Cleanup + rm -rf "${CACHE_DIR}" apt-get autoclean && apt-get clean rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* } diff --git a/.ci/scripts/setup-macos.sh b/.ci/scripts/setup-macos.sh index 4b43a730710..d23a11f3885 100755 --- a/.ci/scripts/setup-macos.sh +++ b/.ci/scripts/setup-macos.sh @@ -21,27 +21,25 @@ install_buck() { brew install curl fi + python -m pip install certifi + pushd .ci/docker - # TODO(huydo): This is a one-off copy of buck2 2024-05-15 to unblock Jon and - # re-enable ShipIt. It’s not ideal that upgrading buck2 will require a manual - # update the cached binary on S3 bucket too. Let me figure out if there is a - # way to correctly implement the previous setup of installing a new version of - # buck2 only when it’s needed. AFAIK, the complicated part was that buck2 - # --version doesn't say anything w.r.t its release version, i.e. 2024-05-15. - # See D53878006 for more details. - # - # If you need to upgrade buck2 version on S3, please reach out to Dev Infra - # team for help. - BUCK2_VERSION=$(cat ci_commit_pins/buck2.txt) - BUCK2=buck2-aarch64-apple-darwin-${BUCK2_VERSION}.zst - curl -s "https://ossci-macos.s3.amazonaws.com/${BUCK2}" -o "${BUCK2}" - - zstd -d "${BUCK2}" -o buck2 - - chmod +x buck2 - mv buck2 /opt/homebrew/bin - - rm "${BUCK2}" + + # Use resolve_buck.py to download and install buck2 + # The script handles platform detection and version management + REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" + + # Create a cache directory for buck2 + CACHE_DIR="${HOME}/.cache/buck2" + mkdir -p "${CACHE_DIR}" + + # Run resolve_buck.py to get the buck2 binary + BUCK2_PATH=$(python "${REPO_ROOT}/tools/cmake/resolve_buck.py" --cache_dir "${CACHE_DIR}") + + # Move buck2 to /opt/homebrew/bin + sudo mv "${BUCK2_PATH}" /opt/homebrew/bin/buck2 + sudo chmod +x /opt/homebrew/bin/buck2 + popd # Kill all running buck2 daemon for a fresh start diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 45e03bd36e1..edf77380aa7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -329,6 +329,24 @@ the CI (continuous integration) jobs. If `main` is broken, consider rebasing your PR onto the `viable/strict` branch, which points to the most recent all-green commit. +### BUCK tests +In addition to CMake, we run `buck` tests in our CI pipeline to ensure continued integration with certain customers. We recognize that `buck` is not a widely used build system and may not be installed on your local machine. If you encounter a failure in the `buck` CI and wish to reproduce it locally, follow these steps: + +``` +# Install buck +pip install zstd certifi +BUCK2_PATH=$(python tools/cmake/resolve_buck.py --cache_dir=/tmp/) +mv "${BUCK2_PATH}" ~/buck2 +chmod +x ~/buck2 + +# Build example +~/buck2 build //runtime/platform/... # replace with other targets + +# Test example +~/buck2 test //runtime/platform/... # replace with other targets +``` + +Please refer to the [official buck documentation](https://buck.build/command/build.html).   ## Updating Documentation diff --git a/pyproject.toml b/pyproject.toml index 00cae6de2e7..5484155b270 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,8 +5,6 @@ requires = [ "pyyaml", # Imported by the kernel codegen tools. "setuptools>=63", # For building the pip package contents. "wheel", # For building the pip package archive. - "zstd", # Imported by resolve_buck.py. - "certifi", # Imported by resolve_buck.py. ] build-backend = "setuptools.build_meta" diff --git a/requirements-dev.txt b/requirements-dev.txt index 9df5e7b93ed..a08e0547d2c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,7 +5,5 @@ pip>=23 # For building the pip package. pyyaml # Imported by the kernel codegen tools. setuptools>=63 # For building the pip package contents. wheel # For building the pip package archive. -zstd # Imported by resolve_buck.py. -certifi # Imported by resolve_buck.py. lintrunner==0.12.7 lintrunner-adapters==0.12.6