Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 624f137

Browse files
committed
Travis - use stages
1 parent 3383d54 commit 624f137

7 files changed

Lines changed: 123 additions & 97 deletions

File tree

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ install:
3434

3535
before_test:
3636
- cd C:\projects\php-cs-fixer
37-
- php C:\tools\composer.phar update --no-interaction --no-progress --optimize-autoloader --prefer-stable --no-ansi
37+
- php C:\tools\composer.phar update --no-interaction --no-progress --prefer-stable --no-ansi
3838

3939
test_script:
4040
- cd C:\projects\php-cs-fixer

.travis.yml

Lines changed: 98 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -5,104 +5,112 @@ sudo: false
55
git:
66
depth: 1
77

8-
env:
9-
global:
10-
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-progress --optimize-autoloader"
11-
- TASK_TESTS=1
12-
- TASK_TESTS_COVERAGE=0
13-
- TASK_CS=1
14-
- TASK_SCA=0
15-
16-
matrix:
17-
fast_finish: true
18-
include:
19-
- php: 7.1
20-
env: DEPLOY=yes TASK_TESTS_COVERAGE=1
21-
- php: nightly
22-
env: TASK_SCA=1 COMPOSER_FLAGS="--ignore-platform-reqs" SYMFONY_DEPRECATIONS_HELPER=weak PHP_CS_FIXER_IGNORE_ENV=1
23-
- php: 5.6
24-
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
25-
- php: 7.0
26-
env: SYMFONY_DEPRECATIONS_HELPER=weak PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1
27-
288
cache:
299
directories:
3010
- $HOME/.composer
3111

32-
before_install:
33-
# check phpdbg
34-
- phpdbg --version 2> /dev/null || { echo 'No phpdbg'; export TASK_TESTS_COVERAGE=0; }
12+
env:
13+
global:
14+
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-progress"
15+
- COMPOSER_FLAGS=""
3516

17+
before_install:
3618
# turn off XDebug
3719
- phpenv config-rm xdebug.ini || return 0
3820

39-
# validate tasks configuration
40-
- if [ $TASK_TESTS == 0 ] && [ $TASK_TESTS_COVERAGE == 1 ]; then travis_terminate 1; fi
41-
42-
# for building a tag release we don't need to run SCA tools, collect code coverage or self-fix CS
43-
- if [ $TRAVIS_TAG ]; then export TASK_SCA=0; fi
44-
- if [ $TRAVIS_TAG ]; then export TASK_TESTS_COVERAGE=0; fi
45-
- if [ $TRAVIS_TAG ]; then export TASK_CS=0; fi
46-
4721
# Composer: boost installation
4822
- composer global show -ND 2>&1 | grep "hirak/prestissimo" || travis_retry composer global require $DEFAULT_COMPOSER_FLAGS hirak/prestissimo
4923

50-
# display tasks configuration for a job
51-
- set | grep ^TASK | sort
52-
53-
install:
54-
- if [ $TASK_SCA == 1 ]; then travis_retry composer global require $DEFAULT_COMPOSER_FLAGS maglnet/composer-require-checker:^0.1.4; fi
55-
- travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
56-
- composer info -D | sort
57-
58-
before_script:
59-
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then COMMIT_RANGE=$TRAVIS_COMMIT_RANGE; else COMMIT_RANGE="HEAD~..HEAD"; fi;
60-
- if [ $TASK_SCA == 1 ]; then export COMMIT_SCA_FILES=`git diff --name-only --diff-filter=ACMRTUXB $COMMIT_RANGE`; fi
61-
62-
script:
63-
- if [ $TASK_SCA == 1 ]; then ./check_trailing_spaces.sh || travis_terminate 1; fi
64-
- if [ $TASK_SCA == 1 ] && [ -n "$COMMIT_SCA_FILES" ]; then vendor/bin/phpmd `echo "$COMMIT_SCA_FILES" | grep -Ev "^(src/Resources|tests/Fixtures)" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi;
65-
- if [ $TASK_SCA == 1 ]; then php php-cs-fixer fix --rules @PHP71Migration,@PHP71Migration:risky,native_function_invocation -q; fi
66-
- if [ $TASK_SCA == 1 ]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS --no-dev --prefer-stable; fi
67-
- if [ $TASK_SCA == 1 ]; then $HOME/.composer/vendor/bin/composer-require-checker check composer.json --config-file=.composer-require-checker.json || travis_terminate 1; fi
68-
- if [ $TASK_SCA == 1 ]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS; fi
69-
70-
- if [ $TASK_TESTS == 1 ] && [ $TASK_TESTS_COVERAGE == 0 ]; then vendor/bin/phpunit --verbose; fi
71-
- if [ $TASK_TESTS == 1 ] && [ $TASK_TESTS_COVERAGE == 1 ]; then phpdbg -qrr vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml; fi
72-
73-
- if [ $TASK_SCA == 1 ]; then git checkout . -q; fi
74-
75-
- if [ $TASK_CS == 1 ]; then php php-cs-fixer --diff --dry-run -v fix; fi
76-
77-
after_success:
78-
- if [ $TASK_TESTS_COVERAGE == 1 ]; then php vendor/bin/coveralls -v; fi
79-
80-
before_deploy:
81-
# install box2
82-
- curl -LSs http://box-project.github.io/box2/installer.php | php
83-
- php box.phar --version
84-
85-
# ensure that deps will work on lowest supported PHP version
86-
- composer config platform.php 2> /dev/null || composer config platform.php 5.6.0
87-
88-
# require suggested packages
89-
- composer require --no-update symfony/polyfill-mbstring
90-
91-
# update deps to highest possible for lowest supported PHP version
92-
- composer update $DEFAULT_COMPOSER_FLAGS --no-dev --prefer-stable
93-
94-
- composer info -D | sort
95-
96-
# build phar file
97-
- php -d phar.readonly=false box.phar build
98-
99-
deploy:
100-
provider: releases
101-
api_key:
102-
secure: K9NKi7X1OPz898fxtVc1RfWrSI+4hTFFYOik932wTz1jC4dQJ64Khh1LV9frA1+JiDS3+R6TvmQtpzbkX3y4L75UrSnP1ADH5wfMYIVmydG3ZjTMo8SWQWHmRMh3ORAKTMMpjl4Q7EkRkLp6RncKe+FAFPP5mgv55mtIMaE4qUk=
103-
file: php-cs-fixer.phar
104-
skip_cleanup: true
105-
on:
106-
repo: FriendsOfPHP/PHP-CS-Fixer
107-
tags: true
108-
condition: $DEPLOY = yes
24+
jobs:
25+
include:
26+
-
27+
stage: Static Code Analysis
28+
php: 7.1
29+
env: COMPOSER_FLAGS="--no-dev --prefer-stable"
30+
install:
31+
- travis_retry composer update -d dev-tools $DEFAULT_COMPOSER_FLAGS
32+
- composer info -d dev-tools -D | sort
33+
34+
- travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
35+
- composer info -D | sort
36+
before_script:
37+
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then COMMIT_RANGE=$TRAVIS_COMMIT_RANGE; else COMMIT_RANGE="HEAD~..HEAD"; fi;
38+
- export COMMIT_SCA_FILES=`git diff --name-only --diff-filter=ACMRTUXB $COMMIT_RANGE`
39+
script:
40+
- ./check_trailing_spaces.sh || travis_terminate 1
41+
- if [ -n "$COMMIT_SCA_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$COMMIT_SCA_FILES" | grep -Ev "^(src/Resources|tests/Fixtures)" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
42+
- ./dev-tools/vendor/bin/composer-require-checker check composer.json --config-file=.composer-require-checker.json
43+
44+
45+
- &STANDARD_TEST_JOB
46+
stage: Test
47+
php: 7.0
48+
install:
49+
- travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
50+
- composer info -D | sort
51+
script:
52+
- vendor/bin/phpunit --verbose || travis_terminate 1
53+
- php php-cs-fixer --diff --dry-run -v fix
54+
55+
-
56+
<<: *STANDARD_TEST_JOB
57+
php: 5.6
58+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
59+
60+
-
61+
<<: *STANDARD_TEST_JOB
62+
php: 7.1
63+
env: COLLECT_COVERAGE=1
64+
before_script:
65+
# check phpdbg
66+
- phpdbg --version 2> /dev/null || { echo 'No phpdbg'; export COLLECT_COVERAGE=0; }
67+
68+
# for building a tag release we don't need to collect code coverage
69+
- if [ $TRAVIS_TAG ]; then export COLLECT_COVERAGE=0; fi
70+
script:
71+
- if [ $COLLECT_COVERAGE == 0 ]; then vendor/bin/phpunit --verbose || travis_terminate 1; fi
72+
- if [ $COLLECT_COVERAGE == 1 ]; then phpdbg -qrr vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml || travis_terminate 1; fi
73+
- php php-cs-fixer --diff --dry-run -v fix || travis_terminate 1
74+
- if [ $COLLECT_COVERAGE == 1 ]; then php vendor/bin/coveralls -v; fi
75+
76+
-
77+
<<: *STANDARD_TEST_JOB
78+
php: nightly
79+
env: COMPOSER_FLAGS="--ignore-platform-reqs" SYMFONY_DEPRECATIONS_HELPER=weak PHP_CS_FIXER_IGNORE_ENV=1 PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1
80+
script:
81+
- php php-cs-fixer fix --rules @PHP70Migration:risky,@PHP71Migration,native_function_invocation -q || travis_terminate 1
82+
- vendor/bin/phpunit --verbose || travis_terminate 1
83+
- git checkout . -q
84+
- php php-cs-fixer --diff --dry-run -v fix
85+
86+
-
87+
stage: Deployment
88+
php: 7.1
89+
env: COMPOSER_FLAGS="--no-dev --prefer-stable"
90+
install: skip
91+
script: skip
92+
before_deploy:
93+
# ensure that deps will work on lowest supported PHP version
94+
- composer config platform.php 2> /dev/null || composer config platform.php 5.6.0
95+
96+
# require suggested packages
97+
- composer require --no-update symfony/polyfill-mbstring
98+
99+
- travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
100+
- composer info -D | sort
101+
102+
# install box2
103+
- curl -LSs http://box-project.github.io/box2/installer.php | php
104+
- php box.phar --version
105+
106+
# build phar file
107+
- php -d phar.readonly=false box.phar build
108+
deploy:
109+
provider: releases
110+
api_key:
111+
secure: K9NKi7X1OPz898fxtVc1RfWrSI+4hTFFYOik932wTz1jC4dQJ64Khh1LV9frA1+JiDS3+R6TvmQtpzbkX3y4L75UrSnP1ADH5wfMYIVmydG3ZjTMo8SWQWHmRMh3ORAKTMMpjl4Q7EkRkLp6RncKe+FAFPP5mgv55mtIMaE4qUk=
112+
file: php-cs-fixer.phar
113+
skip_cleanup: true
114+
on:
115+
repo: FriendsOfPHP/PHP-CS-Fixer
116+
tags: true

check_trailing_spaces.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
files_with_trailing_spaces=$(find . -type f -not -path "./.git/*" -not -path "./vendor/*" -not -path "./tests/Fixtures/*" -exec egrep -nH " $" {} \;)
3+
files_with_trailing_spaces=$(find . -type f -not -path "./.git/*" -not -path "./dev-tools/vendor/*" -not -path "./vendor/*" -not -path "./tests/Fixtures/*" -exec egrep -nH " $" {} \;)
44

55
if [[ $files_with_trailing_spaces ]]
66
then

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
"require-dev": {
3434
"johnkary/phpunit-speedtrap": "^1.1",
3535
"justinrainbow/json-schema": "^5.0",
36-
"mi-schi/phpmd-extension": "^4.2",
37-
"phpmd/phpmd": "^2.4.3",
3836
"phpunit/phpunit": "^4.8.35 || ^5.4.3",
3937
"satooshi/php-coveralls": "^1.0",
4038
"symfony/phpunit-bridge": "^3.2.2"
@@ -47,6 +45,7 @@
4745
"hhvm": "*"
4846
},
4947
"config": {
48+
"optimize-autoloader": true,
5049
"sort-packages": true
5150
},
5251
"autoload": {

dev-tools/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.lock
2+
/vendor/

dev-tools/composer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"require": {
3+
"php": "^7.0"
4+
},
5+
"require-dev": {
6+
"maglnet/composer-require-checker": "^0.1.4",
7+
"mi-schi/phpmd-extension": "^4.2",
8+
"phpmd/phpmd": "^2.4.3"
9+
},
10+
"conflict": {
11+
"hhvm": "*"
12+
},
13+
"config": {
14+
"optimize-autoloader": true,
15+
"sort-packages": true
16+
}
17+
}

phpmd.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
2020

21-
<rule ref="vendor/mi-schi/phpmd-extension/rulesets/cleancode.xml/DataStructureMethods" />
22-
<rule ref="vendor/mi-schi/phpmd-extension/rulesets/cleancode.xml/SwitchStatement" />
21+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/cleancode.xml/DataStructureMethods" />
22+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/cleancode.xml/SwitchStatement" />
2323

24-
<rule ref="vendor/mi-schi/phpmd-extension/rulesets/naming.xml/CommentDescription">
24+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/naming.xml/CommentDescription">
2525
<properties>
2626
<property name="percent" value="70" />
2727
</properties>

0 commit comments

Comments
 (0)