static_code_analysis.yml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #
  2. # Copyright (c) 2006-2024, RT-Thread Development Team
  3. #
  4. # SPDX-License-Identifier: Apache-2.0
  5. #
  6. # Change Logs:
  7. # Date Author Notes
  8. # 2024-09-04 Supperthomas add cppcheck use the latest release version
  9. #
  10. name: Static code analysis
  11. on:
  12. workflow_dispatch:
  13. pull_request:
  14. branches:
  15. - master
  16. paths-ignore:
  17. - documentation/**
  18. - '**/README.md'
  19. - '**/README_zh.md'
  20. concurrency:
  21. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  22. cancel-in-progress: true
  23. jobs:
  24. scancode_job:
  25. runs-on: ubuntu-22.04
  26. name: Static code analysis
  27. if: github.repository_owner == 'RT-Thread'
  28. steps:
  29. - uses: actions/checkout@main
  30. - name: Set up Python
  31. uses: actions/setup-python@main
  32. with:
  33. python-version: 3.8
  34. - name: cppcheck
  35. shell: bash
  36. run: |
  37. sudo apt-get update
  38. pip install click PyYaml
  39. git remote -v
  40. git fetch origin
  41. ls
  42. git branch -a
  43. git clone https://github.com/danmar/cppcheck.git
  44. cd cppcheck
  45. git fetch --tags
  46. latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
  47. echo "Latest release tag: $latest_tag"
  48. git checkout $latest_tag
  49. make FILESDIR=/usr/local/share/Cppcheck -j2
  50. sudo make install FILESDIR=/usr/local/share/Cppcheck
  51. cppcheck --version
  52. cd ..
  53. python tools/ci/cpp_check.py check
  54. # # Post CI status to PR comment
  55. # post-ci-status:
  56. # needs: scancode_job
  57. # if: always() && github.event_name == 'pull_request' && github.repository_owner == 'RT-Thread'
  58. # uses: ./.github/workflows/post_ci_status.yml
  59. # with:
  60. # workflow_name: "Static code analysis"
  61. # workflow_status: ${{ needs.scancode_job.result }}
  62. # pr_number: ${{ github.event.pull_request.number }}
  63. # permissions:
  64. # pull-requests: write
  65. # issues: write