From 8cd5c0c83a6a40a1968a32a5a4dbd8c46257932b Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Mon, 21 Mar 2022 17:12:10 +0100 Subject: [PATCH] chore: add a simple bash to wrap format_app.py to be used in CI --- .github/workflows/code_style_check.yaml | 4 ++++ scripts/check-format.sh | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 scripts/check-format.sh diff --git a/.github/workflows/code_style_check.yaml b/.github/workflows/code_style_check.yaml index 5e3cbe435..5cb284ac4 100644 --- a/.github/workflows/code_style_check.yaml +++ b/.github/workflows/code_style_check.yaml @@ -27,3 +27,7 @@ jobs: - name: Check Elixir code formatting run: | mix format --check-formatted + + - name: Check Erlang code formatting + run: | + ./scripts/check-format.sh diff --git a/scripts/check-format.sh b/scripts/check-format.sh new file mode 100755 index 000000000..dd0873ab8 --- /dev/null +++ b/scripts/check-format.sh @@ -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