-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-shell-env.sh
More file actions
217 lines (186 loc) · 4.91 KB
/
Copy pathsetup-shell-env.sh
File metadata and controls
217 lines (186 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
# Copyright 2026 LiveKit
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
cat <<EOF >/etc/profile.d/ros-portal.sh
export ROS_DISTRO=${ROS_DISTRO}
export WS="${WS}"
_source_ros_env() {
if [ -n "\${ZSH_VERSION:-}" ]; then
source /opt/ros/${ROS_DISTRO}/setup.zsh
else
source /opt/ros/${ROS_DISTRO}/setup.bash
fi
}
_source_ws_overlay() {
if [ -n "\${ZSH_VERSION:-}" ]; then
if [ -f "\${WS}/install/setup.zsh" ]; then
source "\${WS}/install/setup.zsh"
fi
else
if [ -f "\${WS}/install/setup.bash" ]; then
source "\${WS}/install/setup.bash"
fi
fi
}
_enable_ros_autocomplete() {
if command -v register-python-argcomplete3 >/dev/null 2>&1; then
eval "\$(register-python-argcomplete3 ros2)"
fi
}
_source_ros_env
alias bros='cd "\${WS}" && colcon build'
alias dros='cd "\${WS}" && rosdep update && rosdep install --from-paths src --ignore-src -r -y'
alias sros='_source_ros_env && _source_ws_overlay && _enable_ros_autocomplete'
# Helper for running the project clang-format wrapper within the devcontainer
clang_format()
{
cd "\${WS}" && ./scripts/clang-format.sh --fix "\$@"
}
cbpu()
{
cd "\${WS}" && sros
if [ "\$#" -eq 0 ]; then
colcon build --packages-up-to ros_portal
else
colcon build --packages-up-to "\$@"
fi
}
cbps()
{
cd "\${WS}" && sros && colcon build --packages-select "\$@" && sros
}
cbtps()
{
pkgs="\$@"
cd "\${WS}" && sros && colcon build --packages-select "\$pkgs" && colcon test --packages-select "\$pkgs" && colcon test-result --verbose
}
cbtpu()
{
cd "\${WS}" && sros
if [ "\$#" -eq 0 ]; then
set -- ros_portal
fi
colcon build --packages-up-to "\$@" && colcon test --packages-up-to "\$@" && colcon test-result --verbose
}
_prepare_test_env()
{
cd "\${WS}" && _source_ros_env && _source_ws_overlay
}
_source_test_tokens_if_needed()
{
if [ -n "\${LIVEKIT_URL:-}" ] && [ -n "\${LIVEKIT_TOKEN_A:-}" ] && [ -n "\${LIVEKIT_TOKEN_B:-}" ]; then
return 0
fi
if [ -f "\${WS}/.token_helpers/set_test_tokens.bash" ]; then
source "\${WS}/.token_helpers/set_test_tokens.bash"
fi
}
# Run unit tests
test_unit()
{
_prepare_test_env
test_exit=0
GTEST_COLOR=1 colcon test --packages-up-to ros_portal test_utilities custom_msgs \
--packages-skip ros2_medkit_serialization \
--event-handlers console_direct+ \
--return-code-on-test-failure \
--ctest-args -R ros_portal_unit_tests || test_exit=\$?
colcon test-result --verbose --all
return "\${test_exit}"
}
# Run integration tests
test_int()
{
_prepare_test_env
export CI="\${CI:-true}"
_source_test_tokens_if_needed
test_exit=0
GTEST_COLOR=1 colcon test --packages-select ros_portal \
--event-handlers console_direct+ \
--return-code-on-test-failure \
--ctest-args -R ros_portal_integration_tests || test_exit=\$?
colcon test-result --verbose --all
return "\${test_exit}"
}
# Run connection fault tests
test_conn()
{
_prepare_test_env
export CI="\${CI:-true}"
_source_test_tokens_if_needed
export ROS_PORTAL_RUN_CONNECTION_FAULT_TESTS=1
test_exit=0
GTEST_COLOR=1 colcon test --packages-select ros_portal \
--event-handlers console_direct+ \
--return-code-on-test-failure \
--ctest-args -R ros_portal_connection_fault_tests || test_exit=\$?
colcon test-result --verbose --all
return "\${test_exit}"
}
clean_ws()
{
cd "\${WS}" && rm -rf build*/ log*/ install/
}
rtl()
{
cd "\${WS}" && sros && ros2 topic list "\$@"
}
rte()
{
cd "\${WS}" && sros && ros2 topic echo "\$@"
}
rsl()
{
cd "\${WS}" && sros && ros2 service list "\$@"
}
rnl()
{
cd "\${WS}" && sros && ros2 node list "\$@"
}
# print domain id
did()
{
echo "\${ROS_DOMAIN_ID:-}"
}
# source/set domain id
sdid()
{
if [ "\$#" -eq 0 ]; then
echo "Usage: sdid <domain_id>" >&2
return 1
fi
export ROS_DOMAIN_ID="\$1"
}
if [ -n "\${ZSH_VERSION:-}" ]; then
PROMPT='(ros-portal) %n@%m:%~ %# '
else
export PS1='(ros-portal) \u@\h:\w \$ '
fi
EOF
cat <<'EOF' >/root/.bashrc
source /etc/profile.d/ros-portal.sh
EOF
cat <<'EOF' >/root/.bash_profile
source /root/.bashrc
EOF
cat <<'EOF' >/root/.zshrc
source /etc/profile.d/ros-portal.sh
autoload -Uz compinit bashcompinit
compinit
bashcompinit
EOF
cat <<'EOF' >/root/.zprofile
source /root/.zshrc
EOF