Skip to content

Commit

Permalink
[drake_bazel_...] Cleanups for bazel version
Browse files Browse the repository at this point in the history
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_download:
- Upgrade rules_cc to latest 0.0.x release 0.0.17.
- Upgrade rules_python to latest release 0.40.0.

drake_bazel_external:
- Opt-out of bzlmod.

drake_cmake_external:
- Remove unnecessary bazel installation.
  • Loading branch information
jwnimmer-tri committed Nov 24, 2024
1 parent bd3ec3a commit 10b5d9c
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 31 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/bazel_download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
3 changes: 0 additions & 3 deletions drake_bazel_download/.bazeliskrc

This file was deleted.

1 change: 1 addition & 0 deletions drake_bazel_download/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.4.1
4 changes: 2 additions & 2 deletions drake_bazel_download/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module(name = "drake_external_examples")

# Add the Bazel rulesets we need.
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_python", version = "0.31.0")
bazel_dep(name = "rules_cc", version = "0.0.17")
bazel_dep(name = "rules_python", version = "0.40.0")

# Use the host system python.
register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")
Expand Down
5 changes: 5 additions & 0 deletions drake_bazel_download/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 //...
Expand Down
17 changes: 17 additions & 0 deletions drake_bazel_download/setup/install_bazelisk
Original file line number Diff line number Diff line change
@@ -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
12 changes: 0 additions & 12 deletions drake_bazel_download/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
bazel
EOF
)
4 changes: 4 additions & 0 deletions drake_bazel_external/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: MIT-0

# Don't use bzlmod yet.
common --enable_workspace=true
common --enable_bzlmod=false

# Default to an optimized build.
build --compilation_mode=opt

Expand Down
1 change: 1 addition & 0 deletions drake_bazel_external/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.4.1
5 changes: 5 additions & 0 deletions drake_bazel_external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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 //...
Expand Down
17 changes: 17 additions & 0 deletions drake_bazel_external/setup/install_bazelisk
Original file line number Diff line number Diff line change
@@ -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
7 changes: 0 additions & 7 deletions drake_bazel_external/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
bazel
cmake
default-jdk
file
Expand Down
7 changes: 0 additions & 7 deletions drake_cmake_external/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
bazel
cmake
default-jdk
file
Expand Down
12 changes: 12 additions & 0 deletions private/test/file_sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"drake_cmake_installed/LICENSE",
"drake_cmake_installed_apt/LICENSE",
),
(
"drake_bazel_download/.github/ci_build_test",
"drake_bazel_external/.github/ci_build_test",
),
(
"drake_bazel_external/.github/setup",
"drake_cmake_external/.github/setup",
Expand All @@ -54,6 +58,14 @@
"drake_bazel_external/setup/install_prereqs",
"drake_cmake_external/setup/install_prereqs",
),
(
"drake_bazel_download/.bazelversion",
"drake_bazel_external/.bazelversion",
),
(
"drake_bazel_download/setup/install_bazelisk",
"drake_bazel_external/setup/install_bazelisk",
),
)

found_errors = False
Expand Down

0 comments on commit 10b5d9c

Please sign in to comment.