forked from alibaba/COLA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
! improve ci: use and test jdk8/9/11/15 of sdkman
- Loading branch information
Showing
6 changed files
with
214 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
[ -z "${_source_mark_of_common:+dummy}" ] || return 0 | ||
_source_mark_of_common=true | ||
|
||
set -eEuo pipefail | ||
|
||
################################################################################ | ||
# constants | ||
################################################################################ | ||
|
||
# NOTE: $'foo' is the escape sequence syntax of bash | ||
readonly nl=$'\n' # new line | ||
readonly ec=$'\033' # escape char | ||
readonly eend=$'\033[0m' # escape end | ||
|
||
################################################################################ | ||
# common util functions | ||
################################################################################ | ||
|
||
colorEcho() { | ||
local color=$1 | ||
shift | ||
|
||
# if stdout is the console, turn on color output. | ||
[ -t 1 ] && echo "${ec}[1;${color}m$*${eend}" || echo "$*" | ||
} | ||
|
||
redEcho() { | ||
colorEcho 31 "$@" | ||
} | ||
|
||
yellowEcho() { | ||
colorEcho 33 "$@" | ||
} | ||
|
||
blueEcho() { | ||
colorEcho 36 "$@" | ||
} | ||
|
||
headInfo() { | ||
colorEcho "0;34;46" ================================================================================ | ||
yellowEcho "$*" | ||
colorEcho "0;34;46" ================================================================================ | ||
} | ||
|
||
logAndRun() { | ||
local simple_mode=false | ||
[ "$1" = "-s" ] && { | ||
simple_mode=true | ||
shift | ||
} | ||
|
||
if $simple_mode; then | ||
echo "Run under work directory $PWD : $*" | ||
"$@" | ||
else | ||
blueEcho "Run under work directory $PWD :$nl$*" | ||
time "$@" | ||
fi | ||
} | ||
|
||
die() { | ||
redEcho "Error: $*" 1>&2 | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
[ -z "${_source_mark_of_common_build:+dummy}" ] || return 0 | ||
_source_mark_of_common_build=true | ||
|
||
source "$(dirname "$(readlink -f "$BASH_SOURCE")")/common.sh" | ||
|
||
################################################################################ | ||
# build util functions | ||
################################################################################ | ||
|
||
readonly -a MVN_OPTIONS=( | ||
-V --no-transfer-progress | ||
) | ||
|
||
MVN() { | ||
local maven_wrapper_name="mvnw" | ||
|
||
local d="$PWD" | ||
while true; do | ||
[ "/" = "$d" ] && die "Fail to find $maven_wrapper_name!" | ||
[ -f "$d/$maven_wrapper_name" ] && break | ||
|
||
d=$(dirname "$d") | ||
done | ||
|
||
logAndRun "$d/$maven_wrapper_name" "${MVN_OPTIONS[@]}" "$@" | ||
} | ||
|
||
# Where is Maven local repository? | ||
# https://mkyong.com/maven/where-is-maven-local-repository/ | ||
|
||
# NOTE: DO NOT declare mvn_local_repository_dir var as readonly, its value is supplied by subshell. | ||
mvn_local_repository_dir="$( | ||
cd $(dirname "$(readlink -f "$BASH_SOURCE")")/../cola-components/ && | ||
./mvnw --no-transfer-progress help:evaluate -Dexpression=settings.localRepository | | ||
grep '^/' | ||
)" | ||
[ -n "$mvn_local_repository_dir" ] || die "Fail to find find maven local repository directory: $mvn_local_repository_dir" | ||
|
||
echo "find maven local repository directory: $mvn_local_repository_dir" | ||
|
||
cleanMavenInstallOfColaInMavenLocalRepository() { | ||
headInfo "clean maven build and install of COLA in maven local repository:" | ||
logAndRun -s rm -rf "$mvn_local_repository_dir/com/alibaba/demo" | ||
logAndRun -s rm -rf "$mvn_local_repository_dir/com/alibaba/cola" | ||
logAndRun -s rm -rf "$mvn_local_repository_dir/com/alibaba/craftsman" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -eEuo pipefail | ||
# adjust current dir to script dir | ||
cd "$(dirname "$(readlink -f "$0")")" | ||
|
||
source common.sh | ||
source prepare-jdk.sh | ||
|
||
################################################################################ | ||
# multi JDK CI operations | ||
################################################################################ | ||
|
||
# shellcheck disable=SC2154 | ||
for jhm_var_name in "${java_home_var_names[@]}"; do | ||
export JAVA_HOME="${!jhm_var_name}" | ||
|
||
echo | ||
headInfo "test with $jhm_var_name: $JAVA_HOME" | ||
echo | ||
logAndRun ./integration-test.sh | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
# SDKMAN! with Travis | ||
# https://objectcomputing.com/news/2019/01/07/sdkman-travis | ||
set -eEuo pipefail | ||
|
||
[ -z "${_source_mark_of_prepare_jdk:+dummy}" ] || return 0 | ||
export _source_mark_of_prepare_jdk=true | ||
|
||
source "$(dirname "$(readlink -f "$BASH_SOURCE")")/common.sh" | ||
|
||
if [ ! -f "$HOME/.sdkman/bin/sdkman-init.sh" ]; then | ||
[ -d "$HOME/.sdkman" ] && rm -rf "$HOME/.sdkman" | ||
curl -s get.sdkman.io | bash || die "fail to install sdkman" | ||
echo sdkman_auto_answer=true >>"$HOME/.sdkman/etc/config" | ||
|
||
this_time_install_sdk_man=true | ||
fi | ||
set +u | ||
# shellcheck disable=SC1090 | ||
source "$HOME/.sdkman/bin/sdkman-init.sh" | ||
[ -n "$this_time_install_sdk_man" ] && logAndRun sdk ls java | ||
set -u | ||
|
||
jdks_install_by_sdkman=( | ||
8.0.275-amzn | ||
|
||
9.0.7-zulu | ||
#10.0.2-zulu | ||
11.0.9-zulu | ||
|
||
#12.0.2-open | ||
#13.0.5-zulu | ||
#14.0.2-zulu | ||
15.0.1-zulu | ||
) | ||
java_home_var_names=() | ||
|
||
__setJdkHomeVarsAndInstallJdk() { | ||
blueEcho "prepared jdks:" | ||
|
||
local jdkNameOfSdkman | ||
for jdkNameOfSdkman in "${jdks_install_by_sdkman[@]}"; do | ||
local jdkVersion | ||
jdkVersion=$(echo "$jdkNameOfSdkman" | awk -F'[.]' '{print $1}') | ||
|
||
# jdkHomeVarName like JDK7_HOME, JDK11_HOME | ||
local jdkHomeVarName="JDK${jdkVersion}_HOME" | ||
|
||
if [ ! -d "${!jdkHomeVarName:-}" ]; then | ||
local jdkHomePath="$SDKMAN_CANDIDATES_DIR/java/$jdkNameOfSdkman" | ||
|
||
# set JDKx_HOME to global var java_home_var_names | ||
eval "$jdkHomeVarName='${jdkHomePath}'" | ||
|
||
# install jdk by sdkman | ||
[ ! -d "$jdkHomePath" ] && { | ||
set +u | ||
logAndRun sdk install java "$jdkNameOfSdkman" || die "fail to install jdk $jdkNameOfSdkman by sdkman" | ||
set -u | ||
} | ||
fi | ||
|
||
java_home_var_names=(${java_home_var_names[@]:+"${java_home_var_names[@]}"} "$jdkHomeVarName") | ||
printf '%s :\n\t%s\n\tspecified is %s\n' "$jdkHomeVarName" "${!jdkHomeVarName}" "$jdkNameOfSdkman" | ||
done | ||
|
||
echo | ||
blueEcho "ls $SDKMAN_CANDIDATES_DIR/java/ :" | ||
ls -la "$SDKMAN_CANDIDATES_DIR/java/" | ||
} | ||
__setJdkHomeVarsAndInstallJdk |