Skip to content

Commit 7cc394b

Browse files
authored
Merge pull request #103 from WyriHaximus/update-to-latest-qa-setup
Update to latest QA set up
2 parents 46e80e7 + 3aec6a8 commit 7cc394b

28 files changed

+192
-183
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,11 @@ trim_trailing_whitespace = true
1010
[*.json]
1111
indent_size = 2
1212

13+
[*.yml]
14+
indent_size = 2
15+
16+
[*.yaml]
17+
indent_size = 2
18+
1319
[Makefile]
1420
indent_style = tab

.gitattributes

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# Ignoring files for distribution archieves
2-
examples/ export-ignore
2+
.github/ export-ignore
3+
etc/ci/ export-ignore
4+
etc/qa/ export-ignore
35
tests/ export-ignore
4-
.dunitconfig export-ignore
5-
.travis.yml export-ignore
6-
.gitignore export-ignore
6+
var/ export-ignore
7+
.devcontainer.json export-ignore
8+
.editorconfig export-ignore
79
.gitattributes export-ignore
8-
.scrutinizer.yml export-ignore
9-
.styleci.yml export-ignore
10-
appveyor.yml export-ignore
11-
phpunit.xml.dist export-ignore
10+
.gitignore export-ignore
11+
CONTRIBUTING.md export-ignore
12+
infection.json.dist export-ignore
13+
Makefile export-ignore
14+
README.md export-ignore

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
examples/credentials.php
1+
var/*
2+
!var/.gitkeep
3+
src/Generated/*
4+
!src/Generated/.gitkeep
25
vendor/
6+
etc/qa/.phpunit.result.cache

.scrutinizer.yml

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

Makefile

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,88 @@ SHELL=bash
33

44
.PHONY: *
55

6-
DOCKER_CGROUP:=$(shell cat /proc/1/cgroup | grep docker | wc -l)
7-
8-
ifneq ("$(wildcard /.dockerenv)","")
6+
COMPOSER_SHOW_EXTENSION_LIST=$(shell composer show -t | grep -o "\-\-\(ext-\).\+" | sort | uniq | cut -d- -f4- | tr -d '\n' | grep . | sed '/^$$/d' | xargs | sed -e 's/ /, /g' | tr -cd '[:alnum:],' | sed 's/.$$//')
7+
SLIM_DOCKER_IMAGE=$(shell php -r 'echo count(array_intersect(["gd", "vips"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}"))) > 0 ? "" : "-slim";')
8+
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]);")
9+
CONTAINER_NAME=$(shell echo "ghcr.io/wyrihaximusnet/php:${PHP_VERSION}-nts-alpine${SLIM_DOCKER_IMAGE}-dev")
10+
COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
11+
COMPOSER_CONTAINER_CACHE_DIR=$(shell docker run --rm -it ${CONTAINER_NAME} composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
12+
13+
ifneq ("$(wildcard /.you-are-in-a-wyrihaximus.net-php-docker-image)","")
914
IN_DOCKER=TRUE
10-
else ifneq ("$(DOCKER_CGROUP)","0")
11-
IN_DOCKER=TRUE
1215
else
13-
IN_DOCKER=FALSe
16+
IN_DOCKER=FALSE
1417
endif
1518

1619
ifeq ("$(IN_DOCKER)","TRUE")
17-
DOCKER_RUN=
20+
DOCKER_RUN:=
1821
else
19-
DOCKER_RUN=docker run --rm -it \
22+
DOCKER_RUN:=docker run --rm -it \
2023
-v "`pwd`:`pwd`" \
24+
-v "${COMPOSER_CACHE_DIR}:${COMPOSER_CONTAINER_CACHE_DIR}" \
2125
-w "`pwd`" \
22-
"wyrihaximusnet/php:7.4-nts-alpine3.12-dev"
26+
${CONTAINER_NAME}
2327
endif
2428

25-
all: lint cs-fix cs stan psalm unit infection composer-require-checker composer-unused backward-compatibility-check
29+
ifneq (,$(findstring icrosoft,$(shell cat /proc/version)))
30+
THREADS=1
31+
else
32+
THREADS=$(shell nproc)
33+
endif
2634

27-
lint:
35+
all: ## Runs everything ####
36+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "####" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs --open-tty $(MAKE)
37+
38+
syntax-php: ## Lint PHP syntax
2839
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
2940

30-
cs:
31-
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc)
41+
cs-fix: ## Fix any automatically fixable code style issues ###
42+
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml -vvvv
43+
44+
cs: ## Check the code for code style issues
45+
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml
46+
47+
stan: ## Run static analysis (PHPStan)
48+
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c ./etc/qa/phpstan.neon
49+
50+
unit-testing: ## Run tests
51+
$(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
52+
$(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
53+
54+
unit-testing-raw: ## Run tests ####
55+
php vendor/phpunit/phpunit/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
56+
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
57+
58+
composer-require-checker: ## Ensure we require every package used in this package directly
59+
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=./etc/qa/composer-require-checker.json
60+
61+
composer-unused: ## Ensure we don't require any package we don't use in this package directly
62+
$(DOCKER_RUN) vendor/bin/composer-unused --ansi --configuration=./etc/qa/composer-unused.php
3263

33-
cs-fix:
34-
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc)
64+
composer-install: ## Install dependencies
65+
$(DOCKER_RUN) composer install --no-progress --ansi --no-interaction --prefer-dist -o
3566

36-
stan:
37-
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon
67+
backward-compatibility-check: ## Check code for backwards incompatible changes
68+
$(MAKE) backward-compatibility-check-raw || true
3869

39-
psalm:
40-
$(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats
70+
backward-compatibility-check-raw: ## Check code for backwards incompatible changes, doesn't ignore the failure ###
71+
$(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check
4172

42-
unit:
43-
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml
73+
shell: ## Provides Shell access in the expected environment ####
74+
$(DOCKER_RUN) bash
4475

45-
unit-ci: unit
46-
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
76+
install: ## Install dependencies ####
77+
$(DOCKER_RUN) composer install
4778

48-
infection:
49-
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc)
79+
update: ## Update dependencies ####
80+
$(DOCKER_RUN) composer update -W
5081

51-
composer-require-checker:
52-
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json
82+
outdated: ## Show outdated dependencies ####
83+
$(DOCKER_RUN) composer outdated
5384

54-
composer-unused:
55-
$(DOCKER_RUN) composer unused --ansi
85+
task-list-ci: ## CI: Generate a JSON array of jobs to run, matches the commands run when running `make (|all)` ####
86+
@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]'
5687

57-
backward-compatibility-check:
58-
$(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check || true
88+
help: ## Show this help ####
89+
@printf "\033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n"
90+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d '#'

etc/ci/markdown-link-checker.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"httpHeaders": [
3+
{
4+
"urls": ["https://docs.github.com/"],
5+
"headers": {
6+
"Accept-Encoding": "zstd, br, gzip, deflate"
7+
}
8+
}
9+
]
10+
}
File renamed without changes.

etc/qa/composer-unused.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use ComposerUnused\ComposerUnused\Configuration\Configuration;
6+
use ComposerUnused\ComposerUnused\Configuration\NamedFilter;
7+
use ComposerUnused\ComposerUnused\Configuration\PatternFilter;
8+
use Webmozart\Glob\Glob;
9+
10+
return static function (Configuration $config): Configuration {
11+
return $config;
12+
// ->addNamedFilter(NamedFilter::fromString('wyrihaximus/phpstan-rules-wrapper'));
13+
};
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0"?>
22
<ruleset>
3-
<arg name="basepath" value="." />
3+
<arg name="basepath" value="../../" />
44
<arg name="extensions" value="php" /> <!-- which extensions to look for -->
55
<arg name="colors" />
6-
<arg name="cache" value=".phpcs.cache" /> <!-- cache the results and don't commit them -->
6+
<arg name="cache" value="../../var/.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>
10-
<file>tests</file>
9+
<file>../../src</file>
10+
<file>../../tests</file>
1111

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

etc/qa/phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
parameters:
2+
ergebnis:
3+
noExtends:
4+
classesAllowedToBeExtended:
5+
- Exception
6+
7+
includes:
8+
- ../../vendor/wyrihaximus/test-utilities/rules.neon

etc/qa/phpunit.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="../../vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
3+
<testsuites>
4+
<testsuite name="Test Suite">
5+
<directory>../../tests/</directory>
6+
</testsuite>
7+
</testsuites>
8+
<source>
9+
<include>
10+
<directory suffix=".php">../../src/</directory>
11+
</include>
12+
</source>
13+
<extensions>
14+
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
15+
</extensions>
16+
</phpunit>

psalm.xml renamed to etc/qa/psalm.xml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<?xml version="1.0"?>
22
<psalm
3-
totallyTyped="false"
3+
errorLevel="1"
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xmlns="https://getpsalm.org/schema/config"
6-
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
6+
xsi:schemaLocation="https://getpsalm.org/schema/config ../../vendor/vimeo/psalm/config.xsd"
77
>
88
<projectFiles>
9-
<directory name="src"/>
9+
<directory name="../../src"/>
1010
<ignoreFiles>
11-
<directory name="vendor"/>
11+
<directory name="../../vendor"/>
1212
</ignoreFiles>
1313
</projectFiles>
1414

1515
<issueHandlers>
16+
1617
<LessSpecificReturnType errorLevel="error"/>
1718

1819
<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->
@@ -49,4 +50,10 @@
4950

5051
<InvalidStringClass errorLevel="error"/>
5152
</issueHandlers>
52-
<plugins><pluginClass class="Psalm\PhpUnitPlugin\Plugin"/></plugins></psalm>
53+
<plugins>
54+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
55+
<pluginClass class="Orklah\PsalmInsaneComparison\Plugin"/>
56+
<pluginClass class="Psalm\MockeryPlugin\Plugin"/>
57+
<pluginClass class="Psl\Psalm\Plugin"/>
58+
</plugins>
59+
</psalm>

infection.json.dist

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,19 @@
66
]
77
},
88
"logs": {
9-
"text": "infection-log.txt"
9+
"text": "./var/infection.log",
10+
"summary": "./var/infection-summary.log",
11+
"json": "./var/infection.json",
12+
"perMutator": "./var/infection-per-mutator.md",
13+
"github": true
1014
},
15+
"minMsi": 100,
16+
"minCoveredMsi": 100,
17+
"ignoreMsiWithNoMutations": true,
1118
"mutators": {
12-
"@default": true,
13-
"FunctionCallRemoval": {
14-
"ignore": [
15-
"WyriHaximus\\TestUtilities\\TestCase::waitUntilTheNextSecond"
16-
]
17-
},
18-
"MethodCallRemoval": {
19-
"ignore": [
20-
"WyriHaximus\\TestUtilities\\TestCase::tearDown"
21-
]
22-
},
23-
"Continue_": {
24-
"ignore": [
25-
"WyriHaximus\\TestUtilities\\TestCase::rmdir"
26-
]
27-
},
28-
"TrueValue": {
29-
"ignore": [
30-
"WyriHaximus\\TestUtilities\\TestCase::provideTrueFalse"
31-
]
32-
},
33-
"ArrayItemRemoval": false,
34-
"FalseValue": {
35-
"ignore": [
36-
"WyriHaximus\\TestUtilities\\TestCase::provideTrueFalse"
37-
]
38-
},
39-
"PublicVisibility": {
40-
"ignore": [
41-
"WyriHaximus\\TestUtilities\\TestCase::provideTrueFalse"
42-
]
43-
},
44-
"Identical": {
45-
"ignore": [
46-
"WyriHaximus\\TestUtilities\\TestCase::getSysTempDir"
47-
]
48-
},
49-
"UnwrapStrToUpper": {
50-
"ignore": [
51-
"WyriHaximus\\TestUtilities\\TestCase::getSysTempDir"
52-
]
53-
}
19+
"@default": true
20+
},
21+
"phpUnit": {
22+
"configDir": "./etc/qa/"
5423
}
55-
}
24+
}

phpstan.neon

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

phpunit.xml.dist

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

rules.neon

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

src/AdditionalPropertiesInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
interface AdditionalPropertiesInterface
88
{
9-
/**
10-
* @return array<string>
11-
*/
9+
/** @return array<string> */
1210
public function additionalProperties(): array;
1311
}

0 commit comments

Comments
 (0)