You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2023/01/27 20:35:29 UTC

[mynewt-nimble] branch master updated: ci: Make check style output more readable

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new fcf16680 ci: Make check style output more readable
fcf16680 is described below

commit fcf166804ab07d89c2f74ac4ba90b08878149f63
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Jan 27 19:41:01 2023 +0100

    ci: Make check style output more readable
---
 .github/check_style.py | 45 +++++++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/.github/check_style.py b/.github/check_style.py
index 047c0f22..7b2fa5b8 100755
--- a/.github/check_style.py
+++ b/.github/check_style.py
@@ -25,7 +25,7 @@ import subprocess
 import tempfile
 import sys
 
-coding_style_url = "https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md"
+INFO_URL = "https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md"
 
 def get_lines_range(m: re.Match) -> range:
     first = int(m.group(1))
@@ -100,32 +100,41 @@ def main() -> bool:
     mb = run_cmd(f"git merge-base {upstream} {commit}")
     upstream = mb[0]
 
-    has_error = False
-
     cfg_fname = os.path.join(os.path.dirname(__file__), "../.style_ignored_dirs")
     with open(cfg_fname, "r") as x:
         ign_dirs = [s.strip() for s in x.readlines() if
                     s.strip() and not s.startswith("#")]
 
+    results_ok = []
+    results_fail = []
+    results_ign = []
+
     files = run_cmd(f"git diff --diff-filter=AM --name-only {upstream} {commit}")
-    for cfg_fname in files:
-        if is_ignored(cfg_fname, ign_dirs):
-            print(f"\033[90m- {cfg_fname}\033[0m")
+    for fname in files:
+        if is_ignored(fname, ign_dirs):
+            results_ign.append(fname)
             continue
 
-        diff = check_file(cfg_fname, commit, upstream)
-        if len(diff) > 0:
-            print(f"\033[31m! See {coding_style_url} for details.\033[0m")
-            print()
-            print(f"\033[31m! {cfg_fname}\033[0m")
-            print()
-            print("\n".join(diff))
-            print()
-            has_error = True
+        diff = check_file(fname, commit, upstream)
+        if len(diff) == 0:
+            results_ok.append(fname)
         else:
-            print(f"+ {cfg_fname}")
-
-    return not has_error
+            results_fail.append((fname, diff))
+
+    for fname in results_ign:
+        print(f"\033[90m[ NA ] {fname}\033[0m")
+    for fname in results_ok:
+        print(f"\033[32m[ OK ] {fname}\033[0m")
+    for fname, diff in results_fail:
+        print(f"\033[31m[FAIL] {fname}\033[0m")
+        print("\n".join(diff))
+        print()
+
+    if len(results_fail) > 0:
+        print(f"\033[31mYour code has style problems, see {INFO_URL} for "
+              f"details.\033[0m")
+
+    return len(results_fail) == 0
 
 
 if __name__ == "__main__":