Skip to content

Commit

Permalink
Move lint jobs to CircleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
teohhanhui committed Jun 5, 2018
1 parent 99f2724 commit de389ff
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 43 deletions.
80 changes: 74 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ reusable-steps:
- npm-cache-{{ .Revision }}
- npm-cache-{{ .Branch }}
- npm-cache
- &restore-php-cs-fixer-cache
restore_cache:
keys:
- php-cs-fixer-cache-{{ .Revision }}
- php-cs-fixer-cache-{{ .Branch }}
- php-cs-fixer-cache
- &save-composer-cache-by-branch
save_cache:
paths:
Expand All @@ -45,6 +51,16 @@ reusable-steps:
paths:
- ~/.npm
key: npm-cache-{{ .Revision }}-{{ .BuildNum }}
- &save-php-cs-fixer-cache-by-branch
save_cache:
paths:
- .php_cs.cache
key: php-cs-fixer-cache-{{ .Branch }}-{{ .BuildNum }}
- &save-php-cs-fixer-cache-by-revision
save_cache:
paths:
- .php_cs.cache
key: php-cs-fixer-cache-{{ .Revision }}-{{ .BuildNum }}
- &update-composer
run:
name: Update Composer
Expand All @@ -55,7 +71,55 @@ reusable-steps:
command: composer update --prefer-dist --no-progress --no-suggest --ansi

jobs:
phpunit-php-7.2-coverage:
php-cs-fixer:
docker:
- image: circleci/php:7.2-node-browsers
environment:
PHP_CS_FIXER_FUTURE_MODE: 1
working_directory: ~/api-platform/core
steps:
- checkout
- *restore-composer-cache
- *restore-php-cs-fixer-cache
- *disable-xdebug-php-extension
- *disable-php-memory-limit
- *update-composer
- run:
name: Install PHP-CS-Fixer
command: composer global require friendsofphp/php-cs-fixer:^2.12
- *save-composer-cache-by-revision
- *save-composer-cache-by-branch
- run:
name: Run PHP-CS-Fixer
command: |-
export PATH="$PATH:$HOME/.composer/vendor/bin"
php-cs-fixer fix --dry-run --diff --ansi
- *save-php-cs-fixer-cache-by-revision
- *save-php-cs-fixer-cache-by-branch

phpstan:
docker:
- image: circleci/php:7.2-node-browsers
working_directory: ~/api-platform/core
steps:
- checkout
- *restore-composer-cache
- *disable-xdebug-php-extension
- *disable-php-memory-limit
- *update-composer
- *update-project-dependencies
- run:
name: Install PHPStan
command: composer global require phpstan/phpstan:^0.8
- *save-composer-cache-by-revision
- *save-composer-cache-by-branch
- run:
name: Run PHPStan
command: |-
export PATH="$PATH:$HOME/.composer/vendor/bin"
phpstan analyse -c phpstan.neon -l5 --ansi src tests
phpunit-coverage:
docker:
- image: circleci/php:7.2-node-browsers
environment:
Expand Down Expand Up @@ -98,7 +162,7 @@ jobs:
- *save-npm-cache-by-revision
- *save-npm-cache-by-branch

behat-php-7.2-coverage:
behat-coverage:
docker:
- image: circleci/php:7.2-node-browsers
environment:
Expand Down Expand Up @@ -181,11 +245,15 @@ jobs:

workflows:
version: 2
lint:
jobs:
- php-cs-fixer
- phpstan
test-with-coverage:
jobs:
- phpunit-php-7.2-coverage
- behat-php-7.2-coverage
- phpunit-coverage
- behat-coverage
- merge-and-upload-coverage:
requires:
- phpunit-php-7.2-coverage
- behat-php-7.2-coverage
- phpunit-coverage
- behat-coverage
27 changes: 17 additions & 10 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,23 @@ return PhpCsFixer\Config::create()
'location' => 'after_open',
],
'modernize_types_casting' => true,
'no_extra_consecutive_blank_lines' => [
'break',
'continue',
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'throw',
'use',
'native_function_invocation' => [
'include' => [
'@compiler_optimized',
],
],
'no_extra_blank_lines' => [
'tokens' => [
'break',
'continue',
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'throw',
'use',
],
],
'no_useless_else' => true,
'no_useless_return' => true,
Expand Down
32 changes: 5 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ matrix:
- php: '7.0'
- php: '7.1'
- php: '7.2'
- php: '7.2'
env: lint=1
- php: '7.2'
env: deps=low
- php: '7.2'
Expand All @@ -40,12 +38,6 @@ matrix:
before_install:
- phpenv config-rm xdebug.ini || echo "xdebug not available"
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- if [[ $lint = 1 ]]; then
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.12.0/php-cs-fixer.phar;
fi
- if [[ $lint = 1 ]]; then
composer global require --dev 'phpstan/phpstan:^0.8';
fi
- export PATH="$PATH:$HOME/.composer/vendor/bin"

install:
Expand All @@ -56,26 +48,12 @@ install:
fi

script:
- if [[ $lint != 1 ]]; then
tests/Fixtures/app/console cache:clear;
fi
- if [[ $lint != 1 ]]; then
vendor/bin/phpunit;
fi
- if [[ $lint != 1 ]]; then
tests/Fixtures/app/console cache:clear;
fi
- tests/Fixtures/app/console cache:clear
- vendor/bin/phpunit
- tests/Fixtures/app/console cache:clear
- if [[ $APP_ENV = 'postgres' ]]; then
vendor/bin/behat --suite=postgres --format=progress;
elif [[ $lint != 1 ]]; then
else
vendor/bin/behat --suite=default --format=progress;
fi
- if [[ $lint != 1 ]]; then
tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json;
fi
- if [[ $lint = 1 ]]; then
php php-cs-fixer.phar fix --dry-run --diff --no-ansi;
fi
- if [[ $lint = 1 ]]; then
phpstan analyse -c phpstan.neon -l5 --ansi src tests;
fi
- tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json

0 comments on commit de389ff

Please sign in to comment.