From 8e4b0a1898519904d3f98937eedb8b546a10af18 Mon Sep 17 00:00:00 2001 From: kminoda <44218668+kminoda@users.noreply.github.com> Date: Tue, 4 Jun 2024 10:15:22 +0900 Subject: [PATCH 1/2] Ci/add cpp check (#34) * ci: add cppcheck Signed-off-by: kminoda * apply to fixed file Signed-off-by: kminoda --------- Signed-off-by: kminoda --- .github/workflows/cpp-check.yaml | 38 ++++++++++++-------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/.github/workflows/cpp-check.yaml b/.github/workflows/cpp-check.yaml index 4864e3baebf3c..49b1ed2c60231 100644 --- a/.github/workflows/cpp-check.yaml +++ b/.github/workflows/cpp-check.yaml @@ -14,28 +14,18 @@ jobs: - name: Install Cppcheck run: sudo apt-get install -y cppcheck - - name: Run Cppcheck - run: cppcheck --enable=warning,style,performance --error-exitcode=1 . + - name: Get changed files + id: changed-files + run: | + git fetch origin ${{ github.base_ref }} --depth=1 + git diff --name-only ${{ github.base_ref }} ${{ github.head_ref }} > changed_files.txt + cat changed_files.txt - - name: Upload Cppcheck Report - if: failure() - uses: actions/upload-artifact@v2 - with: - name: cppcheck-report - path: cppcheck-report.xml - - - name: Post results as comment - if: failure() - uses: actions/github-script@v6 - with: - script: | - const fs = require('fs'); - const path = 'cppcheck-report.xml'; - const report = fs.readFileSync(path, { encoding: 'utf8' }); - const comment = `Cppcheck Analysis:\n\n\`\`\`xml\n${report}\n\`\`\``; - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: comment - }); \ No newline at end of file + - name: Run Cppcheck on changed files + run: | + files=$(cat changed_files.txt | grep '\.cpp$\|\.h$' | tr '\n' ' ') + if [ -n "$files" ]; then + cppcheck --enable=warning,style,performance --error-exitcode=1 $files + else + echo "No C++ files changed." + shell: bash From ab6ea2ad70c6b206c9e9ac7d0a997d043770865d Mon Sep 17 00:00:00 2001 From: kminoda <44218668+kminoda@users.noreply.github.com> Date: Tue, 4 Jun 2024 10:22:53 +0900 Subject: [PATCH 2/2] Ci/add cpp check (#35) * ci: add cppcheck Signed-off-by: kminoda * apply to fixed file Signed-off-by: kminoda --------- Signed-off-by: kminoda