Skip to content

Commit 22d42e9

Browse files
committed
Documentation on reproducing BUCK CI failures
1 parent 95888a4 commit 22d42e9

File tree

5 files changed

+45
-42
lines changed

5 files changed

+45
-42
lines changed

.ci/docker/common/install_buck.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,23 @@
88
set -ex
99

1010
install_ubuntu() {
11-
apt-get update
12-
apt-get install -y zstd
11+
pip install zstd certifi
12+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13+
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
14+
15+
# Create a cache directory for buck2
16+
CACHE_DIR="/tmp/buck2_cache"
17+
mkdir -p "${CACHE_DIR}"
1318

14-
BUCK2=buck2-x86_64-unknown-linux-gnu.zst
15-
wget -q "https://github.com/facebook/buck2/releases/download/${BUCK2_VERSION}/${BUCK2}"
16-
zstd -d "${BUCK2}" -o buck2
19+
# Run resolve_buck.py to get the buck2 binary
20+
BUCK2_PATH=$(python "${REPO_ROOT}/tools/cmake/resolve_buck.py" --cache_dir "${CACHE_DIR}")
1721

18-
chmod +x buck2
19-
mv buck2 /usr/bin/
22+
# Move buck2 to /usr/bin/
23+
mv "${BUCK2_PATH}" /usr/bin/buck2
24+
chmod +x /usr/bin/buck2
2025

21-
rm "${BUCK2}"
22-
# Cleanup package manager
26+
# Cleanup
27+
rm -rf "${CACHE_DIR}"
2328
apt-get autoclean && apt-get clean
2429
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2530
}

.ci/scripts/setup-macos.sh

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,21 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1313
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
1414

1515
install_buck() {
16-
if ! command -v zstd &> /dev/null; then
17-
brew install zstd
18-
fi
16+
pip install zstd certifi
17+
# Use resolve_buck.py to download and install buck2
18+
# The script handles platform detection and version management
19+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
1920

20-
if ! command -v curl &> /dev/null; then
21-
brew install curl
22-
fi
21+
# Create a cache directory for buck2
22+
CACHE_DIR="${HOME}/.cache/buck2"
23+
mkdir -p "${CACHE_DIR}"
24+
25+
# Run resolve_buck.py to get the buck2 binary
26+
BUCK2_PATH=$(python "${REPO_ROOT}/tools/cmake/resolve_buck.py" --cache_dir "${CACHE_DIR}")
2327

24-
pushd .ci/docker
25-
# TODO(huydo): This is a one-off copy of buck2 2024-05-15 to unblock Jon and
26-
# re-enable ShipIt. It’s not ideal that upgrading buck2 will require a manual
27-
# update the cached binary on S3 bucket too. Let me figure out if there is a
28-
# way to correctly implement the previous setup of installing a new version of
29-
# buck2 only when it’s needed. AFAIK, the complicated part was that buck2
30-
# --version doesn't say anything w.r.t its release version, i.e. 2024-05-15.
31-
# See D53878006 for more details.
32-
#
33-
# If you need to upgrade buck2 version on S3, please reach out to Dev Infra
34-
# team for help.
35-
BUCK2_VERSION=$(cat ci_commit_pins/buck2.txt)
36-
BUCK2=buck2-aarch64-apple-darwin-${BUCK2_VERSION}.zst
37-
curl -s "https://ossci-macos.s3.amazonaws.com/${BUCK2}" -o "${BUCK2}"
38-
39-
zstd -d "${BUCK2}" -o buck2
40-
41-
chmod +x buck2
42-
mv buck2 /opt/homebrew/bin
43-
44-
rm "${BUCK2}"
45-
popd
28+
# Move buck2 to /opt/homebrew/bin
29+
sudo mv "${BUCK2_PATH}" /opt/homebrew/bin/buck2
30+
sudo chmod +x /opt/homebrew/bin/buck2
4631

4732
# Kill all running buck2 daemon for a fresh start
4833
buck2 killall || true
@@ -114,8 +99,8 @@ setup_macos_env_variables() {
11499
setup_macos_env_variables
115100
# NB: we need buck2 in all cases because cmake build also depends on calling
116101
# buck2 atm
117-
install_buck
118102
brew install libomp
103+
install_buck
119104
install_pip_dependencies
120105

121106
# TODO(huydhn): Unlike our self-hosted runner, GitHub runner doesn't have access

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,23 @@ the CI (continuous integration) jobs. If `main` is broken, consider rebasing
329329
your PR onto the `viable/strict` branch, which points to the most recent
330330
all-green commit.
331331

332+
### BUCK tests
333+
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:
334+
335+
```
336+
# Install buck
337+
BUCK2_PATH=$(python tools/cmake/resolve_buck.py --cache_dir=/tmp/)
338+
mv "${BUCK2_PATH}" ~/buck2
339+
chmod +x ~/buck2
340+
341+
# Build example
342+
~/buck2 build //runtime/platform/... # replace with other targets
343+
344+
# Test example
345+
~/buck2 test //runtime/platform/... # replace with other targets
346+
```
347+
348+
Please refer to the [official buck documentation](https://buck.build/command/build.html).
332349
&nbsp;
333350

334351
## Updating Documentation

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ requires = [
55
"pyyaml", # Imported by the kernel codegen tools.
66
"setuptools>=63", # For building the pip package contents.
77
"wheel", # For building the pip package archive.
8-
"zstd", # Imported by resolve_buck.py.
9-
"certifi", # Imported by resolve_buck.py.
108
]
119
build-backend = "setuptools.build_meta"
1210

requirements-dev.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ pip>=23 # For building the pip package.
55
pyyaml # Imported by the kernel codegen tools.
66
setuptools>=63 # For building the pip package contents.
77
wheel # For building the pip package archive.
8-
zstd # Imported by resolve_buck.py.
9-
certifi # Imported by resolve_buck.py.
108
lintrunner==0.12.7
119
lintrunner-adapters==0.12.6

0 commit comments

Comments
 (0)