From 9457844a93dd42fd8a4791cde923cb2a597d505f Mon Sep 17 00:00:00 2001 From: "Y.Hisaki" Date: Thu, 12 Dec 2024 11:16:39 +0900 Subject: [PATCH 1/8] add clang-tidy-pr-comments Signed-off-by: Y.Hisaki --- clang-tidy/action.yaml | 15 ++++++++++++--- clang-tidy/problem-matcher.json | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 clang-tidy/problem-matcher.json diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index 81ea18d2..774bdf43 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -55,7 +55,7 @@ runs: - name: Install Clang-Tidy run: | sudo apt-get -yqq update - sudo apt-get -yqq install clang-tidy libomp-dev + sudo apt-get -yqq install clang-tidy-15 libomp-15-dev shell: bash - name: Set git config @@ -139,8 +139,7 @@ runs: if: ${{ steps.get-target-files.outputs.target-files != '' }} run: | mkdir /tmp/clang-tidy-result - run-clang-tidy -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log && true - echo "exit_code=$?" >> $GITHUB_ENV + run-clang-tidy-15 -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) -use-color false ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log || true echo "${{ github.event.number }}" > /tmp/clang-tidy-result/pr-id.txt echo "${{ github.event.pull_request.head.repo.full_name }}" > /tmp/clang-tidy-result/pr-head-repo.txt echo "${{ github.event.pull_request.head.ref }}" > /tmp/clang-tidy-result/pr-head-ref.txt @@ -152,6 +151,16 @@ runs: with: files: /tmp/clang-tidy-result/report.log + - name: Setup Problem Matcher + if: ${{ steps.check-report-txt-existence.outputs.exists == 'true' }} + run: echo "::add-matcher::$GITHUB_ACTION_PATH/problem-matcher.json" + shell: bash + + - name: Show clang-tidy result + if: ${{ steps.check-report-txt-existence.outputs.exists == 'true' }} + run: cat /tmp/clang-tidy-result/report.log + shell: bash + - name: Check if the fixes.yaml file exists id: check-fixes-yaml-existence uses: autowarefoundation/autoware-github-actions/check-file-existence@v1 diff --git a/clang-tidy/problem-matcher.json b/clang-tidy/problem-matcher.json new file mode 100644 index 00000000..19b1480c --- /dev/null +++ b/clang-tidy/problem-matcher.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "owner": "clang-tidy", + "pattern": [ + { + "regexp": "^(.*):(\\d+):(\\d+):\\s(warning|error):\\s(.*)\\s\\[(.*)\\]$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5, + "code": 6 + } + ] + } + ] +} From 4aabee50be8ef61785b82b98e55021f52c0f10a8 Mon Sep 17 00:00:00 2001 From: "Y.Hisaki" Date: Thu, 12 Dec 2024 11:16:39 +0900 Subject: [PATCH 2/8] use clang-tidy-14 and run-clang-tidy-15 Signed-off-by: Y.Hisaki --- clang-tidy/action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index 774bdf43..caece4a5 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -55,7 +55,7 @@ runs: - name: Install Clang-Tidy run: | sudo apt-get -yqq update - sudo apt-get -yqq install clang-tidy-15 libomp-15-dev + sudo apt-get -yqq install clang-tidy-14 libomp-14-dev clang-tidy-15 shell: bash - name: Set git config @@ -139,7 +139,7 @@ runs: if: ${{ steps.get-target-files.outputs.target-files != '' }} run: | mkdir /tmp/clang-tidy-result - run-clang-tidy-15 -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) -use-color false ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log || true + run-clang-tidy-15 -clang-tidy-binary /usr/bin/clang-tidy-14 -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) -use-color false ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log || true echo "${{ github.event.number }}" > /tmp/clang-tidy-result/pr-id.txt echo "${{ github.event.pull_request.head.repo.full_name }}" > /tmp/clang-tidy-result/pr-head-repo.txt echo "${{ github.event.pull_request.head.ref }}" > /tmp/clang-tidy-result/pr-head-ref.txt From a359eff0ac4dd819706697461da7873dc0f5a1ca Mon Sep 17 00:00:00 2001 From: "Y.Hisaki" Date: Thu, 12 Dec 2024 11:21:22 +0900 Subject: [PATCH 3/8] remove Mark the workflow as failed if clang-tidy find an error Signed-off-by: Y.Hisaki --- clang-tidy/action.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index caece4a5..dc2e61b9 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -173,8 +173,3 @@ runs: with: name: clang-tidy-result path: /tmp/clang-tidy-result/ - - - name: Mark the workflow as failed if clang-tidy find an error - if: ${{ env.exit_code != '0' }} - run: exit 1 - shell: bash From b130bc2318c2913233afc65fb212661bb105f850 Mon Sep 17 00:00:00 2001 From: "Y.Hisaki" Date: Fri, 13 Dec 2024 11:40:37 +0900 Subject: [PATCH 4/8] fix Signed-off-by: Y.Hisaki --- clang-tidy/action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index dc2e61b9..1317f98b 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -152,12 +152,12 @@ runs: files: /tmp/clang-tidy-result/report.log - name: Setup Problem Matcher - if: ${{ steps.check-report-txt-existence.outputs.exists == 'true' }} + if: ${{ steps.check-report-log-existence.outputs.exists == 'true' }} run: echo "::add-matcher::$GITHUB_ACTION_PATH/problem-matcher.json" shell: bash - name: Show clang-tidy result - if: ${{ steps.check-report-txt-existence.outputs.exists == 'true' }} + if: ${{ steps.check-report-log-existence.outputs.exists == 'true' }} run: cat /tmp/clang-tidy-result/report.log shell: bash From fd36f9a20a15a541f58db8000702b7ba602c070a Mon Sep 17 00:00:00 2001 From: "Y.Hisaki" Date: Fri, 13 Dec 2024 11:53:51 +0900 Subject: [PATCH 5/8] fix Signed-off-by: Y.Hisaki --- clang-tidy/action.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index 1317f98b..91a41348 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -139,11 +139,12 @@ runs: if: ${{ steps.get-target-files.outputs.target-files != '' }} run: | mkdir /tmp/clang-tidy-result - run-clang-tidy-15 -clang-tidy-binary /usr/bin/clang-tidy-14 -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) -use-color false ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log || true + run-clang-tidy-15 -clang-tidy-binary /usr/bin/clang-tidy-14 -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) -use-color false ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log echo "${{ github.event.number }}" > /tmp/clang-tidy-result/pr-id.txt echo "${{ github.event.pull_request.head.repo.full_name }}" > /tmp/clang-tidy-result/pr-head-repo.txt echo "${{ github.event.pull_request.head.ref }}" > /tmp/clang-tidy-result/pr-head-ref.txt shell: bash + continue-on-error: true - name: Check if the report.log file exists id: check-report-log-existence From 3827e39f6ad7e66da340343b9ffd04af28f06dc4 Mon Sep 17 00:00:00 2001 From: "Y.Hisaki" Date: Fri, 13 Dec 2024 12:02:44 +0900 Subject: [PATCH 6/8] fix Signed-off-by: Y.Hisaki --- clang-tidy/action.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index 91a41348..fdc2da96 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -174,3 +174,8 @@ runs: with: name: clang-tidy-result path: /tmp/clang-tidy-result/ + + - name: Mark the workflow as failed if clang-tidy find an error + if: ${{ failure() }} + run: exit 1 + shell: bash From 803d7d6c57f3c56497c8fb87b07bdd188b54940c Mon Sep 17 00:00:00 2001 From: "Y.Hisaki" Date: Fri, 13 Dec 2024 12:04:00 +0900 Subject: [PATCH 7/8] fix Signed-off-by: Y.Hisaki --- clang-tidy/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index fdc2da96..5e4f5e6e 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -139,10 +139,10 @@ runs: if: ${{ steps.get-target-files.outputs.target-files != '' }} run: | mkdir /tmp/clang-tidy-result - run-clang-tidy-15 -clang-tidy-binary /usr/bin/clang-tidy-14 -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) -use-color false ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log echo "${{ github.event.number }}" > /tmp/clang-tidy-result/pr-id.txt echo "${{ github.event.pull_request.head.repo.full_name }}" > /tmp/clang-tidy-result/pr-head-repo.txt echo "${{ github.event.pull_request.head.ref }}" > /tmp/clang-tidy-result/pr-head-ref.txt + run-clang-tidy-15 -clang-tidy-binary /usr/bin/clang-tidy-14 -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) -use-color false ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log shell: bash continue-on-error: true From a73b90b33286854f9531e1e3c34e3ab17597cbc0 Mon Sep 17 00:00:00 2001 From: "Y.Hisaki" Date: Fri, 13 Dec 2024 12:12:55 +0900 Subject: [PATCH 8/8] fix Signed-off-by: Y.Hisaki --- clang-tidy/action.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index 5e4f5e6e..b0429093 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -139,12 +139,12 @@ runs: if: ${{ steps.get-target-files.outputs.target-files != '' }} run: | mkdir /tmp/clang-tidy-result + run-clang-tidy-15 -clang-tidy-binary /usr/bin/clang-tidy-14 -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) -use-color false ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log && true + echo "exit_code=$?" >> $GITHUB_ENV echo "${{ github.event.number }}" > /tmp/clang-tidy-result/pr-id.txt echo "${{ github.event.pull_request.head.repo.full_name }}" > /tmp/clang-tidy-result/pr-head-repo.txt echo "${{ github.event.pull_request.head.ref }}" > /tmp/clang-tidy-result/pr-head-ref.txt - run-clang-tidy-15 -clang-tidy-binary /usr/bin/clang-tidy-14 -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) -use-color false ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log shell: bash - continue-on-error: true - name: Check if the report.log file exists id: check-report-log-existence @@ -176,6 +176,6 @@ runs: path: /tmp/clang-tidy-result/ - name: Mark the workflow as failed if clang-tidy find an error - if: ${{ failure() }} + if: ${{ env.exit_code != '0' }} run: exit 1 shell: bash