pvs_studio.yml 3.8 KB

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