build: Enforce check for uncompressed SVG files in CI

- 'dev-scripts/svg_check.sh' is added to the Popups repo
- `svg_check` is run during the npm test script

Bug: T280923
Change-Id: I02715a5a70f0effb3625694f0afb3cd6250ef46c
This commit is contained in:
anjali041 2021-04-23 01:21:19 +05:30 committed by VolkerE
parent c3dc5f8e05
commit 4f12a23794
3 changed files with 17 additions and 1 deletions

1
dev-scripts/.htaccess Normal file
View file

@ -0,0 +1 @@
Deny from all

15
dev-scripts/svg_check.sh Normal file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
found=0
for svgfile in `find resources -type f -name "*.svg"`; do
outfile="$svgfile.tmp"
node_modules/.bin/svgo --config .svgo.config.js -i $svgfile -o $outfile -q
if [ $(wc -c $svgfile | awk '{print $1}') -gt $(wc -c $outfile | awk '{print $1}') ]; then
echo "File $svgfile is not compressed"
found=$((found + 1))
fi
rm $outfile
done
if [ $found -gt 0 ]; then
echo "Found $found uncompressed SVG files. Please compress the files and re-submit the patch"
exit 1
fi

View file

@ -5,7 +5,7 @@
"build-storybook": "./.storybook/storybook-resources.sh && build-storybook --config-dir=.storybook -o docs/ui -s .storybook/static",
"start": "webpack -w --mode=development",
"build": "webpack --mode=production",
"test": "npm -s run check-built-assets && npm run test:lint && npm -s run coverage && npm -s run -s doc && bundlesize && npm run build-storybook",
"test": "npm -s run check-built-assets && npm run test:lint && bash ./dev-scripts/svg_check.sh && npm -s run coverage && npm -s run -s doc && bundlesize && npm run build-storybook",
"test:unit": "mw-node-qunit 'tests/node-qunit/**/*.test.js' --require \"$PWD/tests/node-qunit/run.js\" | tap-mocha-reporter dot",
"test:lint": "npm -s run test:lint:styles && npm -s run test:lint:js && npm -s run test:lint:i18n",
"test:lint:js": "npm -s run linter:js",