Incorporating PEP8 checking on PRs.

This commit is contained in:
Greg Taylor
2016-05-24 13:20:50 -07:00
committed by Neil Williams
parent ade6dfd0c1
commit 31b83a3350
2 changed files with 40 additions and 1 deletions

View File

@@ -42,7 +42,7 @@ build:
# https://github.com/reddit/docker-reddit-py
# Dependency changes in the install scripts can be optionally mirrored to the
# image for speedups, but abstaining from doing so won't break the builds.
image: reddit/reddit-py:2.7.6-v1
image: reddit/reddit-py:2.7.6-v2
environment:
DEBIAN_FRONTEND: noninteractive
commands:
@@ -50,6 +50,8 @@ build:
- install/drone.sh
- cd r2
- nosetests -v .
- cd ..
- ./scripts/stylecheck_git_diff.sh
# These plugins are triggered after a build failure/success.
notify:

37
scripts/stylecheck_git_diff.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
###############################################################################
# git diff style checker
# ----------------------
# This script runs a style check within our Drone setup, or within the
# `drone exec` runner.
#
# Since the codebase has a substantial body of non-conformant code, style
# checks are only ran on the diffs (compared to master). As a consequence of
# this, style checks also only run on non-master branches.
###############################################################################
if [[ ${CI_BRANCH} = "master" ]]; then
echo "Skipping style checks on commit(s) to the master branch."
exit 0
fi
if [[ ${CI_REPO:=} = "" ]]; then
# This assumed to be `drone exec`.
echo "Running style checks on staged local changes..."
git diff --cached | pep8 --diff
else
echo "Running style checks within Drone..."
git fetch --no-tags --depth=10 origin master
git diff origin/${CI_BRANCH} origin/master | pep8 --diff
fi
error_encountered=$?
if [[ ${error_encountered} = 1 ]]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "pep8 issues found. reddit follows pep8: https://github.com/reddit/styleguide"
echo " Please commit a fix or ignore inline with: noqa"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1
fi
echo "Style checks passed. Good jerb!"