forked from alibaba/COLA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration_test
executable file
·145 lines (111 loc) · 4.11 KB
/
integration_test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
set -eEuo pipefail
cd "$(dirname "$(readlink -f "$0")")"
source bash-buddy/lib/trap_error_info.sh
source bash-buddy/lib/common_utils.sh
################################################################################
# prepare
################################################################################
readonly default_build_jdk_version=11
# shellcheck disable=SC2034
readonly PREPARE_JDKS_INSTALL_BY_SDKMAN=(
8
"$default_build_jdk_version"
17
)
source bash-buddy/lib/prepare_jdks.sh
source bash-buddy/lib/java_build_utils.sh
# here use `install` and `-D performRelease` intended
# to check release operations.
#
# De-activate a maven profile from command line
# https://stackoverflow.com/questions/25201430
#
# shellcheck disable=SC2034
JVB_MVN_OPTS=(
"${JVB_DEFAULT_MVN_OPTS[@]}"
-DperformRelease -P'!gen-sign'
)
################################################################################
# ci build logic
################################################################################
cd ..
extractFirstElementValueFromPom() {
(($# == 2)) || die "${FUNCNAME[0]} need only 2 arguments, actual arguments: $*"
local element=$1
local pom_file=$2
grep \<"$element"'>.*</'"$element"\> "$pom_file" | awk -F'</?'"$element"\> 'NR==1 {print $2}'
}
test_cola_archetype() {
(
JVB_MVN_OPTS=("${JVB_DEFAULT_MVN_OPTS[@]}")
readonly archetype_name=cola-framework-archetype-service
cu::head_line_echo "test archetype:generate by $archetype_name"
# NOTE: DO NOT declare archetypeVersion var as readonly, its value is supplied by subshell.
archetypeVersion=$(extractFirstElementValueFromPom version cola-archetypes/cola-archetype-service/pom.xml)
# shellcheck disable=SC2030
readonly demo_dir="cola-archetypes/target/$archetype_name-demo"
rm -rf "$demo_dir"
mkdir -p "$demo_dir"
cd "$demo_dir"
# shellcheck disable=SC2030
readonly artifactId=demo-service
jvb::mvn_cmd archetype:generate \
-DgroupId=com.alibaba.cola.demo.archetype-service \
-DartifactId="$artifactId" \
-Dversion=1.0.0-SNAPSHOT \
-Dpackage=com.alibaba.cola.demo.service \
-DarchetypeGroupId=com.alibaba.cola \
-DarchetypeArtifactId=$archetype_name \
-DarchetypeVersion="$archetypeVersion" \
-DinteractiveMode=false \
-DarchetypeCatalog=local
cd "$artifactId"
jvb::mvn_cmd install
)
(
JVB_MVN_OPTS=("${JVB_DEFAULT_MVN_OPTS[@]}")
readonly archetype_name=cola-framework-archetype-web
cu::head_line_echo "test archetype:generate by $archetype_name"
# NOTE: DO NOT declare archetypeVersion var as readonly, its value is supplied by subshell.
archetypeVersion=$(extractFirstElementValueFromPom version cola-archetypes/cola-archetype-web/pom.xml)
# shellcheck disable=SC2031
readonly demo_dir="cola-archetypes/target/$archetype_name-demo"
rm -rf "$demo_dir"
mkdir -p "$demo_dir"
cd "$demo_dir"
# shellcheck disable=SC2031
readonly artifactId=demo-web
jvb::mvn_cmd archetype:generate \
-DgroupId=com.alibaba.cola.demo.archetype-web \
-DartifactId="$artifactId" \
-Dversion=1.0.0-SNAPSHOT \
-Dpackage=com.alibaba.cola.demo.web \
-DarchetypeGroupId=com.alibaba.cola \
-DarchetypeArtifactId=$archetype_name \
-DarchetypeVersion="$archetypeVersion" \
-DinteractiveMode=false \
-DarchetypeCatalog=local
cd "$artifactId"
jvb::mvn_cmd install
)
}
########################################
# default jdk 11, do build and test
########################################
prepare_jdks::switch_to_jdk "$default_build_jdk_version"
cu::head_line_echo "build and test with Java: $JAVA_HOME"
jvb::mvn_cmd clean install
test_cola_archetype
########################################
# test multi-version java
########################################
for jdk in "${PREPARE_JDKS_INSTALL_BY_SDKMAN[@]}"; do
# default jdk already tested above
[ "$jdk" = "$default_build_jdk_version" ] && continue
prepare_jdks::switch_to_jdk "$jdk"
cu::head_line_echo "test with Java: $JAVA_HOME"
# just test without build
jvb::mvn_cmd surefire:test
test_cola_archetype
done