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
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONTAINER_USER=ubuntu
CONTAINER_HOME=/home/ubuntu
51 changes: 51 additions & 0 deletions .github/workflows/update-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Push RMCS Images

on:
workflow_dispatch:
push:
paths:
- 'Dockerfile'
branches:
- main
Comment on lines +3 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

自动触发范围太窄,会漏掉很多实际改变镜像内容的提交。

镜像还依赖 .script/**、模板脚本,以及 rmcs_ws/src(Dockerfile Line 60-63 的 rosdep install 直接读这里)。现在只监听 Dockerfile,这些路径变化后不会自动重建镜像,发布结果会悄悄落后于 main

🔧 建议修正
   push:
     paths:
     - 'Dockerfile'
+    - '.script/**'
+    - 'rmcs_ws/src/**'
+    - '.github/workflows/update-image.yml'
     branches:
     - main
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/update-image.yml around lines 3 - 9, The workflow's push
trigger only watches 'Dockerfile', which misses other files that affect the
image; update the workflow 'on:' push.paths configuration to include the Docker
build inputs such as the scripts and source directories referenced by the
Dockerfile (e.g. add patterns for .script/**, any template script directories,
and rmcs_ws/src/**) so pushes that change those files will also dispatch the
image rebuild; ensure you keep the existing 'Dockerfile' entry and use glob
patterns (/**) to capture nested changes.


jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up SSH keys
run: |
mkdir -p .ssh
chmod 700 .ssh
echo "${{ secrets.CONTAINER_ID_RSA }}" > .ssh/id_rsa
echo "${{ secrets.CONTAINER_ID_RSA_PUB }}" > .ssh/id_rsa.pub
chmod 600 .ssh/id_rsa
chmod 644 .ssh/id_rsa.pub

- name: Build and push rmcs-develop:latest
uses: docker/build-push-action@v6
with:
context: .
push: true
target: rmcs-develop
tags: qzhhhi/rmcs-develop:latest
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- name: Build and push rmcs-runtime:latest
uses: docker/build-push-action@v6
with:
context: .
push: true
target: rmcs-runtime
tags: qzhhhi/rmcs-runtime:latest
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
url = https://github.com/Alliance-Algorithm/ros2-hikcamera.git
[submodule "rmcs_ws/src/serial"]
path = rmcs_ws/src/serial
url = git@github.com:Alliance-Algorithm/ros2-serial.git
url = https://github.com/Alliance-Algorithm/ros2-serial.git
2 changes: 1 addition & 1 deletion .script/attach-remote
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#!/bin/bash

# if arg[1] == "-r"
if [ "$1" == "-r" ]; then
Expand Down
59 changes: 56 additions & 3 deletions .script/build-rmcs
Original file line number Diff line number Diff line change
@@ -1,7 +1,60 @@
#! /bin/bash
#!/bin/bash

source /opt/ros/jazzy/setup.bash

cd /workspaces/RMCS/rmcs_ws
: "${RMCS_PATH:=/workspaces/RMCS}"

colcon build --symlink-install --merge-install
if [[ ! -d "${RMCS_PATH}/rmcs_ws" ]]; then
echo "> ERROR: Workspace not found: ${RMCS_PATH}/rmcs_ws"
exit 1
fi

cd "${RMCS_PATH}"/rmcs_ws || exit 1

[[ -x /opt/cmake/bin/cmake ]] &&
export PATH="/opt/cmake/bin:$PATH"

cmake_toolchain_args=()
event_handlers_args=()

if [[ "${RMCS_USE_LLVM}" == "ON" ]]; then
missing_tools=()
for tool in clang clang++ llvm-ar llvm-ranlib ld.lld ninja; do
if ! command -v "${tool}" &>/dev/null; then
missing_tools+=("${tool}")
fi
done

if ((${#missing_tools[@]} > 0)); then
echo "> ERROR: LLVM toolchain is required when RMCS_USE_LLVM=ON."
echo "> Missing tools: ${missing_tools[*]}"
echo "> Install the missing tools, or set RMCS_USE_LLVM=OFF to build with GCC."
exit 1
fi

echo "> Compiling With LLVM ToolChain"
export CC=clang
export CXX=clang++
cmake_toolchain_args=(
"-GNinja"
"-DCMAKE_MESSAGE_LOG_LEVEL=ERROR"
"-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld"
"-DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld"
"-DCMAKE_AR=$(command -v llvm-ar)"
"-DCMAKE_RANLIB=$(command -v llvm-ranlib)"
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
event_handlers_args=(
--event-handlers console_cohesion+
)
fi

colcon_args=(
--symlink-install --merge-install
"${event_handlers_args[@]}"
)
cmake_args=(
"${cmake_toolchain_args[@]}"
)

CLICOLOR_FORCE=1 NINJA_STATUS="" \
colcon build "${colcon_args[@]}" "$@" --cmake-args "${cmake_args[@]}"
14 changes: 12 additions & 2 deletions .script/clean-rmcs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#! /bin/bash
#!/bin/bash

rm -rf /workspaces/RMCS/rmcs_ws/build /workspaces/RMCS/rmcs_ws/install /workspaces/RMCS/rmcs_ws/log
: "${RMCS_PATH:=/workspaces/RMCS}"

if [[ -z "${RMCS_PATH}" || "${RMCS_PATH}" == "/" ]]; then
echo "Invalid RMCS_PATH: '${RMCS_PATH}'"
exit 1
fi

rm -rf -- \
"${RMCS_PATH}/rmcs_ws/build" \
"${RMCS_PATH}/rmcs_ws/install" \
"${RMCS_PATH}/rmcs_ws/log"
51 changes: 51 additions & 0 deletions .script/complete/_build-rmcs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#compdef build-rmcs

local _comp_func="${_comps[colcon]}"

if [[ -z "${_comp_func}" ]]; then
if (( $+functions[_python_argcomplete] )); then
_comp_func="_python_argcomplete"
elif (( $+functions[_colcon] )); then
_comp_func="_colcon"
else
_message "colcon completion not found. Please source colcon completion setup."
return 1
fi
fi

if [[ "${_comp_func}" == "_python_argcomplete" ]]; then
local IFS=$'\013'
local -a completions
local _comp_line _comp_point

_comp_line="colcon build${BUFFER#build-rmcs}"
_comp_point=$((CURSOR + 2))
Comment on lines +21 to +22

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

COMP_POINT 计算存在边界情况问题。

当光标位于 build-rmcs 命令名称内部时(例如用户输入 build-rm 后按 Tab),CURSOR + 2 的计算可能不准确。字符串替换将 "build-rmcs"(10字符)替换为 "colcon build"(12字符),偏移量 +2 仅在光标位于命令名之后时正确。

🛠️ 建议修复
-    _comp_line="colcon build${BUFFER#build-rmcs}"
-    _comp_point=$((CURSOR + 2))
+    local _cmd_len=${#${BUFFER%%[[:space:]]*}}
+    _comp_line="colcon build${BUFFER#build-rmcs}"
+    if (( CURSOR <= _cmd_len )); then
+        # Cursor within command name, map proportionally
+        _comp_point=$((CURSOR * 12 / 10))
+    else
+        _comp_point=$((CURSOR + 2))
+    fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
_comp_line="colcon build${BUFFER#build-rmcs}"
_comp_point=$((CURSOR + 2))
local _cmd_len=${#${BUFFER%%[[:space:]]*}}
_comp_line="colcon build${BUFFER#build-rmcs}"
if (( CURSOR <= _cmd_len )); then
# Cursor within command name, map proportionally
_comp_point=$((CURSOR * 12 / 10))
else
_comp_point=$((CURSOR + 2))
fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.script/complete/_build-rmcs around lines 21 - 22, The COMP_POINT
calculation is wrong when the cursor sits inside the token "build-rmcs"; update
the logic around _comp_line and _comp_point to compute the true offset using the
length difference between the replacement and original token and the cursor's
position relative to the token. Specifically, locate the start index of
"build-rmcs" in BUFFER, compute delta = ${`#new_token`} - ${`#old_token`}
(new_token="colcon build", old_token="build-rmcs"), and if CURSOR is after the
token start adjust _comp_point = CURSOR + delta (or keep CURSOR unchanged if
before the token); reference variables/functions: _comp_line, _comp_point,
BUFFER, CURSOR and the token "build-rmcs" when implementing this fix.


completions=($(IFS="$IFS" \
COMP_LINE="${_comp_line}" \
COMP_POINT="${_comp_point}" \
_ARGCOMPLETE=1 \
_ARGCOMPLETE_SHELL="zsh" \
_ARGCOMPLETE_SUPPRESS_SPACE=1 \
__python_argcomplete_run colcon))

_describe colcon completions -o nosort
return 0
fi

local -a _orig_words
local _orig_current

_orig_words=("${words[@]}")
_orig_current=${CURRENT}

words=(colcon build "${_orig_words[@]:1}")
CURRENT=$((_orig_current + 1))

"${_comp_func}" "$@"
local status=$?

words=("${_orig_words[@]}")
CURRENT=${_orig_current}

return $status
7 changes: 7 additions & 0 deletions .script/complete/_play-autoaim
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#compdef play-autoaim

_arguments \
'--user[Remote username]:username:' \
'--remote[Pull SDP from device into container]' \
'--no-copy[Skip copy from container to host]' \
'--ip[IP address of monitor host]:ip:'
22 changes: 22 additions & 0 deletions .script/complete/_set-remote
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#compdef set-remote

_remote_hosts() {
local hosts=(
"169.254.233.233"
"alliance-sentry.local"
"alliance-infantry.local"
"alliance-hero.local"
)

# Extract recently used HostName from ~/.ssh/config
if [[ -f ~/.ssh/config ]]; then
local extracted
extracted=(${(f)"$(grep -A1 'Host remote' ~/.ssh/config | grep HostName | awk '{print $2}')"})
hosts+=(${extracted})
fi

compadd -- $hosts
}

_arguments \
'1:Remote host address:_remote_hosts'
5 changes: 5 additions & 0 deletions .script/foxglove
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source ~/env_setup.bash

ros2 launch foxglove_bridge foxglove_bridge_launch.xml port:=8765
96 changes: 96 additions & 0 deletions .script/host/rmcs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash

set -euo pipefail

readonly DEVELOPER_NAME="ubuntu"
readonly NVIM_PATH="/opt/nvim-linux-x86_64/bin/nvim"
readonly NVIM_PORT=6666
readonly NVIM_HOST="localhost"

function show_help() {
local project_dir="$1"
local service="$2"
echo "Usage: $(basename "$0") [path] [zsh|n|nvim|neovide|vim|ide]"
echo " Project dir: $project_dir"
echo " Service: $service"
}

function rmcs_zsh() {
local service="$1"
echo "Starting and entering container..."
docker compose up -d
docker compose exec "$service" zsh
}

function rmcs_nvim() {
local service="$1"
local timeout=10
local success=0
local port=$NVIM_PORT

echo "Starting container..."
docker compose up -d

echo "Checking available port and starting nvim headless server..."
while nc -z "$NVIM_HOST" "$port" 2>/dev/null; do
echo "Port $port is occupied, trying next..."
port=$((port + 1))
done

echo "Starting nvim server on port $port..."
docker compose exec -u "$DEVELOPER_NAME" -d "$service" \
"$NVIM_PATH" --headless --listen "$NVIM_HOST:$port"

for i in $(seq 1 $timeout); do
if nc -z "$NVIM_HOST" "$port" 2>/dev/null; then
echo "nvim server started on port $port"
success=1
break
fi
echo "Waiting for nvim server to start... ($i/$timeout)"
sleep 1
done

if [ $success -eq 1 ]; then
echo "Starting neovide..."
nohup neovide --server="$NVIM_HOST:$port" >/dev/null 2>&1 &
else
echo "nvim server failed to start within $timeout seconds, neovide not launched"
exit 1
fi
}

function main() {
local project_dir command

if [ -d "${1:-}" ]; then
project_dir="$(cd "$1" && pwd)"
command="${2:-}"
else
project_dir="$(pwd)"
command="${1:-}"
fi

cd "$project_dir" || exit 1

if [ ! -f "docker-compose.yml" ]; then
echo "Error: docker-compose.yml not found in current directory"
exit 1
fi

local service="rmcs-develop"

case "$command" in
zsh)
rmcs_zsh "$service"
;;
n | nvim | neovide | vim | ide)
rmcs_nvim "$service"
;;
*)
show_help "$project_dir" "$service"
;;
esac
}

main "$@"
2 changes: 1 addition & 1 deletion .script/launch-rmcs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#!/bin/bash

source ~/env_setup.bash

Expand Down
Loading