未验证 提交 f91a93bf 编写于 作者: D daquexian 提交者: GitHub

Update run_clang_tidy.py to set return code and add warning-as-errors (#5977)

* use clang-tidy-diff.py return code and add -warnings-as-errors
Signed-off-by: Ndaquexian <daquexian566@gmail.com>

* fix python2 shebang
Signed-off-by: Ndaquexian <daquexian566@gmail.com>
Co-authored-by: Noneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
上级 0c62ea5d
#!/usr/bin/env python2 #!/usr/bin/env python3
# Licensed to the Apache Software Foundation (ASF) under one # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file # or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information # distributed with this work for additional information
......
#!/usr/bin/env python2 #!/usr/bin/env python3
# Licensed to the Apache Software Foundation (ASF) under one # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file # or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information # distributed with this work for additional information
...@@ -20,6 +20,7 @@ import asyncio ...@@ -20,6 +20,7 @@ import asyncio
import argparse import argparse
import subprocess import subprocess
import os import os
from typing import List, Optional
def split_and_print(prefix, text): def split_and_print(prefix, text):
...@@ -55,7 +56,7 @@ async def run_command(cmd=None, dry=False, name=None): ...@@ -55,7 +56,7 @@ async def run_command(cmd=None, dry=False, name=None):
return process.returncode return process.returncode
def download(build_dir, dry=False): def download(build_dir, dry=False) -> Optional[List[str]]:
urls = [ urls = [
"https://github.com/Oneflow-Inc/llvm-project/releases/download/latest/clang-tidy-489012f-x86_64.AppImage" "https://github.com/Oneflow-Inc/llvm-project/releases/download/latest/clang-tidy-489012f-x86_64.AppImage"
if os.getenv("CI") if os.getenv("CI")
...@@ -89,9 +90,10 @@ if __name__ == "__main__": ...@@ -89,9 +90,10 @@ if __name__ == "__main__":
downloaded = download(args.build_dir, dry=True) downloaded = download(args.build_dir, dry=True)
if downloaded is None: if downloaded is None:
downloaded = download(args.build_dir) downloaded = download(args.build_dir)
promises = [ assert downloaded is not None
ret_code = loop.run_until_complete(
run_command( run_command(
f"cd .. && git diff -U0 master | {downloaded[1]} -clang-tidy-binary {downloaded[0]} -path {args.build_dir} -j $(nproc) -p1 -allow-enabling-alpha-checkers -extra-arg=-Xclang -extra-arg=-analyzer-config -extra-arg=-Xclang -extra-arg=aggressive-binary-operation-simplification=true" f"cd .. && git diff -U0 master | {downloaded[1]} -clang-tidy-binary {downloaded[0]} -path {args.build_dir} -j $(nproc) -p1 -allow-enabling-alpha-checkers -extra-arg=-Xclang -extra-arg=-analyzer-config -extra-arg=-Xclang -extra-arg=aggressive-binary-operation-simplification=true -warnings-as-errors=*"
) )
] )
loop.run_until_complete(asyncio.gather(*promises)) exit(ret_code)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册