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

420 feature execute catkin make on docker compose up #497

Merged
merged 3 commits into from
Nov 14, 2024

Conversation

vinzenzm
Copy link
Collaborator

@vinzenzm vinzenzm commented Nov 12, 2024

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Does this PR introduce a breaking change?

e.g. is old functionality not usable anymore

Most important changes

Which files functionalities are most important in this PR. On which part should the reviewer be focussed on?

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (might be obsolete with CI later on)
  • New and existing unit tests pass locally with my changes (might be obsolete with CI later on)

Summary by CodeRabbit

  • New Features
    • Added a recommended extension for Visual Studio Code: "augustocdias.tasks-shell-input".
    • Introduced a new task in Visual Studio Code to run catkin_make within a Docker container, allowing users to easily build their ROS workspace.

These updates enhance the development experience by streamlining task execution and providing useful extension recommendations.

catkin_make inside the container.

One of them is more convenient as a list of containers is automatically provided.
It however depends on a vscode extension not yet in recomendations.
We might need to select one of the two options and remove the other.
As the addition of a vscode extension is no problem,
 the cumbersome way of selecting the task via an input field was removed.
This now requires the tasksshellinput extension.
@vinzenzm vinzenzm linked an issue Nov 12, 2024 that may be closed by this pull request
2 tasks
Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

Walkthrough

The changes involve updates to two Visual Studio Code configuration files. The .vscode/extensions.json file now includes a new recommended extension for tasks, while the .vscode/tasks.json file introduces a new task designed to run catkin_make within a Docker container. This task allows users to select a running container from a list and executes the necessary commands to build a ROS workspace.

Changes

File Change Summary
.vscode/extensions.json Added extension "augustocdias.tasks-shell-input" to the recommendations array.
.vscode/tasks.json Introduced a new task "Run 'catkin_make' in docker container. Choose container from list of running containers." and added input "container_name" of type command.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VSCode
    participant Docker

    User->>VSCode: Select task "Run 'catkin_make' in docker container"
    VSCode->>User: Show list of running containers
    User->>VSCode: Choose a container
    VSCode->>Docker: Execute command to enter container
    Docker-->>VSCode: Container access granted
    VSCode->>Docker: Navigate to `catkin_ws` and source ROS setup
    VSCode->>Docker: Run `catkin_make`
    Docker-->>VSCode: Build completed
Loading

🐰 "In the garden of code, new tasks take flight,
With containers to choose, our futures are bright.
Extensions abound, a shell input delight,
Let's build with our friends, from morning till night!" 🌼


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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

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: 0

🧹 Outside diff range and nitpick comments (1)
.vscode/tasks.json (1)

1-22: This implementation doesn't meet the PR objective

The PR's objective is to "execute catkin make on docker compose up", but these changes only add a manual VS Code task. To achieve the actual objective, you should:

  1. Modify the docker-compose.yml to run catkin_make during container startup
  2. Consider using a Docker entrypoint script that:
    • Checks if build is needed
    • Runs catkin_make
    • Starts the actual application

Would you like assistance in implementing the correct solution in docker-compose.yml?

🧰 Tools
🪛 Biome

[error] 10-10: Expected a property but instead found '}'.

Expected a property here.

(parse)


[error] 19-19: Expected a property but instead found '}'.

Expected a property here.

(parse)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 49792b5 and 676073e.

📒 Files selected for processing (2)
  • .vscode/extensions.json (1 hunks)
  • .vscode/tasks.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .vscode/extensions.json
🧰 Additional context used
🪛 Biome
.vscode/tasks.json

[error] 10-10: Expected a property but instead found '}'.

Expected a property here.

(parse)


[error] 19-19: Expected a property but instead found '}'.

Expected a property here.

(parse)

🔇 Additional comments (2)
.vscode/tasks.json (2)

12-21: 🛠️ Refactor suggestion

Input configuration needs improvement for better error handling

The current implementation has several issues:

  1. No filtering of containers (might list unrelated containers)
  2. No handling of empty container list
  3. JSON formatting issues

Consider this improved implementation:

 "inputs": [
     {
         "id": "container_name",
         "type": "command",
         "command": "shellCommand.execute",
         "args": {
-            "command": "docker ps --format '{{.Names}}'"
+            "command": "docker ps --filter 'label=com.docker.compose.project=paf' --format '{{.Names}}' | grep . || echo 'No running PAF containers found' >&2"
-        }
+        },
+        "description": "Select a running PAF container"
     }
 ]

Let's verify the container labeling:

#!/bin/bash
# Check if docker-compose configuration properly labels containers
rg -g 'docker-compose*.yml' 'labels:'
🧰 Tools
🪛 Biome

[error] 19-19: Expected a property but instead found '}'.

Expected a property here.

(parse)


4-10: ⚠️ Potential issue

Task configuration needs improvements for reliability and security

Several issues need to be addressed:

  1. The -it flags are unnecessary for automated task execution and could cause issues
  2. Relative path navigation (../../) is fragile and could break if the workspace structure changes
  3. The command assumes bash is available in the container
  4. No error handling for failed commands
  5. This task configuration doesn't achieve the PR objective of running catkin_make on docker-compose up

Consider this improved implementation:

 {
     "label": "Run 'catkin_make' in docker container. Choose container from list of running containers.",
     "type": "shell",
-    "command": "docker exec -it ${input:container_name} bash -c 'cd ../../catkin_ws && source /opt/ros/noetic/setup.bash && bash devel/setup.bash && catkin_make'",
+    "command": "docker exec ${input:container_name} sh -c '[ -d /catkin_ws ] || exit 1; cd /catkin_ws && source /opt/ros/noetic/setup.sh && if [ -f devel/setup.sh ]; then . devel/setup.sh; fi && catkin_make'",
     "problemMatcher": [],
-    "detail": "Executes 'catkin_make' selected container. Requires Tasks Shell Input Extension, in order to generate the list of containers.",
+    "detail": "Executes 'catkin_make' in selected container. Note: This is a manual task. For automatic builds, modify docker-compose.yml instead."
 }

Let's verify the container configuration:

🧰 Tools
🪛 Biome

[error] 10-10: Expected a property but instead found '}'.

Expected a property here.

(parse)

Copy link
Collaborator

@THDThieleT THDThieleT left a comment

Choose a reason for hiding this comment

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

this PR does not change much, only adds one line in the extensions json.
The creation of the tasks.json file should not break the project

@vinzenzm vinzenzm merged commit b0be4de into main Nov 14, 2024
4 checks passed
@ll7 ll7 deleted the 420-feature-execute-catkin_make-on-docker-compose-up branch November 15, 2024 09:59
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.

[Feature]: Execute catkin_make on docker compose up
2 participants