-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests
executable file
·101 lines (80 loc) · 2.47 KB
/
run_tests
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
#!/bin/bash
# Save the current
HOME_DIR=$(pwd)
# Prevent test failures from stopping the script
set +e -o pipefail
export CHROME_BIN=`which chromium`
export CHROME_OPTIONS="--headless"
export PUPPETEER_EXECUTABLE_PATH=`which chromium`
export PUPPETEER_SKIP_DOWNLOAD="true"
# Update BHIMA to latest master
cd /home/jenkins/builds/Bhima
git checkout package.json
git checkout package-lock.json
if [[ -z "$PULL_REQUEST" ]]; then
echo "====> Run tests on master"
git checkout master
git pull
else
echo "====> Run tests on pull request $PULL_REQUEST"
git branch -D test$PULL_REQUEST || true
git fetch origin pull/$PULL_REQUEST/head:test$PULL_REQUEST
git checkout test$PULL_REQUEST
fi
# Update the testing environment
npm install
npx update-browserslist-db@latest
npx playwright install chromium
# Save the start time (for the actual tests)
time_start=$(date +%s)
# Delete any old test results files and processes
npm run test:clean
pkill --uid jenkins -f puppeteer || true
pkill --uid jenkins -f node || true
# Delete any zombie server processes
procs=`netstat -tulpn |& grep 8080`
proc=`echo $procs | sed -r 's/.* ([0-9]+)\/node$/\1/g'`
if [[ ! -z "$proc" ]]
then
echo "Deleting zombie node Bhima process $proc"
kill -9 $proc
fi
# Do one preliminary build to be safe
npm run build
# Run the regular tests
echo "================================================================================"
date
set +e
npm run test || true
# Run the end-to-end tests
echo "================================================================================"
date
set +e
export E2E_TEST_SERVER=1
export PWTEST_SKIP_TEST_OUTPUT=1
npm run test:e2e-all || true
echo "================================================================================"
date
# Save the end time
time_end=$(date +%s)
final_time=$(date)
# Clean up
pkill --uid jenkins -f puppeteer || true
pkill --uid jenkins -f node || true
# Show the summary
npm run test:show-results
# Compute the time it took the tests to run
time_total=$(($time_end - $time_start))
mins=$(($time_total / 60))
secs=$(($time_total - ($mins*60)))
printf -v dtime "%02d:%02d\n" "$mins" "$secs"
# Save the artifacts for Jenkins
npm run test:show-results > results/summary.txt
echo "Ending time: $final_time" >> results/summary.txt
echo "Time to run tests: $dtime" >> results/summary.txt
printenv | sort > results/environment.txt
cp package.json results/
rm -f results.zip
zip -r results.zip results
cp -r results $HOME_DIR/
cp results.zip $HOME_DIR/