diff --git a/.travis.yml b/.travis.yml index b4a0a2ed..7799393f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,12 +29,15 @@ env: - PATH="$HOME/.local/bin:$PATH" - SYMFONY_DEPRECATIONS_HELPER=weak - TARGET=test + - UPSTREAM_URL=https://github.com/sonata-project/SonataBlockBundle.git matrix: fast_finish: true include: - php: '7.0' env: TARGET=docs + - php: '7.0' + env: TARGET=lint - php: '5.3' env: COMPOSER_FLAGS="--prefer-lowest" - php: '7.0' @@ -63,6 +66,9 @@ matrix: - env: SONATA_CORE=dev-master@dev before_install: + - git remote add upstream ${UPSTREAM_URL} && git fetch --all + - if [[ -x .travis/check_relevant_${TARGET}.sh && "$TRAVIS_PULL_REQUEST" != "false" ]]; then export RELEVANT=$(.travis/check_relevant_${TARGET}.sh); fi; + - if [[ ! -z ${RELEVANT} ]];then exit 0; fi; - if [ -x .travis/before_install_${TARGET}.sh ]; then .travis/before_install_${TARGET}.sh; fi; install: diff --git a/.travis/check_relevant_docs.sh b/.travis/check_relevant_docs.sh new file mode 100755 index 00000000..9e618c4e --- /dev/null +++ b/.travis/check_relevant_docs.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ev + +RELEVANT_FILES=$(git diff --name-only HEAD upstream/${TRAVIS_BRANCH} -- '*.rst') + +if [[ -z ${RELEVANT_FILES} ]]; then echo -n 'KO'; exit 0; fi; diff --git a/.travis/check_relevant_lint.sh b/.travis/check_relevant_lint.sh new file mode 100755 index 00000000..7a42dcbd --- /dev/null +++ b/.travis/check_relevant_lint.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ev + +RELEVANT_FILES=$(git diff --name-only HEAD upstream/${TRAVIS_BRANCH} -- *.{json}) + +if [[ -z ${RELEVANT_FILES} ]]; then echo -n 'KO'; exit 0; fi; diff --git a/.travis/check_relevant_test.sh b/.travis/check_relevant_test.sh new file mode 100755 index 00000000..9f62f5be --- /dev/null +++ b/.travis/check_relevant_test.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ev + +RELEVANT_FILES=$(git diff --name-only HEAD upstream/${TRAVIS_BRANCH} -- *.{php,yml,xml,twig,js,css,json}) + +if [[ -z ${RELEVANT_FILES} ]]; then echo -n 'KO'; exit 0; fi; diff --git a/.travis/install_lint.sh b/.travis/install_lint.sh new file mode 100755 index 00000000..4c8f60ad --- /dev/null +++ b/.travis/install_lint.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +set -ev + +composer global require sllh/composer-lint:@stable --prefer-dist --no-interaction diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b8706b52..0e698027 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,9 @@ All the sonata team will be glad to review your code changes propositions! :smil But please, read the following before. -### Coding style +### The content + +#### Coding style Each project follows [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/) and [Symfony Coding Standards](http://symfony.com/doc/current/contributing/code/standards.html) for coding style, @@ -64,9 +66,34 @@ and run this command before committing your modifications: php-cs-fixer fix --verbose ``` +#### The documentation + +The documentation is mostly written with the `rst` format. You can test the doc rendering with the `make docs` command. + +If your PR contains a new feature, you must add documentation for it. + +#### The tests + +If your PR contains a fix, tests should be added to prove the bug. + +If your PR contains an addition, a new feature, this one has to be fully covered by tests. + +Some rules have to be respected about the test: + +* Annotations about coverage are prohibited. This concerns: + * `@covers` + * `@coversDefaultClass` + * `@coversNothing` + * `@codeCoverageIgnore` + * `@codeCoverageIgnoreStart` + * `codeCoverageIgnoreEnd` +* All test methods should be prefixed by `test`. Example: `public function testItReturnsNull()`. +* As opposed, the `@test` annotation is prohibited. +* Most of the time, the test class should have the same name as the targeted class, suffixed by `Test`. + ### Writing a Pull Request -#### The content +#### The subject Ideally, a Pull Request should concern one and **only one** subject, so that it remains clear, and independent changes can be merged quickly. diff --git a/Makefile b/Makefile index c0e18e4f..de0af3a7 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ all: @echo "Please choose a task." +lint: + composer validate + test: phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml diff --git a/composer.json b/composer.json index 8d682a0c..f698f111 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ } ], "require": { + "php": "^5.3 || ^7.0", "symfony/http-kernel": "^2.3 || ^3.0", "symfony/form": "^2.3 || ^3.0", "doctrine/common": "^2.3",