From 5856b3c9c5962de9bf334344f3e8138e679868e3 Mon Sep 17 00:00:00 2001 From: project-repo Date: Fri, 17 Feb 2023 21:54:11 +0100 Subject: [PATCH] Add semantic versioning check --- meson.build | 1 + test/versions | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/versions diff --git a/meson.build b/meson.build index e73851e..e906db7 100644 --- a/meson.build +++ b/meson.build @@ -355,3 +355,4 @@ test('Arguments', find_program('test/arguments'), args : [ meson.project_version test('Environment Variables', find_program('test/environment-variables'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'basic') test('Scan-build (static analysis)', find_program('test/scan-build'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release') test('Check for strings indicating problems', find_program('test/illegal-strings'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release') +test('Semantic versioning', find_program('test/versions'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release') diff --git a/test/versions b/test/versions new file mode 100644 index 0000000..b408c71 --- /dev/null +++ b/test/versions @@ -0,0 +1,42 @@ +#!/bin/bash +# Copyright 2023, project-repo and the cagebreak contributors +# SPDX-License-Identifier: MIT + +readonly newversion="${1}" +# shellcheck disable=2155 +readonly oldversion=$(git describe --match=master --abbrev=0) + +RESULT=0 + +# meson.build version +if [[ $(vercmp "${newversion}" "${oldversion}") -gt 0 ]] +then + echo "[x] meson.build version respects semantic versioning" +else + RESULT=1 + echo "[ ] meson.build version is NOT semantic version" +fi + +# shellcheck disable=2164 +cd "${MESONCURRENTCONFIGDIR}" + +for file in man/* +do + if [[ $(head -1 "${file}" | cut -d ' ' -f 3 | rev | cut -c2- | rev ) = "${newversion}" ]] + then + echo "[x] ${file} version is meson.build version" + else + RESULT=1 + echo "[ ] ${file} version is NOT meson.build version" + fi +done + +if head -3 README.md | tail -1 | grep -q "minversion=${newversion}" +then + echo "[x] README.md repology minversion" +else + RESULT=1 + echo "[ ] README.md repology minversion" +fi + +exit "${RESULT}"