Skip to content

Commit ffe5351

Browse files
authored
Merge pull request #145 from php-api-clients/introduce-cs-fixing-and-progress-logging-to-stdout
Introduce CS fixing and process state logging to STDOUT
2 parents 723d32f + a5d79eb commit ffe5351

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2337
-963
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 4
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.json]
11+
indent_size = 2
12+
13+
[*.yml]
14+
indent_size = 2
15+
16+
[*.yaml]
17+
indent_size = 2
18+
19+
[Makefile]
20+
indent_style = tab

.gitattributes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Ignoring files for distribution archieves
2+
.github/ export-ignore
3+
etc/ export-ignore
4+
tests/ export-ignore
5+
var/ export-ignore
6+
.editorconfig export-ignore
7+
.gitattributes export-ignore
8+
.gitignore export-ignore
9+
CONTRIBUTING.md export-ignore
10+
composer.lock export-ignore
11+
infection.json.dist export-ignore
12+
Makefile export-ignore
13+
phpunit.xml.dist export-ignore
14+
README.md export-ignore

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
etc/qa/.phpcs.cache
12
bin/openapi-client-generator
23
example/etc
34
example/generated
45
example/generated-subsplit
5-
vendor
6+
vendor

Makefile

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,26 @@ SHELL=bash
44
.PHONY: *
55

66
DOCKER_CGROUP:=$(shell cat /proc/1/cgroup | grep docker | wc -l)
7-
COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir -q || echo ${HOME}/.composer/cache)
7+
COMPOSER_CACHE_DIR:=$(shell composer config --global cache-dir -q || echo ${HOME}/.composer/cache)
88

99
ifneq ("$(wildcard /.dockerenv)","")
10-
IN_DOCKER=TRUE
10+
IN_DOCKER:=TRUE
1111
else ifneq ("$(DOCKER_CGROUP)","0")
12-
IN_DOCKER=TRUE
12+
IN_DOCKER:=TRUE
1313
else
14-
IN_DOCKER=FALSe
14+
IN_DOCKER:=FALSE
1515
endif
1616

1717
ifeq ("$(IN_DOCKER)","TRUE")
18-
DOCKER_RUN=
18+
DOCKER_RUN:=
1919
else
20-
DOCKER_RUN=docker run --rm -it \
20+
PHP_VERSION:=$(shell docker run --rm -v "`pwd`:`pwd`" jess/jq jq -r -c '.config.platform.php' "`pwd`/composer.json" | php -r "echo str_replace('|', '.', explode('.', implode('|', explode('.', stream_get_contents(STDIN), 2)), 2)[0]);")
21+
DOCKER_RUN:=docker run --rm -it \
2122
-v "`pwd`:`pwd`" \
2223
-v "${COMPOSER_CACHE_DIR}:/home/app/.composer/cache" \
2324
-w "`pwd`" \
2425
-e "FORCE_GENERATION=$$FORCE_GENERATION" \
25-
"wyrihaximusnet/php:8.2-nts-alpine-slim-dev"
26+
"ghcr.io/wyrihaximusnet/php:${PHP_VERSION}-nts-alpine-slim-dev"
2627
endif
2728

2829
all: ## Runs everything ###
@@ -32,31 +33,23 @@ syntax-php: ## Lint PHP syntax
3233
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
3334

3435
cs-fix: ## Fix any automatically fixable code style issues
35-
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc)
36+
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc) --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc) --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc) --standard=./etc/qa/phpcs.xml -vvv
3637

3738
cs: ## Check the code for code style issues
38-
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc)
39+
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc) --standard=./etc/qa/phpcs.xml
3940

4041
stan: ## Run static analysis (PHPStan)
41-
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon
42+
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c ./etc/qa/phpstan.neon
4243

4344
psalm: ## Run static analysis (Psalm)
44-
$(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats
45+
$(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats --config=./etc/qa/psalm.xml
4546

46-
unit: ## Run tests
47-
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml
47+
unit-testing: ## Run tests
48+
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c ./etc/qa/phpunit.xml
49+
$(DOCKER_RUN) test -n "$(COVERALLS_REPO_TOKEN)" && test -n "$(COVERALLS_RUN_LOCALLY)" && test -f ./var/tests-unit-clover-coverage.xml && vendor/bin/php-coveralls -v --coverage_clover ./build/logs/clover.xml --json_path ./var/tests-unit-clover-coverage-upload.json || true
4850

49-
unit-ci: unit
50-
if [ -f ./build/logs/clover.xml ]; then wget https://scrutinizer-ci.com/ocular.phar && sleep 3 && php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml; fi
51-
52-
infection: ## Run mutation testing
53-
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc)
54-
55-
composer-require-checker: ## Ensure we require every package used in this package directly
56-
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json
57-
58-
composer-unused: ## Ensure we don't require any package we don't use in this package directly
59-
$(DOCKER_RUN) composer unused --ansi
51+
mutation-testing: ## Run mutation testing
52+
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc) --ignore-msi-with-no-mutations || (cat ./var/infection.log && false)
6053

6154
backward-compatibility-check: ## Check code for backwards incompatible changes
6255
$(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check || true

bin/openapi-client-generator.source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use ApiClients\Tools\OpenApiClientGenerator\Configuration;
55
use ApiClients\Tools\OpenApiClientGenerator\Generator;
6+
use ApiClients\Tools\OpenApiClientGenerator\Logger;
67
use EventSauce\ObjectHydrator\ObjectMapperUsingReflection;
78
use Symfony\Component\Yaml\Yaml;
89

@@ -20,6 +21,7 @@ use Symfony\Component\Yaml\Yaml;
2021
exit((function (string $configurationFile): int {
2122
$configuration = (new ObjectMapperUsingReflection())->hydrateObject(Configuration::class, Yaml::parseFile($configurationFile));
2223
(new Generator(
24+
Logger::create(),
2325
$configuration,
2426
dirname($configurationFile) . DIRECTORY_SEPARATOR,
2527
))->generate(

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
"wyrihaximus/simple-twig": "^2.1",
4242
"wyrihaximus/async-test-utilities": "^6.1",
4343
"api-clients/github": "^0.2@dev",
44-
"delight-im/random": "^1.0"
44+
"delight-im/random": "^1.0",
45+
"wyrihaximus/monolog-factory": "^1.2",
46+
"maxime-pasquier/monolog-stdout-handler": "^2.1",
47+
"divineomega/php-cli-progress-bar": "^2.1"
4548
},
4649
"autoload": {
4750
"psr-4": {

0 commit comments

Comments
 (0)