Skip to content

Commit

Permalink
= improve ci scripts
Browse files Browse the repository at this point in the history
- fix shellcheck warning
- Quote strings to prevent word splitting
  • Loading branch information
oldratlee committed Jan 8, 2021
1 parent 9c0c914 commit 5015dce
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 28 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# COLA 4.0
# 🥤 COLA 4.0

[![Build Status](https://travis-ci.org/alibaba/COLA.svg?branch=master)](https://travis-ci.org/alibaba/COLA)
[![Maven Central](https://img.shields.io/maven-central/v/com.alibaba.cola/cola-component-dto.svg?color=2d545e)](https://search.maven.org/search?q=g:com.alibaba.cola)
Expand All @@ -8,7 +8,8 @@
[![GitHub Forks](https://img.shields.io/github/forks/alibaba/COLA)](https://github.com/alibaba/COLA/fork)
[![GitHub issues](https://img.shields.io/github/issues/alibaba/COLA.svg)](https://github.com/alibaba/COLA/issues)

<strong>COLA 是 Clean Object-Oriented and Layered Architecture的缩写,代表“整洁面向对象分层架构”。目前COLA已经发展到[COLA 4.0](https://blog.csdn.net/significantfrank/article/details/110934799)。</strong>
<strong>COLA 是 Clean Object-Oriented and Layered Architecture的缩写,代表“整洁面向对象分层架构”。
目前COLA已经发展到[COLA 4.0](https://blog.csdn.net/significantfrank/article/details/110934799)。</strong>

COLA分为两个部分,COLA架构和COLA组件。

Expand Down Expand Up @@ -72,7 +73,7 @@ COLA架构区别于这些架构的地方,在于除了思想之外,我们还

```bash
mvn archetype:generate \
-DgroupId=com.alibaba.cola.demo.service \
-DgroupId=com.alibaba.cola.demo.web \
-DartifactId=demo-web \
-Dversion=1.0.0-SNAPSHOT \
-Dpackage=com.alibaba.demo \
Expand Down
4 changes: 2 additions & 2 deletions scripts/common.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
[ -z "${_source_mark_of_common:+dummy}" ] || return 0
_source_mark_of_common=true
[ -z "${__source_guard_309D8FD8_7655_42EE_B32A_9604A082BD9E:+dummy}" ] || return 0
__source_guard_309D8FD8_7655_42EE_B32A_9604A082BD9E=true

set -eEuo pipefail

Expand Down
19 changes: 11 additions & 8 deletions scripts/common_build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash
[ -z "${_source_mark_of_common_build:+dummy}" ] || return 0
_source_mark_of_common_build=true
[ -z "${__source_guard_7D8ED8FF_636B_4D66_95D7_9D46FE180F0F:+dummy}" ] || return 0
__source_guard_7D8ED8FF_636B_4D66_95D7_9D46FE180F0F=true

source "$(dirname "$(readlink -f "$BASH_SOURCE")")/common.sh"
# shellcheck source=common.sh
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/common.sh"

################################################################################
# build util functions
Expand All @@ -23,12 +24,14 @@ __getMvnwExe() {
}

__getJavaVersion() {
cd $(dirname "$(readlink -f "$BASH_SOURCE")")/../cola-components/ &&
cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/../cola-components/" &&
./mvnw -v | awk -F': |,' '/^Java version/ {print $2}'
}

getMoreMvnOptionsWhenJdk11() {
if ! versionLessThan $(__getJavaVersion) 11 && versionLessThan $(__getJavaVersion) 12; then
__getMoreMvnOptionsWhenJdk11() {
local javaVersion
javaVersion=$(__getJavaVersion)
if ! versionLessThan $javaVersion 11 && versionLessThan $javaVersion 12; then
echo -DperformRelease -P'!gen-sign'
fi
}
Expand All @@ -38,7 +41,7 @@ readonly -a _MVN_BASIC_OPTIONS=(
)
readonly -a _MVN_OPTIONS=(
"${_MVN_BASIC_OPTIONS[@]}"
$(getMoreMvnOptionsWhenJdk11)
$(__getMoreMvnOptionsWhenJdk11)
)

MVN() {
Expand All @@ -54,7 +57,7 @@ MVN_WITH_BASIC_OPTIONS() {

# 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/ &&
cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/../cola-components/" &&
./mvnw --no-transfer-progress help:evaluate -Dexpression=settings.localRepository |
grep '^/'
)"
Expand Down
9 changes: 8 additions & 1 deletion scripts/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

set -eEuo pipefail

source "$(dirname "$(readlink -f "$BASH_SOURCE")")/common_build.sh"
# shellcheck source=common.sh
source "$(dirname "$(readlink -f "$0")")/common.sh"
# shellcheck source=common_build.sh
source "$(dirname "$(readlink -f "$0")")/common_build.sh"

# adjust current dir to project root dir
cd "$(dirname "$0")/.."
Expand Down Expand Up @@ -44,10 +47,12 @@ cleanMavenInstallOfColaInMavenLocalRepository
awk -F'</?version>' 'NR==1 {print $2}'
)

# shellcheck disable=SC2030
readonly demo_dir="cola-archetypes/target/cola-framework-archetype-service-demo"
mkdir -p "$demo_dir"
cd "$demo_dir"

# shellcheck disable=SC2030
readonly artifactId=demo-service

MVN archetype:generate \
Expand All @@ -72,10 +77,12 @@ cleanMavenInstallOfColaInMavenLocalRepository
awk -F'</?version>' 'NR==1 {print $2}'
)

# shellcheck disable=SC2031
readonly demo_dir="cola-archetypes/target/cola-framework-archetype-web-demo"
mkdir -p "$demo_dir"
cd "$demo_dir"

# shellcheck disable=SC2031
readonly artifactId=demo-web

MVN archetype:generate \
Expand Down
1 change: 1 addition & 0 deletions scripts/multi-jdk-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ for jhm_var_name in "${java_home_var_names[@]}"; do
echo
headInfo "test with $jhm_var_name: $JAVA_HOME"
echo

logAndRun ./integration-test.sh
done
37 changes: 23 additions & 14 deletions scripts/prepare-jdk.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
#!/bin/bash
# SDKMAN! with Travis
# https://objectcomputing.com/news/2019/01/07/sdkman-travis

[ -z "${__source_guard_81039D15_3DA9_4EA3_A751_E83DBA84C038:+dummy}" ] || return 0
__source_guard_81039D15_3DA9_4EA3_A751_E83DBA84C038=true

set -eEuo pipefail

[ -z "${_source_mark_of_prepare_jdk:+dummy}" ] || return 0
export _source_mark_of_prepare_jdk=true
# shellcheck source=common.sh
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/common.sh"

source "$(dirname "$(readlink -f "$BASH_SOURCE")")/common.sh"
__loadSdkman() {
local this_time_install_sdk_man=false
# install sdkman
if [ ! -f "$HOME/.sdkman/bin/sdkman-init.sh" ]; then
[ -d "$HOME/.sdkman" ] && rm -rf "$HOME/.sdkman"

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"
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
this_time_install_sdk_man=true
fi

set +u
# shellcheck disable=SC1090
source "$HOME/.sdkman/bin/sdkman-init.sh"
"$this_time_install_sdk_man" && logAndRun sdk ls java
set -u
}
__loadSdkman

jdks_install_by_sdkman=(
8.0.275-amzn
Expand Down

0 comments on commit 5015dce

Please sign in to comment.