summaryrefslogtreecommitdiff
path: root/tools/travis/run.sh
blob: df06b8b3391d3a0c8b93de5146a1f2cc4e0cc7e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
set -e

# Short circuit tests and linting jobs if there are no code changes involved.
if [[ $TOXENV != docs ]]; then
    if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]
    then
        echo "This is not a PR -- will do a complete build."
    else
        # Pull requests are slightly complicated because $TRAVIS_COMMIT_RANGE
        # may include more changes than desired if the history is convoluted.
        # Instead, explicitly fetch the base branch and compare against the
        # merge-base commit.
        git fetch -q origin +refs/heads/$TRAVIS_BRANCH
        changes=$(git diff --name-only HEAD $(git merge-base HEAD FETCH_HEAD))
        echo "Files changed:"
        echo "$changes"
        if ! echo "$changes" | grep -qvE '(\.rst$)|(^docs)|(^news)|(^\.github)'
        then
            echo "Only Documentation was updated -- skipping build."
            exit
        fi
    fi
fi

# Export the correct TOXENV when not provided.
echo "Determining correct TOXENV..."
if [[ -z "$TOXENV" ]]; then
    if [[ ${TRAVIS_PYTHON_VERSION} == pypy* ]]; then
        export TOXENV=${TRAVIS_PYTHON_VERSION}
    else
        # We use the syntax ${string:index:length} to make 2.7 -> py27
        _major=${TRAVIS_PYTHON_VERSION:0:1}
        _minor=${TRAVIS_PYTHON_VERSION:2:1}
        export TOXENV="py${_major}${_minor}"
    fi
fi
echo "TOXENV=${TOXENV}"

# Print the commands run for this test.
set -x
if [[ "$GROUP" == "1" ]]; then
    # Unit tests
    tox -- -m unit
    # Integration tests (not the ones for 'pip install')
    tox -- -m integration -n 4 --duration=5 -k "not test_install"
elif [[ "$GROUP" == "2" ]]; then
    # Separate Job for running integration tests for 'pip install'
    tox -- -m integration -n 4 --duration=5 -k "test_install"
else
    # Non-Testing Jobs should run once
    tox
fi