summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/run-frontend-unittests.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/pybind/mgr/dashboard/run-frontend-unittests.sh
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pybind/mgr/dashboard/run-frontend-unittests.sh')
-rwxr-xr-xsrc/pybind/mgr/dashboard/run-frontend-unittests.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/run-frontend-unittests.sh b/src/pybind/mgr/dashboard/run-frontend-unittests.sh
new file mode 100755
index 000000000..4f6f4d007
--- /dev/null
+++ b/src/pybind/mgr/dashboard/run-frontend-unittests.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+
+failed=false
+SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
+: ${CEPH_ROOT:=$SCRIPTPATH/../../../../}
+
+cd $CEPH_ROOT/src/pybind/mgr/dashboard/frontend
+[ -z "$BUILD_DIR" ] && BUILD_DIR=build
+if [ `uname` != "FreeBSD" ]; then
+ . $CEPH_ROOT/${BUILD_DIR}/src/pybind/mgr/dashboard/node-env/bin/activate
+fi
+
+# Build
+npm run build -- --prod --progress=false || failed=true
+
+# Unit Tests
+npm run test:ci || failed=true
+
+# Linting
+npm run lint --silent
+if [ $? -gt 0 ]; then
+ failed=true
+ echo -e "\nTry running 'npm run fix' to fix some linting errors. \
+Some errors might need a manual fix."
+fi
+
+# I18N
+npm run i18n:extract
+if [ $? -gt 0 ]; then
+ failed=true
+ echo -e "\nTranslations extraction has failed."
+else
+ i18n_lint=`awk '/<source> |<source>$| <\/source>/,/<\/context-group>/ {printf "%-4s ", NR; print}' src/locale/messages.xlf`
+
+ # Excluding the node_modules/ folder errors from the lint error
+ if [[ -n "$i18n_lint" && $i18n_lint != *"node_modules/"* ]]; then
+ echo -e "\nThe following source translations in 'messages.xlf' need to be \
+ fixed, please check the I18N suggestions on https://docs.ceph.com/en/latest/dev/developer_guide/dash-devel/#i18n:\n"
+ echo "${i18n_lint}"
+ failed=true
+ fi
+fi
+
+if [ `uname` != "FreeBSD" ]; then
+ deactivate
+fi
+
+if [ "$failed" = "true" ]; then
+ exit 1
+fi