pvs_studio.yml 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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: 0
  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 artifacts to update server'
  50. if: ${{ !github.event.pull_request.head.repo.fork && (steps.pvs-warn.outputs.warnings != 0) }}
  51. run: |
  52. mkdir -p ~/.ssh
  53. ssh-keyscan -p ${{ secrets.RSYNC_DEPLOY_PORT }} -H ${{ secrets.RSYNC_DEPLOY_HOST }} > ~/.ssh/known_hosts
  54. echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
  55. chmod 600 ./deploy_key;
  56. rsync -avrzP --mkpath \
  57. -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
  58. build/f7-firmware-DC/pvsreport/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:/home/data/firmware-pvs-studio-report/"${BRANCH_NAME}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/";
  59. rm ./deploy_key;
  60. - name: 'Find Previous Comment'
  61. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
  62. uses: peter-evans/find-comment@v2
  63. id: fc
  64. with:
  65. issue-number: ${{ github.event.pull_request.number }}
  66. comment-author: 'github-actions[bot]'
  67. body-includes: 'PVS-Studio report for commit'
  68. - name: 'Create or update comment'
  69. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
  70. uses: peter-evans/create-or-update-comment@v1
  71. with:
  72. comment-id: ${{ steps.fc.outputs.comment-id }}
  73. issue-number: ${{ github.event.pull_request.number }}
  74. body: |
  75. **PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
  76. - [Report](https://update.flipperzero.one/builds/firmware-pvs-studio-report/${{steps.names.outputs.branch_name}}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/index.html)
  77. edit-mode: replace
  78. - name: 'Raise exception'
  79. if: ${{ steps.pvs-warn.outputs.warnings != 0 }}
  80. run: |
  81. echo "Please fix all PVS varnings before merge"
  82. exit 1