Skip to content

Commit c786bfb

Browse files
authored
Fix CI not reporting error when unit tests fail but functional tests pass. (#1274)
1 parent fd93545 commit c786bfb

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

_cms-test-internal.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
sudo chown cmsuser:cmsuser ./codecov
4+
5+
dropdb --host=testdb --username=postgres cmsdbfortesting
6+
createdb --host=testdb --username=postgres cmsdbfortesting
7+
cmsInitDB
8+
9+
pytest --cov . --cov-report xml:codecov/unittests.xml
10+
UNIT=$?
11+
12+
dropdb --host=testdb --username=postgres cmsdbfortesting
13+
createdb --host=testdb --username=postgres cmsdbfortesting
14+
cmsInitDB
15+
16+
cmsRunFunctionalTests -v --coverage codecov/functionaltests.xml
17+
FUNC=$?
18+
19+
# This check is needed because otherwise failing unit tests aren't reported in
20+
# the CI as long as the functional tests are passing. Ideally we should get rid
21+
# of `cmsRunFunctionalTests` and make those tests work with pytest so they can
22+
# be auto-discovered and run in a single command.
23+
if [ $UNIT -ne 0 ] || [ $FUNC -ne 0 ]
24+
then
25+
exit 1
26+
else
27+
exit 0
28+
fi

docker-compose.test.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,4 @@ services:
1818
- "./codecov:/home/cmsuser/cms/codecov"
1919
privileged: true
2020
cgroup: host
21-
command: >
22-
wait-for-it testdb:5432 -- sh -c "
23-
dropdb --host=testdb --username=postgres cmsdbfortesting ;
24-
createdb --host=testdb --username=postgres cmsdbfortesting ;
25-
cmsInitDB ;
26-
sudo chown cmsuser:cmsuser ./codecov ;
27-
pytest --cov . --cov-report xml:codecov/unittests.xml ;
28-
dropdb --host=testdb --username=postgres cmsdbfortesting ;
29-
createdb --host=testdb --username=postgres cmsdbfortesting ;
30-
cmsInitDB ;
31-
cmsRunFunctionalTests -v --coverage codecov/functionaltests.xml ;
32-
"
21+
command: wait-for-it testdb:5432 -- ./_cms-test-internal.sh

0 commit comments

Comments
 (0)