Skip to content
This repository was archived by the owner on Dec 2, 2021. It is now read-only.

Commit 8b2f6bf

Browse files
committed
Better build pipeline
- Add stages - Add psalm - Add php-cs-fixer - Use phpdbg for code coverage - Disable phpdoc_to_comment in php-cs-fixer because it may break Psalm annotations
1 parent 134b247 commit 8b2f6bf

File tree

5 files changed

+76
-27
lines changed

5 files changed

+76
-27
lines changed

.php_cs.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
$rules = [
44
'@Symfony' => true,
55
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
6+
'phpdoc_to_comment' => false,
67
];
78

89
$finder = PhpCsFixer\Finder::create()

.travis.yml

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,68 @@
11
language: php
22

3-
php:
4-
- 7.1
5-
- 7.2
6-
- 7.3
7-
- 7.4
8-
9-
sudo: false
10-
11-
matrix:
12-
fast_finish: true
13-
include:
14-
- php: 7.1
15-
env: COMPOSER_FLAGS="--prefer-lowest"
16-
- php: 7.4
17-
env: SYMFONY_VERSION=^3.4
18-
- php: 7.4
19-
env: SYMFONY_VERSION=^4.0
20-
- php: 7.4
21-
env: SYMFONY_VERSION=^5.0
3+
os:
4+
- linux
225

236
cache:
247
directories:
258
- $HOME/.composer/cache
9+
- vendor
2610

2711
before_install:
12+
- if php -v | grep -q 'Xdebug'; then phpenv config-rm xdebug.ini; fi
2813
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
2914

3015
install:
3116
- travis_retry composer update --prefer-dist --no-interaction --no-suggest $COMPOSER_FLAGS
3217

3318
script:
34-
- mkdir -p build/logs
35-
- ./bin/phpunit --coverage-clover build/logs/clover.xml
36-
- ./bin/phpcs --standard=php_cs.xml --ignore=*/vendor/* .
19+
- ./bin/phpunit
20+
21+
jobs:
22+
include:
23+
# Tests
24+
- php: 7.1
25+
- php: 7.2
26+
- php: 7.3
27+
- php: 7.4
28+
- php: 7.1
29+
env:
30+
- COMPOSER_FLAGS="--prefer-lowest"
31+
- php: 7.4
32+
env:
33+
- SYMFONY_VERSION=^3.4
34+
- php: 7.4
35+
env:
36+
- SYMFONY_VERSION=^4.0
37+
- php: 7.4
38+
env:
39+
- SYMFONY_VERSION=^5.0
40+
41+
# Metrics and Quality
42+
- name: Code Coverage
43+
php: 7.4
44+
before_script:
45+
- mkdir -p build/logs
46+
script:
47+
- phpdbg -qrr ./bin/phpunit --coverage-clover build/logs/clover.xml
48+
after_script:
49+
- travis_retry wget https://scrutinizer-ci.com/ocular.phar
50+
- travis_retry php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
51+
52+
- name: Psalm
53+
php: 7.4
54+
script:
55+
- ./bin/psalm --show-info=true
56+
57+
- name: PHP Code Style Sniffer
58+
php: 7.4
59+
script:
60+
- ./bin/phpcs --standard=php_cs.xml --ignore=*/vendor/* .
3761

38-
after_script:
39-
- travis_retry wget https://scrutinizer-ci.com/ocular.phar
40-
- travis_retry php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
62+
- name: PHP Coding Standards Fixer
63+
php: 7.4
64+
before_script:
65+
- travis_retry wget https://cs.symfony.com/download/php-cs-fixer-v2.phar -O php-cs-fixer
66+
- chmod a+x php-cs-fixer
67+
script:
68+
- ./php-cs-fixer fix --dry-run --stop-on-violation --using-cache=no

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ Before you create a pull request, please make sure your changes fulfill the qual
3232
1) Install the dependencies with `composer install`
3333
2) Run the PHPUnit tests with `bin/phpunit`
3434
3) Run PHP CodeSniffer with `bin/phpcs --standard=php_cs.xml --ignore=/vendor/ .`
35+
4) Run Psalm with `bin/psalm`
36+
5) Ideally, run [PHP-CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) (not provided with the library)

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
"require-dev": {
3030
"doctrine/lexer": "^1.0.1",
3131
"doctrine/orm": "^2.6",
32-
"phpunit/phpunit": "^7.0|^8.0",
32+
"phpunit/phpunit": "^7.0|^8.0|^9.0",
3333
"swiftmailer/swiftmailer": "^6.0",
3434
"symfony/yaml": "^3.4|^4.0|^5.0",
3535
"escapestudios/symfony2-coding-standard": "^3.9",
36-
"squizlabs/php_codesniffer": "^3.5"
36+
"squizlabs/php_codesniffer": "^3.5",
37+
"vimeo/psalm": "^3.11",
38+
"symfony/polyfill-php80": "^1.15"
3739
},
3840
"autoload": {
3941
"psr-4": {

psalm.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
resolveFromConfigFile="true"
4+
errorLevel="3"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
>
9+
<projectFiles>
10+
<directory name="." />
11+
<ignoreFiles>
12+
<directory name="vendor" />
13+
<directory name="Tests" />
14+
</ignoreFiles>
15+
</projectFiles>
16+
</psalm>

0 commit comments

Comments
 (0)