pvs_studio.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 ]
  21. then
  22. git submodule status \
  23. || git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`
  24. fi
  25. - name: 'Checkout code'
  26. uses: actions/checkout@v2
  27. with:
  28. fetch-depth: 0
  29. ref: ${{ github.event.pull_request.head.sha }}
  30. - name: 'Generate suffix and folder name'
  31. id: names
  32. run: |
  33. REF=${{ github.ref }}
  34. if [[ ${{ github.event_name }} == 'pull_request' ]]; then
  35. REF=${{ github.head_ref }}
  36. fi
  37. BRANCH_OR_TAG=${REF#refs/*/}
  38. SHA=$(git rev-parse --short HEAD)
  39. if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
  40. SUFFIX=${BRANCH_OR_TAG//\//_}
  41. else
  42. SUFFIX=${BRANCH_OR_TAG//\//_}-$(date +'%d%m%Y')-${SHA}
  43. fi
  44. echo "WORKFLOW_BRANCH_OR_TAG=${BRANCH_OR_TAG}" >> $GITHUB_ENV
  45. echo "DIST_SUFFIX=${SUFFIX}" >> $GITHUB_ENV
  46. echo "::set-output name=artifacts-path::${BRANCH_OR_TAG}"
  47. echo "::set-output name=suffix::${SUFFIX}"
  48. echo "::set-output name=short-hash::${SHA}"
  49. echo "::set-output name=default-target::${DEFAULT_TARGET}"
  50. - name: 'Make reports directory'
  51. run: |
  52. rm -rf reports/
  53. mkdir reports
  54. - name: 'Generate compile_comands.json'
  55. run: |
  56. FBT_TOOLCHAIN_PATH=/opt ./fbt COMPACT=1 version_json proto_ver icons firmware_cdb dolphin_internal dolphin_blocking
  57. - name: 'Static code analysis'
  58. run: |
  59. FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
  60. pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
  61. pvs-studio-analyzer analyze \
  62. @.pvsoptions \
  63. -j$(grep -c processor /proc/cpuinfo) \
  64. -f build/f7-firmware-DC/compile_commands.json \
  65. -o PVS-Studio.log
  66. - name: 'Convert PVS-Studio output to html page'
  67. run: plog-converter -a GA:1,2,3 -t fullhtml PVS-Studio.log -o reports/${{steps.names.outputs.default-target}}-${{steps.names.outputs.suffix}}
  68. - name: 'Upload artifacts to update server'
  69. if: ${{ !github.event.pull_request.head.repo.fork }}
  70. run: |
  71. echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
  72. chmod 600 ./deploy_key;
  73. rsync -avrzP --mkpath \
  74. -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
  75. reports/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:/home/data/firmware-pvs-studio-report/"${{steps.names.outputs.artifacts-path}}/";
  76. rm ./deploy_key;
  77. - name: 'Find Previous Comment'
  78. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
  79. uses: peter-evans/find-comment@v1
  80. id: fc
  81. with:
  82. issue-number: ${{ github.event.pull_request.number }}
  83. comment-author: 'github-actions[bot]'
  84. body-includes: 'PVS-Studio report for commit'
  85. - name: 'Create or update comment'
  86. if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request}}
  87. uses: peter-evans/create-or-update-comment@v1
  88. with:
  89. comment-id: ${{ steps.fc.outputs.comment-id }}
  90. issue-number: ${{ github.event.pull_request.number }}
  91. body: |
  92. **PVS-Studio report for commit `${{steps.names.outputs.short-hash}}`:**
  93. - [Report](https://update.flipperzero.one/builds/firmware-pvs-studio-report/${{steps.names.outputs.artifacts-path}}/${{steps.names.outputs.default-target}}-${{steps.names.outputs.suffix}}/index.html)
  94. edit-mode: replace