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
Merged
31 changes: 31 additions & 0 deletions .github/workflows/cpp-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: cppcheck

on:
pull_request:

jobs:
cppcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Install Cppcheck
run: sudo apt-get install -y cppcheck

- name: Get changed files
id: changed-files
run: |
git fetch origin ${{ github.base_ref }} --depth=1
git diff --name-only origin/${{ github.base_ref }} ${{ github.head_ref }} > changed_files.txt
cat changed_files.txt

- 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