From 41a9a43429f2ddad3142de14ac2a6be807d91e5e Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Mon, 15 Jan 2024 21:05:07 +0900 Subject: [PATCH] github/actions/static: clean up clang-format checker This is to be squahed before push Signed-off-by: MyungJoo Ham --- .github/workflows/static.check.yml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/static.check.yml b/.github/workflows/static.check.yml index c6702d92c3..f832838a96 100644 --- a/.github/workflows/static.check.yml +++ b/.github/workflows/static.check.yml @@ -12,22 +12,17 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-depth: 5 - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v41 - with: - since_last_remote_commit: true - - name: List all files changed + fetch-depth: 0 + - name: /Preparing/ list changed files. env: - ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + BEFORE_REF: ${{ github.event.before }} + AFTER_REF: ${{ github.event.after }} run: | - for file in "$ALL_CHANGED_FILES"; do + git show --pretty="format:" --name-only --diff-filter=AMRC "$BEFORE_REF...$AFTER_RET" | sort | uniq | grep '.' > /tmp/changed.files + for file in /tmp/changed.files; do echo "$file was changed" done - - name: Run clang-format for cc/hh/hpp/cpp files - env: - ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + - name: /Checker/ clang-format for .cc/.hh/.hpp/.cpp files shell: bash run: | sudo apt update && sudo apt-get install clang-format @@ -36,7 +31,7 @@ jobs: echo ".clang-format file not found" exit 1 fi - for file in "$ALL_CHANGED_FILES"; do + for file in `cat /tmp/changed.files` do if [[ "$file" =~ .*\.hh$ ]] || [[ "$file" =~ .*\.hpp ]] || [[ "$file" =~ .*\.cc$ ]] || [[ "$file" =~ .*\.cpp ]]; then echo "$file appears to be a C++ file. Applying clang-format" clang-format -i ${file} @@ -47,7 +42,7 @@ jobs: git diff -- *.cc *.hh *.hpp *.cpp > .ci.clang-format.patch SIZE=$(stat -c%s .ci.clang-format.patch) if [[ $SIZE -ne 0 ]]; then - echo "clang-format shows that the commit has style errors." + echo "::error clang-format has found style errors in C++ files." cat .ci.clang-format.patch exit 1 fi