Skip to content

Commit

Permalink
add symfony 6 support, stick minimum to 4.4 and test adapter against …
Browse files Browse the repository at this point in the history
…supported versions of symfony packages
  • Loading branch information
sidz committed Nov 7, 2021
1 parent 7a0f08e commit 2b47b6e
Show file tree
Hide file tree
Showing 29 changed files with 305 additions and 1,004 deletions.
26 changes: 21 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,20 +46,31 @@ 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: Globally install symfony/flex
run: composer global require --no-progress --no-scripts --no-plugins symfony/flex

- name: Configure Symfony v6@dev hacks
if: matrix.symfony-require == '^6'
run: |
# not ready for v6 yet
composer remove --no-update --dev php-coveralls/php-coveralls
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

- 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/
/vendor/
infection.log
37 changes: 21 additions & 16 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,25 +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',
],
'protected_to_private' => false,
'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\\.*::.*#'
15 changes: 10 additions & 5 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 Down Expand Up @@ -37,7 +36,8 @@ INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threa
all: test

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

phpstan:
Expand Down Expand Up @@ -103,4 +103,9 @@ build/cache:
$(INFECTION): Makefile
wget -q $(INFECTION_URL) --output-document=$(INFECTION)
chmod a+x $(INFECTION)
touch $@
touch $@

$(PHP_CS_FIXER): Makefile
wget -q $(PHP_CS_FIXER_URL) --output-document=$(PHP_CS_FIXER)
chmod a+x $(PHP_CS_FIXER)
touch $@
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@
"php": "^7.4 || ^8.0",
"infection/abstract-testframework-adapter": "^0.5.0",
"infection/include-interceptor": "^0.2.3",
"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\\PhpSpec\\PhpSpecAdapterFactory"
},
"symfony": {
"require": "^6"
}
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.17",
"php-coveralls/php-coveralls": "^2.4",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^0.12.66",
Expand All @@ -48,6 +50,6 @@
"phpstan/phpstan-webmozart-assert": "^0.12.8",
"phpunit/phpunit": "^9.5",
"thecodingmachine/safe": "^1.3",
"vimeo/psalm": "^4.4"
"vimeo/psalm": "^4.12"
}
}

0 comments on commit 2b47b6e

Please sign in to comment.