Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flow3r
flow3r firmware
Commits
4fac8ae1
Commit
4fac8ae1
authored
1 year ago
by
q3k
Browse files
Options
Downloads
Patches
Plain Diff
ci: run mypy
parent
68aaea0a
No related branches found
No related tags found
1 merge request
!23
ci: v2 (docker, linting/checks)
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+17
-2
17 additions, 2 deletions
.gitlab-ci.yml
tools/codequal-report.py
+51
-15
51 additions, 15 deletions
tools/codequal-report.py
with
68 additions
and
17 deletions
.gitlab-ci.yml
+
17
−
2
View file @
4fac8ae1
...
...
@@ -17,11 +17,26 @@ clang-tidy:
script
:
-
"
idf.py
build"
-
"
idf.py
clang-check"
-
"
python3
tools/c
lang-tidy
-report.py
warnings.txt
>
clang-tidy-
cqual.json"
-
"
python3
tools/c
odequal
-report.py
clang-tidy
warnings.txt
>
cqual.json"
artifacts
:
when
:
always
reports
:
codequality
:
clang-tidy-cqual.json
codequality
:
cqual.json
mypy
:
stage
:
check
variables
:
MYPYPATH
:
python_payload/mypystubs
script
:
-
"
set
+e
+o
pipefail"
-
"
mypy
python_payload/main_st4m.py
--strict
--no-color-output
>
warnings.txt;
result=$?"
-
"
python3
tools/codequal-report.py
mypy
warnings.txt
>
cqual.json"
-
"
set
-e
-o
pipefail"
-
"
[
$result
==
0
]"
artifacts
:
when
:
always
reports
:
codequality
:
cqual.json
build-p3
:
stage
:
build
...
...
This diff is collapsed.
Click to expand it.
tools/c
lang-tidy
-report.py
→
tools/c
odequal
-report.py
+
51
−
15
View file @
4fac8ae1
...
...
@@ -19,7 +19,7 @@ class MagicJSONEncoder(json.JSONEncoder):
@dataclass
class
Position
:
line
:
int
column
:
int
column
:
Union
[
int
,
None
]
@dataclass
...
...
@@ -50,18 +50,26 @@ class Issue:
fingerprint
:
str
def
parse_line
(
s
:
str
)
->
Union
[
Issue
,
None
]:
parts
=
s
.
split
(
'
:
'
,
4
)
def
parse_line
(
s
:
str
,
nocol
:
bool
=
False
)
->
Union
[
Issue
,
None
]:
nparts
=
4
if
nocol
:
nparts
=
3
parts
=
s
.
split
(
'
:
'
,
nparts
)
path
=
parts
[
0
]
path
=
path
.
removeprefix
(
os
.
getcwd
()
+
'
/
'
)
line
=
int
(
parts
[
1
])
col
=
int
(
parts
[
2
])
if
nocol
:
col
=
None
level
=
parts
[
2
].
strip
()
rest
=
parts
[
3
].
strip
()
else
:
level
=
parts
[
3
].
strip
()
col
=
int
(
parts
[
2
])
rest
=
parts
[
4
].
strip
()
severity
:
Severity
=
{
'
warning
'
:
Severity
.
major
,
'
error
'
:
Severity
.
blocker
,
}.
get
(
level
,
Severity
.
info
)
rest
=
parts
[
4
].
strip
()
check
=
''
if
rest
.
endswith
(
'
]
'
):
rest
,
check
=
rest
.
split
(
'
[
'
)
...
...
@@ -72,14 +80,24 @@ def parse_line(s: str) -> Union[Issue, None]:
return
Issue
(
description
=
rest
,
check_name
=
check
,
severity
=
severity
,
location
=
location
,
fingerprint
=
fp
)
def
main
()
->
None
:
if
len
(
sys
.
argv
)
<
2
:
sys
.
stderr
.
write
(
f
"
Usage:
{
sys
.
argv
[
0
]
}
warnings.txt
\n
"
)
sys
.
stderr
.
flush
()
sys
.
exit
(
1
)
def
mypy
(
p
:
str
)
->
List
[
Issue
]:
res
:
List
[
Issue
]
=
[]
with
open
(
p
)
as
f
:
for
line
in
f
:
line
=
line
.
strip
()
if
line
.
startswith
(
'
Found
'
):
continue
if
line
.
startswith
(
'
Success:
'
):
continue
v
=
parse_line
(
line
,
nocol
=
True
)
if
v
is
not
None
:
res
.
append
(
v
)
return
res
def
clang_tidy
(
p
:
str
)
->
List
[
Issue
]:
res
:
List
[
Issue
]
=
[]
with
open
(
sys
.
argv
[
1
]
)
as
f
:
with
open
(
p
)
as
f
:
in_checks
=
False
in_list
=
False
in_context
=
False
...
...
@@ -103,11 +121,29 @@ def main() -> None:
if
v
is
not
None
:
res
.
append
(
v
)
in_context
=
True
return
res
def
main
()
->
None
:
if
len
(
sys
.
argv
)
<
3
:
sys
.
stderr
.
write
(
f
"
Usage:
{
sys
.
argv
[
0
]
}
(clang-tidy|mypy) warnings.txt
\n
"
)
sys
.
stderr
.
flush
()
sys
.
exit
(
1
)
kind
=
sys
.
argv
[
1
]
path
=
sys
.
argv
[
2
]
if
kind
==
'
clang-tidy
'
:
res
=
clang_tidy
(
path
)
elif
kind
==
'
mypy
'
:
res
=
mypy
(
path
)
else
:
sys
.
stderr
.
write
(
f
"
Unknown kind
{
kind
}
\n
"
)
sys
.
stderr
.
flush
()
sys
.
exit
(
1
)
json
.
dump
(
res
,
sys
.
stdout
,
cls
=
MagicJSONEncoder
)
if
res
!=
[]:
sys
.
stderr
.
write
(
"
Clang-tidy report not empty
"
)
sys
.
stderr
.
flush
()
os
.
exit
(
1
)
sys
.
exit
(
1
)
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment