Skip to content

Commit

Permalink
Update tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed Feb 15, 2023
1 parent 352a847 commit 8dd42f0
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 24 deletions.
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ _: list
# Config

PHPCS_CONFIG=tools/phpcs.xml
PHPSTAN_SRC_CONFIG=tools/phpstan.src.neon
PHPSTAN_TESTS_CONFIG=tools/phpstan.tests.neon
PHPSTAN_CONFIG=tools/phpstan.neon
PHPSTAN_BASELINE_CONFIG=tools/phpstan.baseline.neon
PHPUNIT_CONFIG=tools/phpunit.xml
INFECTION_CONFIG=tools/infection.json

Expand All @@ -23,8 +23,10 @@ csf: ## Fix PHP files coding style

phpstan: ## Analyse code with PHPStan
mkdir -p var/tools
$(PRE_PHP) "vendor/bin/phpstan" analyse src -c $(PHPSTAN_SRC_CONFIG) $(ARGS)
$(PRE_PHP) "vendor/bin/phpstan" analyse tests -c $(PHPSTAN_TESTS_CONFIG) $(ARGS)
$(PRE_PHP) "vendor/bin/phpstan" analyse src tests -c $(PHPSTAN_CONFIG) $(ARGS)

phpstan-baseline: ## Add PHPStan errors to baseline
make phpstan ARGS="-b $(PHPSTAN_BASELINE_CONFIG)"

# Tests

Expand All @@ -36,15 +38,15 @@ coverage-clover: ## Generate code coverage in XML format
$(PRE_PHP) $(PHPUNIT_COVERAGE) --coverage-clover=var/coverage/clover.xml $(ARGS)

coverage-html: ## Generate code coverage in HTML format
$(PRE_PHP) $(PHPUNIT_COVERAGE) --coverage-html=var/coverage/coverage-html $(ARGS)
$(PRE_PHP) $(PHPUNIT_COVERAGE) --coverage-html=var/coverage/html $(ARGS)

mutations: ## Check code for mutants
make mutations-tests
make mutations-infection

mutations-tests:
mkdir -p var/coverage
$(PRE_PHP) $(PHPUNIT_COVERAGE) --coverage-xml=var/coverage/coverage-xml --log-junit=var/coverage/junit.xml
$(PRE_PHP) $(PHPUNIT_COVERAGE) --coverage-xml=var/coverage/xml --log-junit=var/coverage/junit.xml

mutations-infection:
$(PRE_PHP) vendor/bin/infection \
Expand All @@ -68,4 +70,4 @@ PRE_PHP=XDEBUG_MODE=off
PHPUNIT_COMMAND="vendor/bin/paratest" -c $(PHPUNIT_CONFIG) --runner=WrapperRunner -p$(LOGICAL_CORES)
PHPUNIT_COVERAGE=php -d pcov.enabled=1 -d pcov.directory=./src $(PHPUNIT_COMMAND)

LOGICAL_CORES=$(shell nproc || sysctl -n hw.logicalcpu || echo 4)
LOGICAL_CORES=$(shell nproc || sysctl -n hw.logicalcpu || wmic cpu get NumberOfLogicalProcessors || echo 4)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</p>

<p align="center">
<a href="https://github.com/orisai/openapi/actions?query=workflow%3Aci">
<img src="https://github.com/orisai/openapi/workflows/ci/badge.svg">
<a href="https://github.com/orisai/openapi/actions?query=workflow%3ACI">
<img src="https://github.com/orisai/openapi/workflows/CI/badge.svg">
</a>
<a href="https://coveralls.io/r/orisai/openapi">
<img src="https://badgen.net/coveralls/c/github/orisai/openapi/v1.x?cache=300">
Expand Down
71 changes: 71 additions & 0 deletions tools/phpstan.baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\Encoding\\:\\:addContentType\\(\\) expects non\\-empty\\-string, string given\\.$#"
count: 1
path: ../tests/Unit/Spec/EncodingTest.php

-
message: "#^Cannot call method toArray\\(\\) on Orisai\\\\OpenAPI\\\\Spec\\\\Schema\\|null\\.$#"
count: 1
path: ../tests/Unit/Spec/HeaderTest.php

-
message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\Header\\:\\:addContent\\(\\) expects non\\-empty\\-string, string given\\.$#"
count: 1
path: ../tests/Unit/Spec/HeaderTest.php

-
message: "#^Cannot call method toArray\\(\\) on Orisai\\\\OpenAPI\\\\Spec\\\\Schema\\|null\\.$#"
count: 1
path: ../tests/Unit/Spec/ParameterTest.php

-
message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\Parameter\\:\\:addContent\\(\\) expects non\\-empty\\-string, string given\\.$#"
count: 1
path: ../tests/Unit/Spec/ParameterTest.php

-
message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\RequestBody\\:\\:addContent\\(\\) expects non\\-empty\\-string, string given\\.$#"
count: 1
path: ../tests/Unit/Spec/RequestBodyTest.php

-
message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\Response\\:\\:addContent\\(\\) expects non\\-empty\\-string, string given\\.$#"
count: 1
path: ../tests/Unit/Spec/ResponseTest.php

-
message: "#^Parameter \\#1 \\$code of method Orisai\\\\OpenAPI\\\\Spec\\\\Responses\\:\\:addResponse\\(\\) expects '1XX'\\|'2XX'\\|'3XX'\\|'4XX'\\|'default'\\|int\\<100, 599\\>, '200' given\\.$#"
count: 1
path: ../tests/Unit/Spec/ResponsesTest.php

-
message: "#^Parameter \\#1 \\$code of method Orisai\\\\OpenAPI\\\\Spec\\\\Responses\\:\\:addResponse\\(\\) expects '1XX'\\|'2XX'\\|'3XX'\\|'4XX'\\|'default'\\|int\\<100, 599\\>, '5XX' given\\.$#"
count: 1
path: ../tests/Unit/Spec/ResponsesTest.php

-
message: "#^Parameter \\#1 \\$code of method Orisai\\\\OpenAPI\\\\Spec\\\\Responses\\:\\:addResponse\\(\\) expects '1XX'\\|'2XX'\\|'3XX'\\|'4XX'\\|'default'\\|int\\<100, 599\\>, int\\|string given\\.$#"
count: 1
path: ../tests/Unit/Spec/ResponsesTest.php

-
message: "#^Offset 0 might not exist on list\\<string\\|null\\>\\|null\\.$#"
count: 1
path: ../tests/Unit/Utils/HeadersTest.php

-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{application/json\\: null, application/xml\\: null, application/x\\-neon\\: null, application/x\\-yaml\\: null, text/csv\\: null, text/\\*\\: null, \\*/\\*\\: null\\} and array\\{text/\\*\\: null, \\*/\\*\\: null, text/csv\\: null, application/x\\-neon\\: null, application/xml\\: null, application/x\\-yaml\\: null, application/json\\: null\\} will always evaluate to false\\.$#"
count: 1
path: ../tests/Unit/Utils/MediaTypesTest.php

-
message: "#^Offset 1 might not exist on list\\<string\\|null\\>\\|null\\.$#"
count: 1
path: ../tests/Unit/Utils/MediaTypesTest.php

-
message: "#^Parameter \\#1 \\$mediaType of static method Orisai\\\\OpenAPI\\\\Utils\\\\MediaTypes\\:\\:format\\(\\) expects non\\-empty\\-string, string given\\.$#"
count: 1
path: ../tests/Unit/Utils/MediaTypesTest.php
3 changes: 3 additions & 0 deletions tools/phpstan.base.neon → tools/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
includes:
- ../vendor/phpstan/phpstan/conf/bleedingEdge.neon
- phpstan.baseline.neon

parameters:
phpVersion: 70400
level: 8
tmpDir: ../var/tools/PHPStan
resultCachePath: %currentWorkingDirectory%/var/tools/PHPStan/resultCache.php

checkBenevolentUnionTypes: true
checkMissingCallableSignature: true
Expand Down
6 changes: 0 additions & 6 deletions tools/phpstan.src.neon

This file was deleted.

9 changes: 0 additions & 9 deletions tools/phpstan.tests.neon

This file was deleted.

0 comments on commit 8dd42f0

Please sign in to comment.