-
Notifications
You must be signed in to change notification settings - Fork 292
Run static analysis on OCaml C stubs in the CI #6338
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b97788b
CI: add a codechecker workflow
edwintorok 6ee60f1
[maintenance] xa_auth.h: avoid using reserved macro names
edwintorok 2a0350f
unixpwd.c: fix error path file descriptor leak
edwintorok 299cb6f
[maintenance] syslog_stubs.c: avoid using reserved identifier names
edwintorok 23e01d7
[maintenance] blkgetsize64: avoid warning about uninit value
edwintorok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"analyze": [ | ||
"--disable=misc-header-include-cycle", | ||
"--disable=clang-diagnostic-unused-parameter" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Run CodeChecker static analyzer on XAPI's C stubs | ||
permissions: {} | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- master | ||
- 'feature/**' | ||
- '*-lcm' | ||
|
||
concurrency: # On new push, cancel old workflows from the same PR, branch or tag: | ||
group: ${{ github.workflow }}-${{github.event_name}}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
staticanalyzer: | ||
name: Static analyzer for OCaml C stubs | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
security-events: write | ||
env: | ||
XAPI_VERSION: "v0.0.0-${{ github.sha }}" | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Restore cache for compile_commands.json | ||
uses: actions/cache/restore@v4 | ||
id: cache-cmds | ||
with: | ||
path: compile_commands.json | ||
key: compile_commands.json-v1-${{ hashFiles('**/dune') }} | ||
|
||
- name: Setup XenAPI environment | ||
if: steps.cache-cmds.outputs.cache-hit != 'true' | ||
uses: ./.github/workflows/setup-xapi-environment | ||
with: | ||
xapi_version: ${{ env.XAPI_VERSION }} | ||
|
||
- name: Install dune-compiledb to generate compile_commands.json | ||
if: steps.cache-cmds.outputs.cache-hit != 'true' | ||
run: | | ||
opam pin add -y ezjsonm https://github.com/mirage/ezjsonm/releases/download/v1.3.0/ezjsonm-1.3.0.tbz | ||
opam pin add -y dune-compiledb https://github.com/edwintorok/dune-compiledb/releases/download/0.6.0/dune-compiledb-0.6.0.tbz | ||
|
||
- name: Trim dune cache | ||
if: steps.cache-cmds.outputs.cache-hit != 'true' | ||
run: opam exec -- dune cache trim --size=2GiB | ||
|
||
- name: Generate compile_commands.json | ||
if: steps.cache-cmds.outputs.cache-hit != 'true' | ||
run: opam exec -- make compile_commands.json | ||
|
||
- name: Save cache for cmds.json | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: compile_commands.json | ||
key: ${{ steps.cache-cmds.outputs.cache-primary-key }} | ||
|
||
- name: Upload compile commands json | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
path: ${{ github.workspace }}/compile_commands.json | ||
|
||
- uses: whisperity/codechecker-analysis-action@v1 | ||
id: codechecker | ||
with: | ||
ctu: true | ||
logfile: ${{ github.workspace }}/compile_commands.json | ||
analyze-output: "codechecker_results" | ||
|
||
- name: Upload CodeChecker report | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: codechecker_results | ||
path: "${{ steps.codechecker.outputs.result-html-dir }}" | ||
|
||
# cppcheck even for other analyzers apparently, this is | ||
# codechecker's output | ||
- name: convert to SARIF | ||
shell: bash | ||
run: report-converter "codechecker_results" --type cppcheck --output codechecker.sarif --export sarif | ||
|
||
- name: Upload CodeChecker SARIF report | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: codechecker_sarif | ||
path: codechecker.sarif | ||
|
||
- name: Upload SARIF report | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: codechecker.sarif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.