pvs_studio.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. runs-on: [self-hosted, FlipperZeroShell]
  16. steps:
  17. - name: 'Decontaminate previous build leftovers'
  18. run: |
  19. if [ -d .git ]
  20. then
  21. git submodule status \
  22. || git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`
  23. fi
  24. - name: 'Checkout code'
  25. uses: actions/checkout@v2
  26. with:
  27. fetch-depth: 0
  28. ref: ${{ github.event.pull_request.head.sha }}
  29. - name: 'Generate suffix and folder name'
  30. id: names
  31. run: |
  32. REF=${{ github.ref }}
  33. if [[ ${{ github.event_name }} == 'pull_request' ]]; then
  34. REF=${{ github.head_ref }}
  35. fi
  36. BRANCH_OR_TAG=${REF#refs/*/}
  37. SHA=$(git rev-parse --short HEAD)
  38. if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
  39. SUFFIX=${BRANCH_OR_TAG//\//_}
  40. else
  41. SUFFIX=${BRANCH_OR_TAG//\//_}-$(date +'%d%m%Y')-${SHA}
  42. fi
  43. echo "WORKFLOW_BRANCH_OR_TAG=${BRANCH_OR_TAG}" >> $GITHUB_ENV
  44. echo "DIST_SUFFIX=${SUFFIX}" >> $GITHUB_ENV
  45. echo "::set-output name=artifacts-path::${BRANCH_OR_TAG}"
  46. echo "::set-output name=suffix::${SUFFIX}"
  47. echo "::set-output name=short-hash::${SHA}"
  48. echo "::set-output name=default-target::${DEFAULT_TARGET}"
  49. - name: 'Make reports directory'
  50. run: |
  51. rm -rf reports/
  52. mkdir reports
  53. - name: 'Generate compile_comands.json'
  54. run: |
  55. FBT_TOOLCHAIN_PATH=/opt ./fbt COMPACT=1 version_json proto_ver icons firmware_cdb dolphin_internal dolphin_blocking
  56. - name: 'Static code analysis'
  57. run: |
  58. FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
  59. pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
  60. pvs-studio-analyzer analyze \
  61. @.pvsoptions \
  62. -j$(grep -c processor /proc/cpuinfo) \
  63. -f build/f7-firmware-DC/compile_commands.json \
  64. -o PVS-Studio.log
  65. - name: 'Convert PVS-Studio output to html page'
  66. run: plog-converter -a GA:1,2,3 -t fullhtml PVS-Studio.log -o reports/${{steps.names.outputs.default-target}}-${{steps.names.outputs.suffix}}
  67. - name: 'Upload artifacts to update server'
  68. if: ${{ !github.event.pull_request.head.repo.fork }}
  69. run: |
  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/"${{steps.names.outputs.artifacts-path}}/";
  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.short-hash}}`:**
  92. - [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)
  93. edit-mode: replace