This repository has been archived by the owner on Nov 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(testing): use Docker for builds (#9)
chore(testing): use Docker for builds
- Loading branch information
1 parent
22d0e94
commit 8b83a3e
Showing
14 changed files
with
191 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,41 @@ | ||
language: php | ||
branches: | ||
only: | ||
- master | ||
|
||
php: | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- hhvm | ||
language: bash | ||
|
||
# This triggers builds to run on the new TravisCI infrastructure. | ||
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ | ||
sudo: false | ||
|
||
## Cache composer | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
before_script: | ||
- mkdir -p build/logs | ||
- travis_retry composer self-update | ||
- travis_retry composer update --no-interaction --prefer-dist | ||
services: | ||
- docker | ||
|
||
sudo: required | ||
|
||
env: | ||
global: | ||
- CODECLIMATE_REPO_TOKEN=7396381ced84304988d8d21526e4b626ac3ab455415d4f0a1154da9609d8cdbb | ||
matrix: | ||
- ENGINE=php VERSION=5.5 INTL=0 | ||
- ENGINE=php VERSION=5.5 INTL=1 | ||
- ENGINE=php VERSION=5.6 INTL=0 | ||
- ENGINE=php VERSION=5.6 INTL=1 | ||
- ENGINE=php VERSION=7.0 INTL=0 | ||
- ENGINE=php VERSION=7.0 INTL=1 | ||
- ENGINE=php VERSION=7.1 INTL=0 | ||
- ENGINE=php VERSION=7.1 INTL=1 | ||
- ENGINE=hhvm INTL=0 | ||
|
||
before_script: | ||
- bash travis/helper.sh install | ||
- bash travis/helper.sh info | ||
- bash travis/helper.sh run mkdir -p build/logs | ||
- bash travis/helper.sh run mkdir -p build/cov | ||
- bash travis/helper.sh run composer self-update | ||
- bash travis/helper.sh run composer update --no-interaction --prefer-dist | ||
|
||
script: | ||
- vendor/bin/phpcs --standard=psr2 src/ | ||
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover | ||
- vendor/bin/phpunit -v --coverage-clover ./build/logs/clover.xml | ||
- bash travis/helper.sh phpunit | ||
- if [[ $ENGINE == 'php' && $VERSION == '7.0' ]]; then bash travis/helper.sh lint; fi | ||
|
||
after_script: | ||
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != '7.0' ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover; fi | ||
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != '7.0' ]]; then php vendor/bin/test-reporter --coverage-report ./build/logs/clover.xml; fi | ||
after_success: | ||
- if [[ $ENGINE == 'php' && $VERSION == '7.0' ]]; then bash travis/helper.sh coverage; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM hhvm/hhvm | ||
|
||
RUN apt-get update && apt-get install -y git curl | ||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM php:5.5 | ||
|
||
RUN apt-get update && apt-get install -y git zlib1g-dev libicu-dev g++ | ||
RUN docker-php-ext-install intl | ||
RUN docker-php-ext-install zip | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM php:5.5 | ||
|
||
RUN apt-get update && apt-get install -y git zlib1g-dev | ||
RUN docker-php-ext-install zip | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM php:5.6 | ||
|
||
RUN apt-get update && apt-get install -y git zlib1g-dev libicu-dev g++ | ||
RUN docker-php-ext-install intl | ||
RUN docker-php-ext-install zip | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM php:5.6 | ||
|
||
RUN apt-get update && apt-get install -y git zlib1g-dev | ||
RUN docker-php-ext-install zip | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM php:7.0 | ||
|
||
RUN apt-get update && apt-get install -y git zlib1g-dev libicu-dev g++ | ||
RUN docker-php-ext-install intl | ||
RUN docker-php-ext-install zip | ||
RUN pecl install xdebug && docker-php-ext-enable xdebug | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM php:7.0 | ||
|
||
RUN apt-get update && apt-get install -y git zlib1g-dev | ||
RUN pecl install xdebug && docker-php-ext-enable xdebug | ||
RUN docker-php-ext-install zip | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM php:7.1 | ||
|
||
RUN apt-get update && apt-get install -y git zlib1g-dev libicu-dev g++ | ||
RUN docker-php-ext-install intl | ||
RUN docker-php-ext-install zip | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM php:7.1 | ||
|
||
RUN apt-get update && apt-get install -y git zlib1g-dev | ||
RUN docker-php-ext-install zip | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Sets IMAGE_NAME if its defined. | ||
function setImageName() { | ||
if [ -f ".docker-image" ]; then | ||
IMAGE_NAME="$(cat .docker-image)" | ||
else | ||
IMAGE_NAME="" | ||
fi | ||
|
||
export IMAGE_NAME | ||
} | ||
|
||
# Prepares Docker environment for running utils. | ||
function prepareEnvironment { | ||
if [ "$ENGINE" == "hhvm" ]; then | ||
IMAGE_NAME="tld-extract/hhvm" | ||
IMAGE_PATH="travis/docker/hhvm" | ||
else | ||
IMAGE_NAME="tld-extract/php-$VERSION" | ||
IMAGE_PATH="travis/docker/php-$VERSION" | ||
fi | ||
|
||
if [[ $INTL == "1" ]]; then | ||
IMAGE_NAME="tld-extract/php-$VERSION-intl" | ||
IMAGE_PATH="travis/docker/php-$VERSION-intl" | ||
fi | ||
|
||
docker build -t "$IMAGE_NAME" "$IMAGE_PATH" | ||
echo -ne $IMAGE_NAME > .docker-image | ||
} | ||
|
||
# Checks that script is running in Travis CI. | ||
function testCI { | ||
# if [ ! -n "${TRAVIS}" ]; then | ||
# echo "This script must be running in Travis CI." | ||
# exit 1 | ||
# fi | ||
echo 1 | ||
} | ||
|
||
# Checks for Docker service. | ||
function testDocker { | ||
docker ps > /dev/null 2>&1 | ||
|
||
if [[ "$?" != "0" ]]; then | ||
echo "This script requires Docker service for running, check .travis.yml." | ||
exit 1 | ||
fi | ||
} | ||
|
||
setImageName | ||
|
||
case "$1" in | ||
'coverage') | ||
docker run -v "$TRAVIS_BUILD_DIR:/opt/src" \ | ||
-w "/opt/src" \ | ||
"$IMAGE_NAME" \ | ||
curl -s https://codecov.io/bash -o codecov | ||
|
||
docker run -v "$TRAVIS_BUILD_DIR:/opt/src" \ | ||
-w "/opt/src" \ | ||
"$IMAGE_NAME" \ | ||
bash codecov -t "$CODECOV_REPO_TOKEN" | ||
;; | ||
|
||
'info') | ||
echo "PHP version :" `docker run "$IMAGE_NAME" php -r "echo phpversion();"` | ||
echo "ext-intl :" `docker run "$IMAGE_NAME" php -r "echo extension_loaded('intl') ? 'yes' : 'no';"` | ||
;; | ||
|
||
'install') | ||
testCI | ||
testDocker | ||
|
||
prepareEnvironment | ||
;; | ||
|
||
'lint') | ||
docker run -v "$TRAVIS_BUILD_DIR:/opt/src" \ | ||
-w "/opt/src" \ | ||
"$IMAGE_NAME" \ | ||
vendor/bin/phpcs --standard=psr2 src/ | ||
;; | ||
|
||
'phpunit') | ||
docker run -v "$TRAVIS_BUILD_DIR:/opt/src" \ | ||
-w "/opt/src" \ | ||
"$IMAGE_NAME" \ | ||
vendor/bin/phpunit -v --coverage-clover ./build/logs/clover.xml | ||
;; | ||
|
||
'run') | ||
docker run -v "$TRAVIS_BUILD_DIR:/opt/src" \ | ||
-w "/opt/src" \ | ||
"$IMAGE_NAME" \ | ||
"${@:2}" | ||
;; | ||
esac |