Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit b7e5cce

Browse files
committed
Use composer scripts for CS, tests, coverage
1 parent 14a7b18 commit b7e5cce

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

.travis.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ matrix:
2525
include:
2626
- php: 5.6
2727
env:
28-
- EXECUTE_TEST_COVERALLS=true
28+
- TEST_COVERAGE=true
2929
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
3030
- PATH="$HOME/.local/bin:$PATH"
3131
- php: 7
3232
env:
33-
- EXECUTE_CS_CHECK=true
33+
- CS_CHECK=true
3434
- php: hhvm
3535
allow_failures:
3636
- php: hhvm
@@ -40,21 +40,21 @@ notifications:
4040
email: false
4141

4242
before_install:
43-
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
43+
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
4444
- composer self-update
45-
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls:^1.0 ; fi
45+
- if [[ $TEST_COVERAGE == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls:^1.0 ; fi
4646

4747
install:
4848
- travis_retry composer install --no-interaction
4949

5050
script:
51-
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi
52-
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit ; fi
53-
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs ; fi
51+
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; fi
52+
- if [[ $TEST_COVERAGE != 'true' ]]; then composer test ; fi
53+
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
5454
- if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi
5555

5656
after_success:
5757
- if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi
5858

5959
after_script:
60-
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls -v ; fi
60+
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi

CONTRIBUTING.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ To run tests:
6262

6363
If you don't have `curl` installed, you can also download `composer.phar` from https://getcomposer.org/
6464

65-
- Run the tests via `phpunit` and the provided PHPUnit config, like in this example:
65+
- Run the tests:
6666

6767
```console
68-
$ ./vendor/bin/phpunit
68+
$ composer test
6969
```
7070

71-
You can turn on conditional tests with the phpunit.xml file.
71+
You can turn on conditional tests with the `phpunit.xml` file.
7272
To do so:
7373

7474
- Copy `phpunit.xml.dist` file to `phpunit.xml`
@@ -77,24 +77,23 @@ To do so:
7777

7878
## Running Coding Standards Checks
7979

80-
This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding
81-
standards checks, and provides configuration for our selected checks.
82-
`phpcs` is installed by default via Composer.
80+
This component follows [PSR-1](http://www.php-fig.org/psr/psr-1/) and
81+
[PSR-2](http://www.php-fig.org/psr/psr-2/) guidelines, and ships with tooling
82+
for both checking code against standards, as well as fixing most errors.
8383

8484
To run checks only:
8585

8686
```console
87-
$ ./vendor/bin/phpcs
87+
$ composer cs-check
8888
```
8989

90-
`phpcs` provides another tool, `phpcbf`, that can automatically fix many common
91-
problems:
90+
To fix common errors:
9291

9392
```console
94-
$ ./vendor/bin/phpcbf
93+
$ composer cs-fix
9594
```
9695

97-
If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure
96+
If you allow tooling to fix CS issues, please re-run the tests to ensure
9897
they pass, and make sure you add and commit the changes after verification.
9998

10099
## Recommended Workflow for Contributions

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,12 @@
4949
"bin": [
5050
"bin/generate-deps-for-config-factory",
5151
"bin/generate-factory-for-class"
52-
]
52+
],
53+
"scripts": {
54+
"cs-check": "phpcs --colors",
55+
"cs-fix": "phpcbf --colors",
56+
"test": "phpunit --colors=always",
57+
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
58+
"upload-coverage": "coveralls -v"
59+
}
5360
}

0 commit comments

Comments
 (0)