From: Fred Morcos Date: Tue, 2 Jan 2024 14:13:30 +0000 (+0100) Subject: Fixup Github clang-tidy helper scripts X-Git-Tag: auth-4.9.0-alpha1~1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F13683%2Fhead;p=thirdparty%2Fpdns.git Fixup Github clang-tidy helper scripts --- diff --git a/.github/scripts/clang-tidy.py b/.github/scripts/clang-tidy.py index d7867c8301..a68c7eec13 100755 --- a/.github/scripts/clang-tidy.py +++ b/.github/scripts/clang-tidy.py @@ -45,11 +45,11 @@ def main(): print("No diagnostics or warnings produced by clang-tidy") return 0 - gh_step_summary = os.getenv('GITHUB_STEP_SUMMARY') + gh_step_summary = os.getenv("GITHUB_STEP_SUMMARY") if gh_step_summary: # Print Markdown summary - summaryFp = open(gh_step_summary, 'a', encoding='utf-8') - print('### clang-tidy summary', file=summaryFp) + summary_fp = open(gh_step_summary, "a", encoding="utf-8") + print("### clang-tidy summary", file=summary_fp) fixes = fixes["Diagnostics"] have_warnings = False @@ -84,20 +84,23 @@ def main(): line = helpers.get_line_from_offset(file_contents, offset) - relative_filename = Path(full_filename).resolve().relative_to(repo_root_dir) + rel_filename = Path(full_filename).resolve().relative_to(repo_root_dir) annotation = "".join( [ - f"::warning file={relative_filename},line={line}", + f"::warning file={rel_filename},line={line}", f"::{message} ({name} - Level={level})", ] ) print(annotation) # User-friendly printout - print(f"{level}: {relative_filename}:{line}: {message} ({name})") + print(f"{level}: {rel_filename}:{line}: {message} ({name})") if gh_step_summary: - print(f'- **{relative_filename}:{line}** {message} (`{name}`)', file=summaryFp) + print( + f"- **{rel_filename}:{line}** {message} (`{name}`)", + file=summary_fp, + ) have_warnings = True diff --git a/.github/scripts/git-filter.py b/.github/scripts/git-filter.py index 32b4fd4691..46f605795e 100755 --- a/.github/scripts/git-filter.py +++ b/.github/scripts/git-filter.py @@ -15,6 +15,7 @@ from pathlib import Path import helpers import unidiff + def create_argument_parser(): """Create command-line argument parser.""" parser = argparse.ArgumentParser( @@ -42,27 +43,38 @@ def main(): diff = sys.stdin.read() patch_set = unidiff.PatchSet(diff) for patch in patch_set: - # We have to deal with several possible cases for input files, as shown by git: + # We have to deal with several possible cases for input files, as shown + # by git: + # # - in ext/: ext/lmdb-safe/lmdb-safe.cc # - in modules/: modules/lmdbbackend/lmdbbackend.cc - # - files that live in the dnsdist or rec dir only: pdns/dnsdistdist/dnsdist-dnsparser.cc or pdns/recursordist/rec-tcp.cc - # - files that live in pdns/ and are used by several products (but possibly not with the same compilation flags, so - # it is actually important that they are processed for all products: pdns/misc.cc + # - files that live in the dnsdist or rec dir only: + # pdns/dnsdistdist/dnsdist-dnsparser.cc or + # pdns/recursordist/rec-tcp.cc + # - files that live in pdns/ and are used by several products (but + # possibly not with the same compilation flags, so it is actually + # important that they are processed for all products: pdns/misc.cc path = Path(patch.path) - if product == 'auth': + if product == "auth": path = Path(cwd).joinpath(path) else: - if str(path).startswith('modules'): - print(f'Skipping {path}: modules do not apply to {product}', file=sys.stderr) + if str(path).startswith("modules"): + print( + f"Skipping {path}: modules do not apply to {product}", + file=sys.stderr, + ) continue - if str(path).startswith('ext'): + if str(path).startswith("ext"): subpath = Path(cwd).joinpath(path) else: subpath = Path(cwd).joinpath(path.name) if not subpath.exists(): - print(f'Skipping {path}: does not exist for {product} ({subpath})', file=sys.stderr) + print( + f"Skip {path}: doesn't exist for {product} ({subpath})", + file=sys.stderr, + ) continue path = subpath @@ -71,7 +83,10 @@ def main(): patch.target_file = str(path) if not str(path) in compdb: - print(f'Skipping {path}: it is not in the compilation db', file=sys.stderr) + print( + f"Skipping {path}: it is not in the compilation db", + file=sys.stderr, + ) continue print(patch, file=sys.stderr)