[go: nahoru, domu]

Skip to content

Commit

Permalink
Upload clang analysis only if issues were found
Browse files Browse the repository at this point in the history
Detect if issues were found and upload SARIF report only in that case,
because reports without entries are not accepted. See
github/codeql-action#390.

The analyzer is run twice in order to get a SARIF report as well as an
exit status when issues are detected, as the scan-build --status-bugs
parameter doesn't work when the output format is SARIF.
  • Loading branch information
hefloryd committed Feb 25, 2021
1 parent 82e4b0c commit d8b2b2d
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/clang-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ jobs:
with:
submodules: true

# Run clang analyzer.
#
# Detect if issues were found and upload SARIF report only in that
# case, because reports without entries are not accepted. See
# https://github.com/github/codeql-action/issues/390. The analyzer
# is run twice in order to get a SARIF report as well as an exit
# status when issues are detected, as the scan-build
# --status-bugs'parameter doesn't work when the output format is
# SARIF.

- name: Run analyzer
id: analyze
continue-on-error: true
run: |
cmake -E make_directory ${{github.workspace}}/build.clang
scan-build cmake \
Expand All @@ -37,13 +49,21 @@ jobs:
make \
-C ${{github.workspace}}/build.clang \
-j4
cmake --build ${{github.workspace}}/build.clang --target clean
scan-build \
--status-bugs \
make \
-C ${{github.workspace}}/build.clang \
-j4
- name: Merge results
- name: Merge results if any
if: steps.analyze.outcome == 'failure'
uses: microsoft/sarif-actions@v0.1
with:
command: 'merge sarif/*/*.sarif'

- name: Upload results
- name: Upload results if any
if: steps.analyze.outcome == 'failure'
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: ${{github.workspace}}/merged.sarif

0 comments on commit d8b2b2d

Please sign in to comment.