Skip to content

Commit

Permalink
review changes: remove redundant arg parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-yankee committed Mar 5, 2025
1 parent ecdeda3 commit d782ce4
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 134 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/bazel_download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,5 @@ jobs:
shell: bash
- name: bazel_download build and test
working-directory: drake_bazel_download
run: |
args=()
if [[ '${{ github.event.inputs.linux_jammy_package_tar }}' != '' ]]; then
args+=(--drake-override)
fi
.github/ci_build_test "${args[@]}"
run: .github/ci_build_test
shell: bash
33 changes: 8 additions & 25 deletions drake_bazel_download/.github/ci_build_test
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,15 @@

set -euxo pipefail

drake_override=0
# 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")

while [ "${1:-}" != "" ]; do
case "$1" in
--drake-override)
drake_override=1
;;
*)
echo 'Invalid command line argument' >&2
exit 1
esac
shift
done

drake_override_flag=()
if [[ ${drake_override} -eq 1 ]]; then
# 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"
fi
# 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 "${drake_override_flag[@]}" //...
21 changes: 1 addition & 20 deletions drake_bazel_download/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,9 @@

set -euxo pipefail

install_args=()

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

echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries
echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes

export DEBIAN_FRONTEND='noninteractive'

setup/install_prereqs "${install_args[@]}"
setup/install_prereqs "$@"
7 changes: 1 addition & 6 deletions drake_bazel_download/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,5 @@ jobs:
shell: bash
- name: bazel_download build and test
working-directory: drake_bazel_download
run: |
args=()
if [[ '${{ github.event.inputs.linux_jammy_package_tar }}' != '' ]]; then
args+=(--drake-override)
fi
.github/ci_build_test "${args[@]}"
run: .github/ci_build_test
shell: bash
21 changes: 1 addition & 20 deletions drake_cmake_installed/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,9 @@

set -euxo pipefail

install_args=()

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

echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries
echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes

export DEBIAN_FRONTEND='noninteractive'

setup/install_prereqs "${install_args[@]}"
setup/install_prereqs "$@"
29 changes: 1 addition & 28 deletions drake_pip/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,9 @@

set -euxo pipefail

install_args=()

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

echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries
echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes

export DEBIAN_FRONTEND='noninteractive'

setup/install_prereqs "${install_args[@]}"
setup/install_prereqs "$@"
29 changes: 1 addition & 28 deletions drake_pip/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,6 @@

set -euxo pipefail

setup_env_args=()

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

maybe_sudo=
if [[ "${EUID}" -ne 0 ]]; then
maybe_sudo=sudo
Expand All @@ -49,4 +22,4 @@ ${maybe_sudo} apt-get install --no-install-recommends $(cat <<EOF
EOF
)

setup/setup_env "${setup_env_args[@]}"
setup/setup_env "$@"
2 changes: 1 addition & 1 deletion drake_pip/setup/setup_env
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ echo "Creating virtual environment with python${python_version}"
# Install from requirements.txt, which currently only includes drake.
"env/bin/pip$python_version" install -r requirements.txt

# Use custom wheels if specified, on the respective OS.
# Use custom wheels if specified.
if [[ ! -z "${wheel_url}" ]]; then
"env/bin/pip$python_version" install "${wheel_url}"
fi

0 comments on commit d782ce4

Please sign in to comment.