chore: add a simple bash to wrap format_app.py to be used in CI

This commit is contained in:
Zaiming (Stone) Shi 2022-03-21 17:12:10 +01:00
parent 817aa3051b
commit 8cd5c0c83a
2 changed files with 29 additions and 0 deletions

View File

@ -27,3 +27,7 @@ jobs:
- name: Check Elixir code formatting - name: Check Elixir code formatting
run: | run: |
mix format --check-formatted mix format --check-formatted
- name: Check Erlang code formatting
run: |
./scripts/check-format.sh

25
scripts/check-format.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
## Used in CI. this scripts wraps format_app.py
## and check git diff
set -euo pipefail
cd -P -- "$(dirname -- "$0")/.."
APPS=()
APPS+=( 'apps/emqx' )
#APPS+=( 'lib-ee/emqx_license' )
for app in "${APPS[@]}"; do
echo "$app ..."
./scripts/format_app.py -a "$app" -f
done
DIFF_FILES="$(git diff --name-only)"
if [ "$DIFF_FILES" != '' ]; then
echo "ERROR: Below files need reformat"
echo "$DIFF_FILES"
exit 1
fi