From a844696d02691a9a2488365dbb0452d0b5b4bb79 Mon Sep 17 00:00:00 2001 From: Michel Jouvin Date: Tue, 12 Nov 2024 22:38:53 +0100 Subject: [PATCH] Update CI scripts --- .ci-scripts/test-library | 4 + .ci-scripts/test-templates | 438 ++++++++++++++++++ .github/workflows/continuous-integration.yaml | 2 + 3 files changed, 444 insertions(+) create mode 100755 .ci-scripts/test-templates diff --git a/.ci-scripts/test-library b/.ci-scripts/test-library index 6bb5bec7..794381c4 100755 --- a/.ci-scripts/test-library +++ b/.ci-scripts/test-library @@ -2,6 +2,10 @@ set -e # halt script on error +echo GITHUB_REPOSITORY: ${GITHUB_REPOSITORY} +echo GITHUB_BASE_REF: ${GITHUB_BASE_REF} +echo GITHUB_WORKSPACE: ${GITHUB_WORKSPACE} + # Retrieve last version of create-vanilla-SCDB from GitHub echo "Downloading create-vanilla-SCDB from GitHub..." rm -f /tmp/create-vanilla-SCDB.sh diff --git a/.ci-scripts/test-templates b/.ci-scripts/test-templates new file mode 100755 index 00000000..ba2b8e23 --- /dev/null +++ b/.ci-scripts/test-templates @@ -0,0 +1,438 @@ +#!/bin/bash +# +# Create one big profile including all pan templates and try to compile it +# (optional) arguments: +# clean: runs git clean (and will remove changes), to be used on jenkins only +# +rm -Rf ./build_temp + +if [ "$1" == "clean" ]; then + git clean -fxd +fi + +mkdir build_temp + +tplfiles=`find . -type f -regex '.*\.tpl' |wc -l` +if [ $tplfiles -ne 0 ]; then + echo "[ERROR] found .tpl files, should be .pan only: $tplfiles" + exit 1 +fi + +# panc-annotations can have issues with multiple threads creating dirs +echo "Testing pan annotations" +find . -type d ! -regex '.*build_temp.*' | xargs -I '{}' mkdir -p 'build_temp/{}' +nrpanfiles=`find . -type f -regex '.*\.pan' | grep -v yumng | wc -l` +panfiles=`find . -type f -regex '.*\.pan' | grep -v yumng` +panc-annotations --output-dir build_temp $panfiles + +nrannofiles=`find build_temp -type f -regex '.*annotation\.xml'|wc -l` +if [ $nrpanfiles != $nrannofiles ]; then + echo "[ERROR]: number of annotation files is not the same as numnber of pan files." + exit 1 +else + echo "pan annotations ok" +fi + +cat > build_temp/test.pan < build_temp/rpms/package_default_versions.pan < build_temp/rpms/web_server.pan <> build_temp/test.pan +find . -type f ! -regex '^./pan/.*' ! -regex '^./build_temp/.*' -name *.pan | grep -v yumng | xargs sed -n "s/^declaration[ ]\+template[ ]\+\(.*\);/include '\1';/p" | sort >> build_temp/test.pan +find . -type f ! -regex '^./build_temp/.*' -name *.pan | grep -v yumng | xargs sed -n "s/^\(unique[ ]\+\)\?template[ ]\+\(.*\);/include '\2';/p" |sort >> build_temp/test.pan + +# fix for multiversion metaconfig +sed -i '/.*metaconfig\/\(elasticsearch\|logstash\|beats\|kibana\|slurm\)\/.*_[0-9].*/d' build_temp/test.pan +# none-versioned ganesha templates are v1 +sed -i "/.*metaconfig\/ganesha\/\(config\(_v1\)\?\|schema\)'/d" build_temp/test.pan +sed -i "/.*metaconfig\/ganesha\/fsal.*/d" build_temp/test.pan +# action.pan is included by the schema and can only be included after inputs.pan +sed -i "/.*metaconfig\/rsyslog\/actions.*/d" build_temp/test.pan + +# only spma yum +sed -i "/.*components\/spma\/\(apt\|ips\).*/d" build_temp/test.pan + +# Only test default schema version of ceph component +sed -i "/.*components\/ceph\/v[1-9][0-9]*\/.*/d" build_temp/test.pan + +# Only test default schema version of ssh component +sed -i "/.*components\/ssh\/schema-.*/d" build_temp/test.pan + +# try to compile it +output=`panc --output-dir build_temp --include-path .:build_temp build_temp/test.pan 2>&1` + +# use "$output" to preserve newlines in echo + +# if it fails, it's sort of ok when due to bind problems because there's no actual data +ec=$? + +if [ $ec -eq 0 ]; then + echo "$output" + echo "[OK] Pan compilation success." +else + echo "$output" | grep 'element does not exist' >& /dev/null + if [ $? -eq 0 ]; then + echo "$output" | grep 'bound to type' >& /dev/null + if [ $? -eq 0 ]; then + echo "$output" + echo "[OK] expected panc failure due to missing data." + ec=0 + fi + fi +fi + +if [ $ec -ne 0 ]; then + echo "$output" + echo "[ERROR] Pan compilation failed" +fi + +exit $ec diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 8c1e8b55..22bc3973 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -48,5 +48,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3 + - name: Install dependencies + run: pip install colorama - name: run indent checker run: .ci-scripts/indent