Skip to content

Commit 334c376

Browse files
author
Anthony Hillairet
authored
Add user check to test suite (#304)
1 parent d3cbea7 commit 334c376

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

test_suite.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ REPORTS_FOLDER="/python/reports/"
44
SECTION_PREFIX="\n#########"
55

66

7+
checkuser() {
8+
WHOAMI=`whoami`
9+
if [ "$WHOAMI" != "python" ]
10+
then
11+
echo "ERROR the user in the docker image is $WHOAMI instead or \"python\""
12+
echo "Use the instruction \"USER python\" in your Dockerfile"
13+
fi
14+
}
15+
16+
717
reportvalidation() {
818
if [ -z "$1" ]
919
then
@@ -24,20 +34,23 @@ then
2434
PYTEST_REPORTS="--junitxml ${REPORTS_FOLDER}unittesting.xml $covconf --cov-report xml:${REPORTS_FOLDER}coverage.xml"
2535
fi
2636

27-
2837
echo -ne "$SECTION_PREFIX RUN TESTS:\n\n"
2938
python -m pytest -vv --durations=3 --cov ./ --cov-report term-missing $PYTEST_REPORTS; STATUS1=$?
3039

40+
echo -ne "$SECTION_PREFIX CHECK DOCKER USER IS PYTHON: "
41+
USEROUT=`checkuser`
42+
reportvalidation "$USEROUT"; STATUS2=$?
43+
3144
echo -ne "$SECTION_PREFIX CHECK TYPING: "
3245
MYPYOUT=`mypy --no-error-summary . $MYPY_REPORTS`
33-
reportvalidation "$MYPYOUT"; STATUS2=$?
46+
reportvalidation "$MYPYOUT"; STATUS3=$?
3447

3548
echo -ne "$SECTION_PREFIX CHECK LINTING: "
3649
FLAKE8OUT=`flake8`
37-
reportvalidation "$FLAKE8OUT"; STATUS3=$?
50+
reportvalidation "$FLAKE8OUT"; STATUS4=$?
3851

3952
echo -ne "$SECTION_PREFIX CHECK FORMATTING: "
40-
BLACKOUT=`black --skip-string-normalization --line-length 99 ./ --check 2>&1`; STATUS4=$?
53+
BLACKOUT=`black --skip-string-normalization --line-length 99 ./ --check 2>&1`; STATUS5=$?
4154
if [[ $BLACKOUT == "All done!"* ]]
4255
then
4356
echo "OK"
@@ -55,5 +68,5 @@ then
5568
echo
5669
fi
5770

58-
TOTAL=$((STATUS1 + STATUS2 + STATUS3 + STATUS4))
71+
TOTAL=$((STATUS1 + STATUS2 + STATUS3 + STATUS4 + STATUS5))
5972
exit $TOTAL

0 commit comments

Comments
 (0)