From bef81668938e9dd48fefa4896eaca9840171bf8d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 17 Nov 2020 09:58:27 +0100 Subject: [PATCH] build: add make-check step to check and generate ".gitlab-ci.yml" --- Makefile.am | 6 ++++++ meson.build | 6 ++++++ tools/check-gitlab-ci.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100755 tools/check-gitlab-ci.sh diff --git a/Makefile.am b/Makefile.am index 12b9736d2f..7fa353f1a4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5013,6 +5013,11 @@ EXTRA_DIST += \ clients/tests/test-client.check-on-disk/test_004.expected \ $(NULL) +check-local-gitlab-ci: + "$(srcdir)/tools/check-gitlab-ci.sh" "$(srcdir)" + +check_local += check-local-gitlab-ci + ############################################################################### # data ############################################################################### @@ -5302,6 +5307,7 @@ EXTRA_DIST += \ tools/check-docs.sh \ tools/check-exports.sh \ tools/check-compare-generated.sh \ + tools/check-gitlab-ci.sh \ tools/create-exports-NetworkManager.sh \ tools/debug-helper.py \ tools/meson-post-install.sh \ diff --git a/meson.build b/meson.build index bd99b79ca6..9461708712 100644 --- a/meson.build +++ b/meson.build @@ -803,6 +803,12 @@ else endif endif +test( + 'check-local-gitlab-ci', + find_program(join_paths(source_root, 'tools', 'check-gitlab-ci.sh')), + args: [source_root], +) + # Tests, utilities and documentation tests = get_option('tests') enable_tests = (tests != 'no') diff --git a/tools/check-gitlab-ci.sh b/tools/check-gitlab-ci.sh new file mode 100755 index 0000000000..da5fcc597b --- /dev/null +++ b/tools/check-gitlab-ci.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e + +if [ $# -eq 0 ] ; then + BASEDIR="$(dirname "$(readlink -f "$0")")/.." +elif [ $# -eq 1 ] ; then + BASEDIR="$1" +else + echo "invalid arguments" + exit 1 +fi + +cd "$BASEDIR" + +if ! [ -f ./.gitlab-ci.yml ] ; then + # we have no gitlab-ci. Probably this is not a git-checkout + # but a dist'ed source-tree. Nothing to check. + exit 0 +fi + +if ! ci-fairy --help 2>&1 >/dev/null ; then + # ci-fairy not available. Cannot check. + exit 0 +fi + + +if [ "$NM_TEST_REGENERATE" == 1 ] ; then + ci-fairy generate-template + exit 0 +fi + +diff "./.gitlab-ci.yml" <(ci-fairy generate-template -o /dev/stdout)