diff --git a/ci/ci.sh b/ci/ci.sh index bd9f7ab3f914..f8f0346d54d2 100755 --- a/ci/ci.sh +++ b/ci/ci.sh @@ -331,16 +331,6 @@ check_sphinx_links() { ) } -install_go() { - local gimme_url="https://raw.githubusercontent.com/travis-ci/gimme/master/gimme" - suppress_xtrace eval "$(curl -f -s -L "${gimme_url}" | GIMME_GO_VERSION=1.18.3 bash)" - - if [ -z "${GOPATH-}" ]; then - GOPATH="${GOPATH:-${HOME}/go_dir}" - export GOPATH - fi -} - _bazel_build_before_install() { local target if [ "${OSTYPE}" = msys ]; then @@ -535,17 +525,22 @@ lint_annotations() { } lint_bazel() { - # Run buildifier without affecting external environment variables - ( - mkdir -p -- "${GOPATH}" - export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}" + if [[ ! "${OSTYPE}" =~ ^linux ]]; then + echo "Bazel lint not supported on non-linux systems." + exit 1 + fi + if [[ "$(uname -m)" != "x86_64" ]]; then + echo "Bazel lint only supported on x86_64." + exit 1 + fi - # Build buildifier - go install github.com/bazelbuild/buildtools/buildifier@latest + LINT_BAZEL_TMP="$(mktemp -d)" + curl -sl "https://github.com/bazelbuild/buildtools/releases/download/v6.1.2/buildifier-linux-amd64" \ + -o "${LINT_BAZEL_TMP}/buildifier" + chmod +x "${LINT_BAZEL_TMP}/buildifier" + BUILDIFIER="${LINT_BAZEL_TMP}/buildifier" "${ROOT_DIR}/lint/bazel-format.sh" - # Now run buildifier - "${ROOT_DIR}"/lint/bazel-format.sh - ) + rm -rf "${LINT_BAZEL_TMP}" # Clean up } lint_bazel_pytest() { @@ -647,7 +642,6 @@ _lint() { } lint() { - install_go # Checkout a clean copy of the repo to avoid seeing changes that have been made to the current one ( WORKSPACE_DIR="$(TMPDIR="${WORKSPACE_DIR}/.." mktemp -d)" @@ -752,10 +746,6 @@ build() { fi fi - if [ "${LINT-}" = 1 ]; then - install_go - fi - if [[ "${NEED_WHEELS}" == "true" ]]; then build_wheels_and_jars fi diff --git a/ci/lint/bazel-format.sh b/ci/lint/bazel-format.sh index c422f0ce9516..3c22c8a673e8 100755 --- a/ci/lint/bazel-format.sh +++ b/ci/lint/bazel-format.sh @@ -2,9 +2,10 @@ # Before running this script, please make sure golang is installed # and buildifier is also installed. The example is showed in .travis.yml. -set -e +set -eo pipefail ROOT_DIR=$(cd "$(dirname "$0")/$(dirname "$(test -L "$0" && readlink "$0" || echo "/")")"; pwd) +BUILDIFIER="${BUILDIFIER:-buildifier}" function usage() { @@ -43,8 +44,17 @@ while [ $# -gt 0 ]; do shift done -pushd "$ROOT_DIR"/../.. -BAZEL_FILES=(bazel/BUILD bazel/ray.bzl BUILD.bazel java/BUILD.bazel \ - cpp/BUILD.bazel cpp/example/BUILD.bazel WORKSPACE) -buildifier -mode=$RUN_TYPE -diff_command="diff -u" "${BAZEL_FILES[@]}" -popd +BAZEL_FILES=( + bazel/BUILD + bazel/ray.bzl + BUILD.bazel + java/BUILD.bazel + cpp/BUILD.bazel + cpp/example/BUILD.bazel + WORKSPACE +) + +( + cd "$ROOT_DIR"/../.. + "${BUILDIFIER}" -mode=$RUN_TYPE -diff_command="diff -u" "${BAZEL_FILES[@]}" +)