forked from WordPress/Requests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
131 lines (116 loc) · 4.27 KB
/
.travis.yml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
dist: xenial
language: php
stages:
- sniff
- test
jobs:
fast_finish: true
include:
- stage: sniff
php: 7.4
install:
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
- travis_retry composer install --no-interaction
before_script: skip
script:
# Check the code against the coding standards.
- composer checkcs
after_script: skip
- stage: test
php: 5.2
dist: precise
env: COMPOSER_PHPUNIT=false
- php: 5.3
dist: precise
env: COMPOSER_PHPUNIT=false
- php: 5.4
dist: trusty
env: COMPOSER_PHPUNIT=false
- php: 5.5
dist: trusty
env: COMPOSER_PHPUNIT=false
- php: 5.6
env: TEST_COVERAGE=1 COMPOSER_PHPUNIT=true
- php: 7.0
env: COMPOSER_PHPUNIT=true
- php: 7.1
env: COMPOSER_PHPUNIT=true
- php: 7.2
env: COMPOSER_PHPUNIT=true
- php: 7.3
env: COMPOSER_PHPUNIT=true
- php: 7.4
env: COMPOSER_PHPUNIT=true
- php: nightly
env: COMPOSER_PHPUNIT=true
allow_failures:
- php: nightly
env: COMPOSER_PHPUNIT=true
cache:
directories:
- $HOME/.cache/pip
# Cache directory for older Composer versions.
- $HOME/.composer/cache/files
# Cache directory for more recent Composer versions.
- $HOME/.cache/composer/files
install:
# Speed up build time by disabling Xdebug unless actually needed.
# https://johnblackbourn.com/reducing-travis-ci-build-times-for-wordpress-projects/
# https://twitter.com/kelunik/status/954242454676475904
- if [ "$TEST_COVERAGE" != '1' ]; then phpenv config-rm xdebug.ini || echo 'No xdebug config.'; fi
# Setup the test server
- phpenv local $( phpenv versions | grep 5.6 | tail -1 )
- if [ "$COMPOSER_PHPUNIT" == 'false' ]; then travis_retry composer remove phpunit/phpunit --dev; fi
- if [ "$COMPOSER_PHPUNIT" == 'false' ]; then export PHPUNIT_BIN="phpunit";
else export PHPUNIT_BIN="$(pwd)/vendor/bin/phpunit";
fi
- |
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" != "Sniff" ]]; then
# The PHPCS dependencies require PHP 5.4, so would block istall on PHP < 5.4.
# As they are only needed in the sniff stage, remove them.
travis_retry composer remove --dev --no-update squizlabs/php_codesniffer phpcompatibility/php-compatibility wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer
fi
- travis_retry composer install --dev --no-interaction
- TESTPHPBIN=$(phpenv which php)
- phpenv local --unset
# Setup the proxy
- pip install --user mitmproxy==0.18.2
before_script:
- PHPBIN=$TESTPHPBIN PORT=8080 vendor/bin/start.sh
- export REQUESTS_TEST_HOST_HTTP="localhost:8080"
- PROXYBIN="$HOME/.local/bin/mitmdump" PORT=9002 tests/utils/proxy/start.sh
- PROXYBIN="$HOME/.local/bin/mitmdump" PORT=9003 AUTH="test:pass" tests/utils/proxy/start.sh
- export REQUESTS_HTTP_PROXY="localhost:9002"
- export REQUESTS_HTTP_PROXY_AUTH="localhost:9003"
- export REQUESTS_HTTP_PROXY_AUTH_USER="test"
- export REQUESTS_HTTP_PROXY_AUTH_PASS="pass"
# Ensure the HTTPS test instance on Heroku is spun up
- curl -s -I http://requests-php-tests.herokuapp.com/ > /dev/null
# Environment checks
- $PHPUNIT_BIN --version
script:
# Lint PHP files against parse errors.
- |
if [ ${TRAVIS_PHP_VERSION:0:3} == "5.2" ]; then
if find $(pwd)/ -path $(pwd)/vendor -prune -o -path $(pwd)/ examples/cookie_jar.php -prune -o -path $(pwd)/tests/phpunit6-compat.php -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi
elif [ ${TRAVIS_PHP_VERSION:0:3} == "5.3" ]; then
if find $(pwd)/ -path $(pwd)/vendor -prune -o -path $(pwd)/ examples/cookie_jar.php -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi
else
if find $(pwd)/ -path $(pwd)/vendor -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi
fi
# Run the unit tests.
- cd tests
- |
if [ "$TEST_COVERAGE" == '1' ]; then
$PHPUNIT_BIN --coverage-clover clover.xml;
# PHPUnit 4.x does not yet support the `no-coverage` flag.
elif [ ${TRAVIS_PHP_VERSION:0:3} == "5.2" ]; then
$PHPUNIT_BIN;
else
$PHPUNIT_BIN --no-coverage;
fi
after_script:
- utils/proxy/stop.sh
- cd ..
- PATH=$PATH vendor/bin/stop.sh
- test $TEST_COVERAGE && bash <(curl -s https://codecov.io/bash)