Skip to content

Commit

Permalink
Update tools and use make to run them
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Dec 6, 2021
1 parent 8e24ede commit 5826c4a
Show file tree
Hide file tree
Showing 10 changed files with 543 additions and 1,025 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ infection.json export-ignore
Makefile export-ignore
phpstan.neon.dist export-ignore
phpstan-baseline.neon export-ignore
phpunit.xml.dist export-ignore
psalm-baseline.xml export-ignore
psalm.xml export-ignore
phpunit.xml.dist export-ignore
/tests export-ignore
/vendor-bin export-ignore
32 changes: 14 additions & 18 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
php-version:
- 8.0
- 8.1

steps:
- name: "Checkout"
Expand All @@ -31,9 +31,6 @@ jobs:
extensions: "mbstring, json"
php-version: ${{ matrix.php-version }}

- name: "Validate composer.json and composer.lock"
run: composer validate --strict

- name: "Cache dependencies installed with composer"
uses: actions/[email protected]
with:
Expand All @@ -45,8 +42,8 @@ jobs:
- name: "Install locked dependencies with composer"
run: composer install --no-interaction --no-progress --no-suggest

- name: "Run localheinz/composer-normalize"
run: composer normalize --dry-run
- name: "Run composer lint"
run: make lint-composer

- name: "Create cache directory for friendsofphp/php-cs-fixer"
run: mkdir -p .build/php-cs-fixer
Expand All @@ -60,7 +57,9 @@ jobs:
php${{ matrix.php-version }}-php-cs-fixer-
- name: "Run friendsofphp/php-cs-fixer"
run: composer cs-diff
env:
PHP_CS_FIXER_IGNORE_ENV: 1
run: make cs

static-code-analysis:
name: "Static Code Analysis"
Expand Down Expand Up @@ -95,13 +94,13 @@ jobs:
run: composer install --no-interaction --no-progress --no-suggest

- name: "Run phpstan/phpstan"
run: composer phpstan
run: make phpstan

- name: "Run psalm"
run: vendor/bin/psalm --config=psalm.xml --diff --shepherd --show-info=false --stats --threads=4
run: make psalm

- name: "Run phpmd"
run: composer phpmd
run: make phpmd

tests:
name: "Test (PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }})"
Expand Down Expand Up @@ -146,7 +145,7 @@ jobs:
run: composer update --no-interaction --no-progress --no-suggest

- name: "Run tests with phpunit/phpunit"
run: composer test
run: make test

code-coverage:
name: "Code Coverage"
Expand Down Expand Up @@ -181,7 +180,7 @@ jobs:
run: composer install --no-interaction --no-progress --no-suggest

- name: "Collect code coverage with pcov and phpunit/phpunit"
run: composer coverage
run: make coverage

- name: "Send code coverage report to Codecov.io"
env:
Expand All @@ -196,7 +195,7 @@ jobs:
strategy:
matrix:
php-version:
- 8.1
- 8.0

steps:
- name: "Checkout"
Expand All @@ -206,7 +205,7 @@ jobs:
uses: shivammathur/[email protected]
with:
coverage: pcov
extensions: "mbstring"
extensions: "mbstring, json"
php-version: ${{ matrix.php-version }}

- name: "Cache dependencies installed with composer"
Expand All @@ -220,8 +219,5 @@ jobs:
- name: "Install locked dependencies with composer"
run: composer install --no-interaction --no-progress --no-suggest

- name: "Download infection"
run: wget -O infection https://github.com/infection/infection/releases/download/0.19.0/infection.phar && chmod +x infection

- name: "Run mutation tests with pcov and infection/infection"
run: ./infection
run: make infection
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.php_cs.cache
.php-cs-fixer.cache
.php-cs-fixer.php
.phpunit.result.cache
coverage
composer.lock
Expand All @@ -7,3 +8,4 @@ phpunit.xml
/vendor/
!/vendor-bin/tools/composer.lock
/vendor-bin/tools/vendor/
/vendor-bin/tools/bin/
7 changes: 5 additions & 2 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
->in([ __DIR__.'/src', __DIR__.'/tests'])
;

$config = PhpCsFixer\Config::create()
$config = (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
Expand All @@ -35,7 +35,10 @@
],
'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
'no_superfluous_phpdoc_tags' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
'remove_inheritdoc' => true,
],
'static_lambda' => true,
'global_namespace_import' => [
'import_classes' => true,
Expand Down
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.PHONY: default
default: lint

.PHONY: fix
fix: cs-fix lint-fix

.PHONY: lint
lint: lint-composer

.PHONY: lint-composer
lint-composer:
composer validate --strict
composer normalize --dry-run

.PHONY: test
test: vendor-bin/tools/vendor
vendor/bin/phpunit --colors=always

.PHONY: infection
infection: vendor/bin/infection
vendor/bin/infection --threads=4

.PHONY: coverage
coverage: vendor-bin/tools/vendor
vendor/bin/phpunit --colors=always --coverage-clover=build/logs/clover.xml

.PHONY: cs
cs: vendor-bin/tools/vendor
vendor/bin/php-cs-fixer fix --verbose --diff --dry-run

.PHONY: cs-fix
cs-fix: vendor-bin/tools/vendor
vendor/bin/php-cs-fixer fix --verbose

.PHONY: psalm
psalm: vendor-bin/tools/vendor
vendor/bin/psalm --config=psalm.xml --diff --shepherd --show-info=false --stats --threads=4

.PHONY: phpstan
phpstan: vendor-bin/tools/vendor
vendor/bin/phpstan analyse

.PHONY: phpmd
phpmd: vendor-bin/tools/vendor
vendor/bin/phpmd src,tests ansi phpmd.xml

.PHONY: lint-fix
lint-fix:
find ./src \\( -name '*.xml' -or -name '*.xml.dist' -or -name '*.xlf' \\) -type f -exec xmllint --encode UTF-8 --output '{}' --format '{}' \\;
find ./src \\( -name '*.yml' -or -name '*.yaml' \\) -not -path '*/vendor/*' | xargs yaml-lint

.PHONY: check-dependencies
check-dependencies: vendor-bin/tools/vendor
vendor/bin/composer-require-checker check --config-file composer-require.json composer.json

#
# Installation tasks
#

vendor-bin/tools/vendor:
composer --working-dir=vendor-bin/tools install

vendor/bin/infection: vendor-bin/tools/vendor
wget -O vendor/bin/infection https://github.com/infection/infection/releases/latest/download/infection.phar && chmod +x vendor/bin/infection
67 changes: 27 additions & 40 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
{
"name": "nucleos/setlistfm",
"type": "library",
"description": "Setlist.fm webservice client for php.",
"license": "MIT",
"type": "library",
"keywords": [
"setlist.fm",
"api",
"bridge",
"webservice client"
],
"homepage": "https://nucleos.rocks",
"license": "MIT",
"authors": [
{
"name": "Christian Gripp",
"email": "[email protected]"
}
],
"homepage": "https://nucleos.rocks",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/core23"
},
{
"type": "opencollective",
"url": "https://opencollective.com/core23"
},
{
"type": "ko-fi",
"url": "https://ko-fi.com/core23"
},
{
"type": "other",
"url": "https://donate.core23.de"
}
],
"require": {
"php": "^8.0",
"ext-json": "*",
Expand All @@ -28,14 +46,11 @@
"bamarni/composer-bin-plugin": "^1.3",
"ergebnis/composer-normalize": "^2.0.1",
"nyholm/psr7": "^1.0",
"symfony/http-client": "^4.4 || ^5.0"
"symfony/http-client": "^5.4 || ^6.0"
},
"suggest": {
"symfony/http-client": "Symfony HTTP client implementation"
},
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"Nucleos\\SetlistFm\\": "src/"
Expand All @@ -46,43 +61,15 @@
"Nucleos\\SetlistFm\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true
},
"scripts": {
"post-install-cmd": [
"@composer bin all install --ansi"
],
"post-update-cmd": [
"@composer bin all install --ansi"
],
"coverage": "vendor/bin/phpunit --colors=always --coverage-clover=build/logs/clover.xml",
"cs": "PHP_CS_FIXER_IGNORE_ENV=1 && vendor/bin/php-cs-fixer fix --verbose",
"cs-diff": "PHP_CS_FIXER_IGNORE_ENV=1 && vendor/bin/php-cs-fixer fix --verbose --diff --diff-format=udiff --dry-run",
"deps": "vendor/bin/composer-require-checker check --config-file composer-require.json composer.json",
"infection": "vendor/bin/infection",
"lint": [
"find ./src \\( -name '*.xml' -or -name '*.xml.dist' -or -name '*.xlf' \\) -type f -exec xmllint --encode UTF-8 --output '{}' --format '{}' \\;",
"find ./src \\( -name '*.yml' -or -name '*.yaml' \\) -not -path '*/vendor/*' | xargs yaml-lint"
],
"phpmd": "vendor/bin/phpmd src,tests ansi phpmd.xml",
"phpstan": "vendor/bin/phpstan analyse",
"psalm": "vendor/bin/psalm --config=psalm.xml --diff --diff-methods --show-info=false --stats --threads=4",
"test": "vendor/bin/phpunit --colors=always"
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/core23"
},
{
"type": "opencollective",
"url": "https://opencollective.com/core23"
},
{
"type": "ko-fi",
"url": "https://ko-fi.com/core23"
},
{
"type": "other",
"url": "https://donate.core23.de"
}
]
]
}
}
5 changes: 1 addition & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ includes:
- phpstan-baseline.neon

parameters:
level: max
level: 8

paths:
- src
- tests

bootstrapFiles:
- vendor-bin/tools/vendor/autoload.php

excludes_analyse:
- tests/bootstrap.php
2 changes: 1 addition & 1 deletion src/Connection/PsrClientConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function call(string $method, array $params = [], string $requestMethod =
$response = $this->client->sendRequest($request);

return $this->parseResponse($response);
} catch (ApiException | NotFoundException $e) {
} catch (ApiException|NotFoundException $e) {
throw $e;
} catch (Exception $e) {
throw new ApiException('Technical error occurred.', 500, $e);
Expand Down
28 changes: 12 additions & 16 deletions vendor-bin/tools/composer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
{
"name": "nucleos/dev-tools",
"type": "project",
"description": "Development tools that do not conflict the project dependencies",
"type": "project",
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"jangregor/phpstan-prophecy": "^0.8",
"maglnet/composer-require-checker": "^2.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"phpmd/phpmd": "^2.9",
"phpspec/prophecy-phpunit": "^2.0",
"friendsofphp/php-cs-fixer": "^3.3",
"maglnet/composer-require-checker": "^3.5",
"phpmd/phpmd": "^2.10",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpstan/phpstan-symfony": "^0.12",
"phpunit/phpunit": "^8.5 || ^9.0",
"psalm/plugin-phpunit": "^0.12",
"symfony/phpunit-bridge": "^5.1",
"vimeo/psalm": "^3.11"
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.16",
"vimeo/psalm": "^4.13"
},
"config": {
"bin-dir": "../../vendor/bin",
"platform": {
"php": "8.0"
"php": "8.0.2"
}
}
}
Loading

0 comments on commit 5826c4a

Please sign in to comment.