pvs_studio.yml 3.2 KB

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