Skip to content

Commit

Permalink
Merge #68213
Browse files Browse the repository at this point in the history
68213: bazel: pin to bazel 4.0.0, migrate to bazelisk in the builder image r=jlinder a=rickystewart

Closes #68181.

Release note: None

Co-authored-by: Ricky Stewart <[email protected]>
  • Loading branch information
craig[bot] and rickystewart committed Jul 30, 2021
2 parents 7475bcf + fd40681 commit aa2d749
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0.0
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,8 @@ $(info $(yellow)Warning: 'ccache' not found, consider installing it for faster b
endif

# Warn maintainers if bazel is not found.
#
# TODO(irfansharif): Assert here instead, on a fixed version of bazel (3.7.0). Something like:
#
# $(error $(yellow)'bazel' not found (`brew install bazel` for macs)$(term-reset))
ifeq (, $(shell which bazel))
$(info $(yellow)Warning: 'bazel' not found (`brew install bazel` for macs)$(term-reset))
$(info $(yellow)Warning: 'bazel' not found (`brew install bazelisk` for macs)$(term-reset))
endif

# Force vendor directory to rebuild.
Expand Down
5 changes: 0 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ yarn_install(
yarn_lock = "//pkg/ui:yarn.lock",
)

# NB: @bazel_skylib comes from go_rules_dependencies().
load("@bazel_skylib//lib:versions.bzl", "versions")

versions.check(minimum_bazel_version = "4.0.0")

# Load gazelle dependencies.
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

Expand Down
20 changes: 11 additions & 9 deletions build/bazelbuilder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN apt-get update \
cmake \
curl \
flex \
g++ \
git \
gnupg2 \
libncurses-dev \
Expand All @@ -32,14 +33,9 @@ RUN curl -fsSL https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-
&& tar --strip-components=1 -C /usr -xzf cmake.tar.gz \
&& rm cmake.tar.gz

RUN echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \
&& curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
bazel-4.0.0

# git - Upgrade to a more modern version
RUN DEBIAN_FRONTEND=noninteractive apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev -y && \
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev -y && \
curl -fsSL https://github.com/git/git/archive/v2.29.2.zip -o "git-2.29.2.zip" && \
unzip "git-2.29.2.zip" && \
cd git-2.29.2 && \
Expand All @@ -56,9 +52,15 @@ RUN apt-get purge -y \
gettext \
&& apt-get autoremove -y

RUN rm -rf /tmp/* /var/lib/apt/lists/*
# Install Bazelisk as Bazel.
# NOTE: you should keep this in sync with build/packer/teamcity-agent.sh -- if
# an update is necessary here, it's probably necessary in the agent as well.
RUN curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.10.1/bazelisk-linux-amd64 > /tmp/bazelisk \
&& echo '4cb534c52cdd47a6223d4596d530e7c9c785438ab3b0a49ff347e991c210b2cd /tmp/bazelisk' | sha256sum -c - \
&& chmod +x /tmp/bazelisk \
&& mv /tmp/bazelisk /usr/bin/bazel

RUN ln -s /usr/bin/bazel-4.0.0 /usr/bin/bazel
RUN rm -rf /tmp/* /var/lib/apt/lists/*

COPY entrypoint.sh /usr/bin
COPY autom4te /usr/local/sbin
Expand Down
1 change: 1 addition & 0 deletions build/packer/teamcity-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ for f in `ls /usr/local/go/bin`; do
done

# Install Bazelisk.
# Keep this in sync with `build/bazelbuilder/Dockerfile`.
curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.10.1/bazelisk-linux-amd64 > /tmp/bazelisk
sha256sum -c - <<EOF
4cb534c52cdd47a6223d4596d530e7c9c785438ab3b0a49ff347e991c210b2cd /tmp/bazelisk
Expand Down
2 changes: 1 addition & 1 deletion build/teamcity-bazel-support.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# FYI: You can run `./dev builder` to run this Docker image. :)
# `dev` depends on this variable! Don't change the name or format unless you
# also update `dev` accordingly.
BAZEL_IMAGE=cockroachdb/bazel:20210723-114244
BAZEL_IMAGE=cockroachdb/bazel:20210729-154657

# Call `run_bazel $NAME_OF_SCRIPT` to start an appropriately-configured Docker
# container with the `cockroachdb/bazel` image running the given script.
Expand Down
16 changes: 16 additions & 0 deletions tools/bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# Bazel calls into this script, setting `BAZEL_REAL` to the location of
# the "actual" Bazel binary, expecting this script to call into Bazel
# appropriately. We output a helpful error message as suggested in
# https://github.com/bazelbuild/bazelisk#ensuring-that-your-developers-use-bazelisk-rather-than-bazel

if [ -z "$BAZELISK_SKIP_WRAPPER" ] && [ -z "$SHUT_UP_ABOUT_BAZELISK" ]
then
echo "You're not using Bazelisk! Your build may fail due to a mismatched"
echo "Bazel version. Using Bazelisk is recommended."
echo "On macOS, you can install Bazelisk with:"
echo " brew uninstall bazel; brew install bazelisk"
fi

$BAZEL_REAL "$@"

0 comments on commit aa2d749

Please sign in to comment.