Skip to content

Commit

Permalink
build: improve build scripts; upgrade bash-buddy to v0.3.3 🚼
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Jul 24, 2023
1 parent ad41a28 commit 506ac0a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 43 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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*

Expand Down
4 changes: 2 additions & 2 deletions demos/cffu-demo/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions demos/cffu-kotlin-demo/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 3 additions & 5 deletions demos/scripts/integration_test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/bump_cffu_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 15 additions & 18 deletions scripts/integration_test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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}}
)
Expand All @@ -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
Expand All @@ -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
16 changes: 10 additions & 6 deletions scripts/maven_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 506ac0a

Please sign in to comment.