Skip to content

Commit d5e534b

Browse files
committed
add annotations
Signed-off-by: Anas Nashif <[email protected]>
1 parent b896b84 commit d5e534b

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

.github/workflows/coding_guidelines.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,20 @@ jobs:
4747
- name: check-warns
4848
run: |
4949
if [[ -s "output.txt" ]]; then
50-
errors=$(cat output.txt)
51-
errors="${errors//'%'/'%25'}"
52-
errors="${errors//$'\n'/'%0A'}"
53-
errors="${errors//$'\r'/'%0D'}"
54-
echo "::error file=output.txt::$errors"
55-
exit=1
50+
errors=$(cat output.txt)
51+
errors="${errors//'%'/'%25'}"
52+
errors="${errors//$'\n'/'%0A'}"
53+
errors="${errors//$'\r'/'%0D'}"
54+
echo "::error file=output.txt::$errors"
55+
exit=1
5656
fi
5757
if [ ${exit} == 1 ]; then
5858
exit 1;
5959
fi
60+
61+
- name: Annotate
62+
uses: Attest/[email protected]
63+
with:
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
input: './violations.json'
66+
title: 'Violations'

scripts/ci/guideline_check.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import argparse
88
import re
99
from unidiff import PatchSet
10+
import json
1011

1112
if "ZEPHYR_BASE" not in os.environ:
1213
exit("$ZEPHYR_BASE environment variable undefined.")
@@ -58,6 +59,7 @@ def main():
5859
zephyr_base = os.getenv("ZEPHYR_BASE")
5960
violations = {}
6061
numViolations = 0
62+
vlist = []
6163

6264
for f in patch_set:
6365
if not f.path.endswith(".c") and not f.path.endswith(".h") or not os.path.exists(zephyr_base + "/" + f.path):
@@ -78,6 +80,13 @@ def main():
7880
if line.is_added:
7981
violation = "{}:{}".format(f.path, line.target_line_no)
8082
if violation in violations:
83+
v = {}
84+
v['message'] = "\t\n".join(violations[violation])
85+
v['path'] = violation.split(":")[0]
86+
v['line'] = { "start": violation.split(":")[1], "end": violation.split(":")[1] }
87+
v['column'] = { "start": 0, "end": 0 }
88+
v['level'] = "warning"
89+
vlist.append(v)
8190
numViolations += 1
8291
if args.output:
8392
with open(args.output, "a+") as fp:
@@ -89,7 +98,8 @@ def main():
8998
"{}:{}".format(
9099
violation, "\t\n".join(
91100
violations[violation])))
92-
101+
with open('violations.json', 'w') as outfile:
102+
json.dump(vlist, outfile)
93103
return numViolations
94104

95105

0 commit comments

Comments
 (0)