Skip to content

Commit 1b63c01

Browse files
authored
Run Jenkins jobs on custom builds of Drake (#376)
Adds experimental parameters to drake_cmake_external, drake_bazel_external, and drake_bazel_external_legacy, and enables running these examples via Jenkins with Drake PRs.
1 parent 5239ff3 commit 1b63c01

File tree

16 files changed

+133
-34
lines changed

16 files changed

+133
-34
lines changed

drake_bazel_external/.bazelignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# Used for setup, do not build
2-
drake-master
1+
drake

drake_bazel_external/.github/ci_build_test

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33

44
set -euxo pipefail
55

6+
# Use what we downloaded to drake_bazel_external/drake,
7+
# rather than the URL to the latest Drake master branch
8+
# found in drake_bazel_external/MODULE.bazel.
9+
override_module_flag="--override_module=drake=drake"
10+
611
bazel version
7-
bazel test //...
12+
bazel test "${override_module_flag}" //...

drake_bazel_external/.github/setup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ set -euxo pipefail
77
sudo .github/ubuntu_setup
88

99
# drake source setup
10-
setup/install_prereqs
10+
setup/install_prereqs "$@"

drake_bazel_external/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ For an introduction to Bazel, refer to
88
## Instructions
99

1010
First, run the `install_prereqs` script to download
11-
the Drake source to `drake-master/` (from the current directory).
11+
the Drake source to `drake/` (from the current directory).
1212
This also runs Drake's setup script to install the required Ubuntu packages:
1313

1414
```bash

drake_bazel_external/setup/install_prereqs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44

55
set -euxo pipefail
66

7+
drake_commit_hash='master'
8+
9+
while [ "${1:-}" != "" ]; do
10+
case "$1" in
11+
--drake-commit-hash)
12+
shift
13+
if [[ $# -eq 0 ]]; then
14+
echo 'No argument specified for --drake-commit-hash' >&2
15+
exit 1
16+
fi
17+
drake_commit_hash="$1"
18+
;;
19+
*)
20+
echo 'Invalid command line argument' >&2
21+
exit 1
22+
esac
23+
shift
24+
done
25+
726
maybe_sudo=
827
if [[ "${EUID}" -ne 0 ]]; then
928
maybe_sudo=sudo
@@ -16,11 +35,9 @@ EOF
1635

1736
# Download the drake source
1837
wget -O drake.tar.gz \
19-
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
38+
https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz
2039
trap 'rm -f drake.tar.gz' EXIT
21-
22-
# Setup script
23-
tar -xf drake.tar.gz
40+
mkdir -p drake && tar -xf drake.tar.gz -C drake --strip-components 1
2441

2542
# Install the source prereqs
26-
drake-master/setup/install_prereqs --with-bazel
43+
drake/setup/install_prereqs --with-bazel
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# Used for setup, do not build
2-
drake-master
1+
drake

drake_bazel_external_legacy/.github/ci_build_test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33

44
set -euxo pipefail
55

6+
# Use what we downloaded to drake_bazel_external_legacy/drake,
7+
# rather than the URL to the latest Drake master branch
8+
# found in drake_bazel_external_legacy/WORKSPACE.
9+
export EXAMPLES_LOCAL_DRAKE_PATH=$(realpath drake)
10+
611
bazel version
712
bazel test //...

drake_bazel_external_legacy/.github/setup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ set -euxo pipefail
77
sudo .github/ubuntu_setup
88

99
# drake source setup
10-
setup/install_prereqs
10+
setup/install_prereqs "$@"

drake_bazel_external_legacy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ For an introduction to Bazel, refer to
1313
## Instructions
1414

1515
First, run the `install_prereqs` script to download the
16-
Drake source to `drake-master/` (from the current directory).
16+
Drake source to `drake/` (from the current directory).
1717
This also runs Drake's setup script to install the required Ubuntu packages:
1818

1919
```bash

drake_bazel_external_legacy/setup/install_prereqs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44

55
set -euxo pipefail
66

7+
drake_commit_hash='master'
8+
9+
while [ "${1:-}" != "" ]; do
10+
case "$1" in
11+
--drake-commit-hash)
12+
shift
13+
if [[ $# -eq 0 ]]; then
14+
echo 'No argument specified for --drake-commit-hash' >&2
15+
exit 1
16+
fi
17+
drake_commit_hash="$1"
18+
;;
19+
*)
20+
echo 'Invalid command line argument' >&2
21+
exit 1
22+
esac
23+
shift
24+
done
25+
726
maybe_sudo=
827
if [[ "${EUID}" -ne 0 ]]; then
928
maybe_sudo=sudo
@@ -16,11 +35,9 @@ EOF
1635

1736
# Download the drake source
1837
wget -O drake.tar.gz \
19-
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
38+
https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz
2039
trap 'rm -f drake.tar.gz' EXIT
21-
22-
# Setup script
23-
tar -xf drake.tar.gz
40+
mkdir -p drake && tar -xf drake.tar.gz -C drake --strip-components 1
2441

2542
# Install the source prereqs
26-
drake-master/setup/install_prereqs --with-bazel
43+
drake/setup/install_prereqs --with-bazel

drake_cmake_external/.github/ci_build_test

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,40 @@
33

44
set -euxo pipefail
55

6+
drake_commit_hash=
7+
8+
while [ "${1:-}" != "" ]; do
9+
case "$1" in
10+
--drake-commit-hash)
11+
shift
12+
if [[ $# -eq 0 ]]; then
13+
echo 'No argument specified for --drake-commit-hash' >&2
14+
exit 1
15+
fi
16+
drake_commit_hash="$1"
17+
;;
18+
*)
19+
echo 'Invalid command line argument' >&2
20+
exit 1
21+
esac
22+
shift
23+
done
24+
625
cmake --version
726

827
mkdir build
928
pushd build
1029

1130
export LD_LIBRARY_PATH="${PWD}/install/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
1231

13-
cmake ..
32+
cmake_args=()
33+
if [[ ! -z "${drake_commit_hash}" ]]; then
34+
# Use a specific commit of Drake source,
35+
# rather than the latest from master.
36+
cmake_args+=(-DDRAKE_COMMIT_HASH=${drake_commit_hash})
37+
fi
38+
39+
cmake .. "${cmake_args[@]}"
1440
cmake --build .
1541

1642
cd drake_external_examples
@@ -20,4 +46,3 @@ popd
2046

2147
chmod -R a+w build || true
2248
rm -rf build
23-

drake_cmake_external/.github/setup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -euxo pipefail
77
sudo .github/ubuntu_setup
88

99
# drake source setup
10-
setup/install_prereqs
10+
setup/install_prereqs "$@"
1111

1212
# Provide regression coverage for the WITH_USER_...=ON options by un-installing
1313
# packages that should not be necessary in this particular build flavor. This

drake_cmake_external/CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,19 @@ ExternalProject_Add(spdlog
9393
# also pass this explicitly to ExternalProject_Add.
9494
set(DRAKE_PREFIX "${PROJECT_BINARY_DIR}/drake-prefix")
9595

96+
# Options to override Drake's latest source on master with a specific commit.
97+
# See README.md for details.
98+
set(DRAKE_COMMIT_HASH "master" CACHE STRING "Commit hash for Drake")
99+
set(DRAKE_COMMIT_SHA256 CACHE STRING "SHA256 hash value for Drake commit archive")
100+
101+
if (NOT "${DRAKE_COMMIT_SHA256}" STREQUAL "")
102+
string(PREPEND DRAKE_COMMIT_SHA256 "SHA256=")
103+
endif()
104+
96105
ExternalProject_Add(drake
97106
DEPENDS eigen fmt spdlog
98-
URL https://github.com/RobotLocomotion/drake/archive/master.tar.gz
99-
# Or from a commit (download and use "shasum -a 256 'xxx.tar.gz'" on it to
100-
# get the URL_HASH.
101-
# URL https://github.com/RobotLocomotion/drake/archive/65c4366ea2b63278a286b1e22b8d464d50fbe365.tar.gz
102-
# URL_HASH SHA256=899d98485522a7cd5251e50a7a6b8a64e40aff2a3af4951a3f0857fd938cafca
107+
URL https://github.com/RobotLocomotion/drake/archive/${DRAKE_COMMIT_HASH}.tar.gz
108+
URL_HASH ${DRAKE_COMMIT_SHA256}
103109
TLS_VERIFY ON
104110
CMAKE_ARGS
105111
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}

drake_cmake_external/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This pulls in Drake using the CMake `ExternalProject_Add(drake)` mechanism.
55
## Instructions
66

77
First, run the `install_prereqs` script to download the
8-
Drake source to `drake-master/` (from the current directory).
8+
Drake source to `drake/` (from the current directory).
99
This also runs Drake's setup script to install the required Ubuntu packages:
1010

1111
```bash
@@ -29,3 +29,13 @@ cmake --build .
2929
cd drake_external_examples
3030
ctest -V .
3131
```
32+
33+
### Using a specific commit of Drake
34+
35+
To use Drake sources from a specific commit, pass two cache variables to
36+
CMake (from either the CLI or the GUI):
37+
38+
* `DRAKE_COMMIT_HASH`: the commit hash
39+
* `DRAKE_COMMIT_SHA256`: the checksum of the archive downloaded from GitHub
40+
(download https://github.com/RobotLocomotion/drake/archive/<DRAKE_COMMIT_HASH>.tar.gz
41+
and use `shasum -a 256 'xxx.tar.gz'`)

drake_cmake_external/setup/install_prereqs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44

55
set -euxo pipefail
66

7+
drake_commit_hash='master'
8+
9+
while [ "${1:-}" != "" ]; do
10+
case "$1" in
11+
--drake-commit-hash)
12+
shift
13+
if [[ $# -eq 0 ]]; then
14+
echo 'No argument specified for --drake-commit-hash' >&2
15+
exit 1
16+
fi
17+
drake_commit_hash="$1"
18+
;;
19+
*)
20+
echo 'Invalid command line argument' >&2
21+
exit 1
22+
esac
23+
shift
24+
done
25+
726
maybe_sudo=
827
if [[ "${EUID}" -ne 0 ]]; then
928
maybe_sudo=sudo
@@ -16,11 +35,9 @@ EOF
1635

1736
# Download the drake source
1837
wget -O drake.tar.gz \
19-
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
38+
https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz
2039
trap 'rm -f drake.tar.gz' EXIT
21-
22-
# Setup script
23-
tar -xf drake.tar.gz
40+
mkdir -p drake && tar -xf drake.tar.gz -C drake --strip-components 1
2441

2542
# Install the source prereqs
26-
drake-master/setup/install_prereqs
43+
drake/setup/install_prereqs

private/test/file_sync_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
".bazelignore",
6161
".bazelproject",
6262
".clang-format",
63-
".github/ci_build_test",
6463
".github/setup",
6564
".github/ubuntu_setup",
6665
"BUILD.bazel",

0 commit comments

Comments
 (0)