From f74f8e7e1008195d1c469ead55a9f5afd031a6de Mon Sep 17 00:00:00 2001 From: Eddy Ashton Date: Thu, 2 Apr 2020 13:32:28 +0100 Subject: [PATCH] Add version check to keep CMake version up-to-date (#1025) --- .azure-pipelines-templates/checks.yml | 12 +++++++++++- CMakeLists.txt | 2 +- check-cmake-version-vs-tag.sh | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 check-cmake-version-vs-tag.sh diff --git a/.azure-pipelines-templates/checks.yml b/.azure-pipelines-templates/checks.yml index 03b9fb15f6..43ffb3f11a 100644 --- a/.azure-pipelines-templates/checks.yml +++ b/.azure-pipelines-templates/checks.yml @@ -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' \ No newline at end of file + displayName: 'Check CMake code format' + condition: succeededOrFailed() diff --git a/CMakeLists.txt b/CMakeLists.txt index ae26101c6b..37375dda8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ) diff --git a/check-cmake-version-vs-tag.sh b/check-cmake-version-vs-tag.sh new file mode 100755 index 0000000000..a15ddf512b --- /dev/null +++ b/check-cmake-version-vs-tag.sh @@ -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 \ No newline at end of file