From c94ab9e417843810576ef54f9b38ee8a35208905 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 22 Jul 2016 21:09:25 +0200 Subject: [PATCH] Running tests for parsed version --- scripts/build.sh | 12 ++++-------- scripts/buildAndTest.sh | 18 +++++++++--------- scripts/common.sh | 24 ++++++++++++++++++++++++ scripts/deploy.sh | 11 ++--------- scripts/downloadDependencies.sh | 10 ++-------- scripts/generateDocs.sh | 10 +++------- scripts/runTests.sh | 20 ++++++++------------ 7 files changed, 52 insertions(+), 53 deletions(-) create mode 100755 scripts/common.sh diff --git a/scripts/build.sh b/scripts/build.sh index 39b93d2a42..8c9597e8f5 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,17 +1,13 @@ #!/usr/bin/env bash -set -o errexit +source common.sh || source scripts/common.sh || echo "No common.sh script found..." -ROOT_FOLDER=`pwd` -echo "Current folder is $ROOT_FOLDER" - -if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - cd .. - ROOT_FOLDER=`pwd` -fi +set -e ADDITIONAL_MAVEN_OPTS=${ADDITIONAL_MAVEN_OPTS:--Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn} +echo "Building Maven and Gradle projects for version [$VERIFIER_VERSION]" + echo "Building Maven stuff with additional opts [$ADDITIONAL_MAVEN_OPTS]" ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Psonar --batch-mode $ADDITIONAL_MAVEN_OPTS diff --git a/scripts/buildAndTest.sh b/scripts/buildAndTest.sh index bad1d5a12d..975e5934d0 100755 --- a/scripts/buildAndTest.sh +++ b/scripts/buildAndTest.sh @@ -1,14 +1,8 @@ #!/usr/bin/env bash -set -o errexit +source common.sh || source scripts/common.sh || echo "No common.sh script found..." -ROOT_FOLDER=`pwd` -echo "Current folder is $ROOT_FOLDER" - -if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - cd .. - ROOT_FOLDER=`pwd` -fi +set -e function print_usage() { cat <\(.*\)<\/version>.*/\1/p;q;}' <<< "$VERSION_NODE") + +[[ -z "${VERIFIER_VERSION}" ]] && VERIFIER_VERSION="$VERSION_VALUE" export VERIFIER_VERSION echo -e "\n\nBUILDING AND RUNNING TESTS FOR VERIFIER IN VERSION [$VERIFIER_VERSION]\n\n" diff --git a/scripts/common.sh b/scripts/common.sh new file mode 100755 index 0000000000..a0e7a85a36 --- /dev/null +++ b/scripts/common.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + +ROOT_FOLDER=`pwd` +echo "Current folder is $ROOT_FOLDER" + +if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then + cd .. + ROOT_FOLDER=`pwd` +fi + +echo "Root folder is $ROOT_FOLDER" + +# Code grepping for the 3rd presence of "version" in pom.xml. +# The 3rd one is where we define the SC-Contract version +VERSION_NODE=`awk '/version/{i++}i==3{print; exit}' $ROOT_FOLDER/pom.xml` +# Extract the contents of the version node +VERSION_VALUE=$(sed -ne '/version/{s/.*\(.*\)<\/version>.*/\1/p;q;}' <<< "$VERSION_NODE") + +echo "Extracted version from root pom.xml is [$VERSION_VALUE]" + +export ROOT_FOLDER +export VERSION_VALUE \ No newline at end of file diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 4d1cd7d5c2..1169109648 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,14 +1,7 @@ #!/usr/bin/env bash -set -o errexit - -ROOT_FOLDER=`pwd` -echo "Current folder is $ROOT_FOLDER" - -if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - cd .. - ROOT_FOLDER=`pwd` -fi +source common.sh || source scripts/common.sh || echo "No common.sh script found..." +set -e ./mvnw clean install && (cd *-gradle-plugin; ./gradlew clean build install) && ./scripts/runTests.sh && ./mvnw deploy && (cd *-gradle-plugin; ./gradlew uploadArchives -x test) diff --git a/scripts/downloadDependencies.sh b/scripts/downloadDependencies.sh index ae4ab6caf8..7ed335d2df 100755 --- a/scripts/downloadDependencies.sh +++ b/scripts/downloadDependencies.sh @@ -1,14 +1,8 @@ #!/usr/bin/env bash -set -o errexit +source common.sh || source scripts/common.sh || echo "No common.sh script found..." -ROOT_FOLDER=`pwd` -echo "Current folder is $ROOT_FOLDER" - -if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - cd .. - ROOT_FOLDER=`pwd` -fi +set -e ./mvnw -s .settings.xml --fail-never dependency:go-offline || true cd $ROOT_FOLDER/spring-cloud-contact-gradle-plugin && ./gradlew resolveDependencies || true diff --git a/scripts/generateDocs.sh b/scripts/generateDocs.sh index 713841f1ab..c625bea814 100755 --- a/scripts/generateDocs.sh +++ b/scripts/generateDocs.sh @@ -1,14 +1,10 @@ #!/usr/bin/env bash -set -o errexit +source common.sh || source scripts/common.sh || echo "No common.sh script found..." -ROOT_FOLDER=`pwd` -echo "Current folder is $ROOT_FOLDER" +set -e -if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - cd .. - ROOT_FOLDER=`pwd` -fi +echo "Generating docs for Spring Cloud Contract version [$VERIFIER_VERSION]" echo "Building main docs" ./mvnw clean install -P docs -DskipTests=true --pl docs diff --git a/scripts/runTests.sh b/scripts/runTests.sh index c0dc9011cf..a9fc5393d8 100755 --- a/scripts/runTests.sh +++ b/scripts/runTests.sh @@ -1,25 +1,21 @@ #!/usr/bin/env bash -set -o errexit +source common.sh || source scripts/common.sh || echo "No common.sh script found..." -ROOT_FOLDER=`pwd` -echo "Current folder is $ROOT_FOLDER" +set -e -if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - cd .. - ROOT_FOLDER=`pwd` -fi +[[ -z "${VERSION_VALUE}" ]] && VERSION_VALUE="1.0.0.BUILD-SNAPSHOT" +[[ -z "${VERIFIER_VERSION}" ]] && VERIFIER_VERSION="$VERSION_VALUE" +export VERIFIER_VERSION -export CONTRACT_VERIFIER_VERSION=${CONTRACT_VERIFIER_VERSION:-1.0.0.BUILD-SNAPSHOT} - -echo "Current Spring Cloud Contract Verifier version is ${CONTRACT_VERIFIER_VERSION}" +echo -e "\n\nRUNNING TESTS FOR VERIFIER IN VERSION [${VERIFIER_VERSION}]\n\n" cd samples/standalone echo "Running Gradle tests" -. ./runTests.sh +./runTests.sh echo "Running Maven tests" -. ./runMavenTests.sh +./runMavenTests.sh cd $ROOT_FOLDER