1
1
#! /bin/bash
2
2
3
- set -e
3
+ backend_test_failed=0
4
+ browser_test_failed=0
4
5
5
6
setupClient () {
6
- cd $GITHUB_WORKSPACE /client # to install frontend dependencies
7
+ cd $GITHUB_WORKSPACE /client # to install frontend dependencies
7
8
npm install -d
8
9
./node_modules/grunt/bin/grunt build_and_instrument
9
10
}
10
11
11
12
setupBackend () {
12
- cd $GITHUB_WORKSPACE /backend # to install backend dependencies
13
+ cd $GITHUB_WORKSPACE /backend # to install backend dependencies
13
14
pip3 install -r requirements/requirements-$( lsb_release -cs) .txt
14
15
}
15
16
@@ -21,16 +22,52 @@ pip install coverage
21
22
setupClient
22
23
setupBackend
23
24
25
+ # Running Backend Unit Tests
24
26
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
26
34
27
35
$GITHUB_WORKSPACE /backend/bin/globaleaks -z
28
36
sleep 5
29
37
38
+ # Running BrowserTesting Locally
30
39
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
32
47
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