-
Notifications
You must be signed in to change notification settings - Fork 6
/
do
executable file
·357 lines (306 loc) · 15.2 KB
/
do
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#!/bin/bash
TitleColor=$(tput setaf 7)
CmdColor=$(tput setaf 4; tput bold)
OkColor=$(tput setaf 2; tput bold)
ResetColor=$(tput sgr0)
((nextParam = 1))
for ((cmd = 1; cmd <= $#; cmd++)); do
((nextParam++))
case "${!cmd}" in
"help")
echo ""
echo "${TitleColor}Helper: (tip: you can chain parameters, e.g.: \"./do cdi rmi docker\" or \"./do w 3.6.0 c t\")${ResetColor}"
echo ""
echo "${CmdColor}fixgit ${ResetColor}set executable flag on git index for required files"
echo "${CmdColor}fixexec ${ResetColor}set executable permission for required files (chmod +x on bash scripts)"
echo "${CmdColor}normgit ${ResetColor}call git add --update --renormalize"
echo "${CmdColor}conv ${ResetColor}generate a Dependency Convergence report in target/site/dependency-convergence.html"
echo "${CmdColor}oga ${ResetColor}check for deprecated groupId and artifactId couples"
echo "${CmdColor}owasp ${ResetColor}generate a OWASP dependencies vulnerabilities report in target/dependency-check-report.html"
echo "${CmdColor}t ${ResetColor}test using embedded HSQLDB"
echo "${CmdColor}td ${ResetColor}test using dockerized MariaDB and Redis (container is started and stopped by script)"
echo "${CmdColor}td-postgres ${ResetColor}test using dockerized PostgreSQL and Redis (container is started and stopped by script)"
echo "${CmdColor}ut ${ResetColor}run unit tests only, no integration tests"
echo "${CmdColor}tc ${ResetColor}run unit + integration tests and generate coverage data"
echo "${CmdColor}itc ${ResetColor}run integration tests only and generate coverage data"
echo "${CmdColor}gatling ${ResetColor}benchmark application via a Gatling container (run './do up' first to start application)"
echo "${CmdColor}sc ${ResetColor}compute and upload Sonar analysis to SonarCloud (set TK1_MANON_SONAR_ORGA and TK1_MANON_SONAR_LOGIN environment variables first)"
echo "${CmdColor}tsc ${ResetColor}similar to \"do tc\" then \"do sc\""
echo "${CmdColor}sb ${ResetColor}scan with SpotBugs then show GUI"
echo "${CmdColor}b ${ResetColor}compile"
echo "${CmdColor}c ${ResetColor}clean"
echo "${CmdColor}p ${ResetColor}package"
echo "${CmdColor}rd ${ResetColor}package and run application with dev-mariadb profile"
echo "${CmdColor}w \$V ${ResetColor}set or upgrade Maven wrapper to version \$V"
echo "${CmdColor}cv ${ResetColor}check plugins and dependencies stable versions"
echo "${CmdColor}cvu ${ResetColor}check plugins and dependencies stable and unstable versions"
echo "${CmdColor}uv ${ResetColor}update plugins and dependencies versions"
echo "${CmdColor}dt ${ResetColor}show dependencies tree"
echo "${CmdColor}rmi ${ResetColor}stop Docker application, then remove its containers and images"
echo "${CmdColor}cdi ${ResetColor}clean up dangling Docker images"
echo "${CmdColor}dockerreset ${ResetColor}stop and remove all containers, remove all images and prune volumes"
echo "${CmdColor}docker ${ResetColor}build Docker image with Dockerfile to a Docker daemon as lermitage-manon:1.0.0-SNAPSHOT"
echo "${CmdColor}dockerpull ${ResetColor}pull 3rd party Docker containers"
echo "${CmdColor}jib ${ResetColor}build Docker image with Jib to a Docker daemon as lermitage-manon:1.0.0-SNAPSHOT"
echo "${CmdColor}jibtar ${ResetColor}build and save Docker image with Jib to a tarball"
echo "${CmdColor}up ${ResetColor}create and start containers via docker-compose"
echo "${CmdColor}stop ${ResetColor}stop containers via docker-compose"
echo "${CmdColor}upelk ${ResetColor}create and start ELK containers via docker-compose"
echo "${CmdColor}stopelk ${ResetColor}stop ELK containers via docker-compose"
echo "${CmdColor}upcerebro ${ResetColor}create and start Cerebro container via docker-compose"
echo "${CmdColor}stopcerebro ${ResetColor}stop Cerebro container via docker-compose"
echo "${CmdColor}maria ${ResetColor}connect to dockerized MariaDB business database by calling MySQL Client provided by container"
echo "${CmdColor}maria-batch ${ResetColor}connect to dockerized MariaDB Spring Batch database by calling MySQL Client provided by container"
echo "${CmdColor}mariah ${ResetColor}connect to dockerized MariaDB business database by calling host MySQL Client (mysql-client package must be installed)"
echo "${CmdColor}mariah-batch ${ResetColor}connect to dockerized MariaDB Spring Batch database by calling host MySQL Client (mysql-client package must be installed)"
echo "${CmdColor}e2e ${ResetColor}run some end-to-end (e2e) tests with Docker. Application image is built from a Dockerfile"
echo "${CmdColor}e2ejib ${ResetColor}run some end-to-end (e2e) tests with Docker. Application image is built with Jib"
;;
"fixgit")
git update-index --chmod=+x "do"
echo "${OkColor}'do' has now executable flag on git index${ResetColor}"
git update-index --chmod=+x "mvnw"
echo "${OkColor}'mvnw' has now executable flag on git index${ResetColor}"
git update-index --chmod=+x "e2e/run-e2e-docker.sh"
echo "${OkColor}'e2e/run-e2e-docker.sh' has now executable flag on git index${ResetColor}"
git update-index --chmod=+x "e2e/run-e2e-jib.sh"
echo "${OkColor}'e2e/run-e2e-jib.sh' has now executable flag on git index${ResetColor}"
git update-index --chmod=+x "e2e/_e2e-executor.sh"
echo "${OkColor}'e2e/_e2e-executor.sh' has now executable flag on git index${ResetColor}"
;;
"fixexec")
chmod +x ./do
echo "${OkColor}'do' is now executable${ResetColor}"
chmod +x ./mvnw
echo "${OkColor}'mvnw' is now executable${ResetColor}"
chmod +x ./e2e/run-e2e-docker.sh
echo "${OkColor}'e2e/run-e2e-docker.sh' is now executable${ResetColor}"
chmod +x ./e2e/run-e2e-jib.sh
echo "${OkColor}'e2e/run-e2e-jib.sh' is now executable${ResetColor}"
chmod +x ./e2e/_e2e-executor.sh
echo "${OkColor}'e2e/_e2e-executor.sh' is now executable${ResetColor}"
;;
"normgit")
git add --update --renormalize
echo "${OkColor}renormalized${ResetColor}"
;;
"conv")
sh ./mvnw project-info-reports:dependency-convergence -U
;;
"oga")
sh ./mvnw biz.lermitage.oga:oga-maven-plugin:check
;;
"owasp")
sh ./mvnw org.owasp:dependency-check-maven:check -P owasp
;;
"t")
sh ./mvnw verify -U
;;
"td")
echo "remove test containers"
docker-compose -f ./docker/docker-compose-test.yml down
echo "start test containers"
docker-compose -f ./docker/docker-compose-test.yml up -d maria-test
docker-compose -f ./docker/docker-compose-test.yml up -d maria-batch-test
docker-compose -f ./docker/docker-compose-test.yml up -d redis-test
echo "run tests"
sh ./mvnw verify -P test-mariadb \
-DMANON_TEST_SQL_JDBC_URL="jdbc:mariadb://127.0.0.1:3307/manon?useUnicode=true&characterEncoding=utf8&autoReconnect=true" \
-DMANON_TEST_BATCH_SQL_JDBC_URL="jdbc:mariadb://127.0.0.1:3308/manon_batch?useUnicode=true&characterEncoding=utf8&autoReconnect=true" \
-DMANON_TEST_REDIS_PORT=6380
echo "stop test containers"
docker-compose -f ./docker/docker-compose-test.yml down
;;
"td-postgres")
echo "remove test containers"
docker-compose -f ./docker/docker-compose-test.yml down
echo "start test containers"
docker-compose -f ./docker/docker-compose-test.yml up -d postgres-test
docker-compose -f ./docker/docker-compose-test.yml up -d postgres-batch-test
docker-compose -f ./docker/docker-compose-test.yml up -d redis-test
echo "run tests"
sh ./mvnw verify -P test-postgres \
-DMANON_TEST_SQL_JDBC_URL="jdbc:postgresql://127.0.0.1:5440/manon" \
-DMANON_TEST_BATCH_SQL_JDBC_URL="jdbc:postgresql://127.0.0.1:5441/manon_batch" \
-DMANON_TEST_REDIS_PORT=6380
echo "stop test containers"
docker-compose -f ./docker/docker-compose-test.yml down
;;
"ut")
sh ./mvnw test -U
;;
"tc")
sh ./mvnw verify -U -P coverage
;;
"itc")
sh ./mvnw verify -U -P coverage -DskipUT=true
;;
"b")
sh ./mvnw compile -DskipUT=true -DskipIT=true -T1 -U
;;
"c")
sh ./mvnw clean
;;
"p")
sh ./mvnw package -DskipUT=true -DskipIT=true -T1 -U
;;
"rd")
sh ./mvnw package -DskipUT=true -DskipIT=true -T1 -U
(
cd target/ || exit
java -jar -Xms128m -Xmx512m -Dspring.profiles.active=dev-mariadb -Dfile.encoding=UTF-8 -Djdk.io.File.enableADS=true -Djava.awt.headless=true -XX:CompileThreshold=1500 manon.jar
)
;;
"w")
mvn -N io.takari:maven:wrapper -Dmaven="${!nextParam}"
;;
"cv")
sh ./mvnw versions:display-property-updates -U
;;
"cvu")
sh ./mvnw versions:display-property-updates -U -P versions-unstable
;;
"uv")
sh ./mvnw versions:update-properties -U
;;
"dt")
sh ./mvnw dependency:tree -U
;;
"sc")
sh ./mvnw sonar:sonar -Dsonar.organization="$TK1_MANON_SONAR_ORGA" -Dsonar.host.url=https://sonarcloud.io -Dsonar.login="$TK1_MANON_SONAR_LOGIN"
;;
"tsc")
sh ./mvnw verify sonar:sonar -U -P coverage -Dsonar.organization="$TK1_MANON_SONAR_ORGA" -Dsonar.host.url=https://sonarcloud.io -Dsonar.login="$TK1_MANON_SONAR_LOGIN"
;;
"sb")
sh ./mvnw clean compile spotbugs:spotbugs spotbugs:gui -P spotbugs
;;
"rmi")
docker-compose -f ./docker/docker-compose.yml stop
docker rm $(docker ps -a | grep "lermitage-manon" | awk '{print $1}')
docker rmi $(docker images | grep -E "^lermitage-manon|<none>" | awk '{print $3}')
;;
"cdi")
docker rmi $(docker images -f "dangling=true" -q)
;;
"dockerreset")
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -a -q)
docker volume prune --force
if [[ -d ~/manon-app-logs ]]; then
sudo rm -R ~/manon-app-logs
fi
if [[ -d ~/manon-maria-db ]]; then
sudo rm -R ~/manon-maria-db
fi
if [[ -d ~/manon-maria-db-batch ]]; then
sudo rm -R ~/manon-maria-db-batch
fi
if [[ -d ~/manon-nginx-logs ]]; then
sudo rm -R ~/manon-nginx-logs
fi
if [[ -d ~/manon-elastic-db ]]; then
sudo rm -R ~/manon-elastic-db
fi
if [[ -d ~/manon-grafana-data ]]; then
sudo rm -R ~/manon-grafana-data
fi
;;
"docker")
docker rm $(docker ps -a | grep "lermitage-manon" | awk '{print $1}')
docker rmi $(docker images | grep -E "^lermitage-manon|<none>" | awk '{print $3}')
sh ./mvnw package -DskipUT=true -DskipIT=true -T1
docker build -f ./docker/Dockerfile -t lermitage-manon:1.0.0-SNAPSHOT .
;;
"dockerpull")
docker-compose -f ./docker/docker-compose.yml pull
docker-compose -f ./docker/docker-compose-cerebro.yml pull
docker-compose -f ./docker/docker-compose-elk.yml pull
docker-compose -f ./docker/docker-compose-gatling.yml pull
docker-compose -f ./docker/docker-compose-test.yml pull
;;
"jib")
docker rm $(docker ps -a | grep "lermitage-manon" | awk '{print $1}')
docker rmi $(docker images | grep -E "^lermitage-manon|<none>" | awk '{print $3}')
sh ./mvnw compile jib:dockerBuild -DskipUT=true -DskipIT=true -U -P jib
;;
"jibtar")
sh ./mvnw compile jib:buildTar -DskipUT=true -DskipIT=true -U -P jib
;;
"up")
if [[ ! -d ~/manon-app-logs ]]; then
mkdir ~/manon-app-logs
echo "$HOME/manon-app-logs directory created"
fi
if [[ ! -d ~/manon-maria-db ]]; then
mkdir ~/manon-maria-db
docker-compose -f ./docker/docker-compose.yml up -d maria
echo "$HOME/manon-maria-db directory created, starting maria and wait 15 seconds..."
sleep 15
echo "Done, maria should be open to connections. If manon startup fails, please restart maria"
fi
if [[ ! -d ~/manon-maria-db-batch ]]; then
mkdir ~/manon-maria-db-batch
docker-compose -f ./docker/docker-compose.yml up -d maria-batch
echo "$HOME/manon-maria-db-batch directory created, starting maria and wait 15 seconds..."
sleep 15
echo "Done, maria-batch should be open to connections. If manon startup fails, please restart maria-batch"
fi
if [[ ! -d ~/manon-nginx-logs ]]; then
mkdir ~/manon-nginx-logs
echo "$HOME/manon-nginx-logs directory created"
fi
if [[ ! -d ~/manon-grafana-data ]]; then
if ! getent passwd grafana >/dev/null 2>&1; then
sudo groupadd grafana -g 472
sudo useradd grafana -u 472 -g grafana
fi
mkdir ~/manon-grafana-data
sudo chown -R grafana ~/manon-grafana-data
echo "$HOME/manon-grafana-data directory created"
fi
docker-compose -f ./docker/docker-compose.yml up -d
;;
"stop")
docker-compose -f ./docker/docker-compose.yml down
;;
"upelk")
if [[ ! -d ~/manon-elastic-db ]]; then
mkdir ~/manon-elastic-db
echo "$HOME/manon-elastic-db directory created"
fi
docker-compose -f ./docker/docker-compose-elk.yml up -d
;;
"stopelk")
docker-compose -f ./docker/docker-compose-elk.yml down
;;
"upcerebro")
docker-compose -f ./docker/docker-compose-cerebro.yml up -d
;;
"stopcerebro")
docker-compose -f ./docker/docker-compose-cerebro.yml down
;;
"gatling")
docker-compose -f ./docker/docker-compose-gatling.yml up --build --force-recreate --renew-anon-volumes
;;
"maria")
docker exec -it maria mysql --user=root --password=woot manon
;;
"maria-batch")
docker exec -it maria-batch mysql --port 3308 --user=root --password=woot manon_batch
;;
"mariah")
mysql -h $(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' maria) --port 3306 --protocol=TCP --user=root --password=woot manon
;;
"mariah-batch")
mysql -h $(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' maria-batch) --port 3306 --protocol=TCP --user=root --password=woot manon_batch
;;
"e2e")
./e2e/run-e2e-docker.sh
;;
"e2ejib")
./e2e/run-e2e-jib.sh
;;
esac
done