Skip to content

add new cut cmake version #265

add new cut cmake version

add new cut cmake version #265

name: static_analysis
on:
push:
branches: ['**']
pull_request:
branches: ['**']
jobs:
#---------------------------------------------------------------------------------------------------#
# We verify the minimal CMake version we support is preserved when building with default CMake flags
minimal_cmake_version:
name: "Minimal CMake version"
timeout-minutes: 30
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: "Install Dependencies"
run: |
work_dir=$(pwd)
# Go back from RealSense directory to parent directory
cd ..
git clone https://github.com/nlohmann/cmake_min_version.git
cd cmake_min_version
# We clone a specific commit which we tested the process as working
git checkout 687dc56e1cf52c865cebf6ac94ad67906d6e1369
echo "Install LibRealSense pre-installed packages requirements"
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev at
python3 -mvenv venv
venv/bin/pip3 install -r requirements.txt
- name: "Get Current CMake version"
id: cmake_version
run: |
work_dir=$(pwd)
cd ..
cd cmake_min_version
venv/bin/python3 cmake_downloader.py --latest_release
output=$(venv/bin/python3 cmake_min_version.py $work_dir)
echo "$output"
# Retrieve CMake minimal version from the last line of the tool output.
current_cmake_version=$(echo ${output} | grep "cmake_minimum_required")
regex_pattern="VERSION [0-9]+\.[0-9]+\.[0-9]+"
if ! [[ "$current_cmake_version" =~ $regex_pattern ]];
then
echo "Error - CMake version $current_cmake_version does not match the pattern VERSION dd.dd.dd"
exit 1
fi
# Leave only digits of major and minor version in the variable
current_cmake_version=$(echo ${current_cmake_version} | grep -oP "\d+\.\d+")
echo "Debug: cmake_minimum_required = $cmake_minimum_required"
# Saving cmake minimal version string in GitHub output
echo "current_cmake_version=$current_cmake_version" >> $GITHUB_OUTPUT
- name: "Check minimal CMake version"
env:
EXPECTED_CMAKE_MAJOR_VER: 3
EXPECTED_CMAKE_MINOR_VER: 8
CURRENT_CMAKE_VERSION: ${{ steps.cmake_version.outputs.current_cmake_version }}
run: |
echo "CURRENT_CMAKE_VERSION $CURRENT_CMAKE_VERSION"
CURRENT_CMAKE_MAJOR_VER=$(echo $CURRENT_CMAKE_VERSION | cut -d'.' -f 1)
CURRENT_CMAKE_MINOR_VER=$(echo $CURRENT_CMAKE_VERSION | cut -d'.' -f 2)
if [ "$CURRENT_CMAKE_MAJOR_VER" \< "${EXPECTED_CMAKE_MAJOR_VER}" ]
then
STATUS="PASSED"
elif [ "$CURRENT_CMAKE_MAJOR_VER" == "${EXPECTED_CMAKE_MAJOR_VER}" ] && [ "$CURRENT_CMAKE_MINOR_VER" == "${EXPECTED_CMAKE_MINOR_VER}" ]
then
STATUS="PASSED"
elif [ "$CURRENT_CMAKE_MAJOR_VER" == "${EXPECTED_CMAKE_MAJOR_VER}" ] && [ "$CURRENT_CMAKE_MINOR_VER" \< "${EXPECTED_CMAKE_MINOR_VER}" ]
then
STATUS="PASSED"
else
STATUS="FAILED"
fi
if [ "$STATUS" == "PASSED" ]
then
echo "The test PASSED, current CMake version is $CURRENT_CMAKE_VERSION and it is not higher than VERSION ${EXPECTED_CMAKE_MAJOR_VER}.${EXPECTED_CMAKE_MINOR_VER}"
else
echo "Error - The minimal CMake version required for LibRS is ${EXPECTED_CMAKE_MAJOR_VER}.${EXPECTED_CMAKE_MINOR_VER} but on this build the minimal CMake version that works is $CURRENT_CMAKE_VERSION"
exit 1
fi