]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/run-frontend-unittests.sh
import 15.2.5
[ceph.git] / ceph / src / pybind / mgr / dashboard / run-frontend-unittests.sh
1 #!/usr/bin/env bash
2
3 failed=false
4 SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
5 : ${CEPH_ROOT:=$SCRIPTPATH/../../../../}
6
7 cd $CEPH_ROOT/src/pybind/mgr/dashboard/frontend
8 [ -z "$BUILD_DIR" ] && BUILD_DIR=build
9 if [ `uname` != "FreeBSD" ]; then
10 . $CEPH_ROOT/${BUILD_DIR}/src/pybind/mgr/dashboard/node-env/bin/activate
11 fi
12
13 # Build
14 npm run build -- --prod --progress=false || failed=true
15
16 # Unit Tests
17 npm run test:ci || failed=true
18
19 # Linting
20 npm run lint --silent
21 if [ $? -gt 0 ]; then
22 failed=true
23 echo -e "\nTry running 'npm run fix' to fix some linting errors. \
24 Some errors might need a manual fix."
25 fi
26
27 # I18N
28 npm run i18n:extract
29 if [ $? -gt 0 ]; then
30 failed=true
31 echo -e "\nTranslations extraction has failed."
32 else
33 i18n_lint=`awk '/<source> |<source>$| <\/source>/,/<\/context-group>/ {printf "%-4s ", NR; print}' src/locale/messages.xlf`
34 if [ "$i18n_lint" ]; then
35 echo -e "\nThe following source translations in 'messages.xlf' need to be \
36 fixed, please check the I18N suggestions in 'HACKING.rst':\n"
37 echo "${i18n_lint}"
38 failed=true
39 fi
40 fi
41
42 # npm resolutions
43 npm run fix:audit
44 resolutions=`git status | grep package-lock.json`
45 if [ "$resolutions" ]; then
46 echo "Please run 'npm run fix:audit' before committing."
47 failed=true
48 fi
49
50 if [ `uname` != "FreeBSD" ]; then
51 deactivate
52 fi
53
54 if [ "$failed" = "true" ]; then
55 exit 1
56 fi