compare-pylint.sh 1.69 KB
Newer Older
1 2
#!/bin/bash
set -o nounset -o xtrace -o errexit
3
source "$(dirname "$0")/common.sh"
4 5

PYFILES=$(find . \
6 7
	-path ./.git -prune -o \
	-path ./contrib -o \
8 9 10 11 12
	-type d -exec test -e '{}/__init__.py' \; -print -prune -o \
	-name '*.py' -print -o \
	-type f -exec grep -qsm1 '^#!.*\bpython' '{}' \; -print)

: check if version under test does not produce critical errors
13
${PYTHON} -m pylint -j $(nproc) -E ${PYFILES}
14 15 16 17 18 19

: no critical errors, compare score between versions
rm -rf ~/.pylint.d
: get test results from common ancestor with master branch
git checkout --force --detach "${MERGEBASE}"
git clean -xdf
20 21 22 23 24
# set of Python files might have changed during checkout
PYFILES=$(find . \
	-type d -exec test -e '{}/__init__.py' \; -print -prune -o \
	-name '*.py' -print -o \
	-type f -exec grep -qsm1 '^#!.*\bpython' '{}' \; -print)
25
${PYTHON} -m pylint -j $(nproc) ${PYFILES} &> /tmp/base.log || : old version is not clear
26 27 28 29 30 31 32 33
LOGS[0]="/tmp/base.log"
echo ==================== merge base ====================
cat /tmp/base.log
echo ==================== merge base end ====================

: get test results from version under test
git checkout --force --detach "${HEAD}"
git clean -xdf
34
${PYTHON} -m pylint -j $(nproc) ${PYFILES} &> /tmp/head.log || : version under test is not clear
35
LOGS[1]="/tmp/head.log"
36 37 38 39 40 41
echo ==================== candidate version ====================
cat /tmp/head.log
echo ==================== candidate end ====================

: check if candidate version produced more messages than the base
grep '^|\(convention\|refactor\|warning\|error\).*+' /tmp/head.log \
42 43 44 45
	&& { \
		echo "New pylint message detected: Use diff base.log head.log and go fix it!"; \
		exit 1; \
	} \
46
	|| echo "OK, no new pylint messages detected"