From 60f9ceabd15c0ac55820d6102dbf8e5e279d3cb3 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 15 Dec 2021 13:36:39 +0100 Subject: [PATCH] tools: can_fast_ci_run.py: ignore comment-only change for `.[ch]` --- dist/tools/ci/can_fast_ci_run.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/dist/tools/ci/can_fast_ci_run.py b/dist/tools/ci/can_fast_ci_run.py index fc1f743bec..c02dc61fcb 100755 --- a/dist/tools/ci/can_fast_ci_run.py +++ b/dist/tools/ci/can_fast_ci_run.py @@ -164,7 +164,10 @@ def classify_changes(riotbase=None, upstream_branch="master"): match = REGEX_GIT_DIFF_SINGLE_FILE.match(line) if match: file = match.group(1) - change_set.add_file(file) + + if only_comment_change(file, upstream_branch) is False: + change_set.add_file(file) + continue raise Exception("Failed to parse \"{}\"".format(line)) @@ -172,6 +175,28 @@ def classify_changes(riotbase=None, upstream_branch="master"): return change_set +def get_hash_without_comments(file, ref): + result = subprocess.run( + f"git show {ref}:{file} | gcc -fpreprocessed -dD -E -P - | md5sum", + shell=True, + capture_output=True, + check=True, + ) + return result.stdout + + +def only_comment_change(file, upstream_branch): + try: + if file[-2:] in {".c", ".h"}: + hash_a = get_hash_without_comments(file, "HEAD") + hash_b = get_hash_without_comments(file, upstream_branch) + return hash_a == hash_b + except Exception: + pass + + return False + + if __name__ == "__main__": parser = argparse.ArgumentParser(description="Check if a fast CI run is possible and which " + "boards / applications to build")