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 GHA jobs on custom builds of Drake #374

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
7 changes: 6 additions & 1 deletion .github/workflows/bazel_download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ jobs:
uses: actions/checkout@v4
- name: setup
working-directory: drake_bazel_download
run: .github/ubuntu_setup
run: |
args=()
if [[ '${{ github.event.inputs.linux_jammy_package_tar }}' != '' ]]; then
args+=(--package-url ${{ github.event.inputs.linux_jammy_package_tar }})
fi
.github/ubuntu_setup "${args[@]}"
shell: bash
- name: install_bazelisk
working-directory: drake_bazel_download
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ on:
schedule:
- cron: '0 12 * * *'
workflow_dispatch:
inputs:
linux_jammy_package_tar:
description: 'Drake linux-jammy-*-packaging .tar.gz artifact URL'
required: false
linux_jammy_package_deb:
description: 'Drake linux-jammy-*-packaging .deb artifact URL'
required: false
mac_arm_sonoma_package_tar:
description: 'Drake mac-arm-sonoma-*-packaging .tar.gz artifact URL'
required: false
linux_jammy_wheel:
description: 'Drake linux-jammy-*-wheel-*-release Python 3.10 artifact URL'
required: false
mac_arm_sonoma_wheel:
description: 'Drake mac-arm-sonoma-*-wheel-*-release Python 3.12 artifact URL'
required: false
concurrency:
# Cancel previous CI runs when additional commits are added to a pull request.
# This will not cancel CI runs associated with `schedule` or `push`.
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/cmake_installed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ jobs:
sudo rm -rf /Library/Frameworks/Python.framework/
- name: setup
working-directory: drake_cmake_installed
run: setup/install_prereqs
run: |
args=()
if [[ '${{ github.event.inputs.mac_arm_sonoma_package_tar }}' != '' ]]; then
args+=(--package-url ${{ github.event.inputs.mac_arm_sonoma_package_tar }})
fi
setup/install_prereqs "${args[@]}"
shell: zsh -efuo pipefail {0}
- name: cmake_installed build and test
working-directory: drake_cmake_installed
Expand All @@ -40,7 +45,12 @@ jobs:
uses: actions/checkout@v4
- name: setup
working-directory: drake_cmake_installed
run: .github/ubuntu_setup
run: |
args=()
if [[ '${{ github.event.inputs.linux_jammy_package_tar }}' != '' ]]; then
args+=(--package-url ${{ github.event.inputs.linux_jammy_package_tar }})
fi
.github/ubuntu_setup "${args[@]}"
shell: bash
- name: cmake_installed build and test
working-directory: drake_cmake_installed
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/cmake_installed_apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ jobs:
uses: actions/checkout@v4
- name: setup
working-directory: drake_cmake_installed_apt
run: .github/ubuntu_apt_setup
run: |
args=()
if [[ '${{ github.event.inputs.linux_jammy_package_deb }}' != '' ]]; then
args+=(--package-url ${{ github.event.inputs.linux_jammy_package_deb }})
fi
.github/ubuntu_apt_setup "${args[@]}"
shell: bash
- name: cmake_installed_apt build and test
working-directory: drake_cmake_installed_apt
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
- name: venv setup and install
working-directory: drake_pip
run: setup/setup_env $PYTHON_VERSION
run: |
args=(--python-version $PYTHON_VERSION)
if [[ '${{ github.event.inputs.mac_arm_sonoma_wheel }}' != '' ]]; then
args+=(--wheel-url ${{ github.event.inputs.mac_arm_sonoma_wheel }})
fi
setup/setup_env "${args[@]}"
shell: zsh -eufo pipefail {0}
- name: pip build and test
working-directory: drake_pip
Expand All @@ -46,7 +51,12 @@ jobs:
uses: actions/checkout@v4
- name: pip setup
working-directory: drake_pip
run: .github/ubuntu_setup
run: |
args=()
if [[ '${{ github.event.inputs.linux_jammy_wheel }}' != '' ]]; then
args+=(--wheel-url ${{ github.event.inputs.linux_jammy_wheel }})
fi
.github/ubuntu_setup "${args[@]}"
shell: bash
- name: pip build and test
working-directory: drake_pip
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ jobs:
working-directory: drake_poetry
run: |
.github/setup
setup/install_prereqs $PYTHON_VERSION
args=(--python-version $PYTHON_VERSION)
if [[ '${{ github.event.inputs.mac_arm_sonoma_wheel }}' != '' ]]; then
args+=(--wheel-url ${{ github.event.inputs.mac_arm_sonoma_wheel }})
fi
setup/install_prereqs "${args[@]}"
shell: zsh -efuo pipefail {0}
- name: poetry test
working-directory: drake_poetry
Expand All @@ -54,6 +58,10 @@ jobs:
run: |
.github/setup
source $HOME/.profile
setup/install_prereqs
args=()
if [[ '${{ github.event.inputs.linux_jammy_wheel }}' != '' ]]; then
args+=(--wheel-url ${{ github.event.inputs.linux_jammy_wheel }})
fi
setup/install_prereqs "${args[@]}"
.github/ci_build_test
shell: bash
12 changes: 11 additions & 1 deletion drake_bazel_download/.github/ci_build_test
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,15 @@

set -euxo pipefail

# Use what we installed to $HOME/drake,
# rather than the URL to the most recent nightly release
# found in drake_bazel_download/MODULE.bazel.
drake_override_flag+=("--override_repository=+_repo_rules2+drake=$HOME/drake")

# Setup $HOME/drake as a Bazel workspace via
# BUILD and WORKSPACE files.
ln -sf $(realpath drake.BUILD.bazel) "$HOME/drake/BUILD.bazel"
touch "$HOME/drake/WORKSPACE.bazel"

bazel version
bazel test //...
bazel test "${drake_override_flag[@]}" //...
2 changes: 1 addition & 1 deletion drake_bazel_download/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes

export DEBIAN_FRONTEND='noninteractive'

setup/install_prereqs
setup/install_prereqs "$@"
11 changes: 10 additions & 1 deletion drake_bazel_download/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
schedule:
- cron: '0 12 * * *'
workflow_dispatch:
inputs:
linux_jammy_package_tar:
description: 'Drake linux-jammy-*-packaging .tar.gz artifact URL'
required: false
concurrency:
# Cancel previous CI runs when additional commits are added to a pull request.
# This will not cancel CI runs associated with `schedule` or `push`.
Expand All @@ -27,7 +31,12 @@ jobs:
uses: actions/checkout@v4
- name: setup
working-directory: drake_bazel_download
run: .github/ubuntu_setup
run: |
args=()
if [[ '${{ github.event.inputs.linux_jammy_package_tar }}' != '' ]]; then
args+=(--package-url ${{ github.event.inputs.linux_jammy_package_tar }})
fi
.github/ubuntu_setup "${args[@]}"
shell: bash
- name: install_bazelisk
working-directory: drake_bazel_download
Expand Down
17 changes: 17 additions & 0 deletions drake_bazel_download/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,20 @@ above command prints out; however, be aware that your working directories may
cause differences. This is important when using tools like
`drake::FindResource` / `pydrake.common.FindResource`.
You may generally want to stick to using `bazel run` when able.

### Using a local checkout of Drake

To use an installation of Drake on disk instead of downloaded from github, pass the flag
``--override_repository=+_repo_rules2+drake=/home/user/stuff/drake`` to bazel on the command line
or add a line such as the following to ``user.bazelrc`` in the current directory:

```bash
build --override_repository=+_repo_rules2+drake=/home/user/stuff/drake
```

Note that the local installation of Drake needs the following two files
inside its top-level directory:

* an empty `WORKSPACE.bazel` file
* a symlink or copy of `drake.BUILD.bazel` (found in the current directory
of this example) named `BUILD.bazel`
22 changes: 20 additions & 2 deletions drake_bazel_download/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@

set -euxo pipefail

package_url=

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

maybe_sudo=
if [[ "${EUID}" -ne 0 ]]; then
maybe_sudo=sudo
Expand All @@ -51,8 +70,7 @@ EOF
)

# Download the drake source
wget -O drake.tar.gz \
https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-jammy.tar.gz
wget -O drake.tar.gz "${package_url:-https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-jammy.tar.gz}"
trap 'rm -f drake.tar.gz' EXIT
tar -xf drake.tar.gz -C $HOME

Expand Down
2 changes: 1 addition & 1 deletion drake_cmake_installed/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes

export DEBIAN_FRONTEND='noninteractive'

setup/install_prereqs
setup/install_prereqs "$@"
21 changes: 19 additions & 2 deletions drake_cmake_installed/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ on:
schedule:
- cron: '0 12 * * *'
workflow_dispatch:
inputs:
linux_jammy_package_tar:
description: 'Drake linux-jammy-*-packaging .tar.gz artifact URL'
required: false
mac_arm_sonoma_package_tar:
description: 'Drake mac-arm-sonoma-*-packaging .tar.gz artifact URL'
required: false
concurrency:
# Cancel previous CI runs when additional commits are added to a pull request.
# This will not cancel CI runs associated with `schedule` or `push`.
Expand All @@ -37,7 +44,12 @@ jobs:
sudo rm -rf /Library/Frameworks/Python.framework/
- name: setup
working-directory: drake_cmake_installed
run: setup/install_prereqs
run: |
args=()
if [[ '${{ github.event.inputs.mac_arm_sonoma_package_tar }}' != '' ]]; then
args+=(--package-url ${{ github.event.inputs.mac_arm_sonoma_package_tar }})
fi
setup/install_prereqs "${args[@]}"
shell: zsh -efuo pipefail {0}
- name: cmake_installed build and test
working-directory: drake_cmake_installed
Expand All @@ -52,7 +64,12 @@ jobs:
uses: actions/checkout@v4
- name: setup
working-directory: drake_cmake_installed
run: .github/ubuntu_setup
run: |
args=()
if [[ '${{ github.event.inputs.linux_jammy_package_tar }}' != '' ]]; then
args+=(--package-url ${{ github.event.inputs.linux_jammy_package_tar }})
fi
.github/ubuntu_setup "${args[@]}"
shell: bash
- name: cmake_installed build and test
working-directory: drake_cmake_installed
Expand Down
24 changes: 21 additions & 3 deletions drake_cmake_installed/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@

set -euxo pipefail

package_url=

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

maybe_sudo=

case "$OSTYPE" in
Expand All @@ -15,7 +34,7 @@ case "$OSTYPE" in
fi

# Download the drake source
curl -o drake.tar.gz https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-mac-arm64.tar.gz
curl -o drake.tar.gz "${package_url:-https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-mac-arm64.tar.gz}"
trap 'rm -f drake.tar.gz' EXIT
tar -xf drake.tar.gz -C $HOME
;;
Expand All @@ -41,8 +60,7 @@ EOF
)

# Download the drake source
wget -O drake.tar.gz \
https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-jammy.tar.gz
wget -O drake.tar.gz "${package_url:-https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-jammy.tar.gz}"
trap 'rm -f drake.tar.gz' EXIT
tar -xf drake.tar.gz -C $HOME

Expand Down
45 changes: 37 additions & 8 deletions drake_cmake_installed_apt/.github/ubuntu_apt_setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,48 @@

set -euxo pipefail

package_url=

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

export DEBIAN_FRONTEND=noninteractive

apt-get -qq update || (sleep 30; apt-get -qq update)
apt-get -o Acquire::Retries=4 -o Dpkg::Use-Pty=0 -qy --no-install-recommends \
install build-essential ca-certificates cmake gnupg lsb-release wget

readonly codename="$(lsb_release -cs)"
if [[ ! -z "${package_url}" ]]; then
# Install a custom Drake package if specified.
wget -O drake.deb ${package_url}
trap 'rm -f drake.deb' EXIT

wget -qO- --retry-connrefused https://drake-apt.csail.mit.edu/drake.asc \
| gpg --dearmor - > /etc/apt/trusted.gpg.d/drake.gpg
echo "deb [arch=amd64] https://drake-apt.csail.mit.edu/${codename} ${codename} main" \
> /etc/apt/sources.list.d/drake.list
apt-get -o Acquire::Retries=4 -o Dpkg::Use-Pty=0 -qy --no-install-recommends \
install ./drake.deb
else
# Otherwise, install the latest released version.
readonly codename="$(lsb_release -cs)"

apt-get -qq update || (sleep 30; apt-get -qq update)
apt-get -o Acquire::Retries=4 -o Dpkg::Use-Pty=0 -qy --no-install-recommends \
install drake-dev
wget -qO- --retry-connrefused https://drake-apt.csail.mit.edu/drake.asc \
| gpg --dearmor - > /etc/apt/trusted.gpg.d/drake.gpg
echo "deb [arch=amd64] https://drake-apt.csail.mit.edu/${codename} ${codename} main" \
> /etc/apt/sources.list.d/drake.list

apt-get -qq update || (sleep 30; apt-get -qq update)
apt-get -o Acquire::Retries=4 -o Dpkg::Use-Pty=0 -qy --no-install-recommends \
install drake-dev
fi
Loading
Loading