From cacba11090298dad1d06d04f81d7a49b7bea4308 Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang Date: Fri, 24 Jun 2022 23:26:14 +0800 Subject: [PATCH] Add workflow action to validate BOM --- .github/workflows/style.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/style.yml diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml new file mode 100644 index 00000000..361add93 --- /dev/null +++ b/.github/workflows/style.yml @@ -0,0 +1,27 @@ +name: style check + +on: [pull_request] + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + # with all history + fetch-depth: 0 + - name: Validate BOM + run: | + ret=0 + for i in $(git diff --name-only origin/${GITHUB_BASE_REF}...${GITHUB_SHA}); do + if [ -f ${i} ]; then + case ${i} in + *.c|*.cc|*.cpp|*.h) + if file ${i} | grep -qv BOM; then + echo "Missing BOM in ${i}" && ret=1; + fi + ;; + esac + fi + done + exit ${ret}