Skip to content

Commit de4743a

Browse files
committed
fix: Remove placeholders that are mistakenly added to certain workspace; Rename placeholders and add comment-only placeholders
1 parent a1e2260 commit de4743a

File tree

10 files changed

+47
-44
lines changed

10 files changed

+47
-44
lines changed

cartographer_ws/docker/.bashrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ if [ ! -f $ROS2_WS/install/setup.bash ]; then
2626
echo "Workspace built."
2727
fi
2828
# TODO: Source other workspace environments as underlay
29-
MULTILINE_PLACEHOLDER
3029
# Source workspace environment
3130
source $ROS2_WS/install/setup.bash

rtabmap_ws/docker/.bashrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ if [ ! -f $ROS2_WS/install/setup.bash ]; then
2626
echo "Workspace built."
2727
fi
2828
# TODO: Source other workspace environments as underlay
29-
MULTILINE_PLACEHOLDER
3029
# Source workspace environment
3130
source $ROS2_WS/install/setup.bash

tests/diff_base/.devcontainer/devcontainer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Reference: https://aka.ms/devcontainer.json */
22
{
3-
"name": "PLACEHOLDER",
3+
"name": "{PLACEHOLDER}",
44
"dockerComposeFile": "../docker/compose.yaml",
5-
"service": "PLACEHOLDER-ws",
5+
"service": "{PLACEHOLDER}-ws",
66
// Workspace settings
7-
"workspaceFolder": "/home/ros2-essentials/PLACEHOLDER_ws",
7+
"workspaceFolder": "/home/ros2-essentials/{PLACEHOLDER}_ws",
88
// Vscode extensions
99
"customizations": {
1010
"vscode": {

tests/diff_base/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
/build
66
/install
77
/log
8-
MULTILINE_PLACEHOLDER
8+
{PLACEHOLDER_MULTILINE}

tests/diff_base/docker/.bashrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ if [ ! -f $ROS2_WS/install/setup.bash ]; then
1919
# TODO: If command `arch` outputs `aarch64`, consider adding `--packages-ignore <package>` to ignore x86 packages
2020
# Ref: https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html
2121
if [ $(arch) == "aarch64" ]; then
22-
colcon build --symlink-installPLACEHOLDER
22+
colcon build --symlink-install{PLACEHOLDER}
2323
else
2424
colcon build --symlink-install
2525
fi
2626
echo "Workspace built."
2727
fi
2828
# TODO: Source other workspace environments as underlay
29-
MULTILINE_PLACEHOLDER
29+
{PLACEHOLDER_MULTILINE}
3030
# Source workspace environment
3131
source $ROS2_WS/install/setup.bash

tests/diff_base/docker/.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
*
22
!.bashrc
3-
MULTILINE_PLACEHOLDER
3+
{PLACEHOLDER_MULTILINE}

tests/diff_base/docker/Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Base Image: PLACEHOLDER
2-
FROM PLACEHOLDER AS amd64
3-
# Base Image: PLACEHOLDER
4-
FROM PLACEHOLDER AS arm64
1+
# Base Image: {PLACEHOLDER}
2+
FROM {PLACEHOLDER} AS amd64
3+
# Base Image: {PLACEHOLDER}
4+
FROM {PLACEHOLDER} AS arm64
55

66
# Use docker automatic platform args to select the base image.
77
# It may be `arm64` or `amd64` depending on the platform.
88
# Ref: https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope
99
FROM $TARGETARCH
1010
ARG TARGETARCH
11-
MULTILINE_PLACEHOLDER
11+
{PLACEHOLDER_MULTILINE}
1212
# Arguments for the default user
1313
ARG USERNAME=user
1414
ARG USER_UID=1000
@@ -84,14 +84,14 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
8484
# apt-get update && apt-get install -y \
8585
# $OTHER_PACKAGES \
8686
# && rm -rf /var/lib/apt/lists/*
87-
MULTILINE_PLACEHOLDER
87+
{PLACEHOLDER_MULTILINE}
8888
USER $USERNAME
8989
# Create Gazebo cache directory with correct ownership to avoid permission issues after volume mount
9090
RUN mkdir /home/$USERNAME/.gazebo
9191
# TODO: Run additional commands as non-root user here
92-
MULTILINE_PLACEHOLDER
92+
{PLACEHOLDER_MULTILINE}
9393
COPY .bashrc /home/$USERNAME/.bashrc
9494
# TODO: Copy additional files here
95-
MULTILINE_PLACEHOLDER
95+
{PLACEHOLDER_MULTILINE}
9696
ENTRYPOINT []
9797
CMD ["/bin/bash"]

tests/diff_base/docker/compose.yaml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
services:
2-
PLACEHOLDER-ws:
2+
{PLACEHOLDER}-ws:
33
build:
44
context: .
55
dockerfile: Dockerfile
66
# TODO: Specify the target platform to build the image, otherwise it will build for the host platform.
77
# Reference: https://docs.docker.com/compose/compose-file/build/#platforms
88
# platforms:
99
# - "linux/arm64"
10-
image: j3soon/ros2-PLACEHOLDER-ws
11-
container_name: ros2-PLACEHOLDER-ws
10+
image: j3soon/ros2-{PLACEHOLDER}-ws
11+
container_name: ros2-{PLACEHOLDER}-ws
1212
stdin_open: true
1313
tty: true
1414
# TODO: Comment the line below if the workspace don't need to communicate through `/dev/*` devices.
15-
PLACEHOLDERprivileged: true
15+
{PLACEHOLDER_#}privileged: true
1616
command: /bin/bash
1717
network_mode: host
18-
working_dir: /home/ros2-essentials/PLACEHOLDER_ws
18+
working_dir: /home/ros2-essentials/{PLACEHOLDER}_ws
1919
environment:
2020
# Set X11 server environment variable for existing display.
2121
- DISPLAY=$DISPLAY
@@ -28,18 +28,18 @@ services:
2828
- ROS_DOMAIN_ID=0
2929
# Domain ID is set to 0 to allow communication through ros1_bridge.
3030
- RCUTILS_COLORIZED_OUTPUT=1
31-
- ROS2_WS=/home/ros2-essentials/PLACEHOLDER_ws
31+
- ROS2_WS=/home/ros2-essentials/{PLACEHOLDER}_ws
3232
# TODO: Set more environment variables.
33-
MULTILINE_PLACEHOLDER
33+
{PLACEHOLDER_MULTILINE}
3434
# TODO: Uncomment the lines below to enable GPU support.
35-
# # Reference: https://docs.docker.com/compose/gpu-support/
36-
# deploy:
37-
# resources:
38-
# reservations:
39-
# devices:
40-
# - driver: nvidia
41-
# count: all
42-
# capabilities: [ gpu ]
35+
{PLACEHOLDER_#}# Reference: https://docs.docker.com/compose/gpu-support/
36+
{PLACEHOLDER_#}deploy:
37+
{PLACEHOLDER_#} resources:
38+
{PLACEHOLDER_#} reservations:
39+
{PLACEHOLDER_#} devices:
40+
{PLACEHOLDER_#} - driver: nvidia
41+
{PLACEHOLDER_#} count: all
42+
{PLACEHOLDER_#} capabilities: [ gpu ]
4343
volumes:
4444
# Mount local timezone into container.
4545
# Reference: https://stackoverflow.com/questions/57607381/how-do-i-change-timezone-in-a-docker-container
@@ -51,13 +51,13 @@ MULTILINE_PLACEHOLDER
5151
- $HOME/.Xauthority:/home/user/.Xauthority
5252
# Xauthority is mounted to allow X11 forwarding for remote display.
5353
# Mount Direct Rendering Infrastructure (DRI) for hardware acceleration support such as OpenGL.
54-
PLACEHOLDER- /dev/dri:/dev/dri
54+
{PLACEHOLDER_#}- /dev/dri:/dev/dri
5555
# Mount sound card to prevent Gazebo warning.
56-
PLACEHOLDER- /dev/snd:/dev/snd
56+
{PLACEHOLDER_#}- /dev/snd:/dev/snd
5757
# Mount shared memory for ROS2 communication.
58-
PLACEHOLDER- /dev/shm:/dev/shm
58+
{PLACEHOLDER_#}- /dev/shm:/dev/shm
5959
# TODO: Uncomment the line below and comment out the three entries above to enable USB support.
60-
PLACEHOLDER- /dev:/dev
60+
{PLACEHOLDER_#}- /dev:/dev
6161
# Mount Gazebo models directory to reuse models downloaded during first launch.
6262
# Reference: https://answers.ros.org/question/365658
6363
# Note that this volume is shared among all workspaces.

tests/lint_comp_template.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
current_dir = os.path.dirname(os.path.realpath(__file__))
1010
repo_dir = os.path.realpath(f"{current_dir}/..")
1111

12+
def get_regexp_from_template_line(line):
13+
regexp = re.escape(line) \
14+
.replace(r'\{PLACEHOLDER_\#\}', '(# )?') \
15+
.replace(r'\{PLACEHOLDER\}', '.*')
16+
return f"^{regexp}$"
17+
1218
def compare_file_with_template(filepath, targetpath=None, ignored_workspaces=[]):
1319
targetpath = targetpath or filepath
1420
logging.info(f"Checking if '{targetpath}' matches the template...")
@@ -28,7 +34,7 @@ def error(msg, i):
2834
raise ValueError(f"'{filepath}' does not match the template: '{filename}'")
2935
i = 0
3036
while i < len(diff):
31-
if "- MULTILINE_PLACEHOLDER" in diff[i]: # don't use exact match to avoid cases without trailing newline
37+
if "- {PLACEHOLDER_MULTILINE}" in diff[i]: # don't use exact match to avoid cases without trailing newline
3238
i += 1
3339
while i < len(diff) and diff[i].startswith('+ '):
3440
i += 1
@@ -47,9 +53,9 @@ def error(msg, i):
4753
j += 1
4854
k = 0
4955
while k < len(stack) and j+k < len(diff) and diff[j+k].startswith('+ '):
50-
if "- MULTILINE_PLACEHOLDER" in diff[i+k]:
51-
raise error("MULTILINE_PLACEHOLDER is not supported in this case yet", i)
52-
regexp = "^" + re.escape(diff[i+k][2:]).replace('PLACEHOLDER', '.*') + "$"
56+
if "- {PLACEHOLDER_MULTILINE}" in diff[i+k]:
57+
raise error("{PLACEHOLDER_MULTILINE} is not supported in this case yet", i)
58+
regexp = get_regexp_from_template_line(diff[i+k][2:])
5359
if not re.match(regexp, diff[j+k][2:]):
5460
error("Expected line deletion and addition to differ only in the placeholder", i)
5561
k += 1
@@ -63,9 +69,9 @@ def error(msg, i):
6369
j += 1
6470
k = 0
6571
while k < len(stack) and j+k < len(diff) and diff[j+k].startswith('- '):
66-
if "- MULTILINE_PLACEHOLDER" in diff[j+k]:
67-
raise error("MULTILINE_PLACEHOLDER is not supported in this case yet", i)
68-
regexp = "^" + re.escape(diff[j+k][2:]).replace('PLACEHOLDER', '.*') + "$"
72+
if "- {PLACEHOLDER_MULTILINE}" in diff[j+k]:
73+
raise error("{PLACEHOLDER_MULTILINE} is not supported in this case yet", i)
74+
regexp = get_regexp_from_template_line(diff[j+k][2:])
6975
if not re.match(regexp, diff[i+k][2:]):
7076
error("Expected line deletion and addition to differ only in the placeholder", i)
7177
k += 1

vlp_ws/docker/.bashrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ if [ ! -f $ROS2_WS/install/setup.bash ]; then
2626
echo "Workspace built."
2727
fi
2828
# TODO: Source other workspace environments as underlay
29-
MULTILINE_PLACEHOLDER
3029
# Source workspace environment
3130
source $ROS2_WS/install/setup.bash

0 commit comments

Comments
 (0)