Skip to content

Commit 28563a1

Browse files
committed
fix annotation on line
1 parent 249189e commit 28563a1

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

tests/restyle.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def find_arduino_files():
8686
class Changed:
8787
file: str
8888
hunk: list[str]
89-
lines: list[str]
89+
lines: list[int]
9090

9191

9292
@dataclass
@@ -122,7 +122,9 @@ def reset_with_line(ctx, line):
122122

123123
def pop(out, context, line):
124124
if ctx.file and ctx.hunk and ctx.markers:
125-
out.append(Changed(ctx.file, "\n".join(ctx.hunk), ", ".join(ctx.markers)))
125+
out.append(
126+
Changed(file=ctx.file, hunk="\n".join(ctx.hunk), lines=ctx.markers)
127+
)
126128

127129
reset_with_line(context, line)
128130

@@ -157,7 +159,7 @@ def pop(out, context, line):
157159
numbers = numbers.replace("+", "")
158160
numbers = numbers.replace("-", "")
159161

160-
ctx.markers.append(numbers)
162+
ctx.markers.append(int(numbers))
161163
ctx.append_hunk = True
162164

163165
# capture diff for the summary
@@ -169,10 +171,12 @@ def pop(out, context, line):
169171
return out
170172

171173

172-
def warning_changed(changed: Changed):
173-
print(
174-
f"::warning file={changed.file},title=Run tests/restyle.sh and re-commit {changed.file}::File {changed.file} failed clang-format style check. (lines {changed.lines})"
175-
)
174+
def errors_changed(changed: Changed):
175+
all_lines = ", ".join(str(x) for x in changed.lines)
176+
for line in changed.lines:
177+
print(
178+
f"::error file={changed.file},title=Run tests/restyle.sh and re-commit {changed.file},line={line}::File {changed.file} failed clang-format style check. (lines {all_lines})"
179+
)
176180

177181

178182
SUMMARY_PATH = pathlib.Path(os.environ.get("GITHUB_STEP_SUMMARY", os.devnull))
@@ -214,8 +218,8 @@ def run_format(args):
214218

215219
def run_assert(args):
216220
for changed in changed_files():
217-
if args.with_warnings:
218-
warning_changed(changed)
221+
if args.with_errors:
222+
errors_changed(changed)
219223
if args.with_summary:
220224
summary_diff(changed)
221225

@@ -246,7 +250,7 @@ def run_assert(args):
246250
assert_ = cmd.add_parser("assert")
247251
assert_.set_defaults(func=run_assert)
248252
assert_.add_argument("--with-summary", action="store_true")
249-
assert_.add_argument("--with-warnings", action="store_true")
253+
assert_.add_argument("--with-errors", action="store_true")
250254

251255
args = parser.parse_args()
252256
args.func(args)

tests/restyle.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ CLANG_FORMAT=${CLANG_FORMAT:-clang-format-15}
1313

1414
cd $root
1515
python $root/tests/restyle.py format --clang-format=$CLANG_FORMAT preset --include core --include arduino
16-
python $root/tests/restyle.py assert --with-summary --with-warnings
16+
python $root/tests/restyle.py assert --with-summary --with-errors

0 commit comments

Comments
 (0)