From e090c5c9af210ff13afadf73b3fb632add212fa2 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 | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/static.check.yml b/.github/workflows/static.check.yml index c6702d92c3..b96600a204 100644 --- a/.github/workflows/static.check.yml +++ b/.github/workflows/static.check.yml @@ -10,25 +10,25 @@ jobs: runs-on: ubuntu-latest name: Static checks steps: - - uses: actions/checkout@v4 + - name: Preparing step 1... + uses: actions/checkout@v4 with: - fetch-depth: 5 - - name: Get changed files + fetch-depth: 0 + - name: Preparing step 2... id: changed-files uses: tj-actions/changed-files@v41 with: since_last_remote_commit: true - - name: List all files changed env: ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} - run: | - for file in "$ALL_CHANGED_FILES"; do - echo "$file was changed" - done - - name: Run clang-format for cc/hh/hpp/cpp files + BEFORE_REF: ${{ github.event.before }} + AFTER_REF: ${{ github.event.after }} + - name: /Checker/ clang-format for .cc/.hh/.hpp/.cpp files + shell: bash env: ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} - shell: bash + BEFORE_REF: ${{ github.event.before }} + AFTER_REF: ${{ github.event.after }} run: | sudo apt update && sudo apt-get install clang-format echo "Check .clang-format file" @@ -36,6 +36,10 @@ jobs: echo ".clang-format file not found" exit 1 fi + #git show --pretty="format:" --name-only --diff-filter=AMRC "$BEFORE_REF...$AFTER_REF" | sort | uniq | grep '.' > changed.files + for file in "$ALL_CHANGED_FILES"; do + echo "$file was changed" + done for file in "$ALL_CHANGED_FILES"; do if [[ "$file" =~ .*\.hh$ ]] || [[ "$file" =~ .*\.hpp ]] || [[ "$file" =~ .*\.cc$ ]] || [[ "$file" =~ .*\.cpp ]]; then echo "$file appears to be a C++ file. Applying clang-format" @@ -47,7 +51,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