Skip to content

Commit 1f7bbf3

Browse files
committed
chore: improve ci scripts
- rename prepare-jdk.sh -> prepare_jdk.sh - update common_build.sh
1 parent 9a233d3 commit 1f7bbf3

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

scripts/codecov.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cd "$(dirname "$(readlink -f "$0")")"
55
export DCM_AGENT_SUPRESS_EXCEPTION_STACK=true
66

77
source ./common_build.sh
8-
source ./prepare-jdk.sh
8+
source ./prepare_jdk.sh
99

1010
cd "$ROOT_PROJECT_DIR"
1111

scripts/common.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/bin/bash
2-
[ -z "${_source_mark_of_common:+dummy}" ] || return 0
3-
_source_mark_of_common=true
4-
52
set -eEuo pipefail
63

4+
[ -z "${__source_guard_4611926F_96EE_4837_8FAD_75929EF1EB98:+dummy}" ] || return 0
5+
__source_guard_4611926F_96EE_4837_8FAD_75929EF1EB98="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
6+
readonly __source_guard_4611926F_96EE_4837_8FAD_75929EF1EB98
7+
78
################################################################################
89
# constants
910
################################################################################
@@ -59,9 +60,8 @@ blueEcho() {
5960

6061
headInfo() {
6162
colorEcho "0;34;46" ================================================================================
62-
echo "$*"
63+
yellowEcho "$*"
6364
colorEcho "0;34;46" ================================================================================
64-
echo
6565
}
6666

6767
# How to compare a program's version in a shell script?
@@ -86,8 +86,19 @@ loose() {
8686
}
8787

8888
logAndRun() {
89-
blueEcho "Run under work directory $PWD :$nl$*" 1>&2
90-
time "$@"
89+
local simple_mode=false
90+
[ "$1" = "-s" ] && {
91+
simple_mode=true
92+
shift
93+
}
94+
95+
if $simple_mode; then
96+
echo "Run under work directory $PWD : $*"
97+
"$@"
98+
else
99+
blueEcho "Run under work directory $PWD :$nl$*" 1>&2
100+
time "$@"
101+
fi
91102
}
92103

93104
die() {

scripts/common_build.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
#!/bin/bash
2-
[ -z "${_source_mark_of_common_build:+dummy}" ] || return 0
3-
_source_mark_of_common_build=true
4-
52
set -eEuo pipefail
63

7-
readonly ROOT_SCRIPTS_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
4+
[ -z "${__source_guard_E2EB46EC_DEB8_4818_8D4E_F425BDF4A275:+dummy}" ] || return 0
5+
__source_guard_E2EB46EC_DEB8_4818_8D4E_F425BDF4A275="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
86

97
# shellcheck source=common.sh
10-
source "$ROOT_SCRIPTS_DIR/common.sh"
8+
source "$__source_guard_E2EB46EC_DEB8_4818_8D4E_F425BDF4A275/common.sh"
119

1210
#################################################################################
1311
# root project common info
1412
#################################################################################
1513

1614
# set project root dir to PROJECT_ROOT_DIR var
17-
readonly ROOT_PROJECT_DIR="$(readlink -f "$ROOT_SCRIPTS_DIR/..")"
15+
readonly ROOT_PROJECT_DIR="$(readlink -f "$__source_guard_E2EB46EC_DEB8_4818_8D4E_F425BDF4A275/..")"
1816

1917
readonly ROOT_PROJECT_VERSION=$(grep '<version>.*</version>' "$ROOT_PROJECT_DIR/pom.xml" | awk -F'</?version>' 'NR==1{print $2}')
2018
readonly ROOT_PROJECT_AID=$(grep '<artifactId>.*</artifactId>' "$ROOT_PROJECT_DIR/pom.xml" | awk -F'</?artifactId>' 'NR==1{print $2}')
@@ -97,3 +95,11 @@ mvnCopyDependencies() {
9795
MVN_CMD dependency:copy-dependencies -DincludeScope=test -DexcludeArtifactIds=jsr305,spotbugs-annotations || die "fail to mvn copy-dependencies!"
9896
)
9997
}
98+
99+
extractFirstElementValueFromPom() {
100+
(($# == 2)) || die "${FUNCNAME[0]} need only 2 arguments, actual arguments: $*"
101+
102+
local element=$1
103+
local pom_file=$2
104+
grep \<"$element"'>.*</'"$element"\> "$pom_file" | awk -F'</?'"$element"\> 'NR==1 {print $2}'
105+
}

scripts/integration-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cd "$(dirname "$(readlink -f "$0")")"
55
export CI_TEST_MODE=true
66
export DCM_AGENT_SUPRESS_EXCEPTION_STACK=true
77

8-
source ./prepare-jdk.sh
8+
source ./prepare_jdk.sh
99
source ./common_build.sh
1010

1111
# default jdk 11, do build and test

0 commit comments

Comments
 (0)