Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/add cpp check #39

Merged
merged 11 commits into from
Jun 4, 2024
Prev Previous commit
Next Next commit
apply to fixed file
Signed-off-by: kminoda <koji.minoda@tier4.jp>
  • Loading branch information
kminoda committed Jun 4, 2024
commit 59710a02873de6fabaf2337bc8fa8e86e826963e
38 changes: 14 additions & 24 deletions .github/workflows/cpp-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
- 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
Loading