pvs_studio.yml 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. jobs:
  14. analyse_c_cpp:
  15. if: ${{ !github.event.pull_request.head.repo.fork }}
  16. runs-on: [self-hosted, FlipperZeroShell]
  17. steps:
  18. - name: 'Decontaminate previous build leftovers'
  19. run: |
  20. if [ -d .git ]; then
  21. git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
  22. fi
  23. - name: 'Checkout code'
  24. uses: actions/checkout@v3
  25. with:
  26. fetch-depth: 0
  27. ref: ${{ github.event.pull_request.head.sha }}
  28. - name: 'Get commit details'
  29. id: names
  30. run: |
  31. if [[ ${{ github.event_name }} == 'pull_request' ]]; then
  32. TYPE="pull"
  33. elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
  34. TYPE="tag"
  35. else
  36. TYPE="other"
  37. fi
  38. python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
  39. - name: 'Make reports directory'
  40. run: |
  41. rm -rf reports/
  42. mkdir reports
  43. - name: 'Generate compile_comands.json'
  44. run: |
  45. FBT_TOOLCHAIN_PATH=/runner/_work ./fbt COMPACT=1 version_json proto_ver icons firmware_cdb dolphin_internal dolphin_blocking _fap_icons
  46. - name: 'Static code analysis'
  47. run: |
  48. FBT_TOOLCHAIN_PATH=/runner/_work source scripts/toolchain/fbtenv.sh
  49. pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
  50. pvs-studio-analyzer analyze \
  51. @.pvsoptions \
  52. -j$(grep -c processor /proc/cpuinfo) \
  53. -f build/f7-firmware-DC/compile_commands.json \
  54. -o PVS-Studio.log
  55. - name: 'Convert PVS-Studio output to html page'
  56. run: plog-converter -a GA:1,2,3 -t fullhtml PVS-Studio.log -o reports/${DEFAULT_TARGET}-${SUFFIX}
  57. - name: 'Upload artifacts to update server'
  58. if: ${{ !github.event.pull_request.head.repo.fork }}
  59. run: |
  60. mkdir -p ~/.ssh
  61. ssh-keyscan -p ${{ secrets.RSYNC_DEPLOY_PORT }} -H ${{ secrets.RSYNC_DEPLOY_HOST }} > ~/.ssh/known_hosts
  62. echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
  63. chmod 600 ./deploy_key;
  64. rsync -avrzP --mkpath \
  65. -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
  66. reports/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:/home/data/firmware-pvs-studio-report/"${BRANCH_NAME}/";
  67. rm ./deploy_key;
  68. - name: 'Find Previous Comment'
  69. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
  70. uses: peter-evans/find-comment@v1
  71. id: fc
  72. with:
  73. issue-number: ${{ github.event.pull_request.number }}
  74. comment-author: 'github-actions[bot]'
  75. body-includes: 'PVS-Studio report for commit'
  76. - name: 'Create or update comment'
  77. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request}}
  78. uses: peter-evans/create-or-update-comment@v1
  79. with:
  80. comment-id: ${{ steps.fc.outputs.comment-id }}
  81. issue-number: ${{ github.event.pull_request.number }}
  82. body: |
  83. **PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
  84. - [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)
  85. edit-mode: replace