-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4786e74
Showing
60 changed files
with
12,619 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
testsuite: | ||
name: Unittests | ||
runs-on: ubuntu-20.04 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-version: ['8.2', '8.3'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
extensions: json, fileinfo | ||
tools: pecl | ||
coverage: pcov | ||
|
||
- name: Composer install | ||
run: | | ||
if [[ ${{ matrix.prefer-lowest == 'prefer-lowest' }} ]]; then | ||
composer update --prefer-lowest --prefer-stable | ||
else | ||
composer install | ||
fi | ||
- name: Run PHPUnit | ||
run: | | ||
if [[ ${{ matrix.php-version }} == '8.2' ]]; then | ||
bin/phpunit --coverage-clover=coverage.xml | ||
else | ||
bin/phpunit | ||
fi | ||
- name: Code Coverage Report | ||
if: success() && matrix.php-version == '8.2' | ||
uses: codecov/codecov-action@v4 | ||
|
||
code-analysis: | ||
name: Coding Standard & Static Analysis | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
extensions: json, fileinfo | ||
coverage: pcov | ||
tools: pecl | ||
|
||
- name: Composer install | ||
run: composer update --prefer-lowest --prefer-stable | ||
|
||
- name: Run phpcs | ||
run: bin/phpcs --version && bin/phpcs --report=source --standard=phpcs.xml | ||
|
||
- name: Run phpstan | ||
run: bin/phpstan -V && bin/phpstan --error-format=github | ||
|
||
- name: Run Infection | ||
run: bin/infection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/vendor/ | ||
/bin/ | ||
/.phive/ | ||
/.phpunit.cache/ | ||
/tmp/ | ||
/tools/ | ||
.idea/ | ||
.env | ||
infection.log | ||
phive.phar | ||
cognitive-analysis.phar |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
help: | ||
@echo "Available commands:" | ||
@echo " - run-tests: Run tests" | ||
@echo " - run-infection: Runs Infection mutation testing" | ||
@echo " - coverage-text: Runs coverage text" | ||
@echo " - coverage-html: Runs coverage html" | ||
@echo " - all: Runs CS-Fixer, CS-Checker, Static Analyser and Tests" | ||
@echo " - shell: Run shell" | ||
@echo " - self-test: Run cognitive analyses self-test" | ||
@echo " - self-test-halstead: Run cognitive analyses self-test" | ||
@echo " - build-phar: Build phar" | ||
|
||
run-tests: | ||
@echo "Running tests" | ||
docker compose run php composer test | ||
|
||
run-infection: | ||
@echo "Running infection mutation testing" | ||
docker compose run php composer infection | ||
|
||
coverage-text: | ||
@echo "Running coverage text" | ||
docker compose run php composer test-coverage | ||
|
||
coverage-html: | ||
@echo "Running coverage text" | ||
docker compose run php composer test-coverage-html | ||
|
||
all: | ||
@echo "Running CS-Fixer, CS-Checker, Static Analyser and Tests" | ||
docker compose run php composer all | ||
|
||
shell: | ||
@echo "Running shell" | ||
docker compose run --service-ports --entrypoint /bin/bash php | ||
|
||
self-test: | ||
@echo "Running cognitive analyses self-test" | ||
docker compose run php php analyse.php metrics:cognitive src | ||
|
||
self-test-halstead: | ||
@echo "Running cognitive analyses self-test" | ||
docker compose run php php analyse.php metrics:halstead src | ||
|
||
build-phar: | ||
@echo "Building phar" | ||
docker compose run php composer build-phar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
use Phauthentic\CodeQualityMetrics\Command\CognitiveMetricsCommand; | ||
use Phauthentic\CodeQualityMetrics\Command\HalsteadMetricsCommand; | ||
use Symfony\Component\Console\Application; | ||
|
||
$application = new Application(); | ||
$application->add(new CognitiveMetricsCommand()); | ||
$application->add(new HalsteadMetricsCommand()); | ||
|
||
$application->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"main": "./analyse.php", | ||
"compression": "GZ", | ||
"output": "cognitive-analysis.phar" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"name": "phauthentic/code-quality", | ||
"type": "project", | ||
"require": { | ||
"php": "^8.1", | ||
"nikic/php-parser": "^5.1", | ||
"symfony/console": "^7.1", | ||
"symfony/config": "^7.1", | ||
"symfony/yaml": "^7.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Phauthentic\\CodeQualityMetrics\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Phauthentic\\CodeQualityMetrics\\Tests\\": "tests/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Florian Krämer" | ||
} | ||
], | ||
"require-dev": { | ||
"roave/security-advisories": "dev-latest", | ||
"phpunit/phpunit": "^11.3", | ||
"infection/infection": "^0.29.6", | ||
"phpmd/phpmd": "^2.15", | ||
"phpstan/phpstan": "^1.11", | ||
"squizlabs/php_codesniffer": "^3.10", | ||
"symfony/var-dumper": "^7.1" | ||
}, | ||
"config": { | ||
"bin-dir": "bin", | ||
"allow-plugins": { | ||
"infection/extension-installer": true | ||
} | ||
}, | ||
"scripts": { | ||
"test": [ | ||
"phpunit" | ||
], | ||
"infection": [ | ||
"infection" | ||
], | ||
"test-coverage": [ | ||
"phpunit --coverage-text" | ||
], | ||
"test-coverage-html": [ | ||
"phpunit --coverage-html tmp/coverage/" | ||
], | ||
"cscheck": [ | ||
"phpcs src/ tests/ -s" | ||
], | ||
"csfix": [ | ||
"phpcbf src/ tests/" | ||
], | ||
"analyze": [ | ||
"phpstan analyse src/" | ||
], | ||
"phpmd": [ | ||
"bin/phpmd ./src text cleancode,codesize,controversial,design" | ||
], | ||
"benchmark": [ | ||
"bin/phpbench run tests/Benchmark/ --report=aggregate" | ||
], | ||
"all": [ | ||
"@csfix", | ||
"@cscheck", | ||
"@analyze", | ||
"@test" | ||
], | ||
"build-phar": [ | ||
"if [ ! -f phive.phar ]; then wget -O phive.phar \"https://phar.io/releases/phive.phar\"; fi", | ||
"if [ ! -f tools/box ]; then php phive.phar install humbug/box; fi", | ||
"tools/box compile" | ||
] | ||
} | ||
} |
Oops, something went wrong.