pvs_studio.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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: 'Make reports directory'
  41. run: |
  42. rm -rf reports/
  43. mkdir reports
  44. - name: 'Generate compile_comands.json'
  45. run: |
  46. ./fbt COMPACT=1 version_json proto_ver icons firmware_cdb dolphin_internal dolphin_blocking _fap_icons api_syms
  47. - name: 'Static code analysis'
  48. run: |
  49. source scripts/toolchain/fbtenv.sh
  50. pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
  51. pvs-studio-analyzer analyze \
  52. @.pvsoptions \
  53. -C gccarm \
  54. -j$(grep -c processor /proc/cpuinfo) \
  55. -f build/f7-firmware-DC/compile_commands.json \
  56. -o PVS-Studio.log
  57. - name: 'Convert PVS-Studio output to html and detect warnings'
  58. id: pvs-warn
  59. run: |
  60. WARNINGS=0
  61. plog-converter \
  62. -a GA:1,2,3 \
  63. -t fullhtml \
  64. --indicate-warnings \
  65. PVS-Studio.log \
  66. -o reports/${DEFAULT_TARGET}-${SUFFIX} || WARNINGS=1
  67. echo "warnings=${WARNINGS}" >> $GITHUB_OUTPUT
  68. - name: 'Upload artifacts to update server'
  69. if: ${{ !github.event.pull_request.head.repo.fork && (steps.pvs-warn.outputs.warnings != 0) }}
  70. run: |
  71. mkdir -p ~/.ssh
  72. ssh-keyscan -p ${{ secrets.RSYNC_DEPLOY_PORT }} -H ${{ secrets.RSYNC_DEPLOY_HOST }} > ~/.ssh/known_hosts
  73. echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
  74. chmod 600 ./deploy_key;
  75. rsync -avrzP --mkpath \
  76. -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
  77. reports/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:/home/data/firmware-pvs-studio-report/"${BRANCH_NAME}/";
  78. rm ./deploy_key;
  79. - name: 'Find Previous Comment'
  80. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
  81. uses: peter-evans/find-comment@v2
  82. id: fc
  83. with:
  84. issue-number: ${{ github.event.pull_request.number }}
  85. comment-author: 'github-actions[bot]'
  86. body-includes: 'PVS-Studio report for commit'
  87. - name: 'Create or update comment'
  88. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
  89. uses: peter-evans/create-or-update-comment@v1
  90. with:
  91. comment-id: ${{ steps.fc.outputs.comment-id }}
  92. issue-number: ${{ github.event.pull_request.number }}
  93. body: |
  94. **PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
  95. - [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)
  96. edit-mode: replace
  97. - name: 'Raise exception'
  98. if: ${{ steps.pvs-warn.outputs.warnings != 0 }}
  99. run: |
  100. echo "Please fix all PVS varnings before merge"
  101. exit 1