Skip to content

Commit b02a0de

Browse files
authored
Merge pull request #11 from reactphp-parallel/next-gen-qa-set-up
Next gen QA set up
2 parents bacb9dc + f6046c6 commit b02a0de

File tree

10 files changed

+89
-31
lines changed

10 files changed

+89
-31
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
var
12
vendor

Makefile

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,61 @@ SHELL=bash
33

44
.PHONY: *
55

6+
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)
8+
69
ifneq ("$(wildcard /.dockerenv)","")
7-
DOCKER_RUN=
10+
IN_DOCKER:=TRUE
11+
else ifneq ("$(DOCKER_CGROUP)","0")
12+
IN_DOCKER:=TRUE
13+
else
14+
IN_DOCKER:=FALSE
15+
endif
16+
17+
ifeq ("$(IN_DOCKER)","TRUE")
18+
DOCKER_RUN:=
819
else
9-
DOCKER_RUN=docker run --rm -it \
10-
-v `pwd`:`pwd` \
11-
-w `pwd` \
12-
"wyrihaximusnet/php:7.4-zts-alpine3.11-dev"
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 \
22+
-v "`pwd`:`pwd`" \
23+
-v "${COMPOSER_CACHE_DIR}:/home/app/.composer/cache" \
24+
-w "`pwd`" \
25+
"ghcr.io/wyrihaximusnet/php:${PHP_VERSION}-zts-alpine3.12-dev"
1326
endif
1427

15-
all: lint cs-fix cs stan psalm composer-require-checker composer-unused
28+
all: ## Runs everything ###
29+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "###" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs --open-tty $(MAKE)
1630

17-
lint:
31+
syntax-php: ## Lint PHP syntax
1832
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
1933

20-
cs:
21-
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(nproc)
34+
cs-fix: ## Fix any automatically fixable code style issues
35+
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml -vvvv
2236

23-
cs-fix:
24-
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(nproc)
37+
cs: ## Check the code for code style issues
38+
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml
2539

26-
stan:
27-
$(DOCKER_RUN) vendor/bin/phpstan analyse src --level max --ansi -c phpstan.neon
40+
stan: ## Run static analysis (PHPStan)
41+
$(DOCKER_RUN) vendor/bin/phpstan analyse src --level max --ansi -c ./etc/qa/phpstan.neon
2842

29-
psalm:
30-
$(DOCKER_RUN) vendor/bin/psalm --threads=$(nproc) --shepherd --stats src
43+
psalm: ## Run static analysis (Psalm)
44+
$(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats --config=./psalm.xml
3145

32-
composer-require-checker:
33-
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json
46+
composer-require-checker: ## Ensure we require every package used in this package directly
47+
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=./etc/qa/composer-require-checker.json
3448

35-
composer-unused:
49+
composer-unused: ## Ensure we don't require any package we don't use in this package directly
3650
$(DOCKER_RUN) composer unused --ansi
51+
52+
backward-compatibility-check: ## Check code for backwards incompatible changes
53+
$(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check || true
54+
55+
shell: ## Provides Shell access in the expected environment ###
56+
$(DOCKER_RUN) ash
57+
58+
task-list-ci: ## CI: Generate a JSON array of jobs to run, matches the commands run when running `make (|all)` ###
59+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "###" | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c 'split("\n")| .[0:-1]'
60+
61+
help: ## Show this help ###
62+
@printf "\033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n"
63+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d '#'

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"react-parallel/event-loop": "^1.0",
1919
"react/event-loop": "^1.1",
2020
"react/promise": "^2.7",
21+
"thecodingmachine/safe": "^1.3",
2122
"wyrihaximus/async-test-utilities": "^3.2",
2223
"wyrihaximus/iterator-or-array-to-array": "^1.1",
2324
"wyrihaximus/pool-info": "^1.0"

composer.lock

Lines changed: 29 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

etc/qa/.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:37:"PHPUnit\Runner\DefaultTestResultCache":488:{a:2:{s:7:"defects";a:0:{}s:5:"times";a:6:{s:55:"ReactParallel\Tests\EventLoop\EventLoopBridgeTest::read";d:2.018;s:56:"ReactParallel\Tests\EventLoop\EventLoopBridgeTest::close";d:1.004;s:57:"ReactParallel\Tests\EventLoop\EventLoopBridgeTest::cancel";d:3.004;s:55:"ReactParallel\Tests\EventLoop\EventLoopBridgeTest::kill";d:3.005;s:63:"ReactParallel\Tests\EventLoop\EventLoopBridgeTest::channelError";d:1.002;s:62:"ReactParallel\Tests\EventLoop\EventLoopBridgeTest::futureError";d:1.004;}}}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"null", "true", "false",
44
"static", "self", "parent",
55
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object",
6-
"Safe\\sleep"
6+
"WyriHaximus\\Constants\\ComposerAutoloader\\LOCATION", "WyriHaximus\\Constants\\Boolean\\FALSE_",
7+
"WyriHaximus\\Constants\\Boolean\\TRUE_", "WyriHaximus\\Constants\\Numeric\\ZERO", "Safe\\sleep"
78
],
89
"php-core-extensions" : [
910
"Core",

phpcs.xml.dist renamed to etc/qa/phpcs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<arg name="cache" value=".phpcs.cache" /> <!-- cache the results and don't commit them -->
77
<arg value="np" /> <!-- n = ignore warnings, p = show progress -->
88

9-
<file>src</file>
9+
<file>../../src</file>
1010

1111
<rule ref="WyriHaximus-OSS" />
1212
</ruleset>

etc/qa/phpstan.neon

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
parameters:
2+
checkMissingIterableValueType: false
3+
ignoreErrors:
4+
- '#Call to an undefined method React\\Promise\\PromiseInterface::always\(\).#'
5+
ergebnis:
6+
classesAllowedToBeExtended:
7+
- Exception
8+
includes:
9+
- ../../vendor/wyrihaximus/async-test-utilities/rules.neon

phpstan.neon

Lines changed: 0 additions & 10 deletions
This file was deleted.

var/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)