Skip to content

Commit caa0a17

Browse files
authored
Travis CI Stages, cleanup and autodetection magic
Merge pull request #5450 from pradyunsg/misc/ci-stages-and-cleanup
2 parents 5575d25 + c19f991 commit caa0a17

File tree

5 files changed

+71
-41
lines changed

5 files changed

+71
-41
lines changed

.travis.yml

+41-28
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,62 @@ sudo: false
33
cache: pip
44
dist: trusty
55

6-
matrix:
7-
fast_finish: true
6+
stages:
7+
- primary
8+
- secondary
9+
10+
jobs:
811
include:
9-
- env: TOXENV=docs
12+
# Basic Checks
13+
- stage: primary
14+
env: TOXENV=docs
1015
- env: TOXENV=lint-py2
1116
- env: TOXENV=lint-py3
17+
python: 3.6
1218
- env: TOXENV=mypy
1319
- env: TOXENV=packaging
14-
# PyPy jobs start first -- they are the slowest
15-
- env: TOXENV=pypy3-functional-install
16-
python: pypy3
17-
- env: TOXENV=pypy3-others
18-
python: pypy3
19-
- env: TOXENV=pypy-functional-install
20-
python: pypy
21-
- env: TOXENV=pypy-others
22-
python: pypy
23-
# Latest Stable CPython jobs
24-
- env: TOXENV=py27-functional-install
20+
# Latest CPython
21+
- env: GROUP=1
2522
python: 2.7
26-
- env: TOXENV=py27-others
23+
- env: GROUP=2
2724
python: 2.7
28-
- env: TOXENV=py36-functional-install
25+
- env: GROUP=1
2926
python: 3.6
30-
- env: TOXENV=py36-others
27+
- env: GROUP=2
3128
python: 3.6
32-
# All the other Py3 versions
33-
- env: TOXENV=py35-functional-install
29+
30+
# Complete checking for ensuring compatibility
31+
# PyPy
32+
- stage: secondary
33+
env: GROUP=1
34+
python: pypy3
35+
- env: GROUP=2
36+
python: pypy3
37+
- env: GROUP=1
38+
python: pypy
39+
- env: GROUP=2
40+
python: pypy
41+
# Older Supported CPython
42+
- env: GROUP=1
3443
python: 3.5
35-
- env: TOXENV=py35-others
44+
- env: GROUP=2
3645
python: 3.5
37-
- env: TOXENV=py34-functional-install
46+
- env: GROUP=1
3847
python: 3.4
39-
- env: TOXENV=py34-others
48+
- env: GROUP=2
4049
python: 3.4
41-
# Nightly Python goes last
42-
- env: TOXENV=py37-functional-install
43-
python: nightly
44-
- env: TOXENV=py37-others
45-
python: nightly
50+
51+
- env: GROUP=1
52+
python: 3.7-dev
53+
- env: GROUP=2
54+
python: 3.7-dev
55+
56+
# It's okay to fail on the in-development CPython version.
57+
fast_finish: true
4658
allow_failures:
47-
- python: nightly
59+
- python: 3.7-dev
4860

61+
before_install: .travis/setup.sh
4962
install: travis_retry .travis/install.sh
5063
script: .travis/run.sh
5164

.travis/install.sh

-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,5 @@
22
set -e
33
set -x
44

5-
git config --global user.email "[email protected]"
6-
git config --global user.name "pip"
7-
85
pip install --upgrade setuptools
96
pip install --upgrade tox

.travis/run.sh

+23-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22
set -e
3-
set -x
43

54
# Short circuit tests and linting jobs if there are no code changes involved.
65
if [[ $TOXENV != docs ]]; then
@@ -24,16 +23,31 @@ if [[ $TOXENV != docs ]]; then
2423
fi
2524
fi
2625

27-
if [[ $TOXENV == py*-functional-install ]]; then
28-
# Only run test_install*.py integration tests
29-
tox -- -m integration -n 4 --duration=5 -k test_install
30-
elif [[ $TOXENV == py* ]]; then
31-
# Run unit tests
32-
tox -- -m unit
26+
# Export the correct TOXENV when not provided.
27+
echo "Determining correct TOXENV..."
28+
if [[ -z "$TOXENV" ]]; then
29+
if [[ ${TRAVIS_PYTHON_VERSION} == pypy* ]]; then
30+
export TOXENV=${TRAVIS_PYTHON_VERSION}
31+
else
32+
# We use the syntax ${string:index:length} to make 2.7 -> py27
33+
_major=${TRAVIS_PYTHON_VERSION:0:1}
34+
_minor=${TRAVIS_PYTHON_VERSION:2:1}
35+
export TOXENV="py${_major}${_minor}"
36+
fi
37+
fi
38+
echo "TOXENV=${TOXENV}"
3339

34-
# Run other integration tests
40+
# Print the commands run for this test.
41+
set -x
42+
if [[ "$GROUP" == "1" ]]; then
43+
# Unit tests
44+
tox -- -m unit
45+
# Integration tests (not the ones for 'pip install')
3546
tox -- -m integration -n 4 --duration=5 -k "not test_install"
47+
elif [[ "$GROUP" == "2" ]]; then
48+
# Separate Job for running integration tests for 'pip install'
49+
tox -- -m integration -n 4 --duration=5 -k "test_install"
3650
else
37-
# Run once
51+
# Non-Testing Jobs should run once
3852
tox
3953
fi

.travis/setup.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Setting Git Credentials..."
5+
git config --global user.email "[email protected]"
6+
git config --global user.name "pip"

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
envlist =
33
docs, packaging, lint-py2, lint-py3, mypy,
4-
py{27,34,35,36,37,py,py3}-{functional-install,others}
4+
py27, py34, py35, py67, py37, pypy, pypy3
55

66
[testenv]
77
passenv = CI GIT_SSL_CAINFO

0 commit comments

Comments
 (0)