pvs_studio.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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@v2
  25. with:
  26. fetch-depth: 0
  27. ref: ${{ github.event.pull_request.head.sha }}
  28. - name: 'Get commit details'
  29. run: |
  30. FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
  31. if [[ ${{ github.event_name }} == 'pull_request' ]]; then
  32. python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--is_pull"
  33. else
  34. python3 scripts/get_env.py "--event_file=${{ github.event_path }}"
  35. fi
  36. - name: 'Generate suffixes for comment'
  37. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
  38. id: names
  39. run: |
  40. echo "::set-output name=branch_name::${BRANCH_NAME}"
  41. echo "::set-output name=commit_sha::${COMMIT_SHA}"
  42. echo "::set-output name=default_target::${DEFAULT_TARGET}"
  43. echo "::set-output name=suffix::${SUFFIX}"
  44. - name: 'Make reports directory'
  45. run: |
  46. rm -rf reports/
  47. mkdir reports
  48. - name: 'Generate compile_comands.json'
  49. run: |
  50. FBT_TOOLCHAIN_PATH=/opt ./fbt COMPACT=1 version_json proto_ver icons firmware_cdb dolphin_internal dolphin_blocking
  51. - name: 'Static code analysis'
  52. run: |
  53. FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
  54. pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
  55. pvs-studio-analyzer analyze \
  56. @.pvsoptions \
  57. -j$(grep -c processor /proc/cpuinfo) \
  58. -f build/f7-firmware-DC/compile_commands.json \
  59. -o PVS-Studio.log
  60. - name: 'Convert PVS-Studio output to html page'
  61. run: plog-converter -a GA:1,2,3 -t fullhtml PVS-Studio.log -o reports/${DEFAULT_TARGET}-${SUFFIX}
  62. - name: 'Upload artifacts to update server'
  63. if: ${{ !github.event.pull_request.head.repo.fork }}
  64. run: |
  65. echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
  66. chmod 600 ./deploy_key;
  67. rsync -avrzP --mkpath \
  68. -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
  69. reports/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:/home/data/firmware-pvs-studio-report/"${BRANCH_NAME}/";
  70. rm ./deploy_key;
  71. - name: 'Find Previous Comment'
  72. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
  73. uses: peter-evans/find-comment@v1
  74. id: fc
  75. with:
  76. issue-number: ${{ github.event.pull_request.number }}
  77. comment-author: 'github-actions[bot]'
  78. body-includes: 'PVS-Studio report for commit'
  79. - name: 'Create or update comment'
  80. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request}}
  81. uses: peter-evans/create-or-update-comment@v1
  82. with:
  83. comment-id: ${{ steps.fc.outputs.comment-id }}
  84. issue-number: ${{ github.event.pull_request.number }}
  85. body: |
  86. **PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
  87. - [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)
  88. edit-mode: replace