Skip to content

Commit 5adfde1

Browse files
committed
Restore files modified for testing purposes(new)
1 parent f7e4328 commit 5adfde1

File tree

7 files changed

+29
-55
lines changed

7 files changed

+29
-55
lines changed

.github/workflows/file_check.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
name: Check File Format, License and Static Code Analysis(cppcheck)
1+
name: Check File Format and License
22

33
on: [pull_request]
44

55
jobs:
66
scancode_job:
77
runs-on: ubuntu-latest
8-
name: Scan code format, license and static code analysis
8+
name: Scan code format and license
99
steps:
1010
- uses: actions/checkout@v3
1111
- name: Set up Python
1212
uses: actions/setup-python@v3
1313
with:
1414
python-version: 3.8
1515

16-
- name: Check Format, License and Static Code Analysis(cppcheck)
16+
- name: Check Format and License
1717
shell: bash
1818
run: |
19-
sudo apt-get update
20-
sudo apt-get -qq install cppcheck
21-
cppcheck --version
2219
pip install click chardet PyYaml
2320
python tools/ci/file_check.py check 'https://github.com/RT-Thread/rt-thread' 'master'

.github/workflows/static_code_analysis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Static code analysis
22

3-
on: [push]
4-
# pull_request:
5-
# branches:
6-
# - master
3+
on:
4+
pull_request:
5+
branches:
6+
- master
77

88
jobs:
99
scancode_job:
@@ -27,4 +27,4 @@ jobs:
2727
cppcheck --version
2828
ls
2929
git branch -a
30-
python tools/ci/cpp_check.py check 'https://github.com/RT-Thread/rt-thread' 'master'
30+
python tools/ci/cpp_check.py check

bsp/wch/risc-v/.ignore_format.yml

-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44

55
dir_path:
66
- Libraries/CH32V10x_StdPeriph_Driver
7-
- Libraries/ch56x_drivers

bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_gpio.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static rt_base_t gpio_pin_get(const char *name)
186186
}
187187
if (pin < 32 && (pin_ports[port].pin_mark & (1 << pin)))
188188
{
189-
return port * 32 + pin;
189+
return port * 32 + pin;
190190
}
191191
}
192192
}

tools/ci/cpp_check.py

+3-15
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# Change Logs:
77
# Date Author Notes
8-
# 2021-04-01 LiuKang the first version
8+
# 2023-05-16 dejavudwh the first version
99
#
1010

1111
import click
@@ -36,25 +36,13 @@ def cli(ctx):
3636
pass
3737

3838
@cli.command()
39-
@click.argument(
40-
'repo',
41-
nargs=1,
42-
type=click.STRING,
43-
default='https://github.com/RT-Thread/rt-thread',
44-
)
45-
@click.argument(
46-
'branch',
47-
nargs=1,
48-
type=click.STRING,
49-
default='master',
50-
)
51-
def check(repo, branch):
39+
def check():
5240
"""
5341
static code analysis(cppcheck).
5442
"""
5543
format_ignore.init_logger()
5644
# get modified files list
57-
checkout = format_ignore.CheckOut(repo, branch)
45+
checkout = format_ignore.CheckOut()
5846
file_list = checkout.get_new_file()
5947
if file_list is None:
6048
logging.error("checkout files fail")

tools/ci/file_check.py

+4-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2006-2023, RT-Thread Development Team
2+
# Copyright (c) 2006-2022, RT-Thread Development Team
33
#
44
# SPDX-License-Identifier: Apache-2.0
55
#
@@ -16,7 +16,6 @@
1616
import chardet
1717
import logging
1818
import datetime
19-
import subprocess
2019

2120
def init_logger():
2221
log_format = "[%(filename)s %(lineno)d %(levelname)s] %(message)s "
@@ -221,21 +220,6 @@ def check(self):
221220

222221
return check_result
223222

224-
class CPPCheck:
225-
def __init__(self, file_list):
226-
self.file_list = file_list
227-
228-
def check(self):
229-
file_list_filtered = [file for file in self.file_list if file.endswith(('.c', '.cpp', '.cc', '.cxx'))]
230-
logging.info("Start to static code analysis.")
231-
check_result = True
232-
for file in file_list_filtered:
233-
result = subprocess.run(['cppcheck', '--enable=warning', 'performance', 'portability', '--inline-suppr', '--error-exitcode=1', '--force', file], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
234-
logging.info(result.stdout.decode())
235-
logging.info(result.stderr.decode())
236-
if result.stderr:
237-
check_result = False
238-
return check_result
239223

240224
@click.group()
241225
@click.pass_context
@@ -266,7 +250,7 @@ def cli(ctx):
266250
)
267251
def check(check_license, repo, branch):
268252
"""
269-
check files license, format and static code analysis(cppcheck).
253+
check files license and format.
270254
"""
271255
init_logger()
272256
# get modified files list
@@ -279,15 +263,13 @@ def check(check_license, repo, branch):
279263
# check modified files format
280264
format_check = FormatCheck(file_list)
281265
format_check_result = format_check.check()
282-
cpp_check = CPPCheck(file_list)
283-
cpp_check_result = cpp_check.check()
284266
license_check_result = True
285267
if check_license:
286268
license_check = LicenseCheck(file_list)
287269
license_check_result = license_check.check()
288270

289-
if not format_check_result or not cpp_check_result or not license_check_result:
290-
logging.error("file format check or license check or static code analysis(cppcheck) fail.")
271+
if not format_check_result or not license_check_result:
272+
logging.error("file format check or license check fail.")
291273
sys.exit(1)
292274
logging.info("check success.")
293275
sys.exit(0)

tools/ci/format_ignore.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#
2+
# Copyright (c) 2006-2023, RT-Thread Development Team
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Change Logs:
7+
# Date Author Notes
8+
# 2023-05-16 dejavudwh the first version
9+
#
10+
111
import yaml
212
import logging
313
import os
@@ -12,11 +22,9 @@ def init_logger():
1222
)
1323

1424
class CheckOut:
15-
def __init__(self, rtt_repo, rtt_branch):
16-
self.root = os.getcwd()
17-
self.rtt_repo = rtt_repo
18-
self.rtt_branch = rtt_branch
19-
25+
def __init__(self):
26+
pass
27+
2028
def __exclude_file(self, file_path):
2129
dir_number = file_path.split('/')
2230
ignore_path = file_path

0 commit comments

Comments
 (0)