Merge pull request #17405 from kaspar030/can_fast_ci_run_skipcomments
tools: can_fast_ci_run.py: ignore comment changes for `\.[ch]$`
This commit is contained in:
commit
385e65f497
27
dist/tools/ci/can_fast_ci_run.py
vendored
27
dist/tools/ci/can_fast_ci_run.py
vendored
@ -164,7 +164,10 @@ def classify_changes(riotbase=None, upstream_branch="master"):
|
|||||||
match = REGEX_GIT_DIFF_SINGLE_FILE.match(line)
|
match = REGEX_GIT_DIFF_SINGLE_FILE.match(line)
|
||||||
if match:
|
if match:
|
||||||
file = match.group(1)
|
file = match.group(1)
|
||||||
change_set.add_file(file)
|
|
||||||
|
if only_comment_change(file, upstream_branch) is False:
|
||||||
|
change_set.add_file(file)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
raise Exception("Failed to parse \"{}\"".format(line))
|
raise Exception("Failed to parse \"{}\"".format(line))
|
||||||
@ -172,6 +175,28 @@ def classify_changes(riotbase=None, upstream_branch="master"):
|
|||||||
return change_set
|
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__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description="Check if a fast CI run is possible and which "
|
parser = argparse.ArgumentParser(description="Check if a fast CI run is possible and which "
|
||||||
+ "boards / applications to build")
|
+ "boards / applications to build")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user