Skip to content

Commit

Permalink
Run language checker in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rbiasini committed Jul 8, 2019
1 parent 205ec34 commit 91ff6bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
14 changes: 14 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -94,3 +107,4 @@ workflows:
- misra-c2012
- build
- safety_replay
- language_check
1 change: 0 additions & 1 deletion tests/language/list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,3 @@ whore
willies
willy
xrated
xxx
12 changes: 6 additions & 6 deletions tests/language/test_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 91ff6bb

Please sign in to comment.