From f91a93bf9895825a589e17b063d3b0ee6dbe0f04 Mon Sep 17 00:00:00 2001 From: daquexian Date: Fri, 20 Aug 2021 21:46:07 +0800 Subject: [PATCH] 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: daquexian * fix python2 shebang Signed-off-by: daquexian Co-authored-by: oneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com> --- ci/check/run_clang_format.py | 2 +- ci/check/run_clang_tidy.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ci/check/run_clang_format.py b/ci/check/run_clang_format.py index 943f9301f1..2b62e017a4 100644 --- a/ci/check/run_clang_format.py +++ b/ci/check/run_clang_format.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information diff --git a/ci/check/run_clang_tidy.py b/ci/check/run_clang_tidy.py index 4679ee1785..fef81779a5 100644 --- a/ci/check/run_clang_tidy.py +++ b/ci/check/run_clang_tidy.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -20,6 +20,7 @@ import asyncio import argparse import subprocess import os +from typing import List, Optional def split_and_print(prefix, text): @@ -55,7 +56,7 @@ async def run_command(cmd=None, dry=False, name=None): return process.returncode -def download(build_dir, dry=False): +def download(build_dir, dry=False) -> Optional[List[str]]: urls = [ "https://github.com/Oneflow-Inc/llvm-project/releases/download/latest/clang-tidy-489012f-x86_64.AppImage" if os.getenv("CI") @@ -89,9 +90,10 @@ if __name__ == "__main__": downloaded = download(args.build_dir, dry=True) if downloaded is None: downloaded = download(args.build_dir) - promises = [ + assert downloaded is not None + ret_code = loop.run_until_complete( 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) -- GitLab