Skip to content

Conversation

patrickelectric
Copy link
Member

@patrickelectric patrickelectric commented Sep 14, 2025

Summary by Sourcery

Add validation for GIT_DESCRIBE_TAGS in the bootstrap Dockerfile and correct the docker run examples in code and documentation to use the proper mount path and image name

Enhancements:

  • Validate GIT_DESCRIBE_TAGS build argument format in bootstrap Dockerfile to prevent invalid builds
  • Update docker run example in main.py and README to fix config volume mount path and align the image name with blueos-bootstrap

Copy link

sourcery-ai bot commented Sep 14, 2025

Reviewer's Guide

This PR adds validation of Git-describe tags during the Docker build and updates bootstrap usage examples to correct image names and volume mount paths.

Class diagram for Dockerfile build argument validation

classDiagram
    class Dockerfile {
        +ARG GIT_DESCRIBE_TAGS
        +ENV GIT_DESCRIBE_TAGS
        +RUN: Validate GIT_DESCRIBE_TAGS format
    }
Loading

File-Level Changes

Change Details Files
Enforce Git-describe tags in Docker build
  • Add GIT_DESCRIBE_TAGS build argument and default environment variable
  • Insert shell script to check for presence of GIT_DESCRIBE_TAGS and validate its format
  • Provide error messages and exit codes for missing or invalid tags
bootstrap/Dockerfile
Correct bootstrap container command in logs
  • Specify target mount for $HOME/.config/blueos as /root/.config/blueos
  • Fix spacing in the log string to properly include the image argument
bootstrap/main.py
Update README with new image name
  • Change Docker run example to use 'bluerobotics/blueos-bootstrap:master'
bootstrap/README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Consider extracting the Dockerfile's version-validation RUN block into a separate script or file to improve readability and maintainability.
  • The multi-line string concatenation in main.py for the docker run example is hard to read; using a single triple-quoted string or textwrap.dedent can simplify it.
  • You may want to centralize the image name and default config paths as constants to avoid duplication between README, Dockerfile, and Python code.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the Dockerfile's version-validation RUN block into a separate script or file to improve readability and maintainability.
- The multi-line string concatenation in main.py for the docker run example is hard to read; using a single triple-quoted string or textwrap.dedent can simplify it.
- You may want to centralize the image name and default config paths as constants to avoid duplication between README, Dockerfile, and Python code.

## Individual Comments

### Comment 1
<location> `bootstrap/Dockerfile:7` </location>
<code_context>
+# The format can be invalid if someone is build BlueOS without a tag as reference
+ARG GIT_DESCRIBE_TAGS
+ENV GIT_DESCRIBE_TAGS=${GIT_DESCRIBE_TAGS:-0.0.0-0-g00000000}
+RUN <<-EOF
+set -e
+
+    if [ -z "$GIT_DESCRIBE_TAGS" ]; then
+        echo "GIT_DESCRIBE_TAGS argument not provided."
+        echo "Use: --build-arg GIT_DESCRIBE_TAGS=\$(git describe --tags --long --always)"
+        exit 1
+    fi
+
+    if [[ ! $GIT_DESCRIBE_TAGS =~ -[0-9]+-g[a-f0-9]{8}$ ]]; then
+        echo "Invalid format: $GIT_DESCRIBE_TAGS (E.g: <TAG>-<COMMIT_NUMBER>-g<SHORT_HASH>)"
+        exit 1
+    fi
+
+EOF
+
 COPY startup.json.default bootstrap/ /bootstrap/
</code_context>

<issue_to_address>
The Dockerfile uses bash-specific syntax (e.g., [[ ... ]]) which may not be supported by /bin/sh.

To ensure compatibility, either specify bash explicitly in the RUN command or replace [[ ... ]] with POSIX-compliant [ ... ] syntax.
</issue_to_address>

### Comment 2
<location> `bootstrap/main.py:20` </location>
<code_context>
         logger.info("Example docker command line:")
         logger.info(
             "docker run -it -v /var/run/docker.sock:/var/run/docker.sock"
-            " -v $HOME/.config/blueos:"
+            " -v $HOME/.config/blueos:/root/.config/blueos"
             " -v /var/logs/blueos:/var/logs/blueos"
-            "/root/.config/blueos -e BLUEOS_CONFIG_PATH=$HOME/.config/blueos"
</code_context>

<issue_to_address>
The volume mapping now explicitly maps $HOME/.config/blueos to /root/.config/blueos.

This mapping only works if the container runs as root. Please document or address cases where a different user is used.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 7 to 10
RUN <<-EOF
set -e

if [ -z "$GIT_DESCRIBE_TAGS" ]; then
echo "GIT_DESCRIBE_TAGS argument not provided."
echo "Use: --build-arg GIT_DESCRIBE_TAGS=\$(git describe --tags --long --always)"
exit 1
fi

if [[ ! $GIT_DESCRIBE_TAGS =~ -[0-9]+-g[a-f0-9]{8}$ ]]; then
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): The Dockerfile uses bash-specific syntax (e.g., [[ ... ]]) which may not be supported by /bin/sh.

To ensure compatibility, either specify bash explicitly in the RUN command or replace [[ ... ]] with POSIX-compliant [ ... ] syntax.

logger.info("Example docker command line:")
logger.info(
"docker run -it -v /var/run/docker.sock:/var/run/docker.sock"
" -v $HOME/.config/blueos:"
Copy link

Choose a reason for hiding this comment

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

suggestion: The volume mapping now explicitly maps $HOME/.config/blueos to /root/.config/blueos.

This mapping only works if the container runs as root. Please document or address cases where a different user is used.

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
It's set by default

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
@joaoantoniocardoso joaoantoniocardoso merged commit 27e991c into bluerobotics:master Sep 24, 2025
7 checks passed
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.

2 participants