Skip to content

Commit 6efe866

Browse files
Copilotwdconinc
andauthored
feat: add CMake check to verify project version agrees with schema version (#144)
Schema version in `edm4eic.yaml` must equal `100*major + 10*minor + patch` from `CMakeLists.txt`, but this was neither enforced nor in sync (850 vs 860 for version 8.6.0). ## Changes - **Fixed version mismatch**: Updated `schema_version` from 850 to 860 - **CMake check**: Fails configuration if `schema_version ≠ 100*VERSION_MAJOR + 10*VERSION_MINOR + VERSION_PATCH` The check runs at CMake configure time, extracts versions, computes expected schema version, and fails with clear error messages on mismatch: ```cmake # In CMakeLists.txt - runs at configure time math(EXPR EXPECTED_SCHEMA_VERSION "${VERSION_MAJOR} * 100 + ${VERSION_MINOR} * 10 + ${VERSION_PATCH}") if(NOT SCHEMA_VERSION EQUAL EXPECTED_SCHEMA_VERSION) message(FATAL_ERROR "Schema version mismatch: ...") endif() ``` This CMake-based validation ensures any build attempt will fail if versions are out of sync, eliminating the need for a separate CI workflow. Patch version changes remain schema-invariant as documented. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>CI check to verify project version agrees with schema version</issue_title> > <issue_description>**Is your feature request related to a problem? Please describe.** > Sometimes the project version in CMakeLists.txt is updated without updating the version number in edm4eic.yml, or the other way round. > > **Describe the solution you'd like** > A small CI test should verify that the project version and schema version are always in sync. Possibly this can also be implemented as a CMake requirement and CMake configuration can fail in case of disagreement.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #143 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
1 parent 0473067 commit 6efe866

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@ SET( ${PROJECT_NAME}_VERSION_MINOR 6 )
1111
SET( ${PROJECT_NAME}_VERSION_PATCH 0 )
1212
SET( ${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}" )
1313

14+
# Verify that schema version in edm4eic.yaml matches project version
15+
# Schema version is defined as 100*major + 10*minor + patch
16+
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/edm4eic.yaml" EDM4EIC_YAML_CONTENT)
17+
string(REGEX MATCH "schema_version:[ \t]*([0-9]+)" SCHEMA_VERSION_MATCH "${EDM4EIC_YAML_CONTENT}")
18+
if(SCHEMA_VERSION_MATCH)
19+
set(SCHEMA_VERSION ${CMAKE_MATCH_1})
20+
math(EXPR EXPECTED_SCHEMA_VERSION "${${PROJECT_NAME}_VERSION_MAJOR} * 100 + ${${PROJECT_NAME}_VERSION_MINOR} * 10 + ${${PROJECT_NAME}_VERSION_PATCH}")
21+
if(NOT SCHEMA_VERSION EQUAL EXPECTED_SCHEMA_VERSION)
22+
message(FATAL_ERROR
23+
"Schema version mismatch: edm4eic.yaml has schema_version=${SCHEMA_VERSION}, "
24+
"but CMakeLists.txt version ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH} "
25+
"requires schema_version=${EXPECTED_SCHEMA_VERSION}. "
26+
"Please update schema_version in edm4eic.yaml to match the project version.")
27+
endif()
28+
else()
29+
message(WARNING "Could not find schema_version in edm4eic.yaml")
30+
endif()
31+
1432
# C++ standard
1533
set(CMAKE_CXX_STANDARD_MIN 17)
1634
set(CMAKE_CXX_STANDARD 17 CACHE STRING "Set the C++ standard to be used")

edm4eic.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Some datatypes based on EDM4hep. EDM4hep license applies to those sections.
44
---
55
## Schema versioning
6-
## This is required to be an integer, and defined as 100*major+minor.
6+
## This is required to be an integer, and defined as 100*major+10*minor+patch.
77
## Patch level changes are required to be schema invariant.
88
##
99
## If there are schema version changes that can be evolved, see the podio documentation

0 commit comments

Comments
 (0)