Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/test-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ jobs:
- osrf_ros
- upstream_ros
- workspace_overlay
- shells
steps:
- uses: actions/checkout@v6

Expand Down
24 changes: 17 additions & 7 deletions features/src/ros2/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,26 @@ chmod 0644 /etc/profile.d/ros2.sh

remote_user="${_REMOTE_USER:-${_CONTAINER_USER:-}}"
remote_user_home="${_REMOTE_USER_HOME:-${_CONTAINER_USER_HOME:-}}"
ros_profile_line='[ -f /etc/profile.d/ros2.sh ] && . /etc/profile.d/ros2.sh'

if [[ -n "${remote_user}" && -n "${remote_user_home}" && -d "${remote_user_home}" ]]; then
shell_init="${remote_user_home}/.bashrc"
touch "${shell_init}"
if ! grep -Fq '[ -f /etc/profile.d/ros2.sh ] && . /etc/profile.d/ros2.sh' "${shell_init}"; then
printf '\n%s\n' '[ -f /etc/profile.d/ros2.sh ] && . /etc/profile.d/ros2.sh' >> "${shell_init}"
shell_inits=("${remote_user_home}/.bashrc")
if command -v zsh >/dev/null 2>&1; then
shell_inits+=("${remote_user_home}/.zshrc")
fi
if ! grep -Fq '[ -f /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash ] && . /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash' "${shell_init}"; then
printf '%s\n' '[ -f /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash ] && . /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash' >> "${shell_init}"
for shell_init in "${shell_inits[@]}"; do
touch "${shell_init}"
if ! grep -Fq "${ros_profile_line}" "${shell_init}"; then
printf '\n%s\n' "${ros_profile_line}" >> "${shell_init}"
fi
chown "${remote_user}:$(id -gn "${remote_user}")" "${shell_init}"
done

bash_completion_line='[ -f /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash ] && . /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash'
bash_init="${remote_user_home}/.bashrc"
if ! grep -Fq "${bash_completion_line}" "${bash_init}"; then
printf '%s\n' "${bash_completion_line}" >> "${bash_init}"
fi
chown "${remote_user}:$(id -gn "${remote_user}")" "${shell_init}"
else
echo "No effective Dev Container user was provided; skipping user-specific shell configuration."
fi
Expand Down
1 change: 1 addition & 0 deletions features/test/ros2-idempotency/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ RUN bash -lc 'test "${ROS_DISTRO}" = jazzy' \
&& sudo -u vscode bash -ic 'complete -p colcon >/dev/null' \
&& test -f /etc/ros/rosdep/sources.list.d/20-default.list \
&& test "$(grep -Fc '[ -f /etc/profile.d/ros2.sh ] && . /etc/profile.d/ros2.sh' /home/vscode/.bashrc)" -eq 1 \
&& test "$(grep -Fc '[ -f /etc/profile.d/ros2.sh ] && . /etc/profile.d/ros2.sh' /home/vscode/.zshrc)" -eq 1 \
&& test "$(grep -Fc '[ -f /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash ] && . /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash' /home/vscode/.bashrc)" -eq 1
10 changes: 10 additions & 0 deletions features/test/ros2/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,15 @@
"workspace_overlay": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
"features": { "ros2": { "package": "ros-base", "workspace": "/tmp/ros2_overlay" } }
},
"shells": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
"features": {
"ros2": {
"distro": "jazzy",
"package": "ros-base",
"workspace": "/tmp/ros2_shell_overlay"
}
}
}
}
17 changes: 17 additions & 0 deletions features/test/ros2/shells.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -e
source dev-container-features-test-lib

mkdir -p /tmp/ros2_shell_overlay/install
printf '%s\n' 'export ROS2_SHELL_OVERLAY_TEST=loaded' > /tmp/ros2_shell_overlay/install/setup.sh

check "Bash ROS CLI is available" bash -lc 'command -v ros2 >/dev/null'
check "Bash ROS distribution is available" bash -lc '[ "${ROS_DISTRO:-}" = "jazzy" ]'
check "Bash workspace overlay is sourced" bash -lc '[ "${ROS2_SHELL_OVERLAY_TEST:-}" = loaded ]'
check "Zsh ROS CLI is available" zsh -ic 'command -v ros2 >/dev/null'
check "Zsh ROS distribution is available" zsh -ic '[ "${ROS_DISTRO:-}" = "jazzy" ]'
check "Zsh workspace overlay is sourced" zsh -ic '[ "${ROS2_SHELL_OVERLAY_TEST:-}" = loaded ]'
check "Bash colcon completion is enabled" bash -ic 'complete -p colcon >/dev/null'

reportResults