Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA: lint PHP files in this repo #358

Merged
merged 1 commit into from
Oct 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ install:
- phpenv local $( phpenv versions | grep 5.6 | tail -1 )
- if [ "$COMPOSER_PHPUNIT" == 'false' ]; then composer remove phpunit/phpunit --dev; fi
- if [ "$COMPOSER_PHPUNIT" == 'false' ]; then export PHPUNIT_BIN="phpunit";
else export PHPUNIT_BIN="../vendor/bin/phpunit";
else export PHPUNIT_BIN="$(pwd)/vendor/bin/phpunit";
fi
- composer install --dev --no-interaction
- TESTPHPBIN=$(phpenv which php)
Expand All @@ -62,22 +62,32 @@ before_script:
- PHPBIN=$TESTPHPBIN PORT=8080 vendor/bin/start.sh
- export REQUESTS_TEST_HOST_HTTP="localhost:8080"

# Work out of the tests directory
- cd tests
- PROXYBIN="$HOME/.local/bin/mitmdump" PORT=9002 utils/proxy/start.sh
- PROXYBIN="$HOME/.local/bin/mitmdump" PORT=9003 AUTH="test:pass" utils/proxy/start.sh
- 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;
Expand Down