pylint.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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=$(which python)
  14. set +e
  15. PY_DIFF=$(/usr/bin/git diff --name-only $OLDREV $NEWREV --diff-filter=ACM | grep ".py$")
  16. set -e
  17. FILES_TO_TEST=""
  18. for PY_FILE in $PY_DIFF; do
  19. IGNORE_FILE=false
  20. for UPSTREAM_FILE in "${ANSIBLE_UPSTREAM_FILES[@]}"; do
  21. if [ "${PY_FILE}" == "${UPSTREAM_FILE}" ]; then
  22. IGNORE_FILE=true
  23. break
  24. fi
  25. done
  26. if [ "${IGNORE_FILE}" == true ]; then
  27. echo "Skipping file ${PY_FILE} as an upstream Ansible file..."
  28. continue
  29. fi
  30. if [ -e "${PY_FILE}" ]; then
  31. FILES_TO_TEST="${FILES_TO_TEST} ${PY_FILE}"
  32. fi
  33. done
  34. if [ "${FILES_TO_TEST}" != "" ]; then
  35. echo "Testing files: ${FILES_TO_TEST}"
  36. exec ${PYTHON} -m pylint --rcfile ${WORKSPACE}/git/.pylintrc ${FILES_TO_TEST}
  37. else
  38. exit 0
  39. fi