Build: add Python lint target

https://fedorahosted.org/freeipa/ticket/6418

Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
Petr Spacek
2016-11-08 09:55:13 +01:00
committed by Martin Babinsky
parent 2df9877255
commit 14c1c8dfd0
3 changed files with 39 additions and 1 deletions

View File

@@ -13,4 +13,4 @@ script:
- >
docker run -v $PWD:/freeipa -w /freeipa
martbab/freeipa-fedora-builder:${TRAVIS_BRANCH}-latest
/bin/bash -c 'dnf builddep -y -D "with_lint 1" --spec freeipa.spec.in && ./makerpms.sh'
/bin/bash -c 'dnf builddep -y -D "with_lint 1" --spec freeipa.spec.in && autoreconf -i && ./configure && make lint && make rpms'

View File

@@ -44,3 +44,25 @@ rpms: dist-gzip rpmroot rpmdistdir
rpmbuild --define "_topdir $(RPMBUILD)" -ba $(top_builddir)/$(PACKAGE).spec
cp $(RPMBUILD)/RPMS/*/*.rpm $(top_builddir)/dist/rpms/
cp $(RPMBUILD)/SRPMS/*.src.rpm $(top_builddir)/dist/srpms/
.PHONY: lint
if WITH_PYLINT
PYLINT_TARGET = pylint
endif WITH_PYLINT
lint: $(PYLINT_TARGET)
.PHONY: pylint
pylint:
FILES=`find $(top_srcdir) \
-type d -exec test -e '{}/__init__.py' \; -print -prune -o \
-path '*/.*' -o \
-path '*.in' -o \
-path './dist/*' -o \
-path './lextab.py' -o \
-path './yacctab.py' -o \
-name '*~' -o \
-name \*.py -print -o \
-type f -exec grep -qsm1 '^#!.*\bpython' '{}' \; -print`; \
echo "Pylint is running, please wait ..."; \
PYTHONPATH=$(top_srcdir) $(PYLINT) \
--rcfile=$(top_srcdir)/pylintrc $${FILES}

View File

@@ -411,6 +411,22 @@ else
AC_MSG_RESULT(no)
fi
dnl ---------------------------------------------------------------------------
dnl Linters
dnl ---------------------------------------------------------------------------
AC_ARG_WITH([pylint],
AS_HELP_STRING([--with-pylint=path],
[path to Pylint]),
dnl --without-pylint will set PYLINT=no
[PYLINT=$with_pylint],
[AC_PATH_PROG([PYLINT], [pylint])]
)
if test "x${PYLINT}" == "x"; then
AC_MSG_ERROR([cannot find Pylint])
fi
AC_SUBST([PYLINT])
AM_CONDITIONAL([WITH_PYLINT], [test "x${PYLINT}" != "xno"])
# Flags
AC_SUBST(CFLAGS)