From 91ff6bb2147a6da3ca9f4bbadb7db392533105c5 Mon Sep 17 00:00:00 2001 From: Riccardo Date: Mon, 8 Jul 2019 12:01:00 -0700 Subject: [PATCH] Run language checker in CI --- .circleci/config.yml | 14 ++++++++++++++ tests/language/list.txt | 1 - tests/language/test_language.py | 12 ++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 57ca3a91d859d9..fdafd3da1846bf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -86,6 +86,19 @@ jobs: command: | docker run panda_safety_replay /bin/bash -c "cd /openpilot/panda/tests/safety_replay; PYTHONPATH=/openpilot ./test_safety_replay.py" + language_check: + machine: + docker_layer_caching: true + steps: + - checkout + - run: + name: Build image + command: "docker build -t language_check -f tests/language/Dockerfile ." + - run: + name: Check code for bad language + command: | + docker run language_check /bin/bash -c "cd /panda/tests/language; ./test_language.py" + workflows: version: 2 main: @@ -94,3 +107,4 @@ workflows: - misra-c2012 - build - safety_replay + - language_check diff --git a/tests/language/list.txt b/tests/language/list.txt index 0a6753562ab264..cfd25897d8dc55 100644 --- a/tests/language/list.txt +++ b/tests/language/list.txt @@ -449,4 +449,3 @@ whore willies willy xrated -xxx diff --git a/tests/language/test_language.py b/tests/language/test_language.py index 03b5cd2f4bf34c..3afb34619aa19f 100755 --- a/tests/language/test_language.py +++ b/tests/language/test_language.py @@ -10,19 +10,19 @@ suffix_cmd = " " for i in checked_ext: - suffix_cmd += "-- '*." + i + "' " + suffix_cmd += "--include \*." + i + " " - found_profanity = False + found_bad_language = False for line in handle: line = line.rstrip('\n').rstrip(" ") try: - cmd = "cd ../../; git grep --ignore-case -w '" + line + "'" + suffix_cmd + cmd = "cd ../../; grep -R -i -w " + suffix_cmd + " '" + line + "'" res = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) print res - found_profanity = True + found_bad_language = True except subprocess.CalledProcessError as e: pass - if found_profanity: - sys.exit("Failed: Found profanities") + if found_bad_language: + sys.exit("Failed: found bad language") else: print "Success"