diff options
Diffstat (limited to 'git')
| -rw-r--r-- | git/.pylintrc | 6 | ||||
| -rwxr-xr-x | git/pylint.sh | 46 | 
2 files changed, 43 insertions, 9 deletions
diff --git a/git/.pylintrc b/git/.pylintrc index af8f1656f..fe6eef6de 100644 --- a/git/.pylintrc +++ b/git/.pylintrc @@ -71,7 +71,7 @@ confidence=  # no Warning level messages displayed, use"--disable=all --enable=classes  # --disable=W"  # w0511 - fixme - disabled because TODOs are acceptable -disable=E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623,W1622,W1625,W1624,W1609,W1608,W1607,W1606,W1605,W1604,W1603,W1602,W1601,W1639,W1640,I0021,W1638,I0020,W1618,W1619,W1630,W1626,W1637,W1634,W1635,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,W1632,W1633,W0704,W1628,W1629,W1636,W0511 +disable=E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623,W1622,W1625,W1624,W1609,W1608,W1607,W1606,W1605,W1604,W1603,W1602,W1601,W1639,W1640,I0021,W1638,I0020,W1618,W1619,W1630,W1626,W1637,W1634,W1635,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,W1632,W1633,W0704,W1628,W1629,W1636,W0511,R0801  [REPORTS] @@ -205,7 +205,7 @@ docstring-min-length=-1  [SIMILARITIES]  # Minimum lines number of a similarity. -min-similarity-lines=4 +min-similarity-lines=0  # Ignore comments when computing similarities.  ignore-comments=yes @@ -214,7 +214,7 @@ ignore-comments=yes  ignore-docstrings=yes  # Ignore imports when computing similarities. -ignore-imports=no +ignore-imports=yes  [VARIABLES] diff --git a/git/pylint.sh b/git/pylint.sh index 286747565..55e8b6131 100755 --- a/git/pylint.sh +++ b/git/pylint.sh @@ -1,14 +1,48 @@  #!/usr/bin/env bash +set -eu +ANSIBLE_UPSTREAM_FILES=( +    'inventory/aws/hosts/ec2.py' +    'inventory/gce/hosts/gce.py' +    'inventory/libvirt/hosts/libvirt_generic.py' +    'inventory/openstack/hosts/nova.py' +    'lookup_plugins/sequence.py' +  )  OLDREV=$1  NEWREV=$2 -TRG_BRANCH=$3 +#TRG_BRANCH=$3 -PYTHON=/var/lib/jenkins/python27/bin/python +PYTHON=$(which python) -/usr/bin/git diff --name-only $OLDREV $NEWREV --diff-filter=ACM | \ - grep ".py$" | \ - xargs -r -I{} ${PYTHON} -m pylint --rcfile ${WORKSPACE}/git/.pylintrc  {} +set +e +PY_DIFF=$(/usr/bin/git diff --name-only $OLDREV $NEWREV --diff-filter=ACM | grep ".py$") +set -e -exit $? +FILES_TO_TEST="" + +for PY_FILE in $PY_DIFF; do +  IGNORE_FILE=false +  for UPSTREAM_FILE in "${ANSIBLE_UPSTREAM_FILES[@]}"; do +    if [ "${PY_FILE}" == "${UPSTREAM_FILE}" ]; then +      IGNORE_FILE=true +      break +    fi +  done + +  if [ "${IGNORE_FILE}" == true ]; then +    echo "Skipping file ${PY_FILE} as an upstream Ansible file..." +    continue +  fi + +  if [ -e "${PY_FILE}" ]; then +    FILES_TO_TEST="${FILES_TO_TEST} ${PY_FILE}" +  fi +done + +if [ "${FILES_TO_TEST}" != "" ]; then +  echo "Testing files: ${FILES_TO_TEST}" +  exec ${PYTHON} -m pylint --rcfile ${WORKSPACE}/git/.pylintrc ${FILES_TO_TEST} +else +  exit 0 +fi  | 
