1
0
Fork 0

Add clang-tidy and clang-format command to "reproduce locally"

This commit is contained in:
Mikhail Goncharov 2020-07-23 09:50:06 +02:00
parent 00a2c76d0b
commit ac3cdef23d
3 changed files with 7 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import re
import subprocess import subprocess
from typing import Optional from typing import Optional
def upload_file(base_dir: str, file: str): def upload_file(base_dir: str, file: str):
""" """
Uploads artifact to buildkite and returns URL to it Uploads artifact to buildkite and returns URL to it

View file

@ -45,6 +45,7 @@ def run(base_commit, ignore_config, step: Optional[Step], report: Optional[Repor
report = Report() # For debugging. report = Report() # For debugging.
if step is None: if step is None:
step = Step() # For debugging. step = Step() # For debugging.
step.reproduce_commands.append(f'git-clang-format {base_commit}')
r, patch = get_diff(base_commit) r, patch = get_diff(base_commit)
if not r: if not r:
step.success = False step.success = False

View file

@ -22,6 +22,7 @@ from typing import Optional
import pathspec import pathspec
import ignore_diff import ignore_diff
from buildkite.utils import format_url
from phabtalk.phabtalk import Report, Step from phabtalk.phabtalk import Report, Step
@ -43,6 +44,7 @@ def run(base_commit, ignore_config, step: Optional[Step], report: Optional[Repor
ignore = pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, []) ignore = pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, [])
p = subprocess.Popen(['clang-tidy-diff', '-p0', '-quiet'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, p = subprocess.Popen(['clang-tidy-diff', '-p0', '-quiet'], stdout=subprocess.PIPE, stdin=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
step.reproduce_commands.append(f'git diff -U0 --no-prefix {base_commit} | clang-tidy-diff -p0')
a = ''.join(diff) a = ''.join(diff)
logging.info(f'clang-tidy input: {a}') logging.info(f'clang-tidy input: {a}')
out = p.communicate(input=a.encode())[0].decode() out = p.communicate(input=a.encode())[0].decode()
@ -98,10 +100,11 @@ def run(base_commit, ignore_config, step: Optional[Step], report: Optional[Repor
report.add_artifact(os.getcwd(), p, 'clang-tidy') report.add_artifact(os.getcwd(), p, 'clang-tidy')
if errors_count + warn_count != 0: if errors_count + warn_count != 0:
step.success = False step.success = False
url = format_url("https://github.com/google/llvm-premerge-checks/blob/master/docs/clang_tidy.md"
"#review-comments.", "why?")
step.messages.append( step.messages.append(
f'clang-tidy found {errors_count} errors and {warn_count} warnings. {inline_comments} of them are added ' f'clang-tidy found {errors_count} errors and {warn_count} warnings. {inline_comments} of them are added '
f'as review comments. See' f'as review comments {url}')
f'https://github.com/google/llvm-premerge-checks/blob/master/docs/clang_tidy.md#review-comments.')
logging.debug(f'report: {report}') logging.debug(f'report: {report}')
logging.debug(f'step: {step}') logging.debug(f'step: {step}')