From 044f0090e4c1dc4cbc235d4012d6895d2ab89636 Mon Sep 17 00:00:00 2001 From: Sergio Date: Mon, 4 Nov 2024 14:29:42 +0100 Subject: [PATCH] GH Actions: Fix code formatter action --- .github/workflows/format.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 904e4f4..5079e0f 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -3,24 +3,26 @@ name: Clang format on: [pull_request] jobs: - clang-format-8: - runs-on: ubuntu-latest + clang-format: + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - - name: Run clang-foramt on changed files + - name: Run clang-format on changed files run: | set -x + sudo apt install clang-format + git config --global --add safe.directory '*' git fetch origin ${{ github.event.pull_request.base.ref }} git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }} BASE_COMMIT=$(git rev-parse ${{ github.event.pull_request.base.sha }}) - COMMIT_FILES=$(git diff --name-only ${BASE_COMMIT} | grep -i -v LinkDef) - RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES}) + COMMIT_FILES=$(git diff --name-only "${BASE_COMMIT}" | grep -i -v LinkDef) + RESULT_OUTPUT=$(git clang-format --commit "${BASE_COMMIT}" --diff --binary "$(which clang-format)" -- "${COMMIT_FILES}") if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ]; then exit 0 else - git-clang-format-8 --commit $BASE_COMMIT --diff --binary $(which clang-format-8) + git clang-format --commit "$BASE_COMMIT" --diff --binary "$(which clang-format)" echo "$RESULT_OUTPUT" exit 1 - fi + fi