Skip to content

Commit a1e421f

Browse files
authored
Merge pull request #6 from reactphp-parallel/upgrade-to-test-utilities-v3
Upgrade to test utilities v3
2 parents 3106526 + a15ae0f commit a1e421f

File tree

12 files changed

+5786
-4079
lines changed

12 files changed

+5786
-4079
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,25 @@ jobs:
4646
- name: Install Dependencies
4747
run: composer update --ansi --no-progress --no-interaction --prefer-dist -o
4848
if: matrix.composer == 'highest'
49+
examples:
50+
strategy:
51+
matrix:
52+
php: [7.4]
53+
composer: [lowest, current, highest]
54+
example: [sleep, versions]
55+
needs: composer-install
56+
runs-on: ubuntu-latest
57+
container:
58+
image: wyrihaximusnet/php:${{ matrix.php }}-zts-alpine3.12-dev-root
59+
steps:
60+
- uses: actions/checkout@v1
61+
- name: Cache composer packages
62+
uses: actions/[email protected]
63+
with:
64+
path: ./vendor/
65+
key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
66+
- name: 'Run Example: ${{ matrix.example }}'
67+
run: php ./examples/${{ matrix.example }}.php
4968
qa:
5069
strategy:
5170
fail-fast: false

Makefile

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,68 @@ 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 unit infection 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 tests --level max --ansi -c phpstan.neon
40+
stan: ## Run static analysis (PHPStan)
41+
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c ./etc/qa/phpstan.neon
2842

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

32-
unit:
33-
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml
46+
unit-testing: ## Run tests
47+
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c ./etc/qa/phpunit.xml --coverage-text --coverage-html ./var/tests-unit-coverage-html --coverage-clover ./var/tests-unit-clover-coverage.xml
48+
$(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
3449

35-
infection:
36-
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(nproc) -s
50+
mutation-testing: ## Run mutation testing
51+
$(DOCKER_RUN) vendor/bin/roave-infection-static-analysis-plugin --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc) --ignore-msi-with-no-mutations
3752

38-
composer-require-checker:
39-
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv
53+
composer-require-checker: ## Ensure we require every package used in this package directly
54+
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=./etc/qa/composer-require-checker.json
4055

41-
composer-unused:
56+
composer-unused: ## Ensure we don't require any package we don't use in this package directly
4257
$(DOCKER_RUN) composer unused --ansi
58+
59+
backward-compatibility-check: ## Check code for backwards incompatible changes
60+
$(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check || true
61+
62+
shell: ## Provides Shell access in the expected environment ###
63+
$(DOCKER_RUN) ash
64+
65+
task-list-ci: ## CI: Generate a JSON array of jobs to run, matches the commands run when running `make (|all)` ###
66+
@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]'
67+
68+
help: ## Show this help ###
69+
@printf "\033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n"
70+
@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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
"ext-parallel": "*",
1515
"react-parallel/contracts": "^1.0",
1616
"react-parallel/event-loop": "^1.0",
17+
"react-parallel/pool-tests": "^3.0",
1718
"react-parallel/runtime": "^2.0",
1819
"react/event-loop": "^1.1",
1920
"react/promise": "^2.7",
20-
"wyrihaximus/constants": "^1.4",
21+
"wyrihaximus/async-test-utilities": "^3.2",
22+
"wyrihaximus/constants": "^1.5",
2123
"wyrihaximus/pool-info": "^1.0",
2224
"wyrihaximus/ticking-promise": "^1.6"
2325
},
2426
"require-dev": {
2527
"bruli/php-value-objects": "^2.0",
2628
"moneyphp/money": "^3.2 || ^3.2.1",
2729
"ocramius/package-versions": "^1.4",
28-
"react-parallel/pool-tests": "^2.0",
29-
"wyrihaximus/async-test-utilities": "^2.2",
3030
"wyrihaximus/iterator-or-array-to-array": "^1.1"
3131
},
3232
"config": {

0 commit comments

Comments
 (0)