-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_projects.sh
More file actions
executable file
·113 lines (97 loc) · 3.05 KB
/
test_projects.sh
File metadata and controls
executable file
·113 lines (97 loc) · 3.05 KB
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
#!/bin/bash
RED="$(tput setaf 1)" && readonly RED
GREEN="$(tput setaf 2)" && readonly GREEN
YELLOW="$(tput setaf 3)" && readonly YELLOW
END="$(tput sgr0)" && readonly END
warn() { echo "$YELLOW$*$END"; } >&2
die() { echo; echo "$RED$*$END"; echo; exit 1; } >&2
SOURCE_ROOT="$(cd "$(dirname "$0")" && pwd)" && readonly SOURCE_ROOT
declare -a ANDROID_PROJECTS=(
"$(cd "$SOURCE_ROOT/android-application" && pwd)"
"$(cd "$SOURCE_ROOT/android-library" && pwd)"
) && readonly ANDROID_PROJECTS
declare -a JAVA_PROJECTS=(
"$(cd "$SOURCE_ROOT/jvm-application" && pwd)"
"$(cd "$SOURCE_ROOT/jvm-library" && pwd)"
) && readonly JAVA_PROJECTS
declare -a OTHER_PROJECTS=(
"$(cd "$SOURCE_ROOT/gradle-plugin" && pwd)"
) && readonly OTHER_PROJECTS
JACOCO_ANDROID_FILE='build/reports/jacoco/jacocoAndroid/jacocoAndroid.xml' && \
readonly JACOCO_ANDROID_FILE
JACOCO_JAVA_FILE='build/reports/jacoco/test/jacocoTestReport.xml' && \
readonly JACOCO_JAVA_FILE
PAGES_DIR='website/build/pages/' && readonly PAGES_DIR
for project in "${ANDROID_PROJECTS[@]}"; do
warn "Testing $project..."
echo '(1/3) Running Gradle tasks'
cd "$project" || exit 1
./gradlew -q clean check
./gradlew -q jacocoAndroid # do not join this task
./gradlew -q deployPages
echo '(2/3) Checking coverage file'
is_app=false
if [[ "$project" == *'-application' ]]; then
is_app=true
if [[ ! -e "$JACOCO_ANDROID_FILE" ]]; then
die 'Coverage not found.'
fi
else
if [[ ! -e "library/$JACOCO_ANDROID_FILE" ]] ||
[[ ! -e "library-extension/$JACOCO_ANDROID_FILE" ]]; then
die 'Coverage not found.'
fi
fi
echo '(3/3) Checking website directory'
if [[ "$is_app" = true ]]; then
if [[ ! -e "$PAGES_DIR" ]]; then
die 'Website not built.'
fi
else
if [[ ! -e "${PAGES_DIR}library" ]] ||
[[ ! -e "${PAGES_DIR}library-extension" ]]; then
die 'Website not built.'
fi
fi
done
for project in "${JAVA_PROJECTS[@]}"; do
warn "Testing $project..."
echo '(1/3) Running Gradle tasks'
cd "$project" || exit 1
./gradlew -q clean check jacocoTestReport deployPages
echo '(2/3) Checking coverage file'
is_app=false
if [[ "$project" == *'-application' ]]; then
is_app=true
if [[ ! -e "$JACOCO_JAVA_FILE" ]]; then
die 'Coverage not found.'
fi
else
if [[ ! -e "library/$JACOCO_JAVA_FILE" ]] ||
[[ ! -e "library-extension/$JACOCO_JAVA_FILE" ]]; then
die 'Coverage not found.'
fi
fi
echo '(3/3) Checking website directory'
if [[ "$is_app" = true ]]; then
if [[ ! -e "$PAGES_DIR" ]]; then
die 'Website not built.'
fi
else
if [[ ! -e "${PAGES_DIR}library" ]] ||
[[ ! -e "${PAGES_DIR}library-extension" ]]; then
die 'Website not built.'
fi
fi
done
for project in "${OTHER_PROJECTS[@]}"; do
warn "Testing $project..."
echo '(1/2) Running Gradle tasks'
cd "$project" || exit 1
./gradlew -q clean check deployPages
echo '(2/2) Checking website directory'
if [[ ! -e "${PAGES_DIR}plugin" ]]; then
die 'Website not built.'
fi
done
echo "${GREEN}Tests complete.$END"