|
| 1 | +name: Run CodeChecker static analyzer on XAPI's C stubs |
| 2 | +permissions: {} |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - master |
| 9 | + - 'feature/**' |
| 10 | + - '*-lcm' |
| 11 | + |
| 12 | +concurrency: # On new push, cancel old workflows from the same PR, branch or tag: |
| 13 | + group: ${{ github.workflow }}-${{github.event_name}}-${{ github.event.pull_request.number || github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + staticanalyzer: |
| 18 | + name: Static analyzer for OCaml C stubs |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + security-events: write |
| 23 | + env: |
| 24 | + XAPI_VERSION: "v0.0.0-${{ github.sha }}" |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Restore cache for compile_commands.json |
| 31 | + uses: actions/cache/restore@v4 |
| 32 | + id: cache-cmds |
| 33 | + with: |
| 34 | + path: compile_commands.json |
| 35 | + key: compile_commands.json-v1-${{ hashFiles('**/dune') }} |
| 36 | + |
| 37 | + - name: Setup XenAPI environment |
| 38 | + if: steps.cache-cmds.outputs.cache-hit != 'true' |
| 39 | + uses: ./.github/workflows/setup-xapi-environment |
| 40 | + with: |
| 41 | + xapi_version: ${{ env.XAPI_VERSION }} |
| 42 | + |
| 43 | + - name: Install dune-compiledb to generate compile_commands.json |
| 44 | + if: steps.cache-cmds.outputs.cache-hit != 'true' |
| 45 | + run: | |
| 46 | + opam pin add -y ezjsonm https://github.com/mirage/ezjsonm/releases/download/v1.3.0/ezjsonm-1.3.0.tbz |
| 47 | + opam pin add -y dune-compiledb https://github.com/edwintorok/dune-compiledb/releases/download/0.6.0/dune-compiledb-0.6.0.tbz |
| 48 | +
|
| 49 | + - name: Trim dune cache |
| 50 | + if: steps.cache-cmds.outputs.cache-hit != 'true' |
| 51 | + run: opam exec -- dune cache trim --size=2GiB |
| 52 | + |
| 53 | + - name: Generate compile_commands.json |
| 54 | + if: steps.cache-cmds.outputs.cache-hit != 'true' |
| 55 | + run: opam exec -- make compile_commands.json |
| 56 | + |
| 57 | + - name: Save cache for cmds.json |
| 58 | + uses: actions/cache/save@v4 |
| 59 | + with: |
| 60 | + path: compile_commands.json |
| 61 | + key: ${{ steps.cache-cmds.outputs.cache-primary-key }} |
| 62 | + |
| 63 | + - name: Upload compile commands json |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + path: ${{ github.workspace }}/compile_commands.json |
| 67 | + |
| 68 | + - uses: whisperity/codechecker-analysis-action@v1 |
| 69 | + id: codechecker |
| 70 | + with: |
| 71 | + ctu: true |
| 72 | + logfile: ${{ github.workspace }}/compile_commands.json |
| 73 | + analyze-output: "codechecker_results" |
| 74 | + |
| 75 | + - name: Upload CodeChecker report |
| 76 | + uses: actions/upload-artifact@v4 |
| 77 | + with: |
| 78 | + name: codechecker_results |
| 79 | + path: "${{ steps.codechecker.outputs.result-html-dir }}" |
| 80 | + |
| 81 | + # cppcheck even for other analyzers apparently, this is |
| 82 | + # codechecker's output |
| 83 | + - name: convert to SARIF |
| 84 | + shell: bash |
| 85 | + run: report-converter "codechecker_results" --type cppcheck --output codechecker.sarif --export sarif |
| 86 | + |
| 87 | + - name: Upload CodeChecker SARIF report |
| 88 | + uses: actions/upload-artifact@v4 |
| 89 | + with: |
| 90 | + name: codechecker_sarif |
| 91 | + path: codechecker.sarif |
| 92 | + |
| 93 | + - name: Upload SARIF report |
| 94 | + uses: github/codeql-action/upload-sarif@v3 |
| 95 | + with: |
| 96 | + sarif_file: codechecker.sarif |
0 commit comments