From 506ac0a5c173d01d25aa18da423703563dc8afa0 Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Mon, 17 Jul 2023 19:49:26 +0800 Subject: [PATCH] =?UTF-8?q?build:=20improve=20build=20scripts;=20upgrade?= =?UTF-8?q?=20`bash-buddy`=20to=20`v0.3.3`=20=F0=9F=9A=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yaml | 10 ++------ demos/cffu-demo/scripts/run.sh | 4 ++-- demos/cffu-kotlin-demo/scripts/run.sh | 4 ++-- demos/scripts/integration_test | 8 +++---- scripts/bash-buddy | 2 +- scripts/bump_cffu_version.sh | 2 +- scripts/integration_test | 33 ++++++++++++--------------- scripts/maven_deploy.sh | 16 ++++++++----- 8 files changed, 36 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bef30bea..65f57421 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,7 +48,8 @@ jobs: java-version: 21-ea distribution: zulu - - run: scripts/integration_test + - name: run integration test + run: scripts/integration_test && demos/scripts/integration_test env: JAVA8_HOME: ${{ env.JAVA_HOME_8_X64 }} JAVA11_HOME: ${{ env.JAVA_HOME_11_X64 }} @@ -57,13 +58,6 @@ jobs: JAVA20_HOME: ${{ env.JAVA_HOME_20_X64 }} JAVA21_HOME: ${{ env.JAVA_HOME_21_X64 }} - - run: demos/scripts/integration_test - env: - JAVA8_HOME: ${{ env.JAVA_HOME_8_X64 }} - JAVA11_HOME: ${{ env.JAVA_HOME_11_X64 }} - JAVA17_HOME: ${{ env.JAVA_HOME_17_X64 }} - JAVA20_HOME: ${{ env.JAVA_HOME_20_X64 }} - - name: remove self maven install files run: rm -rf $HOME/.m2/repository/io/foldright/cffu* diff --git a/demos/cffu-demo/scripts/run.sh b/demos/cffu-demo/scripts/run.sh index c876fdc9..eafadecc 100755 --- a/demos/cffu-demo/scripts/run.sh +++ b/demos/cffu-demo/scripts/run.sh @@ -6,6 +6,6 @@ cd "$(dirname "$(readlink -f "$0")")"/.. readonly BABY_ROOT="$PWD/../../scripts/bash-buddy" source "$BABY_ROOT"/lib/trap_error_info.sh source "$BABY_ROOT"/lib/common_utils.sh -source "$BABY_ROOT"/lib/java_build_utils.sh +source "$BABY_ROOT"/lib/maven_utils.sh -jvb::mvn_cmd clean compile exec:exec +mvu::mvn_cmd clean compile exec:exec diff --git a/demos/cffu-kotlin-demo/scripts/run.sh b/demos/cffu-kotlin-demo/scripts/run.sh index c876fdc9..eafadecc 100755 --- a/demos/cffu-kotlin-demo/scripts/run.sh +++ b/demos/cffu-kotlin-demo/scripts/run.sh @@ -6,6 +6,6 @@ cd "$(dirname "$(readlink -f "$0")")"/.. readonly BABY_ROOT="$PWD/../../scripts/bash-buddy" source "$BABY_ROOT"/lib/trap_error_info.sh source "$BABY_ROOT"/lib/common_utils.sh -source "$BABY_ROOT"/lib/java_build_utils.sh +source "$BABY_ROOT"/lib/maven_utils.sh -jvb::mvn_cmd clean compile exec:exec +mvu::mvn_cmd clean compile exec:exec diff --git a/demos/scripts/integration_test b/demos/scripts/integration_test index ea86a03e..b2bc4e51 100755 --- a/demos/scripts/integration_test +++ b/demos/scripts/integration_test @@ -6,7 +6,7 @@ cd "$(dirname "$(readlink -f "$0")")"/.. readonly BABY_ROOT="$PWD/../scripts/bash-buddy" source "$BABY_ROOT"/lib/trap_error_info.sh source "$BABY_ROOT"/lib/common_utils.sh -source "$BABY_ROOT"/lib/java_build_utils.sh +source "$BABY_ROOT"/lib/java_utils.sh readonly JDK_VERSIONS=( 8 @@ -16,11 +16,9 @@ readonly JDK_VERSIONS=( ) for jdk_version in "${JDK_VERSIONS[@]}"; do - jh_var_name="JAVA${jdk_version}_HOME" - [ -d "${!jh_var_name:-}" ] || cu::die "\$${jh_var_name}(${!jh_var_name:-}) dir is not existed!" - export JAVA_HOME="${!jh_var_name}" + jvu::switch_to_jdk "$jdk_version" - cu::head_line_echo "test with Java $jdk_version: $JAVA_HOME" + cu::head_line_echo "test demos with Java $jdk_version: $JAVA_HOME" cffu-demo/scripts/run.sh cffu-kotlin-demo/scripts/run.sh diff --git a/scripts/bash-buddy b/scripts/bash-buddy index eb0cb6fc..d53f5610 160000 --- a/scripts/bash-buddy +++ b/scripts/bash-buddy @@ -1 +1 @@ -Subproject commit eb0cb6fc995ec14ba20b9fca5a7779937212c31f +Subproject commit d53f56109ae97028ff70264491eec7b1a4ba1a6b diff --git a/scripts/bump_cffu_version.sh b/scripts/bump_cffu_version.sh index 53bf99e0..9eb8dedc 100755 --- a/scripts/bump_cffu_version.sh +++ b/scripts/bump_cffu_version.sh @@ -5,7 +5,7 @@ cd "$(dirname "$(readlink -f "$0")")" source "$PWD/bash-buddy/lib/trap_error_info.sh" source "$PWD/bash-buddy/lib/common_utils.sh" -source "$PWD/bash-buddy/lib/java_build_utils.sh" +source "$PWD/bash-buddy/lib/java_utils.sh" readonly nl=$'\n' # new line diff --git a/scripts/integration_test b/scripts/integration_test index 46c6bc5c..b10f7e8c 100755 --- a/scripts/integration_test +++ b/scripts/integration_test @@ -6,7 +6,8 @@ BASH_BUDDY_ROOT="$(readlink -f bash-buddy)" readonly BASH_BUDDY_ROOT source "$BASH_BUDDY_ROOT/lib/trap_error_info.sh" source "$BASH_BUDDY_ROOT/lib/common_utils.sh" -source "$BASH_BUDDY_ROOT/lib/java_build_utils.sh" +source "$BASH_BUDDY_ROOT/lib/java_utils.sh" +source "$BASH_BUDDY_ROOT/lib/maven_utils.sh" ################################################################################ # ci build logic @@ -22,7 +23,6 @@ readonly JDK_VERSIONS=( 20 21 ) -readonly default_jh_var_name="JAVA${default_build_jdk_version}_HOME" # here use `install` and `-D performRelease` intended # to check release operations. @@ -31,8 +31,8 @@ readonly default_jh_var_name="JAVA${default_build_jdk_version}_HOME" # https://stackoverflow.com/questions/25201430 # # shellcheck disable=SC2034 -readonly JVB_MVN_OPTS=( - "${JVB_DEFAULT_MVN_OPTS[@]}" +readonly MVU_MVN_OPTS=( + "${MVU_DEFAULT_MVN_OPTS[@]}" -DperformRelease -P'!gen-sign' ${CI_MORE_MVN_OPTS:+${CI_MORE_MVN_OPTS}} ) @@ -43,16 +43,15 @@ cd .. # build and test by default version jdk ######################################## -[ -d "${!default_jh_var_name:-}" ] || cu::die "\$${default_jh_var_name}(${!default_jh_var_name:-}) dir is not existed!" -export JAVA_HOME="${!default_jh_var_name}" +jvu::switch_to_jdk "$default_build_jdk_version" cu::log_then_run scripts/gen_CffuApiCompatibilityTest.sh cu::head_line_echo "check kotlin compiler api version 1.5 with kotlin 1.8 " -jvb::mvn_cmd clean test-compile -D kotlin.version=1.8.22 -D kotlin.compiler.apiVersion=1.5 +mvu::mvn_cmd clean test-compile -D kotlin.version=1.8.22 -D kotlin.compiler.apiVersion=1.5 cu::head_line_echo "build and test with Java $default_build_jdk_version: $JAVA_HOME" -jvb::mvn_cmd clean install +mvu::mvn_cmd clean install ######################################## # test by multiply version jdks @@ -63,24 +62,22 @@ readonly KT_VERSION_FOR_JAVA11=1.6.0 readonly KT_VERSION_FOR_JAVA17=1.7.0 readonly KT_VERSION_FOR_JAVA20=1.8.22 +# about CI env var +# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables +if [ "${CI:-}" = true ]; then + readonly CI_MORE_BEGIN_OPTS=jacoco:prepare-agent CI_MORE_END_OPTS=jacoco:report +fi + for jdk_version in "${JDK_VERSIONS[@]}"; do # skip default jdk, already tested above [ "$jdk_version" = "$default_build_jdk_version" ] && continue - jh_var_name="JAVA${jdk_version}_HOME" - [ -d "${!jh_var_name:-}" ] || cu::die "\$${jh_var_name}(${!jh_var_name:-}) dir is not existed!" - export JAVA_HOME="${!jh_var_name}" + jvu::switch_to_jdk "$jdk_version" # just test without build cu::head_line_echo "test with Java $jdk_version: $JAVA_HOME" kt_version_var_name="KT_VERSION_FOR_JAVA${jdk_version}" kt_version_opt="${!kt_version_var_name:+-Dkotlin.version=${!kt_version_var_name}}" - # about CI env var - # https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables - if [ "${CI:-}" = true ]; then - jvb::mvn_cmd jacoco:prepare-agent surefire:test jacoco:report $kt_version_opt - else - jvb::mvn_cmd surefire:test $kt_version_opt - fi + mvu::mvn_cmd ${CI_MORE_BEGIN_OPTS:-} dependency:properties surefire:test ${CI_MORE_END_OPTS:-} $kt_version_opt done diff --git a/scripts/maven_deploy.sh b/scripts/maven_deploy.sh index 7ec96b11..a08f0711 100755 --- a/scripts/maven_deploy.sh +++ b/scripts/maven_deploy.sh @@ -2,16 +2,20 @@ set -eEuo pipefail cd "$(dirname "$(readlink -f "$0")")/.." -source "scripts/bash-buddy/lib/common_utils.sh" +source "scripts/bash-buddy/lib/java_utils.sh" -readonly jh_var_name="JAVA19_HOME" -[ -d "${!jh_var_name:-}" ] || - cu::die "\$${jh_var_name}(${!jh_var_name:-}) dir is not existed!" -export JAVA_HOME="${!jh_var_name}" +jvu::switch_to_jdk 19 +######################################## +# integration test +######################################## rm -rf "$HOME/.m2/repository/io/foldright"/cffu* -scripts/integration_test +cu::log_then_run scripts/integration_test +cu::log_then_run demos/scripts/integration_test +######################################## +# maven deploy +######################################## rm -rf "$HOME/.m2/repository/io/foldright"/cffu* cu::log_then_run ./mvnw clean cu::log_then_run ./mvnw deploy -DperformRelease -Dmaven.test.skip