diff --git a/.ci/lib.sh b/.ci/lib.sh index ca954da59a..6771512ca1 100644 --- a/.ci/lib.sh +++ b/.ci/lib.sh @@ -11,20 +11,6 @@ die(){ exit 1 } -# Check that kata_confing_version file is updated -# when there is any change in the kernel directory. -# If there is a change in the directory, but the config -# version is not updated, return error. -check_kata_kernel_version(){ - kernel_version_file="kernel/kata_config_version" - modified_files=$(git diff --name-only master..) - if echo "$modified_files" | grep "kernel/"; then - echo "$modified_files" | grep "$kernel_version_file" || \ - die "Please bump version in $kernel_version_file" - fi - -} - install_yq() { GOPATH=${GOPATH:-${HOME}/go} local yq_path="${GOPATH}/bin/yq" diff --git a/.ci/run.sh b/.ci/run.sh index 6e0c28570f..2e1aba2c7c 100755 --- a/.ci/run.sh +++ b/.ci/run.sh @@ -14,9 +14,6 @@ source "${cidir}/lib.sh" source /etc/os-release # This script will execute packaging tests suite -# TODO: Add steps needed to build packages - -check_kata_kernel_version if [ "$ID" == ubuntu ];then echo "Building snap image" diff --git a/.ci/test.sh b/.ci/test.sh index bce06ebc0d..06076778cb 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -9,7 +9,7 @@ set -o nounset set -o pipefail CI=${CI:-} -script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly toplevel_mk="${script_dir}/../Makefile" source "${script_dir}/lib.sh" @@ -17,20 +17,47 @@ make_target() { target=$1 dir=$2 - if [ -n "${CI}" ] && [ "${target}" == "test-packaging-tools" ];then - echo "skip $target see https://github.com/kata-containers/packaging/issues/72" - return - fi - pushd "${script_dir}/.." >> /dev/null - if [ -n "${CI}" ] && ! git whatchanged origin/master..HEAD "${dir}" | grep "${dir}" >> /dev/null; then + pushd "${script_dir}/.." >>/dev/null + + if [ -n "${CI}" ] && ! git whatchanged origin/master..HEAD "${dir}" | grep "${dir}" >>/dev/null; then echo "Not changes in ${dir}" return fi - popd >> /dev/null + case "${target}" in + test-packaging-tools) + skip_msg="skip $target see https://github.com/kata-containers/packaging/issues/72" + [ -n "${CI}" ] && echo "${skip_msg}" && return + ;; + + test-build-kernel) + [ -n "${CI}" ] && check_kata_kernel_version + ;; + esac + + popd >>/dev/null echo "Changes found in ${dir}" make -f "${toplevel_mk}" "${target}" } +# Check that kata_confing_version file is updated +# when there is any change in the kernel directory. +# If there is a change in the directory, but the config +# version is not updated, return error. +check_kata_kernel_version() { + kernel_version_file="kernel/kata_config_version" + modified_files=$(git diff --name-only origin/master..HEAD) + echo "Check Changes in kernel" + git diff origin/master..HEAD ${kernel_version_file} + git diff --name-only origin/master..HEAD + if git whatchanged origin/master..HEAD "kernel/" | grep "kernel/" >>/dev/null; then + echo "Kernel directory has changes check $kernel_version_file changed" + echo "$modified_files" | grep "$kernel_version_file" || + die "Please bump version in $kernel_version_file" + fi + echo "OK - config version file was updated" + +} + make_target test-release-tools "release/" make_target test-packaging-tools "obs-packaging/" make_target test-static-build "static-build/" diff --git a/kernel/kata_config_version b/kernel/kata_config_version index d00491fd7e..0cfbf08886 100644 --- a/kernel/kata_config_version +++ b/kernel/kata_config_version @@ -1 +1 @@ -1 +2