pylint.sh 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env bash
  2. set -eu
  3. ANSIBLE_UPSTREAM_FILES=(
  4. 'inventory/aws/hosts/ec2.py'
  5. 'inventory/gce/hosts/gce.py'
  6. 'inventory/libvirt/hosts/libvirt_generic.py'
  7. 'inventory/openstack/hosts/nova.py'
  8. 'lookup_plugins/sequence.py'
  9. )
  10. OLDREV=$1
  11. NEWREV=$2
  12. #TRG_BRANCH=$3
  13. PYTHON=/var/lib/jenkins/python27/bin/python
  14. PY_DIFF=$(/usr/bin/git diff --name-only $OLDREV $NEWREV --diff-filter=ACM | grep ".py$")
  15. FILES_TO_TEST=""
  16. for PY_FILE in $PY_DIFF; do
  17. IGNORE_FILE=false
  18. for UPSTREAM_FILE in "${ANSIBLE_UPSTREAM_FILES[@]}"; do
  19. if [ "${PY_FILE}" == "${UPSTREAM_FILE}" ]; then
  20. IGNORE_FILE=true
  21. break
  22. fi
  23. done
  24. if [ "${IGNORE_FILE}" == true ]; then
  25. echo "Skipping file ${PY_FILE} as an upstream Ansible file..."
  26. continue
  27. fi
  28. if [ -e "${PY_FILE}" ]; then
  29. FILES_TO_TEST="${FILES_TO_TEST} ${PY_FILE}"
  30. fi
  31. done
  32. if [ "${FILES_TO_TEST}" != "" ]; then
  33. echo "Testing files: ${FILES_TO_TEST}"
  34. ${PYTHON} -m pylint --rcfile ${WORKSPACE}/git/.pylintrc ${FILES_TO_TEST}
  35. fi