Add version check to keep CMake version up-to-date (#1025)

This commit is contained in:
Eddy Ashton 2020-04-02 13:32:28 +01:00 коммит произвёл GitHub
Родитель 7e67cbb4bb
Коммит f74f8e7e10
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 26 добавлений и 2 удалений

Просмотреть файл

@ -11,15 +11,23 @@ jobs:
- script: find . -type f -regex ".*\.sh$" | egrep -v "^./3rdparty/" | xargs shellcheck -s bash -e SC2044,SC2002,SC1091
displayName: 'Shell Check'
condition: succeededOrFailed()
- script: ./check-cmake-version-vs-tag.sh
displayName: 'Check project version in CMake against git tag'
condition: succeededOrFailed()
- script: ./check-todo.sh src
displayName: 'Check for TODOs'
condition: succeededOrFailed()
- script: ./check-format.sh src samples
displayName: 'Check C++ code format'
condition: succeededOrFailed()
- script: python3.7 notice-check.py
displayName: 'Check CCF copyright notices'
condition: succeededOrFailed()
- script: |
python3.7 -m venv env
@ -27,9 +35,11 @@ jobs:
pip install black
black --check sphinx/ tests/ notice-check.py
displayName: 'Check Python code format'
condition: succeededOrFailed()
- script: |
source env/bin/activate
pip install cmake_format
cmake-format --check CMakeLists.txt $(find ./cmake ./samples ./src ./tests -name "*.cmake" | tr "\n" " ")
displayName: 'Check CMake code format'
displayName: 'Check CMake code format'
condition: succeededOrFailed()

Просмотреть файл

@ -7,7 +7,7 @@ include(${CCF_DIR}/cmake/preproject.cmake)
project(
ccf
VERSION 0.8.2
VERSION 0.9.1 # CCF_VERSION < This is a search marker for CI version check
LANGUAGES C CXX
)

14
check-cmake-version-vs-tag.sh Executable file
Просмотреть файл

@ -0,0 +1,14 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.
git_tag=$(git describe --tags --abbrev=0)
git_tag=${git_tag#v}
cmake_version=$(grep CCF_VERSION CMakeLists.txt | grep -Po "(\d)+(\.(\d)+)*")
# Check git tag is <= CMake version. Use sort --version-sort to handle semver (0.9 < 0.10)
if echo "$git_tag $cmake_version" | tr " " "\n" | sort --version-sort -c ; then
echo "Git tag ($git_tag) is safely <= CMake version ($cmake_version)"
else
echo "Git tag ($git_tag) is later than CMake version ($cmake_version) - please update CMake version!"
exit 1
fi