pvs_studio.yml 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. name: 'Static C/C++ analysis with PVS-Studio'
  2. on:
  3. push:
  4. branches:
  5. - dev
  6. - "release*"
  7. tags:
  8. - '*'
  9. pull_request:
  10. env:
  11. TARGETS: f7
  12. DEFAULT_TARGET: f7
  13. FBT_TOOLCHAIN_PATH: /runner/_work
  14. jobs:
  15. analyse_c_cpp:
  16. if: ${{ !github.event.pull_request.head.repo.fork }}
  17. runs-on: [self-hosted, FlipperZeroShell]
  18. steps:
  19. - name: 'Decontaminate previous build leftovers'
  20. run: |
  21. if [ -d .git ]; then
  22. git submodule status || (
  23. git ls-files --stage | egrep '^160000' | awk '{print $4}' | while read submodule
  24. do
  25. git rm -rf --cached "$submodule"
  26. done
  27. )
  28. fi
  29. - name: 'Checkout code'
  30. uses: actions/checkout@v3
  31. with:
  32. fetch-depth: 1
  33. ref: ${{ github.event.pull_request.head.sha }}
  34. - name: 'Get commit details'
  35. id: names
  36. run: |
  37. if [[ ${{ github.event_name }} == 'pull_request' ]]; then
  38. TYPE="pull"
  39. elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
  40. TYPE="tag"
  41. else
  42. TYPE="other"
  43. fi
  44. python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
  45. - name: 'Supply PVS credentials'
  46. run: |
  47. pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
  48. - name: 'Convert PVS-Studio output to html and detect warnings'
  49. id: pvs-warn
  50. run: |
  51. WARNINGS=0
  52. ./fbt COMPACT=1 PVSNOBROWSER=1 firmware_pvs || WARNINGS=1
  53. echo "warnings=${WARNINGS}" >> $GITHUB_OUTPUT
  54. - name: 'Upload report'
  55. if: ${{ !github.event.pull_request.head.repo.fork && (steps.pvs-warn.outputs.warnings != 0) }}
  56. uses: prewk/s3-cp-action@v2
  57. with:
  58. aws_s3_endpoint: "${{ secrets.PVS_AWS_ENDPOINT }}"
  59. aws_access_key_id: "${{ secrets.PVS_AWS_ACCESS_KEY }}"
  60. aws_secret_access_key: "${{ secrets.PVS_AWS_SECRET_KEY }}"
  61. source: "./build/f7-firmware-DC/pvsreport"
  62. dest: "s3://${{ secrets.PVS_AWS_BUCKET }}/${{steps.names.outputs.branch_name}}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/"
  63. flags: "--recursive --acl public-read"
  64. - name: 'Find Previous Comment'
  65. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
  66. uses: peter-evans/find-comment@v2
  67. id: fc
  68. with:
  69. issue-number: ${{ github.event.pull_request.number }}
  70. comment-author: 'github-actions[bot]'
  71. body-includes: 'PVS-Studio report for commit'
  72. - name: 'Create or update comment'
  73. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
  74. uses: peter-evans/create-or-update-comment@v1
  75. with:
  76. comment-id: ${{ steps.fc.outputs.comment-id }}
  77. issue-number: ${{ github.event.pull_request.number }}
  78. body: |
  79. **PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
  80. - [Report](https://pvs.flipp.dev/${{steps.names.outputs.branch_name}}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/index.html)
  81. edit-mode: replace
  82. - name: 'Raise exception'
  83. if: ${{ steps.pvs-warn.outputs.warnings != 0 }}
  84. run: |
  85. echo "Please fix all PVS warnings before merge"
  86. exit 1