run.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. set -e
  3. # Short circuit tests and linting jobs if there are no code changes involved.
  4. if [[ $TOXENV != docs ]]; then
  5. if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]
  6. then
  7. echo "This is not a PR -- will do a complete build."
  8. else
  9. # Pull requests are slightly complicated because $TRAVIS_COMMIT_RANGE
  10. # may include more changes than desired if the history is convoluted.
  11. # Instead, explicitly fetch the base branch and compare against the
  12. # merge-base commit.
  13. git fetch -q origin +refs/heads/$TRAVIS_BRANCH
  14. changes=$(git diff --name-only HEAD $(git merge-base HEAD FETCH_HEAD))
  15. echo "Files changed:"
  16. echo "$changes"
  17. if ! echo "$changes" | grep -qvE '(\.rst$)|(^docs)|(^news)|(^\.github)'
  18. then
  19. echo "Only Documentation was updated -- skipping build."
  20. exit
  21. fi
  22. fi
  23. fi
  24. # Export the correct TOXENV when not provided.
  25. echo "Determining correct TOXENV..."
  26. if [[ -z "$TOXENV" ]]; then
  27. if [[ ${TRAVIS_PYTHON_VERSION} == pypy* ]]; then
  28. export TOXENV=${TRAVIS_PYTHON_VERSION}
  29. else
  30. # We use the syntax ${string:index:length} to make 2.7 -> py27
  31. _major=${TRAVIS_PYTHON_VERSION:0:1}
  32. _minor=${TRAVIS_PYTHON_VERSION:2:1}
  33. export TOXENV="py${_major}${_minor}"
  34. fi
  35. fi
  36. echo "TOXENV=${TOXENV}"
  37. # Print the commands run for this test.
  38. set -x
  39. if [[ "$GROUP" == "1" ]]; then
  40. # Unit tests
  41. tox -- -m unit
  42. # Integration tests (not the ones for 'pip install')
  43. tox -- -m integration -n 4 --duration=5 -k "not test_install"
  44. elif [[ "$GROUP" == "2" ]]; then
  45. # Separate Job for running integration tests for 'pip install'
  46. tox -- -m integration -n 4 --duration=5 -k "test_install"
  47. else
  48. # Non-Testing Jobs should run once
  49. tox
  50. fi