pvs_studio.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
  23. fi
  24. - name: 'Checkout code'
  25. uses: actions/checkout@v3
  26. with:
  27. fetch-depth: 1
  28. ref: ${{ github.event.pull_request.head.sha }}
  29. - name: 'Get commit details'
  30. id: names
  31. run: |
  32. if [[ ${{ github.event_name }} == 'pull_request' ]]; then
  33. TYPE="pull"
  34. elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
  35. TYPE="tag"
  36. else
  37. TYPE="other"
  38. fi
  39. python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
  40. - name: 'Supply PVS credentials'
  41. run: |
  42. pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
  43. - name: 'Convert PVS-Studio output to html and detect warnings'
  44. id: pvs-warn
  45. run: |
  46. WARNINGS=0
  47. ./fbt COMPACT=1 PVSNOBROWSER=1 firmware_pvs || WARNINGS=1
  48. echo "warnings=${WARNINGS}" >> $GITHUB_OUTPUT
  49. - name: 'Upload report'
  50. if: ${{ !github.event.pull_request.head.repo.fork && (steps.pvs-warn.outputs.warnings != 0) }}
  51. uses: prewk/s3-cp-action@v2
  52. with:
  53. aws_s3_endpoint: "${{ secrets.PVS_AWS_ENDPOINT }}"
  54. aws_access_key_id: "${{ secrets.PVS_AWS_ACCESS_KEY }}"
  55. aws_secret_access_key: "${{ secrets.PVS_AWS_SECRET_KEY }}"
  56. source: "./build/f7-firmware-DC/pvsreport"
  57. dest: "s3://${{ secrets.PVS_AWS_BUCKET }}/${{steps.names.outputs.branch_name}}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/"
  58. flags: "--recursive --acl public-read"
  59. - name: 'Find Previous Comment'
  60. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
  61. uses: peter-evans/find-comment@v2
  62. id: fc
  63. with:
  64. issue-number: ${{ github.event.pull_request.number }}
  65. comment-author: 'github-actions[bot]'
  66. body-includes: 'PVS-Studio report for commit'
  67. - name: 'Create or update comment'
  68. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
  69. uses: peter-evans/create-or-update-comment@v1
  70. with:
  71. comment-id: ${{ steps.fc.outputs.comment-id }}
  72. issue-number: ${{ github.event.pull_request.number }}
  73. body: |
  74. **PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
  75. - [Report](https://pvs.flipp.dev/${{steps.names.outputs.branch_name}}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/index.html)
  76. edit-mode: replace
  77. - name: 'Raise exception'
  78. if: ${{ steps.pvs-warn.outputs.warnings != 0 }}
  79. run: |
  80. echo "Please fix all PVS warnings before merge"
  81. exit 1