Skip to content

Commit de389ff

Browse files
committed
Move lint jobs to CircleCI
1 parent 99f2724 commit de389ff

File tree

3 files changed

+96
-43
lines changed

3 files changed

+96
-43
lines changed

.circleci/config.yml

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ reusable-steps:
2525
- npm-cache-{{ .Revision }}
2626
- npm-cache-{{ .Branch }}
2727
- npm-cache
28+
- &restore-php-cs-fixer-cache
29+
restore_cache:
30+
keys:
31+
- php-cs-fixer-cache-{{ .Revision }}
32+
- php-cs-fixer-cache-{{ .Branch }}
33+
- php-cs-fixer-cache
2834
- &save-composer-cache-by-branch
2935
save_cache:
3036
paths:
@@ -45,6 +51,16 @@ reusable-steps:
4551
paths:
4652
- ~/.npm
4753
key: npm-cache-{{ .Revision }}-{{ .BuildNum }}
54+
- &save-php-cs-fixer-cache-by-branch
55+
save_cache:
56+
paths:
57+
- .php_cs.cache
58+
key: php-cs-fixer-cache-{{ .Branch }}-{{ .BuildNum }}
59+
- &save-php-cs-fixer-cache-by-revision
60+
save_cache:
61+
paths:
62+
- .php_cs.cache
63+
key: php-cs-fixer-cache-{{ .Revision }}-{{ .BuildNum }}
4864
- &update-composer
4965
run:
5066
name: Update Composer
@@ -55,7 +71,55 @@ reusable-steps:
5571
command: composer update --prefer-dist --no-progress --no-suggest --ansi
5672

5773
jobs:
58-
phpunit-php-7.2-coverage:
74+
php-cs-fixer:
75+
docker:
76+
- image: circleci/php:7.2-node-browsers
77+
environment:
78+
PHP_CS_FIXER_FUTURE_MODE: 1
79+
working_directory: ~/api-platform/core
80+
steps:
81+
- checkout
82+
- *restore-composer-cache
83+
- *restore-php-cs-fixer-cache
84+
- *disable-xdebug-php-extension
85+
- *disable-php-memory-limit
86+
- *update-composer
87+
- run:
88+
name: Install PHP-CS-Fixer
89+
command: composer global require friendsofphp/php-cs-fixer:^2.12
90+
- *save-composer-cache-by-revision
91+
- *save-composer-cache-by-branch
92+
- run:
93+
name: Run PHP-CS-Fixer
94+
command: |-
95+
export PATH="$PATH:$HOME/.composer/vendor/bin"
96+
php-cs-fixer fix --dry-run --diff --ansi
97+
- *save-php-cs-fixer-cache-by-revision
98+
- *save-php-cs-fixer-cache-by-branch
99+
100+
phpstan:
101+
docker:
102+
- image: circleci/php:7.2-node-browsers
103+
working_directory: ~/api-platform/core
104+
steps:
105+
- checkout
106+
- *restore-composer-cache
107+
- *disable-xdebug-php-extension
108+
- *disable-php-memory-limit
109+
- *update-composer
110+
- *update-project-dependencies
111+
- run:
112+
name: Install PHPStan
113+
command: composer global require phpstan/phpstan:^0.8
114+
- *save-composer-cache-by-revision
115+
- *save-composer-cache-by-branch
116+
- run:
117+
name: Run PHPStan
118+
command: |-
119+
export PATH="$PATH:$HOME/.composer/vendor/bin"
120+
phpstan analyse -c phpstan.neon -l5 --ansi src tests
121+
122+
phpunit-coverage:
59123
docker:
60124
- image: circleci/php:7.2-node-browsers
61125
environment:
@@ -98,7 +162,7 @@ jobs:
98162
- *save-npm-cache-by-revision
99163
- *save-npm-cache-by-branch
100164

101-
behat-php-7.2-coverage:
165+
behat-coverage:
102166
docker:
103167
- image: circleci/php:7.2-node-browsers
104168
environment:
@@ -181,11 +245,15 @@ jobs:
181245

182246
workflows:
183247
version: 2
248+
lint:
249+
jobs:
250+
- php-cs-fixer
251+
- phpstan
184252
test-with-coverage:
185253
jobs:
186-
- phpunit-php-7.2-coverage
187-
- behat-php-7.2-coverage
254+
- phpunit-coverage
255+
- behat-coverage
188256
- merge-and-upload-coverage:
189257
requires:
190-
- phpunit-php-7.2-coverage
191-
- behat-php-7.2-coverage
258+
- phpunit-coverage
259+
- behat-coverage

.php_cs.dist

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,23 @@ return PhpCsFixer\Config::create()
4242
'location' => 'after_open',
4343
],
4444
'modernize_types_casting' => true,
45-
'no_extra_consecutive_blank_lines' => [
46-
'break',
47-
'continue',
48-
'curly_brace_block',
49-
'extra',
50-
'parenthesis_brace_block',
51-
'return',
52-
'square_brace_block',
53-
'throw',
54-
'use',
45+
'native_function_invocation' => [
46+
'include' => [
47+
'@compiler_optimized',
48+
],
49+
],
50+
'no_extra_blank_lines' => [
51+
'tokens' => [
52+
'break',
53+
'continue',
54+
'curly_brace_block',
55+
'extra',
56+
'parenthesis_brace_block',
57+
'return',
58+
'square_brace_block',
59+
'throw',
60+
'use',
61+
],
5562
],
5663
'no_useless_else' => true,
5764
'no_useless_return' => true,

.travis.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ matrix:
1616
- php: '7.0'
1717
- php: '7.1'
1818
- php: '7.2'
19-
- php: '7.2'
20-
env: lint=1
2119
- php: '7.2'
2220
env: deps=low
2321
- php: '7.2'
@@ -40,12 +38,6 @@ matrix:
4038
before_install:
4139
- phpenv config-rm xdebug.ini || echo "xdebug not available"
4240
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
43-
- if [[ $lint = 1 ]]; then
44-
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.12.0/php-cs-fixer.phar;
45-
fi
46-
- if [[ $lint = 1 ]]; then
47-
composer global require --dev 'phpstan/phpstan:^0.8';
48-
fi
4941
- export PATH="$PATH:$HOME/.composer/vendor/bin"
5042

5143
install:
@@ -56,26 +48,12 @@ install:
5648
fi
5749

5850
script:
59-
- if [[ $lint != 1 ]]; then
60-
tests/Fixtures/app/console cache:clear;
61-
fi
62-
- if [[ $lint != 1 ]]; then
63-
vendor/bin/phpunit;
64-
fi
65-
- if [[ $lint != 1 ]]; then
66-
tests/Fixtures/app/console cache:clear;
67-
fi
51+
- tests/Fixtures/app/console cache:clear
52+
- vendor/bin/phpunit
53+
- tests/Fixtures/app/console cache:clear
6854
- if [[ $APP_ENV = 'postgres' ]]; then
6955
vendor/bin/behat --suite=postgres --format=progress;
70-
elif [[ $lint != 1 ]]; then
56+
else
7157
vendor/bin/behat --suite=default --format=progress;
7258
fi
73-
- if [[ $lint != 1 ]]; then
74-
tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json;
75-
fi
76-
- if [[ $lint = 1 ]]; then
77-
php php-cs-fixer.phar fix --dry-run --diff --no-ansi;
78-
fi
79-
- if [[ $lint = 1 ]]; then
80-
phpstan analyse -c phpstan.neon -l5 --ansi src tests;
81-
fi
59+
- tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json

0 commit comments

Comments
 (0)