From b48c2745c149a608a9c3dc47ec6c0e18b660cb11 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 16 Jun 2020 14:38:13 +0200 Subject: [PATCH] CI: apply schema-validation to the example config files - Any config file with a schema gets a test (validate-) to test the file. --- src/modules/CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 533c704f8..0b81c4b3f 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -66,3 +66,21 @@ endforeach() include( CalamaresAddTranslations ) add_calamares_python_translations( ${CALAMARES_TRANSLATION_LANGUAGES} ) + +# TODO:3.3: Use FindPython3 +if ( BUILD_TESTING AND PYTHONINTERP_FOUND AND PYTHON_EXECUTABLE ) + # The tests for each config file are independent of whether the + # module is enabled or not: the config file should match its schema + # regardless. + foreach( SUBDIRECTORY ${SUBDIRECTORIES} ) + set( _schema_file "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/${SUBDIRECTORY}.schema.yaml" ) + set( _conf_file "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/${SUBDIRECTORY}.conf" ) + if ( EXISTS "${_schema_file}" AND EXISTS "${_conf_file}" ) + add_test( + NAME validate-${SUBDIRECTORY} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/ci/configvalidator.py" "${_schema_file}" "${_conf_file}" + ) + endif() + endforeach() +endif() +