Skip to content

Commit

Permalink
annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
mcspr committed Jul 31, 2024
1 parent 1769b47 commit 697ea8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions tests/restyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,18 @@ def pop(out, context, line):
return out


def notice_changed(changed: Changed):
def warning_changed(changed: Changed):
print(
f"::notice file={changed.file},title=Run tests/restyle.sh and re-commit {changed.file}::File {changed.file} failed clang-format style check. (lines {changed.lines})"
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})"
)


SUMMARY_PATH = pathlib.Path(os.environ.get("GITHUB_STEP_SUMMARY", os.devnull))
SUMMARY_OUTPUT = SUMMARY_PATH.open("a")


def summary_diff(changed: Changed):
with contextlib.redirect_stdout(SUMMARY_OUTPUT):
print(f"# {changed.file} (suggested change)")
print("```diff")
print(changed.hunk)
print("```")
Expand Down Expand Up @@ -215,8 +215,8 @@ def run_format(args):

def run_assert(args):
for changed in changed_files():
if args.with_notice:
notice_changed(changed)
if args.with_warnings:
warning_changed(changed)
if args.with_summary:
summary_diff(changed)

Expand Down Expand Up @@ -247,7 +247,7 @@ def run_assert(args):
assert_ = cmd.add_parser("assert")
assert_.set_defaults(func=run_assert)
assert_.add_argument("--with-summary", action="store_true")
assert_.add_argument("--with-notice", action="store_true")
assert_.add_argument("--with-warnings", action="store_true")

args = parser.parse_args()
args.func(args)
2 changes: 1 addition & 1 deletion tests/restyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ CLANG_FORMAT=${CLANG_FORMAT:-clang-format-15}

cd $root
python $root/tests/restyle.py format --clang-format=$CLANG_FORMAT preset --include core --include arduino
python $root/tests/restyle.py assert --with-summary --with-notice
python $root/tests/restyle.py assert --with-summary --with-warnings

0 comments on commit 697ea8b

Please sign in to comment.