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