Skip to content

Commit 932e1da

Browse files
committed
[ci] Ensure both backend and client tests are always executed even if one of the two fails
1 parent 9d2d8df commit 932e1da

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed
+46-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/bin/bash
22

3-
set -e
3+
backend_test_failed=0
4+
browser_test_failed=0
45

56
setupClient() {
6-
cd $GITHUB_WORKSPACE/client # to install frontend dependencies
7+
cd $GITHUB_WORKSPACE/client # to install frontend dependencies
78
npm install -d
89
./node_modules/grunt/bin/grunt build_and_instrument
910
}
1011

1112
setupBackend() {
12-
cd $GITHUB_WORKSPACE/backend # to install backend dependencies
13+
cd $GITHUB_WORKSPACE/backend # to install backend dependencies
1314
pip3 install -r requirements/requirements-$(lsb_release -cs).txt
1415
}
1516

@@ -21,16 +22,52 @@ pip install coverage
2122
setupClient
2223
setupBackend
2324

25+
# Running Backend Unit Tests
2426
echo "Running backend unit tests"
25-
cd $GITHUB_WORKSPACE/backend && coverage run setup.py test
27+
cd $GITHUB_WORKSPACE/backend && coverage run setup.py test
28+
if [ $? -ne 0 ]; then
29+
echo "Backend unit tests failed!"
30+
backend_test_failed=1
31+
else
32+
echo "Backend unit tests succeeded!"
33+
fi
2634

2735
$GITHUB_WORKSPACE/backend/bin/globaleaks -z
2836
sleep 5
2937

38+
# Running BrowserTesting Locally
3039
echo "Running BrowserTesting locally collecting code coverage"
31-
cd $GITHUB_WORKSPACE/client && npm test
40+
cd $GITHUB_WORKSPACE/client && npm test
41+
if [ $? -ne 0 ]; then
42+
echo "Browser tests failed!"
43+
browser_test_failed=1
44+
else
45+
echo "Browser tests succeeded!"
46+
fi
3247

33-
cd $GITHUB_WORKSPACE/backend && coverage xml
34-
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Python -r $GITHUB_WORKSPACE/backend/coverage.xml
35-
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l TypeScript -r $GITHUB_WORKSPACE/client/cypress/coverage/lcov.info
36-
bash <(curl -Ls https://coverage.codacy.com/get.sh) final
48+
cd $GITHUB_WORKSPACE/backend && coverage xml
49+
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Python -r $GITHUB_WORKSPACE/backend/coverage.xml
50+
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l TypeScript -r $GITHUB_WORKSPACE/client/cypress/coverage/lcov.info
51+
52+
# At the end, check if any of the critical tests failed
53+
echo "Test Results Summary:"
54+
if [ $backend_test_failed -eq 1 ]; then
55+
echo " - Backend unit tests: FAILED"
56+
else
57+
echo " - Backend unit tests: PASSED"
58+
fi
59+
60+
if [ $browser_test_failed -eq 1 ]; then
61+
echo " - Browser tests: FAILED"
62+
else
63+
echo " - Browser tests: PASSED"
64+
fi
65+
66+
# Final exit based on the test results
67+
if [ $backend_test_failed -eq 1 ] || [ $browser_test_failed -eq 1 ]; then
68+
echo "One or both critical tests failed."
69+
exit 1 # Exit with failure if either critical test failed
70+
else
71+
echo "Script completed successfully."
72+
exit 0 # Exit successfully if no critical test failed
73+
fi

0 commit comments

Comments
 (0)