Skip to content

Generate version.h with git branch and commit hash#2793

Merged
rhaschke merged 6 commits intomoveit:masterfrom
captain-yoshi:git-commit-hash
Sep 9, 2022
Merged

Generate version.h with git branch and commit hash#2793
rhaschke merged 6 commits intomoveit:masterfrom
captain-yoshi:git-commit-hash

Conversation

@captain-yoshi
Copy link
Copy Markdown
Contributor

@captain-yoshi captain-yoshi commented Jul 29, 2021

Description

This PR stores the git current branch and commit hash into the version header file. This is needed for benchmarking different commits so we can aggregate the results. This was taken from this blog who lead to this git repo.

Pitfalls

You have to re-cmake to update the hash definition. There is another solution that will force a re-configure of cmake before a build every time the HEAD commit changes.

Discussion

There may be better ways to find the .git folder.

We could remove the else block and define the git information as an empty string before the execute_process function.

Result

Generated version.h file:

#ifndef MOVEIT_VERSION_
#define MOVEIT_VERSION_
 
#define MOVEIT_VERSION "1.1.5-Alpha"
 
#define MOVEIT_VERSION_MAJOR 1
#define MOVEIT_VERSION_MINOR 1
#define MOVEIT_VERSION_PATCH 5
#define MOVEIT_VERSION_EXTRA "Alpha"
 
#define MOVEIT_GIT_BRANCH "git-commit-hash"
#define MOVEIT_GIT_COMMIT_HASH "f733739ec99bfa72f534d2b65c693dc0cfe696a3"
 
#endif

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 29, 2021

Codecov Report

Merging #2793 (1991b6c) into master (0a0fc56) will decrease coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2793      +/-   ##
==========================================
- Coverage   62.12%   62.09%   -0.02%     
==========================================
  Files         375      375              
  Lines       33144    33144              
==========================================
- Hits        20586    20577       -9     
- Misses      12558    12567       +9     
Impacted Files Coverage Δ
.../ompl_interface/src/detail/constrained_sampler.cpp 43.91% <0.00%> (-17.07%) ⬇️
...eit_ros/manipulation/pick_place/src/pick_place.cpp 88.58% <0.00%> (-3.80%) ⬇️
...ipulation/pick_place/src/manipulation_pipeline.cpp 73.56% <0.00%> (-0.82%) ⬇️
...nning_scene_monitor/src/planning_scene_monitor.cpp 66.35% <0.00%> (-0.12%) ⬇️
...raint_samplers/src/default_constraint_samplers.cpp 81.29% <0.00%> (+0.30%) ⬆️
...meterization/work_space/pose_model_state_space.cpp 81.77% <0.00%> (+1.77%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@simonschmeisser
Copy link
Copy Markdown
Contributor

With our internal jenkins CI we need to use the following as it otherwise shows the branch as "head"

if (DEFINED ENV{BRANCH_NAME})
    set(GIT_BRANCH $ENV{BRANCH_NAME})
else ()
    execute_process(
        COMMAND
            git rev-parse --abbrev-ref HEAD
        WORKING_DIRECTORY
            ${CMAKE_CURRENT_SOURCE_DIR}
        RESULT_VARIABLE
            GIT_BRANCH_RESULT
        OUTPUT_VARIABLE
            GIT_BRANCH
        OUTPUT_STRIP_TRAILING_WHITESPACE
    )
endif ()

don't know if that's need/works with github ci

@v4hn
Copy link
Copy Markdown
Contributor

v4hn commented Jul 30, 2021

You have to re-cmake to update the hash definition

That's a pretty harsh requirement and would lead to incorrect results for user workspaces (including mine) the whole time!
If somehow possible I would like to avoid that pitfall.

There is another solution that will force a re-configure of cmake before a build every time the HEAD commit changes

What does that mean for catkin workspaces? it's also a hassle if catkin_make/catkin build has to configure the whole workspace each time. If that should be the case (I would expect that), maybe there's a way to generate the hash entry at build-time instead of using configure_file?
EDIT: @jspricke just pointed out add_custom_command which is pretty much what I had in mind. It would still requires some scripting to get this to only touch the header if the version/commit changed.

Also, we probably want to add the hash as output to moveit_version

@rhaschke
Copy link
Copy Markdown
Contributor

rhaschke commented Sep 8, 2022

I fixed the open issues:

@rhaschke rhaschke changed the title [WIP] Generate header with git branch and commit hash Generate version.h with git branch and commit hash Sep 9, 2022
@rhaschke rhaschke merged commit 9225971 into moveit:master Sep 9, 2022
sjahr added a commit to sjahr/moveit that referenced this pull request Jun 21, 2024
* docker.yaml: Enable caching
* [TEMP] moveit2_rolling.repos: add not yet released packages
* Skip broken ci-testing image: osrf/ros2:testing doesn't contain /opt/ros!
* use boost::timer::progress_display if available
   check for header to stay compatible with ubuntu 20.04.
   Support boost >= 1.83

   Slightly ugly due to the double alias, but boost::timer was a class
   before 1.72, so using `boost::timer::progress_display` in the code
   breaks with older versions.
* cherry-pick of moveit#3547 from MoveIt1
* Tag ci image as ci-testing as well

---------

Co-authored-by: Michael Görner <me@v4hn.de>
Co-authored-by: Sebastian Jahr <sebastian.jahr@picknik.ai>
Co-authored-by: Henning Kayser <henningkayser@picknik.ai>
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.

4 participants