From e72f702fad7df7df27e94b8fbc8823092cc83e5e Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Mon, 18 Dec 2017 17:15:35 -0500 Subject: [PATCH] Handling the case of a new chart in the e2e tests (#3083) --- test/changed.sh | 25 ++++++++++++++++++------- test/semvercompare.sh | 4 ---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/test/changed.sh b/test/changed.sh index aff42e07f9..5df924d1ae 100755 --- a/test/changed.sh +++ b/test/changed.sh @@ -33,13 +33,10 @@ fi # include the semvercompare function curDir="$(dirname "$0")" source "$curDir/semvercompare.sh" +exitCode=0 # Cleanup any releases and namespaces left over from the test function cleanup { - if [ $semvercomparePassed -eq 0 ]; then - echo "Error please increment the new chart version to be greater than the existing version of $semvercompareOldVer" - fi - if [ -n "$CURRENT_RELEASE" ]; then helm delete --purge ${CURRENT_RELEASE} > cleanup_log 2>&1 || true fi @@ -47,6 +44,20 @@ function cleanup { } trap cleanup EXIT +function dosemvercompare { + # Note, the trap and automatic exiting are disabled for the semver comparison + # because it catches its own errors. If the comparison fails exitCode is set + # to 1. So, trapping and exiting is re-enabled and then the exit is handled + trap - EXIT + set +e + semvercompare ${1} + trap cleanup EXIT + set -e + if [ $exitCode == 1 ]; then + exit 1 + fi +} + if [ ! -f "${KUBECONFIG:=}" ];then # Get credentials for test cluster gcloud auth activate-service-account --key-file="${GOOGLE_APPLICATION_CREDENTIALS}" @@ -87,11 +98,11 @@ for directory in ${CHANGED_FOLDERS}; do elif [ -d $directory ]; then CHART_NAME=`echo ${directory} | cut -d '/' -f2` - # semvercompare is here as well as in the circleci tests. The circleci tests - # provide almost immediate feedback to chart authors. This test is also + # A semver comparison is here as well as in the circleci tests. The circleci + # tests provide almost immediate feedback to chart authors. This test is also # re-run right before the bot merges a PR so we can make sure the chart # version is always incremented. - semvercompare ${directory} + dosemvercompare ${directory} RELEASE_NAME="${CHART_NAME:0:7}-${BUILD_NUMBER}" CURRENT_RELEASE=${RELEASE_NAME} helm dep build ${directory} diff --git a/test/semvercompare.sh b/test/semvercompare.sh index 89359aeee1..9ce4f852e7 100644 --- a/test/semvercompare.sh +++ b/test/semvercompare.sh @@ -13,11 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -exitCode=0 - semvercompareOldVer="" semvercompareNewVer="" -semvercomparePassed=0 # Verify that the semver for the chart was increased semvercompare() { @@ -61,7 +58,6 @@ semvercompare() { exitCode=1 else echo "New higher version $semvercompareNewVer found" - semvercomparePassed=1 fi # Clean up