From d6e69077b51ce8e0c92392386f903b798119706c Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Sun, 24 Nov 2024 11:50:47 -0800 Subject: [PATCH] [drake_bazel_...] Cleanups for bazel version drake_bazel_download and drake_bazel_external: - Install bazelisk (instead of using the bazel apt site) so that we can pin to a specific version. We use a separate script for this so that users have control over whether or not they want to install our version (and so that file_sync_test retains its governance over various files). - Use .bazelversion (not .bazeliskrc) to pin a bazel version. When using bazelisk, this is the more canonical approach. Cover the version dotfile with file_sync_test. - Upgrade bazel to latest release 7.4.1. - Add missing file_sync_test coverage of ci_build_test. drake_bazel_external: - Opt-out of bzlmod. drake_cmake_external: - Remove unnecessary bazel installation. --- .github/workflows/bazel_download.yml | 4 ++++ Jenkinsfile | 3 +++ drake_bazel_download/.bazeliskrc | 3 --- drake_bazel_download/.bazelversion | 1 + drake_bazel_download/README.md | 5 +++++ drake_bazel_download/setup/install_bazelisk | 17 +++++++++++++++++ drake_bazel_download/setup/install_prereqs | 12 ------------ drake_bazel_external/.bazelrc | 4 ++++ drake_bazel_external/.bazelversion | 1 + drake_bazel_external/README.md | 5 +++++ drake_bazel_external/setup/install_bazelisk | 17 +++++++++++++++++ drake_bazel_external/setup/install_prereqs | 7 ------- drake_cmake_external/setup/install_prereqs | 7 ------- private/test/file_sync_test.py | 12 ++++++++++++ 14 files changed, 69 insertions(+), 29 deletions(-) delete mode 100644 drake_bazel_download/.bazeliskrc create mode 100644 drake_bazel_download/.bazelversion create mode 100755 drake_bazel_download/setup/install_bazelisk create mode 100644 drake_bazel_external/.bazelversion create mode 100755 drake_bazel_external/setup/install_bazelisk diff --git a/.github/workflows/bazel_download.yml b/.github/workflows/bazel_download.yml index 104d876c..5595e3af 100644 --- a/.github/workflows/bazel_download.yml +++ b/.github/workflows/bazel_download.yml @@ -17,6 +17,10 @@ jobs: working-directory: drake_bazel_download run: .github/ubuntu_setup shell: bash + - name: install_bazelisk + working-directory: drake_bazel_download + run: setup/install_bazelisk + shell: bash - name: bazel_download build and test working-directory: drake_bazel_download run: .github/ci_build_test diff --git a/Jenkinsfile b/Jenkinsfile index c22adb90..b7bb7202 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,6 +22,9 @@ node('linux-jammy-unprovisioned') { stage('bazel_external setup') { sh '.github/setup' } + stage('bazel_external bazelisk') { + sh 'setup/install_bazelisk' + } stage('bazel_external build and test') { sh '.github/ci_build_test' } diff --git a/drake_bazel_download/.bazeliskrc b/drake_bazel_download/.bazeliskrc deleted file mode 100644 index 6a62267c..00000000 --- a/drake_bazel_download/.bazeliskrc +++ /dev/null @@ -1,3 +0,0 @@ -# Keep this version number in sync with the Ubuntu deb installed by -# drake/setup/ubuntu/source_distribution/install_bazel.sh. -USE_BAZEL_VERSION=7.0.2 diff --git a/drake_bazel_download/.bazelversion b/drake_bazel_download/.bazelversion new file mode 100644 index 00000000..815da58b --- /dev/null +++ b/drake_bazel_download/.bazelversion @@ -0,0 +1 @@ +7.4.1 diff --git a/drake_bazel_download/README.md b/drake_bazel_download/README.md index 4c9cf5e3..7409a25c 100644 --- a/drake_bazel_download/README.md +++ b/drake_bazel_download/README.md @@ -14,6 +14,11 @@ First, install the required Ubuntu packages: sudo setup/install_prereqs ``` +If you don't already have bazel or bazelisk installed, then install bazelisk: +``` +sudo setup/install_bazelisk +``` + Then, to build and test all apps: ``` bazel test //... diff --git a/drake_bazel_download/setup/install_bazelisk b/drake_bazel_download/setup/install_bazelisk new file mode 100755 index 00000000..0032a5a6 --- /dev/null +++ b/drake_bazel_download/setup/install_bazelisk @@ -0,0 +1,17 @@ +#!/bin/bash + +# TODO(jwnimmer-tri) Drake's install_prereqs script should offer to perform +# this install step for us, but it doesn't -- so we need this work-around +# in the meantime. + +set -euxo pipefail + +if [[ "${EUID:-}" -ne 0 ]]; then + echo 'This script must be run as root' >&2 + exit 2 +fi + +wget -O bazelisk.deb \ + https://github.com/bazelbuild/bazelisk/releases/download/v1.24.0/bazelisk-amd64.deb +dpkg -i bazelisk.deb +rm -f bazelisk.deb diff --git a/drake_bazel_download/setup/install_prereqs b/drake_bazel_download/setup/install_prereqs index ae499368..42113566 100755 --- a/drake_bazel_download/setup/install_prereqs +++ b/drake_bazel_download/setup/install_prereqs @@ -59,15 +59,3 @@ tar -xf drake.tar.gz -C /opt echo -e "\ndrake VERSION.TXT: $(cat /opt/drake/share/doc/drake/VERSION.TXT)\n" /opt/drake/share/drake/setup/install_prereqs - -apt-get install --no-install-recommends gnupg - -apt-key adv --fetch-keys https://bazel.build/bazel-release.pub.gpg -echo 'deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8' \ - > /etc/apt/sources.list.d/bazel.list - -apt-get update -apt-get install --no-install-recommends $(cat <&2 + exit 2 +fi + +wget -O bazelisk.deb \ + https://github.com/bazelbuild/bazelisk/releases/download/v1.24.0/bazelisk-amd64.deb +dpkg -i bazelisk.deb +rm -f bazelisk.deb diff --git a/drake_bazel_external/setup/install_prereqs b/drake_bazel_external/setup/install_prereqs index 20ba6acc..c312b871 100755 --- a/drake_bazel_external/setup/install_prereqs +++ b/drake_bazel_external/setup/install_prereqs @@ -74,15 +74,8 @@ echo -e "\ndrake VERSION.TXT: $(cat /opt/drake/share/doc/drake/VERSION.TXT)\n" /opt/drake/share/drake/setup/install_prereqs -apt-get install --no-install-recommends gnupg - -apt-key adv --fetch-keys https://bazel.build/bazel-release.pub.gpg -echo 'deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8' \ - > /etc/apt/sources.list.d/bazel.list - apt-get update apt-get install --no-install-recommends $(cat < /etc/apt/sources.list.d/bazel.list - apt-get update apt-get install --no-install-recommends $(cat <