forked from deepchem/deepchem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a travis CI test which fails when code is not properly formatted. Create a git pre-commit hook which will auto-format changed python files
- Loading branch information
1 parent
d5d081d
commit dcb3651
Showing
5 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[style] | ||
# YAPF uses the chromium style | ||
based_on_style = google | ||
indent_width = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
CHANGED_FILES=`git diff --cached --name-only | grep .py$` | ||
if [ -z $CHANGED_FILES ] | ||
then | ||
echo "No Python Files Changed" | ||
else | ||
echo $CHANGED_FILES | ||
yapf -i $CHANGED_FILES | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash -e | ||
|
||
CHANGED_FILES=($(git diff --name-only $TRAVIS_COMMIT_RANGE)) | ||
|
||
exit_success () { | ||
echo "Passed Formatting Test" | ||
exit 0 | ||
} | ||
|
||
if [ -z $CHANGED_FILES ] | ||
then | ||
echo "No Python Files Changed" | ||
exit_success | ||
fi | ||
|
||
yapf -d $CHANGED_FILES > diff.txt | ||
cat diff.txt | ||
|
||
if [ -s diff.txt ] | ||
then | ||
cat diff.txt | ||
echo "" | ||
echo "Failing Formatting Test" | ||
echo "Please run yapf over the files changed" | ||
echo "pip install yapf" | ||
echo "yapf -i $CHANGED_FILES" | ||
exit 1 | ||
else | ||
exit_success | ||
fi | ||
exit 1 |