summaryrefslogtreecommitdiff
path: root/.github/workflows/static_code_analysis.yml
blob: 4a05c2cf916aef1f2e306db12b438ecc3180d5ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#
# Copyright (c) 2006-2024, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0
#
# Change Logs:
# Date           Author       Notes
# 2024-09-04     Supperthomas add cppcheck use the latest release version
#
name: Static code analysis

on:
  workflow_dispatch:
  pull_request:
    branches:
      - master
    paths-ignore:
      - documentation/**
      - '**/README.md'
      - '**/README_zh.md'

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  scancode_job:
    runs-on: ubuntu-22.04
    name: Static code analysis
    if: github.repository_owner == 'RT-Thread'
    steps:
      - uses: actions/checkout@main
      - name: Set up Python
        uses: actions/setup-python@main
        with:
          python-version: 3.8
      
      - name: cppcheck
        shell: bash
        run: |
          sudo apt-get update
          pip install click PyYaml
          git remote -v
          git fetch origin
          ls
          git branch -a
          git clone https://github.com/danmar/cppcheck.git
          cd cppcheck
          git fetch --tags
          latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
          echo "Latest release tag: $latest_tag"
          git checkout $latest_tag
          make FILESDIR=/usr/local/share/Cppcheck -j2
          sudo make install FILESDIR=/usr/local/share/Cppcheck 
          cppcheck --version
          cd ..
          python tools/ci/cpp_check.py check

  # # Post CI status to PR comment
  # post-ci-status:
  #   needs: scancode_job
  #   if: always() && github.event_name == 'pull_request' && github.repository_owner == 'RT-Thread'
  #   uses: ./.github/workflows/post_ci_status.yml
  #   with:
  #     workflow_name: "Static code analysis"
  #     workflow_status: ${{ needs.scancode_job.result }}
  #     pr_number: ${{ github.event.pull_request.number }}
  #   permissions:
  #     pull-requests: write
  #     issues: write