pvs_studio.yml 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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
  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. -j$(grep -c processor /proc/cpuinfo) \
  54. -f build/f7-firmware-DC/compile_commands.json \
  55. -o PVS-Studio.log
  56. - name: 'Convert PVS-Studio output to html page'
  57. run: plog-converter -a GA:1,2,3 -t fullhtml PVS-Studio.log -o reports/${DEFAULT_TARGET}-${SUFFIX}
  58. - name: 'Upload artifacts to update server'
  59. if: ${{ !github.event.pull_request.head.repo.fork }}
  60. run: |
  61. mkdir -p ~/.ssh
  62. ssh-keyscan -p ${{ secrets.RSYNC_DEPLOY_PORT }} -H ${{ secrets.RSYNC_DEPLOY_HOST }} > ~/.ssh/known_hosts
  63. echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
  64. chmod 600 ./deploy_key;
  65. rsync -avrzP --mkpath \
  66. -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
  67. reports/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:/home/data/firmware-pvs-studio-report/"${BRANCH_NAME}/";
  68. rm ./deploy_key;
  69. - name: 'Find Previous Comment'
  70. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
  71. uses: peter-evans/find-comment@v1
  72. id: fc
  73. with:
  74. issue-number: ${{ github.event.pull_request.number }}
  75. comment-author: 'github-actions[bot]'
  76. body-includes: 'PVS-Studio report for commit'
  77. - name: 'Create or update comment'
  78. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request}}
  79. uses: peter-evans/create-or-update-comment@v1
  80. with:
  81. comment-id: ${{ steps.fc.outputs.comment-id }}
  82. issue-number: ${{ github.event.pull_request.number }}
  83. body: |
  84. **PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
  85. - [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)
  86. edit-mode: replace