Skip to content

Commit

Permalink
Support Symfony 6 (#11)
Browse files Browse the repository at this point in the history
* Support Symfony 6

* update static analyze configs

* fix pipeline

* add more tests

* remove php-cs-fixer from composer.json

* move all tests under Adapter namespace, add more tests

* increase MSI and covered MSI
  • Loading branch information
sidz committed Nov 16, 2021
1 parent 99c0da1 commit f976aaa
Show file tree
Hide file tree
Showing 24 changed files with 470 additions and 952 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ on:
jobs:
tests:
runs-on: ubuntu-latest
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-require }}

strategy:
matrix:
operating-system: [ubuntu-latest]
php-version: ['7.4', '8.0', '8.1']
coverage-driver: [pcov]
symfony-require: ['^4', '^5', '^6']
exclude:
- symfony-require: "^6"
php-version: "7.4"

name: CI with PHP ${{ matrix.php-version }}, using ${{ matrix.coverage-driver }}
name: CI with PHP ${{ matrix.php-version }}, using ${{ matrix.coverage-driver }}, with Symfony ${{ matrix.symfony-require }}

steps:
- name: Checkout
Expand All @@ -41,15 +46,20 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-require }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-require }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
- name: Configure Symfony v6@dev hacks
if: matrix.symfony-require == '^6'
run: |
composer config minimum-stability beta
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist
run: composer update --optimize-autoloader --no-interaction --no-progress --prefer-dist

- name: Run tests and generate coverage
run: make test-unit
Expand All @@ -60,6 +70,7 @@ jobs:
run: make test-e2e

- name: Upload coverage results to Coveralls
if: matrix.symfony-require != '^6'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: vendor/bin/php-coveralls
1 change: 0 additions & 1 deletion .github/workflows/cs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/mt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-${{ matrix.dependencies }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.phpunit.result.cache
/.composer/
/.idea
/.php_cs.cache
/.php-cs-fixer.cache
/.tools/
/build/
/infection.log
Expand Down
36 changes: 21 additions & 15 deletions .php_cs.dist → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,17 @@
])
->ignoreDotFiles(false)
->name('*php')
->name('.php_cs.dist')
;

return Config::create()
return (new Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHPUnit60Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'blank_line_before_statement' => [
'statements' => [
'break',
Expand All @@ -88,15 +87,14 @@
],
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'final_static_access' => true,
'fully_qualified_strict_types' => true,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'header_comment' => [
'commentType' => 'PHPDoc',
'comment_type' => 'PHPDoc',
'header' => $header,
'location' => 'after_open',
'separate' => 'bottom',
Expand All @@ -105,10 +103,13 @@
'syntax' => 'short',
],
'logical_operators' => true,
'native_constant_invocation' => false,
'native_function_invocation' => false,
'native_constant_invocation' => true,
'native_function_invocation' => [
'include' => ['@internal'],
],
'no_alternative_syntax' => true,
'no_superfluous_phpdoc_tags' => true,
'no_trailing_whitespace_in_string' => false,
'no_unset_cast' => true,
'no_useless_else' => true,
'no_useless_return' => true,
Expand All @@ -119,24 +120,29 @@
'phpdoc_align' => [
'align' => 'left',
],
'phpdoc_no_empty_return' => true,
'phpdoc_order' => true,
'phpdoc_summary' => false,
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_strict' => true,
'php_unit_dedicate_assert' => true,
'php_unit_method_casing' => [
'case' => 'snake_case',
],
'php_unit_ordered_covers' => true,
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_strict' => true,
'phpdoc_order_by_value' => [
'annotations' => ['covers'],
],
'php_unit_test_annotation' => [
'case' => 'snake',
'style' => 'prefix',
],
'php_unit_test_case_static_method_calls' => [
'call_type' => 'this',
],
'phpdoc_no_empty_return' => true,
'phpdoc_order' => true,
'phpdoc_summary' => false,
'self_static_accessor' => true,
'single_line_throw' => false,
'static_lambda' => true,
'strict_comparison' => true,
'strict_param' => true,
'yoda_style' => [
'equal' => false,
'identical' => false,
Expand Down
2 changes: 2 additions & 0 deletions .phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ includes:
parameters:
level: max
inferPrivatePropertyTypeFromConstructor: true
ignoreErrors:
- '#Dynamic call to static method PHPUnit\\Framework\\.*::.*#'
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ PHP=$(shell which php)
JOBS=$(shell nproc)

# PHP CS Fixer
PHP_CS_FIXER=vendor/bin/php-cs-fixer
PHP_CS_FIXER_ARGS=--diff --diff-format=udiff --verbose
export PHP_CS_FIXER_IGNORE_ENV=1
PHP_CS_FIXER=./.tools/php-cs-fixer
PHP_CS_FIXER_URL="https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.2.1/php-cs-fixer.phar"

# PHPUnit
PHPUNIT=vendor/bin/phpunit
Expand All @@ -30,14 +29,14 @@ COMPOSER=$(PHP) $(shell which composer)
# Infection
INFECTION=./.tools/infection.phar
INFECTION_URL="https://github.com/infection/infection/releases/download/0.24.0/infection.phar"
MIN_MSI=78
MIN_COVERED_MSI=98
INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --log-verbosity=none --no-interaction --no-progress
MIN_MSI=87
MIN_COVERED_MSI=99
INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --log-verbosity=none --no-interaction --no-progress --show-mutations

all: test

cs:
$(PHP_CS_FIXER) fix $(PHP_CS_FIXER_ARGS) --dry-run
cs: $(PHP_CS_FIXER)
$(PHP_CS_FIXER) fix -v --diff --dry-run
LC_ALL=C sort -u .gitignore -o .gitignore

phpstan:
Expand Down Expand Up @@ -79,7 +78,7 @@ analyze: cs-fix
$(PSALM) $(PSALM_ARGS)

cs-fix: test-prerequisites
$(PHP_CS_FIXER) fix $(PHP_CS_FIXER_ARGS)
$(PHP_CS_FIXER) fix -v --diff
LC_ALL=C sort -u .gitignore -o .gitignore

##############################################################
Expand All @@ -106,3 +105,8 @@ $(INFECTION): Makefile
wget -q $(INFECTION_URL) --output-document=$(INFECTION)
chmod a+x $(INFECTION)
touch $@

$(PHP_CS_FIXER): Makefile
wget -q $(PHP_CS_FIXER_URL) --output-document=$(PHP_CS_FIXER)
chmod a+x $(PHP_CS_FIXER)
touch $@
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,25 @@
"php": "^7.4 || ^8.0",
"infection/abstract-testframework-adapter": "^0.5.0",
"infection/include-interceptor": "^0.2.0",
"symfony/filesystem": "^3.4.29 || ^4.0 || ^5.0",
"symfony/process": "^3.4.29 || ^4.0 || ^5.0",
"symfony/yaml": "^3.4.29 || ^4.0 || ^5.0"
"symfony/filesystem": "^4.4 || ^5.0 || ^6.0",
"symfony/process": "^4.4 || ^5.0 || ^6.0",
"symfony/yaml": "^4.4 || ^5.0 || ^6.0"
},
"extra": {
"infection": {
"class": "Infection\\TestFramework\\Codeception\\CodeceptionAdapterFactory"
}
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.18",
"php-coveralls/php-coveralls": "^2.4",
"php-coveralls/php-coveralls": "^2.5",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^0.12.70",
"phpstan/phpstan-phpunit": "^0.12.17",
"phpstan/phpstan-strict-rules": "^0.12.9",
"phpstan/phpstan-webmozart-assert": "^0.12.9",
"phpunit/phpunit": "^9.5",
"thecodingmachine/safe": "^1.3",
"vimeo/psalm": "^4.4"
"vimeo/psalm": "^4.12"
},
"conflict": {
"codeception/codeception": "<4.1.9"
Expand Down
Loading

0 comments on commit f976aaa

Please sign in to comment.