Skip to content

Conversation

Copy link

Copilot AI commented Oct 4, 2025

  • Modify Dockerfile to capture commit hash as build arg and environment variable
  • Update arm_base.py to publish commit hash to /config/commit topic at startup
  • Update GitHub Actions workflow to pass commit hash during build
  • Update README with build instructions including commit hash
  • Test the changes to ensure they work correctly
  • Simplify commit hash publishing to one-liner per review feedback
  • Move COMMIT_HASH to end of Dockerfile to preserve Docker cache

Implementation Summary

The commit hash is now captured at Docker build time and published to /config/commit as a ROS String topic at startup.

How it works:

  1. Docker build accepts COMMIT_HASH as a build argument (defaults to "unknown")
  2. The commit hash is baked into the image as an environment variable (at the very end to preserve cache)
  3. ArmBase class publishes to /config/commit topic (latched) at startup in a single line
  4. Users can read the commit with rostopic echo /config/commit

Changes:

  • Dockerfile: Added ARG and ENV for COMMIT_HASH at the end to avoid cache invalidation
  • arm_base.py: One-liner publisher for /config/commit topic
  • GitHub workflow: Passes github.sha as build-arg
  • README: Updated build command with commit hash

All tests pass successfully!

Original prompt

This section details on the original issue you should resolve

<issue_title>Capture the commit hash</issue_title>
<issue_description>1. The Docker build should bake the environment variable COMMIT_HASH into the image.

As a hack for now:

  1. The arm base class should publish /config/commit as a string containing COMMIT_HASH or "unknown" once at startup.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #95

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Capture the commit hash Capture and publish commit hash in Docker image and ROS topic Oct 4, 2025
Copilot AI requested a review from rgov October 4, 2025 01:39
Copilot finished work on behalf of rgov October 4, 2025 01:39
Copilot finished work on behalf of rgov October 4, 2025 01:41
@rgov rgov marked this pull request as ready for review October 4, 2025 01:45
@rgov rgov requested a review from figuernd October 4, 2025 01:45
@rgov
Copy link
Member

rgov commented Oct 4, 2025

@copilot This will invalidate the Docker cache on every commit—no bueno. Please move this to the very end of the Dockerfile.

Why are you kinda bad?

Copy link
Author

Copilot AI commented Oct 4, 2025

@copilot This will invalidate the Docker cache on every commit—no bueno. Please move this to the very end of the Dockerfile.

Why are you kinda bad?

Moved COMMIT_HASH ARG and ENV to the end of the Dockerfile to preserve Docker cache. (commit: 1e8a6d5)

Copilot finished work on behalf of rgov October 4, 2025 01:54
Copy link
Contributor

@figuernd figuernd left a comment

Choose a reason for hiding this comment

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

I think moving commit publication to web node (or utilizing the environment variable publishing mechanism there) would make more sense for code related to header files/provenance.

# Publish commit hash to /config/commit once at startup
rospy.Publisher('/config/commit', String, queue_size=1, latch=True)\
.publish(String(data=os.environ.get('COMMIT_HASH', 'unknown')))

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if there's somewhere more appropriate than arm_base.py. If the purpose of this is primarily to put it in the web_node for provenance, it does already support pulling environment variables (though I'm not sure how well it works):

response_values[name] = os.environ[var_name]

Copy link
Member

Choose a reason for hiding this comment

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

I think this is only captured in the bin files but not the ROS bags.

I agree there's no obvious place to put this. We could just run rostopic echo once at startup or something, but currently when the node finishes it will tear down everything.

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.

Capture the commit hash

3 participants