Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Jenkins jobs on custom builds of Drake #376

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drake_bazel_external/.bazelignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Used for setup, do not build
drake-master
drake
7 changes: 6 additions & 1 deletion drake_bazel_external/.github/ci_build_test
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@

set -euxo pipefail

# Use what we downloaded to drake_bazel_external/drake,
# rather than the URL to the latest Drake master branch
# found in drake_bazel_external/MODULE.bazel.
override_module_flag="--override_module=drake=drake"

bazel version
bazel test //...
bazel test "${override_module_flag}" //...
2 changes: 1 addition & 1 deletion drake_bazel_external/.github/setup
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ set -euxo pipefail
sudo .github/ubuntu_setup

# drake source setup
setup/install_prereqs
setup/install_prereqs "$@"
2 changes: 1 addition & 1 deletion drake_bazel_external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For an introduction to Bazel, refer to
## Instructions

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

```bash
Expand Down
27 changes: 22 additions & 5 deletions drake_bazel_external/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@

set -euxo pipefail

drake_commit_hash='master'

while [ "${1:-}" != "" ]; do
case "$1" in
--drake-commit-hash)
shift
if [[ $# -eq 0 ]]; then
echo 'No argument specified for --drake-commit-hash' >&2
exit 1
fi
drake_commit_hash="$1"
;;
*)
echo 'Invalid command line argument' >&2
exit 1
esac
shift
done

maybe_sudo=
if [[ "${EUID}" -ne 0 ]]; then
maybe_sudo=sudo
Expand All @@ -16,11 +35,9 @@ EOF

# Download the drake source
wget -O drake.tar.gz \
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz
trap 'rm -f drake.tar.gz' EXIT

# Setup script
tar -xf drake.tar.gz
mkdir -p drake && tar -xf drake.tar.gz -C drake --strip-components 1

# Install the source prereqs
drake-master/setup/install_prereqs --with-bazel
drake/setup/install_prereqs --with-bazel
2 changes: 1 addition & 1 deletion drake_bazel_external_legacy/.bazelignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Used for setup, do not build
drake-master
drake
6 changes: 6 additions & 0 deletions drake_bazel_external_legacy/.github/ci_build_test
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@

set -euxo pipefail

# Use what we downloaded to drake_bazel_external_legacy/drake,
# rather than the URL to the latest Drake master branch
# found in drake_bazel_external_legacy/WORKSPACE.
export EXAMPLES_LOCAL_DRAKE_PATH=$(realpath drake)
trap 'unset EXAMPLES_LOCAL_DRAKE_PATH' EXIT

bazel version
bazel test //...
2 changes: 1 addition & 1 deletion drake_bazel_external_legacy/.github/setup
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ set -euxo pipefail
sudo .github/ubuntu_setup

# drake source setup
setup/install_prereqs
setup/install_prereqs "$@"
2 changes: 1 addition & 1 deletion drake_bazel_external_legacy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For an introduction to Bazel, refer to
## Instructions

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

```bash
Expand Down
27 changes: 22 additions & 5 deletions drake_bazel_external_legacy/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@

set -euxo pipefail

drake_commit_hash='master'

while [ "${1:-}" != "" ]; do
case "$1" in
--drake-commit-hash)
shift
if [[ $# -eq 0 ]]; then
echo 'No argument specified for --drake-commit-hash' >&2
exit 1
fi
drake_commit_hash="$1"
;;
*)
echo 'Invalid command line argument' >&2
exit 1
esac
shift
done

maybe_sudo=
if [[ "${EUID}" -ne 0 ]]; then
maybe_sudo=sudo
Expand All @@ -16,11 +35,9 @@ EOF

# Download the drake source
wget -O drake.tar.gz \
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz
trap 'rm -f drake.tar.gz' EXIT

# Setup script
tar -xf drake.tar.gz
mkdir -p drake && tar -xf drake.tar.gz -C drake --strip-components 1

# Install the source prereqs
drake-master/setup/install_prereqs --with-bazel
drake/setup/install_prereqs --with-bazel
36 changes: 34 additions & 2 deletions drake_cmake_external/.github/ci_build_test
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,47 @@

set -euxo pipefail

drake_commit_hash=

while [ "${1:-}" != "" ]; do
case "$1" in
--drake-commit-hash)
shift
if [[ $# -eq 0 ]]; then
echo 'No argument specified for --drake-commit-hash' >&2
exit 1
fi
drake_commit_hash="$1"
;;
*)
echo 'Invalid command line argument' >&2
exit 1
esac
shift
done

cmake --version

mkdir build
pushd build

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

cmake ..
cmake_args=()
if [[ ! -z "${drake_commit_hash}" ]]; then
# Use a specific commit of Drake source,
# rather than the latest from master.
cmake_args+=(-DDRAKE_COMMIT_HASH=${drake_commit_hash})

# Find the SHA-256 by downloading and running shasum.
wget -O drake.tar.gz \
https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz
trap 'rm -f drake.tar.gz' EXIT
drake_commit_sha256=$(echo $(shasum -a 256 drake.tar.gz | awk '{print $1}'))
cmake_args+=(-DDRAKE_COMMIT_SHA256=${drake_commit_sha256})
fi

cmake .. "${cmake_args[@]}"
cmake --build .

cd drake_external_examples
Expand All @@ -20,4 +53,3 @@ popd

chmod -R a+w build || true
rm -rf build

2 changes: 1 addition & 1 deletion drake_cmake_external/.github/setup
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -euxo pipefail
sudo .github/ubuntu_setup

# drake source setup
setup/install_prereqs
setup/install_prereqs "$@"

# Provide regression coverage for the WITH_USER_...=ON options by un-installing
# packages that should not be necessary in this particular build flavor. This
Expand Down
17 changes: 12 additions & 5 deletions drake_cmake_external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,20 @@ ExternalProject_Add(spdlog
# also pass this explicitly to ExternalProject_Add.
set(DRAKE_PREFIX "${PROJECT_BINARY_DIR}/drake-prefix")

# Options to override Drake's latest source on master with a specific commit.
# Download https://github.com/RobotLocomotion/drake/archive/${DRAKE_COMMIT_HASH}.tar.gz
# and use "shasum -a 256 'xxx.tar.gz'" on it to get the DRAKE_COMMIT_SHA256.
set(DRAKE_COMMIT_HASH "master" CACHE STRING "Commit hash for Drake")
set(DRAKE_COMMIT_SHA256 CACHE STRING "SHA256 hash value for Drake commit archive")

if (NOT "${DRAKE_COMMIT_SHA256}" STREQUAL "")
string(PREPEND DRAKE_COMMIT_SHA256 "SHA256=")
endif()

ExternalProject_Add(drake
DEPENDS eigen fmt spdlog
URL https://github.com/RobotLocomotion/drake/archive/master.tar.gz
# Or from a commit (download and use "shasum -a 256 'xxx.tar.gz'" on it to
# get the URL_HASH.
# URL https://github.com/RobotLocomotion/drake/archive/65c4366ea2b63278a286b1e22b8d464d50fbe365.tar.gz
# URL_HASH SHA256=899d98485522a7cd5251e50a7a6b8a64e40aff2a3af4951a3f0857fd938cafca
URL https://github.com/RobotLocomotion/drake/archive/${DRAKE_COMMIT_HASH}.tar.gz
URL_HASH ${DRAKE_COMMIT_SHA256}
TLS_VERIFY ON
CMAKE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
Expand Down
12 changes: 11 additions & 1 deletion drake_cmake_external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This pulls in Drake using the CMake `ExternalProject_Add(drake)` mechanism.
## Instructions

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

```bash
Expand All @@ -29,3 +29,13 @@ cmake --build .
cd drake_external_examples
ctest -V .
```

### Using a specific commit of Drake

To use Drake sources from a specific commit, pass two cache variables to
CMake (from either the CLI or the GUI):

* `DRAKE_COMMIT_HASH`: the commit hash
* `DRAKE_COMMIT_SHA256`: the checksum of the archive downloaded from GitHub
(download https://github.com/RobotLocomotion/drake/archive/<DRAKE_COMMIT_HASH>.tar.gz
and use `shasum -a 256 'xxx.tar.gz'`)
27 changes: 22 additions & 5 deletions drake_cmake_external/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@

set -euxo pipefail

drake_commit_hash='master'

while [ "${1:-}" != "" ]; do
case "$1" in
--drake-commit-hash)
shift
if [[ $# -eq 0 ]]; then
echo 'No argument specified for --drake-commit-hash' >&2
exit 1
fi
drake_commit_hash="$1"
;;
*)
echo 'Invalid command line argument' >&2
exit 1
esac
shift
done

maybe_sudo=
if [[ "${EUID}" -ne 0 ]]; then
maybe_sudo=sudo
Expand All @@ -16,11 +35,9 @@ EOF

# Download the drake source
wget -O drake.tar.gz \
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz
trap 'rm -f drake.tar.gz' EXIT

# Setup script
tar -xf drake.tar.gz
mkdir -p drake && tar -xf drake.tar.gz -C drake --strip-components 1

# Install the source prereqs
drake-master/setup/install_prereqs
drake/setup/install_prereqs
5 changes: 0 additions & 5 deletions private/test/file_sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
"drake_pip/LICENSE",
"drake_poetry/LICENSE",
),
(
"drake_bazel_download/.github/ci_build_test",
"drake_bazel_external/.github/ci_build_test",
),
(
"drake_bazel_external/.github/ubuntu_setup",
"drake_cmake_external/.github/ubuntu_setup",
Expand All @@ -62,7 +58,6 @@
".bazelignore",
".bazelproject",
".clang-format",
".github/ci_build_test",
".github/setup",
".github/ubuntu_setup",
"BUILD.bazel",
Expand Down
Loading