pvs_studio.yml 4.0 KB

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