pvs_studio.yml 3.2 KB

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