@@ -570,9 +570,9 @@ prepare_serverless_stack() {
570570}
571571
572572is_spec_3_0_0 () {
573- local pkg_spec
573+ local pkg_spec= " "
574574 pkg_spec=$( cat manifest.yml | yq ' .format_version' )
575- local major_version
575+ local major_version= " "
576576 major_version=$( echo " $pkg_spec " | cut -d ' .' -f 1)
577577
578578 if [ " ${major_version} " -ge 3 ]; then
@@ -670,10 +670,8 @@ get_to_changeset() {
670670
671671is_pr_affected () {
672672 local package=" ${1} "
673- local from=${2:- " " }
674- local to=${3:- " " }
675-
676- echoerr " [${package} ] Original commits: from '${from} ' - to: '${to} '"
673+ local from=" ${2} "
674+ local to=" ${3} "
677675
678676 if ! is_supported_stack ; then
679677 echo " [${package} ] PR is not affected: unsupported stack (${STACK_VERSION} )"
@@ -689,30 +687,31 @@ is_pr_affected() {
689687 echo " [${package} ] PR is not affected: capabilities not mached with the project (${SERVERLESS_PROJECT} )"
690688 return 1
691689 fi
690+ if [[ " ${package} " == " fleet_server" ]]; then
691+ echoerr " fleet_server not supported. Skipped"
692+ echo " [${package} ] not supported"
693+ return 1
694+ fi
695+ if ! is_spec_3_0_0 ; then
696+ echoerr " Not v3 spec version. Skipped"
697+ echo " [${package} ] spec <3.0.0"
698+ return 1
699+ fi
692700 fi
693701
694702 if [[ " ${FORCE_CHECK_ALL} " == " true" ]]; then
695703 echo " [${package} ] PR is affected: \" force_check_all\" parameter enabled"
696704 return 0
697705 fi
698706
699- if [[ " ${from} " == " " || " ${to} " == " " ]]; then
700- echo " [${package} ] Calculating commits: from '${from} ' - to: '${to} '"
701- # setting range of changesets to check differences
702- from=" $( get_from_changeset) "
703- to=" $( get_to_changeset) "
704- fi
705-
706- echo " [${package} ]: commits: from: '${from} ' - to: '${to} '"
707-
708- echo " [${package} ] git-diff: check non-package files"
709707 commit_merge=$( git merge-base " ${from} " " ${to} " )
710- if git diff --name-only " ${commit_merge} " " ${to} " | grep -E -v ' ^(packages/|\.github/(CODEOWNERS|ISSUE_TEMPLATE|PULL_REQUEST_TEMPLATE)|README\.md|docs/)' ; then
708+ echoerr " [${package} ] git-diff: check non-package files (${commit_merge} ..${to} )"
709+ if git diff --name-only " ${commit_merge} " " ${to} " | grep -q -E -v ' ^(packages/|\.github/(CODEOWNERS|ISSUE_TEMPLATE|PULL_REQUEST_TEMPLATE)|README\.md|docs/)' ; then
711710 echo " [${package} ] PR is affected: found non-package files"
712711 return 0
713712 fi
714- echo " [${package} ] git-diff: check package files"
715- if git diff --name-only " ${commit_merge} " " ${to} " | grep -E " ^packages/${package} /" ; then
713+ echoerr " [${package} ] git-diff: check package files ( ${commit_merge} .. ${to} ) "
714+ if git diff --name-only " ${commit_merge} " " ${to} " | grep -q - E " ^packages/${package} /" ; then
716715 echo " [${package} ] PR is affected: found package files"
717716 return 0
718717 fi
@@ -728,7 +727,11 @@ is_pr() {
728727}
729728
730729kubernetes_service_deployer_used () {
731- find . -type d | grep -E ' _dev/deploy/k8s$'
730+ # Not able to use -q in parameter
731+ # as set -o pipefail is defined, when adding "-q" parameter, grep finishes with its first match
732+ # but find still is writing to the pipe causing the SIGPIPE
733+ # https://tldp.org/LDP/lpg/node20.html
734+ find . -type d | grep -E " _dev/deploy/k8s$" > /dev/null
732735}
733736
734737teardown_serverless_test_package () {
@@ -954,54 +957,35 @@ upload_safe_logs_from_package() {
954957
955958# Helper to run all tests and checks for a package
956959process_package () {
957- local package=" $1 "
958- local from=${2:- " " }
959- local to=${3:- " " }
960+ local package=" ${1} "
961+ local failed_packages_file=" ${2:- " " } "
960962 local exit_code=0
961963
962964 echo " --- Package ${package} : check"
963965 pushd " ${package} " > /dev/null
964966
965967 clean_safe_logs
966968
967- if is_serverless ; then
968- if [[ " ${package} " == " fleet_server" ]]; then
969- echo " fleet_server not supported. Skipped"
970- echo " - [${package} ] not supported" >> " ${SKIPPED_PACKAGES_FILE_PATH} "
971- popd > /dev/null
972- return
973- fi
974- if ! is_spec_3_0_0 ; then
975- echo " Not v3 spec version. Skipped"
976- echo " - [${package} ] spec <3.0.0" >> " ${SKIPPED_PACKAGES_FILE_PATH} "
977- popd > /dev/null
978- return
979- fi
980- fi
981-
982- if ! reason=$( is_pr_affected " ${package} " " ${from} " " ${to} " ) ; then
983- echo " ${reason} "
984- echo " - ${reason} " >> " ${SKIPPED_PACKAGES_FILE_PATH} "
985- popd > /dev/null
986- return
987- fi
988-
989- echo " ${reason} "
990-
991969 use_kind=0
992- if kubernetes_service_deployer_used ; then
993- echo " Kubernetes service deployer is used. Creating Kind cluster"
994- use_kind=1
995- if ! create_kind_cluster ; then
996- popd > /dev/null
997- return 1
970+ if ! is_serverless ; then
971+ # TODO: in serverless system tests are not triggered,
972+ # there is no need to create the kind cluster in these CI builds.
973+ if kubernetes_service_deployer_used ; then
974+ echo " Kubernetes service deployer is used. Creating Kind cluster"
975+ use_kind=1
976+ if ! create_kind_cluster ; then
977+ popd > /dev/null
978+ return 1
979+ fi
998980 fi
999981 fi
1000982
1001983 if ! run_tests_package " ${package} " ; then
1002984 exit_code=1
1003985 echo " [${package} ] run_tests_package failed"
1004- echo " - ${package} " >> " ${FAILED_PACKAGES_FILE_PATH} "
986+ if [[ " ${failed_packages_file} " != " " ]]; then
987+ echo " - ${package} " >> " ${failed_packages_file} "
988+ fi
1005989 fi
1006990
1007991 if ! is_serverless ; then
0 commit comments