|
| 1 | +name: Static Analysis |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master, main] |
| 6 | + pull_request: |
| 7 | + branches: [master, main] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + # Required for cpp-linter to post annotations |
| 12 | + checks: write |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: static-analysis-${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + clang-tidy: |
| 20 | + name: "clang-tidy" |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Install clang-tidy |
| 26 | + run: | |
| 27 | + sudo apt-get update |
| 28 | + sudo apt-get install -y clang-tidy |
| 29 | +
|
| 30 | + - name: Create compile_commands.json |
| 31 | + run: | |
| 32 | + cmake -S . -B build \ |
| 33 | + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ |
| 34 | + -DBITCAL_BUILD_TESTS=ON \ |
| 35 | + -DBITCAL_NATIVE_ARCH=OFF |
| 36 | +
|
| 37 | + - name: Run clang-tidy |
| 38 | + run: | |
| 39 | + clang-tidy -p build \ |
| 40 | + --checks='-*,performance-*,portability-*,bugprone-*,cert-*,cppcoreguidelines-*' \ |
| 41 | + include/bitcal/*.hpp \ |
| 42 | + tests/*.cpp \ |
| 43 | + 2>&1 | tee clang-tidy-report.txt |
| 44 | +
|
| 45 | + - name: Upload report |
| 46 | + uses: actions/upload-artifact@v4 |
| 47 | + with: |
| 48 | + name: clang-tidy-report |
| 49 | + path: clang-tidy-report.txt |
| 50 | + |
| 51 | + cppcheck: |
| 52 | + name: "cppcheck" |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - name: Install cppcheck |
| 58 | + run: | |
| 59 | + sudo apt-get update |
| 60 | + sudo apt-get install -y cppcheck |
| 61 | +
|
| 62 | + - name: Run cppcheck |
| 63 | + run: | |
| 64 | + cppcheck --enable=all \ |
| 65 | + --suppress=missingIncludeSystem \ |
| 66 | + --suppress=unusedFunction \ |
| 67 | + --suppress=preprocessorErrorDirective \ |
| 68 | + --error-exitcode=0 \ |
| 69 | + --inline-suppr \ |
| 70 | + --std=c++17 \ |
| 71 | + -I include \ |
| 72 | + include/bitcal/ tests/ \ |
| 73 | + 2>&1 | tee cppcheck-report.txt |
| 74 | +
|
| 75 | + - name: Upload report |
| 76 | + uses: actions/upload-artifact@v4 |
| 77 | + with: |
| 78 | + name: cppcheck-report |
| 79 | + path: cppcheck-report.txt |
0 commit comments