-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrunBasicChecks.sh
73 lines (61 loc) · 2.65 KB
/
runBasicChecks.sh
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
#!/usr/bin/env bash
#This script is intended for developers to check whether or not basic tests in the pipeline will fail.
#It takes one parameter to switch between full mode (if nothing or "full" is provided) and short mode (any other input).
#The script must be executed from the same directory it is located in.
set -euo pipefail
exit_log () {
local rc=$1
local message=$2
echo "ERROR: $message"
exit "$rc"
}
mode="${1:-full}"
log_dir=./log
mkdir -p "$log_dir"
rm "$log_dir"/*.log 2>/dev/null || echo "No files to clean up."
declare -A pids
declare -A commands
#Commands for the setup block
commands[clean]=clean
commands[client_frontend]=dataland-frontend:generateClients
commands[client_e2e]=dataland-e2etests:generateClients
#Commands for the test block
commands[ktlint]="./gradlew ktlintFormat"
commands[detekt]="./gradlew detekt"
commands[backend_unit_tests]="./gradlew dataland-backend:test"
commands[e2e_compilation]="./gradlew dataland-e2etests:compileTestKotlin"
commands[eslint]="npm --prefix ./dataland-frontend run lint"
commands[cypress_compilation]="npm --prefix ./dataland-frontend run checkcypresscompilation"
commands[frontend_compilation]="npm --prefix ./dataland-frontend run build"
commands[fixture_compilation]="npm --prefix ./dataland-frontend run checkfakefixturecompilation"
commands[dependency]="npm --prefix ./dataland-frontend run checkdependencies"
commands[frontend_component_tests]="npm --prefix ./dataland-frontend run testcomponent"
tests="ktlint detekt eslint dependency frontend_compilation cypress_compilation fixture_compilation e2e_compilation"
if [[ $mode == full ]]; then
if curl -L https://local-dev.dataland.com/api/actuator/health/ping 2>/dev/null | grep -q UP; then
echo "ERROR: The backend is currently running. This will interfere with the cleanup."
echo "Shut down the running process and restart the script."
exit 1
fi
setup="clean client_frontend client_e2e"
tests+=" backend_unit_tests frontend_component_tests"
echo "Preparing a clean state for running the tests."
else
setup=""
echo "Running in short mode, setup steps will be skipped."
fi
for step in $setup; do
echo "Executing step: $step"
./gradlew ${commands[$step]} &> "$log_dir/$step.log" || exit_log $? "Step $step failed. Please check the log file $log_dir/$step.log"
done
echo "Starting tests in parallel:"
for check in $tests; do
echo "Executing test: $check"
${commands[$check]} &> $log_dir/"$check".log &
pids[$check]=$!
done
for check in $tests; do
echo "Waiting for test $check (pid ${pids[$check]})"
wait ${pids[$check]} || echo "Test $check failed. Please check the log file $log_dir/$check"
done
echo "Finished script execution."