Skip to content

Commit 340c7db

Browse files
committed
Added Travis toolchain
- Adds CS fixes, and Coveralls support
1 parent aa3a488 commit 340c7db

File tree

4 files changed

+78
-8
lines changed

4 files changed

+78
-8
lines changed

.php_cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
printf("Executing php_cs!!!\n\n");
3+
$finder = Symfony\CS\Finder\DefaultFinder::create()
4+
->in(__DIR__)
5+
->ignoreDotFiles(true)
6+
->filter(function (SplFileInfo $file) {
7+
$path = $file->getPathname();
8+
9+
switch (true) {
10+
case (strrpos($path, '/bin/')):
11+
return false;
12+
case (strrpos($path, '/test/Bootstrap.php')):
13+
return false;
14+
case (strrpos($path, '/vendor/')):
15+
return false;
16+
default:
17+
return true;
18+
}
19+
});
20+
21+
return Symfony\CS\Config\Config::create()
22+
->fixers(array(
23+
'controls_spaces',
24+
'braces',
25+
'elseif',
26+
'eof_ending',
27+
'function_declaration',
28+
'include',
29+
'indentation',
30+
'linefeed',
31+
'php_closing_tag',
32+
'psr0',
33+
'short_tag',
34+
'trailing_spaces',
35+
'unused_use',
36+
'visibility',
37+
))
38+
->finder($finder);

.travis.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
language: php
22

33
php:
4-
- "5.3"
5-
- "5.4"
6-
7-
before_install:
8-
- wget http://cs.sensiolabs.org/get/php-cs-fixer.phar
4+
- 5.3
5+
- 5.4
6+
- 5.5
97

108
before_script:
11-
- composer install --dev
9+
- composer self-update
10+
- composer install --dev --prefer-source
1211

1312
script:
14-
- (cd test ; ../vendor/bin/phpunit -c phpunit.xml)
15-
- output=$(php php-cs-fixer.phar fix -v --dry-run --level=psr2 .); if [[ $output ]]; then while read -r line; do echo -e "\e[00;31m$line\e[00m"; done <<< "$output"; false; fi;
13+
- ./vendor/bin/phpunit -c ./test --coverage-clover ./build/logs/clover.xml
14+
- ./bin/check-cs.sh
15+
16+
after_script:
17+
- php ./vendor/bin/coveralls -v
18+
19+
notifications:
20+
irc: "irc.freenode.org#apigility-dev"
21+
email: false

bin/check-cs.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
FIXER_CONFIG="`dirname $0`/../.php_cs"
4+
FIXER_PATH="`dirname $0`/../vendor/fabpot/php-cs-fixer/php-cs-fixer"
5+
CS=""
6+
7+
(
8+
cd "`dirname $0`/../" ;
9+
CS=$(php vendor/fabpot/php-cs-fixer/php-cs-fixer fix -v --dry-run .)
10+
)
11+
12+
if [[ "$CS" ]];
13+
then
14+
echo -en '\E[31m'"$CS\033[1m\033[0m";
15+
printf "\n";
16+
echo -en '\E[31;47m'"\033[1mCoding standards check failed!\033[0m"
17+
printf "\n";
18+
exit 2;
19+
fi
20+
21+
echo -en '\E[32m'"\033[1mCoding standards check passed!\033[0m"
22+
printf "\n";
23+
24+
echo $CS

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
"zendframework/zend-view": "~2.3"
3434
},
3535
"require-dev": {
36+
"fabpot/php-cs-fixer": "*@dev",
3637
"phpunit/PHPUnit": "3.7.*",
38+
"satooshi/php-coveralls": ">=0.6.0",
3739
"zendframework/zend-console": "~2.3",
3840
"zendframework/zend-http": "~2.3",
3941
"zendframework/zend-loader": "~2.3"

0 commit comments

Comments
 (0)