Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ros2 add docker #469

Merged
merged 5 commits into from
Dec 20, 2024
Merged

Ros2 add docker #469

merged 5 commits into from
Dec 20, 2024

Conversation

rafal-gorecki
Copy link
Contributor

@rafal-gorecki rafal-gorecki commented Dec 17, 2024

Waiting on: #467

Description

  • add panther-docker functionalities into husarion_ugv repo
  • clean up workflows

Requirements

  • Code style guidelines followed
  • Documentation updated

Tests 🧪

  • Robot (build only)
  • Container
  • Simulation

Summary by CodeRabbit

  • New Features

    • Introduced new Docker Compose configurations for hardware, RViz, and simulation environments.
    • Added new scripts for environment setup and configuration file updates.
    • Enhanced README documentation for Docker images with detailed usage instructions.
  • Bug Fixes

    • Improved handling of environment variables in Docker configurations.
  • Documentation

    • Updated README.md for Docker images with comprehensive usage and setup instructions.
  • Chores

    • Added new GitHub Actions workflows for building Docker images and managing releases.
    • Updated existing workflows for clarity and enhanced functionality.

Copy link
Contributor

coderabbitai bot commented Dec 17, 2024

Walkthrough

This pull request introduces significant changes to the project's Docker and GitHub Actions configurations. Modifications include enhancements to the Docker build process through new Dockerfiles for hardware and simulation environments, updates to multiple workflow files with renamed jobs and refined triggers, and the addition of utility scripts for environment setup. The changes aim to streamline the continuous integration and deployment strategies of the project.

Changes

File Change Summary
.dockerignore Added entries to ignore hidden files and the docker/ directory
.github/workflows/* Multiple workflow files updated with renamed jobs, refined triggers, and updated action versions
docker/Dockerfile.hardware New Dockerfile for hardware-specific ROS environment
docker/Dockerfile.simulation New Dockerfile for simulation ROS environment
docker/demo/* Added Docker Compose files for hardware, RViz, and simulation configurations
docker/utils/ Added setup_environment.sh and update_config_directory.sh utility scripts
husarion_ugv/package.xml Updated dependencies with conditional build type checks

Sequence Diagram

sequenceDiagram
    participant Workflow as GitHub Actions
    participant Docker as Docker Build
    participant Config as Configuration Scripts
    
    Workflow->>Docker: Trigger Docker build
    Docker->>Config: Run setup_environment.sh
    Config->>Config: Check and update config directory
    Config-->>Docker: Configuration ready
    Docker->>Docker: Build image
    Docker-->>Workflow: Image build complete
Loading

Possibly related PRs

  • Charging Dock Plugin based on dock pose subscriber #431: The main PR modifies the .dockerignore file to streamline Docker builds, while this PR introduces a new executable related to the dock_pose_publisher, which may involve Docker configurations for the docking functionality.
  • ROS2 docking nav2 #443: This PR includes changes to the docking_components.yaml file, which may relate to the Docker context by defining components that could be affected by the .dockerignore modifications.
  • Ros2 devel pr template #458: Although primarily focused on the pull request template, this PR's emphasis on dependencies could indirectly relate to the changes in the main PR regarding Docker configurations.
  • Readme files minor fixes  #463: The README updates in this PR may include references to Docker configurations or usage, which could be relevant to the changes made in the main PR regarding the .dockerignore file.

Suggested reviewers

  • Gomez33

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rafal-gorecki rafal-gorecki requested a review from KmakD December 18, 2024 11:37
rafal-gorecki and others added 2 commits December 20, 2024 14:38
* Update workflow

* Clean up

* Update workflow version

* update token

* Update tags in compose files

* Fixes

* Fix

* fix

* Fix

* Change action name

* Update docker/Dockerfile.hardware

Co-authored-by: Dawid Kmak <73443304+KmakD@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Dawid Kmak <73443304+KmakD@users.noreply.github.com>

* Add envs to compose

* Add needs

* Update docker/demo/compose.simulation.yaml

Co-authored-by: Dawid Kmak <73443304+KmakD@users.noreply.github.com>

---------

Co-authored-by: action-bot <action-bot@action-bot.com>
Co-authored-by: Dawid Kmak <73443304+KmakD@users.noreply.github.com>
@rafal-gorecki rafal-gorecki marked this pull request as ready for review December 20, 2024 13:43
@rafal-gorecki
Copy link
Contributor Author

rafal-gorecki commented Dec 20, 2024

Merged without aprove because it's a secondary branch to see the differences between panther-docker after the port.
The correct aprove is:

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

🔭 Outside diff range comments (2)
.github/workflows/unit-tests.yaml (1)

Line range hint 4-9: Enable pull request trigger for automated testing

The pull request trigger is currently disabled with a TODO comment. This means tests aren't automatically run on PRs, which could lead to quality issues.

Remove the TODO comment and uncomment the pull request trigger:

on:
  workflow_dispatch:
-  # TODO: ENABLE WHEN READY
-  # pull_request:
-  #     branches:
-  #         - ros2-devel
+  pull_request:
+    branches:
+      - ros2-devel
.github/workflows/release-repository.yaml (1)

Line range hint 52-122: Add error handling for critical GitHub CLI operations.

The workflow performs critical operations (merging PRs, creating releases) without proper error handling. Consider adding error checking and fallback mechanisms.

Example improvement:

- gh pr merge ${{ github.event.inputs.release_candidate }} \
-   --merge --delete-branch
+ if ! gh pr merge ${{ github.event.inputs.release_candidate }} \
+   --merge --delete-branch; then
+   echo "::error::Failed to merge PR"
+   exit 1
+ fi
🧹 Nitpick comments (19)
docker/demo/.env.cpu (1)

2-3: Document performance implications of software rendering.

Consider adding a comment explaining that LIBGL_ALWAYS_SOFTWARE=1 forces software rendering, which might impact performance but ensures compatibility in CPU-only environments.

docker/utils/setup_environment.sh (1)

1-11: Consider adding security measures for config management.

The script should:

  1. Validate file permissions after copying
  2. Consider using checksums for copied files
  3. Add logging for audit trail

Would you like me to provide an example implementation with these security measures?

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 8-8: Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.

(SC2010)

docker/demo/compose.rviz.yaml (1)

19-29: Consider documenting X11 prerequisites and version update strategy.

The configuration is well-structured, but consider:

  1. Document X11 setup requirements for users
  2. Define a strategy for updating the pinned image version

Consider adding a comment in the compose file or documentation about:

  • Required X11 setup on the host
  • How/when to update the image version
docker/demo/compose.simulation.yaml (1)

1-27: Consider consolidating common configurations.

The configuration blocks are duplicated across compose files. Consider:

  1. Moving common configurations to a shared compose file
  2. Using Docker Compose's extends feature or including shared YAML files

Example approach:

# docker/demo/compose.common.yaml
x-common-config: &common-config
  network_mode: host
  ipc: host
  environment:
    - RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
    # ... other common env vars

Then in service-specific files:

include:
  - compose.common.yaml
.github/workflows/protect-default-branch.yaml (1)

Line range hint 2-27: Branch protection logic looks good, consider enhancing error reporting.

The branch naming validation is well-implemented with clear patterns. Consider:

  1. Adding more detailed error messages that include examples of valid branch names
  2. Logging the actual branch name in the error message

Example enhancement:

- echo "PRs must come from branches containing 'hotfix' phrase or matching X.X.X-YYYYMMDD pattern."
+ echo "Invalid branch name: ${{ github.head_ref }}"
+ echo "Branch names must either:"
+ echo "- Contain 'hotfix' (e.g., feature-hotfix-123)"
+ echo "- Match pattern X.X.X-YYYYMMDD (e.g., 1.2.3-20241225)"
docker/Dockerfile.simulation (3)

19-22: Consider using vcs for specific controller versions.

Instead of manually copying specific controllers, consider using a more maintainable approach by specifying exact versions in the .repos file. This would make updates easier to track and manage.


30-31: Make version extraction more robust.

The current version extraction using grep and sed could fail with malformed XML. Consider using xmllint or similar XML-aware tools.

-echo $(cat /ros2_ws/src/husarion_ugv/husarion_ugv/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt
+echo $(xmllint --xpath "string(//version)" /ros2_ws/src/husarion_ugv/husarion_ugv/package.xml) >> /version.txt

1-38: Add HEALTHCHECK instruction.

Consider adding a Docker HEALTHCHECK to ensure the ROS2 environment is functioning correctly.

+HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
+    CMD source /opt/ros/$ROS_DISTRO/setup.bash && ros2 node list || exit 1

Also, consider creating a non-root user for better security:

+RUN groupadd -g 1001 ros && \
+    useradd -u 1000 -g ros -s /bin/bash -m ros && \
+    echo "ros ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/ros
+USER ros
docker/utils/update_config_directory.sh (2)

38-39: Avoid hardcoded user/group IDs.

The script uses hardcoded user (1000) and group (1001) IDs. Consider making these configurable through environment variables.

-chown -R 1000:1001 /config
+: "${CONFIG_USER_ID:=1000}"
+: "${CONFIG_GROUP_ID:=1001}"
+chown -R "$CONFIG_USER_ID:$CONFIG_GROUP_ID" /config

1-39: Add verbose mode and proper error handling.

Consider adding a verbose mode for debugging and proper error handling throughout the script.

 #!/bin/bash
 set -e
+set -o pipefail
+
+# Enable debug mode with DEBUG=1
+[[ ${DEBUG:-0} == 1 ]] && set -x
+
+# Log error messages
+error() {
+  echo "ERROR: $*" >&2
+}
+
+# Log info messages when verbose
+info() {
+  [[ ${VERBOSE:-0} == 1 ]] && echo "INFO: $*"
+}
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 8-8: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 16-16: Declare and assign separately to avoid masking return values.

(SC2155)

docker/Dockerfile.hardware (2)

1-7: Consider adding platform-specific build args

The Dockerfile looks well-structured, but consider adding TARGETPLATFORM and BUILDPLATFORM build args for multi-architecture support, especially since this is for hardware deployment.

ARG ROS_DISTRO=humble
+ARG TARGETPLATFORM
+ARG BUILDPLATFORM

FROM husarnet/ros:${ROS_DISTRO}-ros-core

14-37: Optimize the RUN layer to reduce image size

The build process is correct but could be optimized to reduce the final image size:

  1. Consider combining apt-get update with installation
  2. Use --no-install-recommends for apt-get
  3. Move version extraction before cleanup to avoid potential issues
-RUN apt-get update  && \
+RUN apt-get update && \
     apt-get install -y \
+        --no-install-recommends \
         ros-dev-tools && \
     # Setup workspace
     vcs import src < src/husarion_ugv/husarion_ugv/${HUSARION_ROS_BUILD_TYPE}_deps.repos && \
     cp -r src/ros2_controllers/diff_drive_controller src && \
     cp -r src/ros2_controllers/imu_sensor_broadcaster src && \
     rm -rf src/ros2_controllers && \
     # Install dependencies
     rosdep init && \
     rosdep update --rosdistro $ROS_DISTRO && \
     rosdep install --from-paths src -y -i && \
     # Build
     source /opt/ros/$ROS_DISTRO/setup.bash && \
     colcon build --symlink-install --packages-up-to husarion_ugv --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$BUILD_TEST && \
+    # Get version
+    echo $(cat /ros2_ws/src/husarion_ugv/husarion_ugv/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \
     # Size optimization
     export SUDO_FORCE_REMOVE=yes && \
     apt-get remove -y \
         ros-dev-tools && \
     apt-get autoremove -y && \
     apt-get clean && \
-    rm -rf /var/lib/apt/lists/*
-    # Get version
-    echo $(cat /ros2_ws/src/husarion_ugv/husarion_ugv/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt
+    rm -rf /var/lib/apt/lists/*
docker/demo/compose.hardware.yaml (1)

1-7: Consider adding health checks to common configuration

The common configuration looks good but could benefit from health checks to ensure service stability.

x-common-config: &common-config
  network_mode: host
  ipc: host
  restart: always
+  healthcheck:
+    test: ["CMD-SHELL", "ros2 node list || exit 1"]
+    interval: 30s
+    timeout: 10s
+    retries: 3
  env_file:
    - /home/husarion/config/common/.env
docker/README.md (2)

36-41: Improve configuration backup instructions

The note about configuration backup could be more detailed and include actual commands.

   > [!NOTE]
-   > This may overwrite your changes made in the `config` directory. If you want to keep your configuration you should skip this step or create backup of the `config` directory.
+   > This will overwrite your changes in the `config` directory. To preserve your configurations:
+   > 1. Create a backup: `cp -r /home/husarion/config /home/husarion/config.backup`
+   > 2. After updating, review and merge your changes from the backup

   ```bash
   docker run --rm -v /home/husarion/config:/config husarion/panther:humble-<newest_tag> update_config_directory

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 LanguageTool</summary>

[uncategorized] ~37-~37: Possible missing comma found.
Context: ...ig` directory. If you want to keep your configuration you should skip this step or create bac...

(AI_HYDRA_LEO_MISSING_COMMA)

---

[uncategorized] ~37-~37: Possible missing article found.
Context: ...ion you should skip this step or create backup of the `config` directory.     ```bash ...

(AI_HYDRA_LEO_MISSING_A)

</details>

</details>

---

`68-71`: **Enhance NVIDIA GPU configuration instructions**

The note about NVIDIA GPU configuration could be more detailed and include verification steps.

Add verification steps:
```bash
# Verify NVIDIA Container Toolkit installation
nvidia-ctk --version
nvidia-container-cli info

# Test GPU access
docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
🧰 Tools
🪛 LanguageTool

[style] ~68-~68: Using many exclamation marks might seem excessive (in this case: 4 exclamation marks for a text that’s 2364 characters long)
Context: ...e -f compose.simulation.yaml up ``` > [!NOTE] > > 1. You can change robot model ...

(EN_EXCESSIVE_EXCLAMATION)


[uncategorized] ~71-~71: Possible missing article found.
Context: ...DIA Container Toolkit installed, modify following Docker compose file by replacing `*cpu-...

(AI_HYDRA_LEO_MISSING_THE)

.github/workflows/build-docker.yaml (1)

71-85: Consider adding Docker image security scanning

The workflow builds Docker images but doesn't include security scanning. Consider adding a step to scan for vulnerabilities.

You could add Trivy scanning after the build step:

      - name: Scan Docker Image
        uses: aquasecurity/trivy-action@master
        with:
          image-ref: 'your-image-name:${{ matrix.tag }}'
          format: 'table'
          exit-code: '1'
          ignore-unfixed: true
          vuln-type: 'os,library'
          severity: 'CRITICAL,HIGH'
.github/workflows/unit-tests.yaml (1)

Line range hint 13-14: Review security implications of self-hosted runner

Using a self-hosted runner can expose your infrastructure to security risks, especially if the workflow can be triggered by external pull requests.

Consider:

  1. Implementing proper job isolation
  2. Using GitHub-hosted runners for public repositories
  3. Adding security controls for workflow dispatch triggers
.github/workflows/release-candidate.yaml (1)

75-79: Validate access token usage

The workflow uses RAFAL_ACCESS_TOKEN for cross-repository operations. Consider using a dedicated service account instead of a personal access token.

Best practices for cross-repository access:

  1. Use GitHub Apps instead of personal access tokens
  2. Limit token permissions to the minimum required
  3. Rotate tokens regularly
  4. Use environment secrets for different environments
.github/workflows/release-repository.yaml (1)

Line range hint 63-67: Consider simplifying complex conditional expressions.

While the fromJSON usage for boolean parsing is correct, consider extracting complex conditions into shell variables or composite conditions for better readability.

Example refactor:

- if: ${{ github.event.inputs.release_candidate != env.MAIN_BRANCH && fromJSON(inputs.automatic_mode) == true }}
+ if: ${{ env.IS_NOT_MAIN_BRANCH == 'true' && fromJSON(inputs.automatic_mode) == true }}

Add at the job level:

env:
  IS_NOT_MAIN_BRANCH: ${{ github.event.inputs.release_candidate != env.MAIN_BRANCH }}

Also applies to: 73-77, 84-88, 95-104

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 644e008 and e673e44.

📒 Files selected for processing (19)
  • .dockerignore (1 hunks)
  • .github/workflows/build-docker.yaml (1 hunks)
  • .github/workflows/pre-commit.yaml (1 hunks)
  • .github/workflows/protect-default-branch.yaml (1 hunks)
  • .github/workflows/release-candidate.yaml (2 hunks)
  • .github/workflows/release-project.yaml (3 hunks)
  • .github/workflows/release-repository.yaml (1 hunks)
  • .github/workflows/unit-tests.yaml (2 hunks)
  • docker/Dockerfile.hardware (1 hunks)
  • docker/Dockerfile.simulation (1 hunks)
  • docker/README.md (1 hunks)
  • docker/demo/.env.cpu (1 hunks)
  • docker/demo/.env.gpu (1 hunks)
  • docker/demo/compose.hardware.yaml (1 hunks)
  • docker/demo/compose.rviz.yaml (1 hunks)
  • docker/demo/compose.simulation.yaml (1 hunks)
  • docker/utils/setup_environment.sh (1 hunks)
  • docker/utils/update_config_directory.sh (1 hunks)
  • husarion_ugv/package.xml (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • .dockerignore
  • .github/workflows/pre-commit.yaml
🧰 Additional context used
🪛 LanguageTool
docker/README.md

[style] ~26-~26: Consider a more expressive alternative.
Context: ... physical robot or run a simulation. To do this, clone this repository to your rob...

(DO_ACHIEVE)


[uncategorized] ~37-~37: Possible missing comma found.
Context: ...ig` directory. If you want to keep your configuration you should skip this step or create bac...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~37-~37: Possible missing article found.
Context: ...ion you should skip this step or create backup of the config directory. ```bash ...

(AI_HYDRA_LEO_MISSING_A)


[uncategorized] ~61-~61: Possible missing comma found.
Context: ...mulation To give Docker access to your screen run: ```bash xhost local:docker docker...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~68-~68: Using many exclamation marks might seem excessive (in this case: 4 exclamation marks for a text that’s 2364 characters long)
Context: ...e -f compose.simulation.yaml up ``` > [!NOTE] > > 1. You can change robot model ...

(EN_EXCESSIVE_EXCLAMATION)


[uncategorized] ~71-~71: Possible missing article found.
Context: ...DIA Container Toolkit installed, modify following Docker compose file by replacing `*cpu-...

(AI_HYDRA_LEO_MISSING_THE)

🪛 Shellcheck (0.10.0)
docker/utils/update_config_directory.sh

[warning] 8-8: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 16-16: Declare and assign separately to avoid masking return values.

(SC2155)

docker/utils/setup_environment.sh

[warning] 8-8: Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.

(SC2010)

🪛 actionlint (1.7.4)
.github/workflows/build-docker.yaml

11-11: input "build_type" of workflow_call event has the default value "development", but it is also required. if an input is marked as required, its default value will never be used

(events)

🔇 Additional comments (12)
docker/demo/.env.cpu (1)

1-1: LGTM! Good error handling for DISPLAY variable.

The parameter expansion with error message is a good practice to catch configuration issues early.

docker/demo/.env.gpu (1)

1-1: LGTM! Consistent error handling with CPU version.

The DISPLAY variable configuration maintains consistency across environments.

docker/demo/compose.rviz.yaml (2)

10-13: Verify the existence of .env.cpu file.

The configuration references an external environment file.

Let's check if the file exists and its contents:

✅ Verification successful

Environment file exists with required display configurations

The .env.cpu file exists in the expected location with appropriate display-related environment variables:

  • DISPLAY: Ensures X11 display is properly configured
  • LIBGL_ALWAYS_SOFTWARE: Forces software rendering
  • QT_X11_NO_MITSHM: Disables MIT-SHM X11 extension
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if .env.cpu exists and its contents
if [ -f "docker/demo/.env.cpu" ]; then
    echo "File exists"
    cat "docker/demo/.env.cpu"
else
    echo "File not found"
fi

Length of output: 187


14-18: Verify the existence of .env.gpu file and NVIDIA runtime requirements.

The configuration properly sets up NVIDIA runtime support.

Let's check the GPU environment file and documentation:

✅ Verification successful

GPU configuration is properly documented and implemented

The verification confirms:

  • .env.gpu file exists with correct NVIDIA environment variables
  • GPU configuration is documented in docker/README.md with instructions for NVIDIA Container Toolkit installation
  • GPU config is consistently used across multiple compose files (compose.rviz.yaml and compose.simulation.yaml)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check GPU-related files and documentation
if [ -f "docker/demo/.env.gpu" ]; then
    echo "GPU env file exists"
    cat "docker/demo/.env.gpu"
fi

# Check if README mentions NVIDIA runtime requirements
rg -i "nvidia" README.md

Length of output: 243


Script:

#!/bin/bash
# Let's check for any documentation about GPU requirements or setup
fd -t f "README|INSTALL|SETUP|CONTRIBUTING" -e md -X rg -i "gpu|nvidia"

# Check if there are any other GPU-related environment files
fd -t f ".env" -X rg -i "gpu|nvidia"

# Check if there are any GPU-related configuration files
fd -t f "compose|config|settings" -e yml -e yaml -X rg -i "gpu|nvidia"

Length of output: 1040

husarion_ugv/package.xml (1)

18-19: Verify ROS2 environment variable condition support.

The conditional dependencies based on $HUSARION_ROS_BUILD_TYPE are a good practice for separating hardware and simulation dependencies. However, let's verify if this approach is supported in ROS2.

docker/Dockerfile.hardware (1)

42-43: Verify the entrypoint script modification

The sed command modifies all files ending with _entrypoint.sh. This could be risky if there are multiple such files.

.github/workflows/build-docker.yaml (1)

58-65: Verify platform compatibility for Docker builds

The matrix configuration specifies different platforms for hardware (arm64) and simulation (amd64). Ensure these platform choices align with your deployment requirements.

✅ Verification successful

Platform choices are appropriate for the intended deployment

The platform choices in the matrix configuration are correctly aligned with deployment requirements:

  • Hardware Dockerfile (arm64): Uses a generic ROS base image husarnet/ros:${ROS_DISTRO}-ros-core and includes hardware-specific dependencies through hardware_deps.repos. This is appropriate for ARM-based hardware deployments.
  • Simulation Dockerfile (amd64): Uses the same base image but includes simulation-specific dependencies through simulation_deps.repos. This is suitable for desktop/server simulation environments.

Both Dockerfiles are platform-agnostic in their instructions, relying on the build platform specified in the workflow matrix, and the dependencies are managed through ROS's platform-aware package management system (rosdep).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check Dockerfile contents for platform-specific instructions
echo "Checking hardware Dockerfile for ARM-specific instructions:"
rg -n 'FROM.*arm|RUN.*arm' docker/Dockerfile.hardware

echo "Checking simulation Dockerfile for AMD64-specific instructions:"
rg -n 'FROM.*amd|RUN.*amd' docker/Dockerfile.simulation

Length of output: 379


Script:

#!/bin/bash
# Let's check the base images and any platform-specific configurations in both Dockerfiles
echo "=== Hardware Dockerfile contents ==="
cat docker/Dockerfile.hardware

echo -e "\n=== Simulation Dockerfile contents ==="
cat docker/Dockerfile.simulation

# Also check if there are any platform-specific build arguments or configurations in the workflow file
echo -e "\n=== GitHub Workflow file contents ==="
cat .github/workflows/build-docker.yaml

Length of output: 6010

.github/workflows/release-candidate.yaml (1)

48-52: Add validation for Docker image tags

The sed commands modify Docker compose files without validating the resulting content.

.github/workflows/release-project.yaml (3)

Line range hint 2-29: LGTM! Well-structured workflow inputs with clear validation requirements.

The input parameters are well-documented with explicit format requirements for version and date stamps.


37-44: Security improvement: Using local workflow file.

Good practice using a local workflow file instead of referencing an external repository, which reduces supply chain security risks.


46-49: Verify the 'development' build type configuration.

Please ensure that the build_type: development parameter is properly handled in the build-docker.yaml workflow.

✅ Verification successful

Let me check the actual content of the workflow file to see how the build_type parameter is used.


The 'development' build type parameter is properly configured and used

The build_type parameter is correctly:

  • Defined as a workflow input with proper description and validation
  • Has "development" as the default value
  • Properly passed to the downstream action (husarion-ci/ros-docker-img-action)
  • Used consistently across both workflow_call and workflow_dispatch triggers
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check how build_type parameter is used in the workflow
rg -l "build_type|development" .github/workflows/build-docker.yaml

Length of output: 104


Script:

#!/bin/bash
# Display the content of build-docker.yaml to analyze build_type parameter usage
cat .github/workflows/build-docker.yaml

Length of output: 2829

.github/workflows/release-repository.yaml (1)

Line range hint 2-29: LGTM! Well-structured reusable workflow with typed inputs.

Good improvements:

  • Added explicit type definitions for all inputs
  • Clear parameter documentation
  • Appropriate default values for boolean flags

docker/demo/.env.gpu Show resolved Hide resolved
docker/utils/setup_environment.sh Show resolved Hide resolved
docker/utils/setup_environment.sh Show resolved Hide resolved
docker/demo/compose.rviz.yaml Show resolved Hide resolved
docker/utils/update_config_directory.sh Show resolved Hide resolved
docker/demo/compose.hardware.yaml Show resolved Hide resolved
docker/README.md Show resolved Hide resolved
.github/workflows/build-docker.yaml Show resolved Hide resolved
.github/workflows/release-candidate.yaml Show resolved Hide resolved
.github/workflows/release-project.yaml Show resolved Hide resolved
@rafal-gorecki rafal-gorecki merged commit a229d32 into ros2-devel Dec 20, 2024
3 of 5 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
.github/workflows/release-candidate.yaml (1)

32-38: ⚠️ Potential issue

Critical: Remove TODO and implement unit tests

Skipping unit tests in the release candidate workflow is a critical issue that could lead to quality problems in releases.

🧹 Nitpick comments (1)
.github/workflows/release-candidate.yaml (1)

58-59: Consider using GitHub Actions bot for commits.

Instead of using a custom action-bot, consider using the default GitHub Actions bot credentials:

-          author_name: action-bot
-          author_email: action-bot@action-bot.com
+          author_name: github-actions[bot]
+          author_email: github-actions[bot]@users.noreply.github.com
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e673e44 and 54dac0f.

📒 Files selected for processing (1)
  • .github/workflows/release-candidate.yaml (2 hunks)
🔇 Additional comments (1)
.github/workflows/release-candidate.yaml (1)

Line range hint 2-17: LGTM! Well-structured workflow configuration.

The workflow trigger configuration is well-defined with clear input validations and proper environment variable setup.

with:
owner: husarion
repo: docs_new
github_token: ${{ secrets.GH_PAT }}
workflow_file_name: test-release.yml
github_token: ${{ secrets.RAFAL_ACCESS_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider using GITHUB_TOKEN instead of personal access token.

Using a personal access token (RAFAL_ACCESS_TOKEN) could be a security risk as these tokens typically have broader permissions. Consider using GITHUB_TOKEN if possible, or ensure the personal token has minimal required permissions.

Comment on lines +72 to +79
- name: Create new branch
uses: GuillaumeFalourd/create-other-repo-branch-action@v1.5
with:
owner: husarion
repo: panther-docker
github_token: ${{ secrets.GH_PAT }}
workflow_file_name: ros-docker-image.yaml
ref: ${{ env.RC_BRANCH_NAME }}
client_payload: |
{
"panther_codebase_version": "${{ env.RC_BRANCH_NAME }}",
"build_type": "development",
"target_distro": "humble"
}
repository_owner: husarion
repository_name: panther-rpi-os-img
new_branch_name: ${{ env.RC_BRANCH_NAME }}
new_branch_ref: ros2-devel
access_token: ${{ secrets.RAFAL_ACCESS_TOKEN}}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add timeouts and error handling for external operations.

The workflow makes multiple external calls without proper timeout controls or error handling:

  1. Branch creation could fail silently
  2. External workflow triggers have no timeout specified
  3. Personal access token is used repeatedly

Consider these improvements:

  1. Add timeout to workflow triggers:
 uses: convictional/trigger-workflow-and-wait@v1.6.5
 with:
+  trigger_workflow_timeout: '3600'  # 1 hour timeout
  1. Use GITHUB_TOKEN where possible or centralize the token usage:
-  github_token: ${{ secrets.RAFAL_ACCESS_TOKEN }}
+  github_token: ${{ secrets.GITHUB_TOKEN }}
  1. Add error handling for branch creation:
 - name: Create new branch
   uses: GuillaumeFalourd/create-other-repo-branch-action@v1.5
+  id: create_branch
   with:
     repository_owner: husarion
     repository_name: panther-rpi-os-img
     new_branch_name: ${{ env.RC_BRANCH_NAME }}
     new_branch_ref: ros2-devel
     access_token: ${{ secrets.RAFAL_ACCESS_TOKEN}}
+  continue-on-error: true
+
+- name: Check branch creation
+  if: steps.create_branch.outcome == 'failure'
+  run: |
+    echo "Failed to create branch"
+    exit 1

Also applies to: 86-86, 101-101

Comment on lines +48 to +52
- name: Update docker image tag
run: |
sed -i 's/\(husarion\/panther:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.hardware.yaml
sed -i 's/\(husarion\/panther:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.rviz.yaml
sed -i 's/\(husarion\/panther-gazebo:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.simulation.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for sed operations.

The sed commands could fail silently if the files don't exist or if the patterns aren't found. Consider adding error checking:

-          sed -i 's/\(husarion\/panther:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.hardware.yaml
-          sed -i 's/\(husarion\/panther:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.rviz.yaml
-          sed -i 's/\(husarion\/panther-gazebo:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.simulation.yaml
+          for file in docker/demo/compose.{hardware,rviz}.yaml; do
+            if [ ! -f "$file" ]; then
+              echo "Error: $file not found"
+              exit 1
+            fi
+            if ! sed -i 's/\(husarion\/panther:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' "$file"; then
+              echo "Error: Failed to update $file"
+              exit 1
+            fi
+          done
+          
+          if [ ! -f "docker/demo/compose.simulation.yaml" ]; then
+            echo "Error: compose.simulation.yaml not found"
+            exit 1
+          fi
+          if ! sed -i 's/\(husarion\/panther-gazebo:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.simulation.yaml; then
+            echo "Error: Failed to update compose.simulation.yaml"
+            exit 1
+          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
- name: Update docker image tag
run: |
sed -i 's/\(husarion\/panther:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.hardware.yaml
sed -i 's/\(husarion\/panther:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.rviz.yaml
sed -i 's/\(husarion\/panther-gazebo:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.simulation.yaml
- name: Update docker image tag
run: |
for file in docker/demo/compose.{hardware,rviz}.yaml; do
if [ ! -f "$file" ]; then
echo "Error: $file not found"
exit 1
fi
if ! sed -i 's/\(husarion\/panther:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' "$file"; then
echo "Error: Failed to update $file"
exit 1
fi
done
if [ ! -f "docker/demo/compose.simulation.yaml" ]; then
echo "Error: compose.simulation.yaml not found"
exit 1
fi
if ! sed -i 's/\(husarion\/panther-gazebo:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.simulation.yaml; then
echo "Error: Failed to update compose.simulation.yaml"
exit 1
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant