Skip to content

Commit

Permalink
Merge pull request #2849 from lcobucci/update-build
Browse files Browse the repository at this point in the history
Update build to use stages (adding PHPCS to check for CS violations)
  • Loading branch information
Ocramius authored Sep 10, 2017
2 parents 8d18a33 + a39ea6b commit 24b4ebf
Show file tree
Hide file tree
Showing 172 changed files with 3,055 additions and 2,883 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build.properties export-ignore
build.xml export-ignore
phpunit.xml.dist export-ignore
run-all.sh export-ignore
/phpcs.xml.dist export-ignore
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ dist/
download/
vendor/
*.phpunit.xml
composer.lock
composer.lock
/phpunit.xml
/.phpcs-cache
213 changes: 141 additions & 72 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: php
sudo: false
dist: trusty

cache:
directories:
Expand All @@ -8,155 +9,223 @@ cache:

php:
- 7.1
- 7.2
- nightly

env:
- DB=sqlite
- DB=mysql
- DB=mysqli

before_install:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"

before_script:
- if [[ $TRAVIS_PHP_VERSION = '7.1' && $DB = 'sqlite' ]]; then PHPUNIT_FLAGS="--coverage-clover .clover.xml"; else PHPUNIT_FLAGS=""; fi
- if [[ "$PHPUNIT_FLAGS" == "" ]]; then phpenv config-rm xdebug.ini || true; fi
- if [ "$MYSQL_VERSION" == "5.7" ]; then bash ./tests/travis/install-mysql-5.7.sh; fi;
- if [[ "$MYSQL_VERSION" == "5.6" || "$MYSQL_VERSION" == "5.7" ]]; then mysql -e "CREATE SCHEMA doctrine_tests; GRANT ALL PRIVILEGES ON doctrine_tests.* to travis@'%'"; fi;
- if [[ "$MYSQL_VERSION" == "5.6" || "$MYSQL_VERSION" == "5.7" ]]; then mysql -e "CREATE SCHEMA test_create_database; GRANT ALL PRIVILEGES ON test_create_database.* to travis@'%'"; fi;
- if [[ "$MYSQL_VERSION" == "5.6" || "$MYSQL_VERSION" == "5.7" ]]; then mysql -e "CREATE SCHEMA test_drop_database; GRANT ALL PRIVILEGES ON test_drop_database.* to travis@'%'"; fi;

matrix:
fast_finish: true
include:
- php: 7.1
env: DB=mysql MYSQL_VERSION=5.6
dist: trusty
- php: nightly
env: DB=mysql MYSQL_VERSION=5.6
dist: trusty
- if [[ "$DB" == "mysql" || "$DB" == "mysqli" || "$DB" == "mariadb" ]]; then mysql < tests/travis/create-mysql-schema.sql; fi;

install:
- travis_retry composer -n install

- php: 7.1
env: DB=mysqli MYSQL_VERSION=5.6
dist: trusty
script: ./vendor/bin/phpunit --configuration tests/travis/$DB.travis.xml

jobs:
allow_failures:
- php: nightly
env: DB=mysqli MYSQL_VERSION=5.6
dist: trusty

- php: 7.1
include:
- stage: Test
php: 7.1
env: DB=mysql MYSQL_VERSION=5.7
dist: trusty
sudo: required
- php: nightly
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
- stage: Test
php: 7.2
env: DB=mysql MYSQL_VERSION=5.7
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
- stage: Test
php: nightly
env: DB=mysql MYSQL_VERSION=5.7
dist: trusty
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh

- php: 7.1
- stage: Test
php: 7.1
env: DB=mysqli MYSQL_VERSION=5.7
dist: trusty
sudo: required
- php: nightly
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
- stage: Test
php: 7.2
env: DB=mysqli MYSQL_VERSION=5.7
dist: trusty
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
- stage: Test
php: nightly
env: DB=mysqli MYSQL_VERSION=5.7
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh

- php: 7.1
- stage: Test
php: 7.1
env: DB=mariadb MARIADB_VERSION=10.0
addons:
mariadb: 10.0
- php: nightly
- stage: Test
php: 7.2
env: DB=mariadb MARIADB_VERSION=10.0
addons:
mariadb: 10.0
- stage: Test
php: nightly
env: DB=mariadb MARIADB_VERSION=10.0
addons:
mariadb: 10.0

- php: 7.1
- stage: Test
php: 7.1
env: DB=mariadb MARIADB_VERSION=10.1
addons:
mariadb: 10.1
- php: nightly
- stage: Test
php: 7.2
env: DB=mariadb MARIADB_VERSION=10.1
addons:
mariadb: 10.1
- stage: Test
php: nightly
env: DB=mariadb MARIADB_VERSION=10.1
addons:
mariadb: 10.1

- php: 7.1
- stage: Test
php: 7.1
env: DB=pgsql POSTGRESQL_VERSION=9.2
services:
- postgresql
addons:
postgresql: "9.2"
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=9.2
services:
- postgresql
env: DB=pgsql POSTGRESQL_VERSION=9.2
- php: nightly
addons:
postgresql: "9.2"
- stage: Test
php: nightly
env: DB=pgsql POSTGRESQL_VERSION=9.2
services:
- postgresql
env: DB=pgsql POSTGRESQL_VERSION=9.2
addons:
postgresql: "9.2"

- php: 7.1
- stage: Test
php: 7.1
env: DB=pgsql POSTGRESQL_VERSION=9.3
services:
- postgresql
addons:
postgresql: "9.3"
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=9.3
services:
- postgresql
env: DB=pgsql POSTGRESQL_VERSION=9.3
- php: nightly
addons:
postgresql: "9.3"
- stage: Test
php: nightly
env: DB=pgsql POSTGRESQL_VERSION=9.3
services:
- postgresql
env: DB=pgsql POSTGRESQL_VERSION=9.3
addons:
postgresql: "9.3"

- php: 7.1
- stage: Test
php: 7.1
env: DB=pgsql POSTGRESQL_VERSION=9.4
services:
- postgresql
addons:
postgresql: "9.4"
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=9.4
services:
- postgresql
env: DB=pgsql POSTGRESQL_VERSION=9.4
- php: nightly
addons:
postgresql: "9.4"
- stage: Test
php: nightly
env: DB=pgsql POSTGRESQL_VERSION=9.4
services:
- postgresql
env: DB=pgsql POSTGRESQL_VERSION=9.4
addons:
postgresql: "9.4"

- php: 7.1
sudo: false
dist: trusty
- stage: Test
php: 7.1
env: DB=pgsql POSTGRESQL_VERSION=9.5
services:
- postgresql
addons:
postgresql: "9.5"
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=9.5
services:
- postgresql
env: DB=pgsql POSTGRESQL_VERSION=9.5
- php: nightly
sudo: false
dist: trusty
addons:
postgresql: "9.5"
- stage: Test
php: nightly
env: DB=pgsql POSTGRESQL_VERSION=9.5
services:
- postgresql
env: DB=pgsql POSTGRESQL_VERSION=9.5
addons:
postgresql: "9.5"

- php: 7.1
sudo: false
dist: trusty
- stage: Test
php: 7.1
env: DB=pgsql POSTGRESQL_VERSION=9.6
services:
- postgresql
addons:
postgresql: "9.6"
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=9.6
services:
- postgresql
env: DB=pgsql POSTGRESQL_VERSION=9.6
- php: nightly
sudo: false
dist: trusty
addons:
postgresql: "9.6"
- stage: Test
php: nightly
env: DB=pgsql POSTGRESQL_VERSION=9.6
services:
- postgresql
env: DB=pgsql POSTGRESQL_VERSION=9.6

allow_failures:
- php: nightly

after_script:
- if [[ "$PHPUNIT_FLAGS" != "" ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [[ "$PHPUNIT_FLAGS" != "" ]]; then php ocular.phar code-coverage:upload --format=php-clover .clover.xml; fi

install:
- travis_retry composer install
addons:
postgresql: "9.6"

script: ./vendor/bin/phpunit --configuration tests/travis/$DB.travis.xml $PHPUNIT_FLAGS
- stage: Coverage
php: 7.1
env: DB=sqlite
before_script:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
script:
- ./vendor/bin/phpunit --configuration tests/travis/$DB.travis.xml --coverage-clover clover.xml
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover clover.xml

- stage: Coding standard
php: nightly
script:
- ./vendor/bin/phpcs
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
"doctrine/common": "^2.7.1"
},
"require-dev": {
"phpunit/phpunit": "^5.4.6",
"phpunit/phpunit": "^6.3",
"phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5",
"symfony/console": "2.*||^3.0"
"symfony/console": "2.*||^3.0",
"doctrine/coding-standard": "^1.0",
"squizlabs/php_codesniffer": "^3.0"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
Expand Down
24 changes: 24 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors" />

<!-- Ignore warnings and show progress of the run -->
<arg value="np"/>

<file>lib</file>
<file>tests</file>

<rule ref="Doctrine"/>

<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>

<rule ref="Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase">
<exclude-pattern>lib/Doctrine/DBAL/Events.php</exclude-pattern>
</rule>
</ruleset>
11 changes: 7 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
Example: phpunit -c mysqlconf.xml
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
backupGlobals="false"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
verbose="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
>
<php>
<ini name="error_reporting" value="-1" />
Expand All @@ -30,7 +32,7 @@
<var name="db_port" value="3306"/>
-->
<!--<var name="db_event_subscribers" value="Doctrine\DBAL\Event\Listeners\OracleSessionInit">-->

<!-- Database for temporary connections (i.e. to drop/create the main database) -->
<var name="tmpdb_type" value="pdo_mysql"/>
<var name="tmpdb_host" value="localhost" />
Expand All @@ -49,6 +51,7 @@
<directory>./tests/Doctrine/Tests/DBAL/Performance</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="Doctrine\Tests\DbalPerformanceTestListener"/>
</listeners>
Expand Down
Loading

0 comments on commit 24b4ebf

Please sign in to comment.