Skip to content

Commit

Permalink
Update build tools
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Dec 14, 2021
1 parent 46a3648 commit e692fb3
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 66 deletions.
55 changes: 24 additions & 31 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ jobs:
uses: shivammathur/setup-php@2.14.0
with:
coverage: none
extensions: "mbstring, json, mongodb-1.9.0"
extensions: "mbstring, json, mongodb"
php-version: ${{ matrix.php-version }}

- name: "Validate composer.json and composer.lock"
run: composer validate --strict

- name: "Cache dependencies installed with composer"
uses: actions/cache@v2.1.6
with:
Expand All @@ -43,10 +40,10 @@ jobs:
php${{ matrix.php-version }}-composer-
- name: "Install locked dependencies with composer"
run: composer install --no-interaction --no-progress --no-suggest
run: composer install --no-interaction --no-progress

- name: "Run localheinz/composer-normalize"
run: composer normalize --dry-run
- name: "Run composer lint"
run: make lint-composer

- name: "Create cache directory for friendsofphp/php-cs-fixer"
run: mkdir -p .build/php-cs-fixer
Expand All @@ -60,7 +57,9 @@ jobs:
php${{ matrix.php-version }}-php-cs-fixer-
- name: "Run friendsofphp/php-cs-fixer"
run: composer cs-diff
env:
PHP_CS_FIXER_IGNORE_ENV: 1
run: make cs

static-code-analysis:
name: "Static Code Analysis"
Expand All @@ -80,7 +79,7 @@ jobs:
uses: shivammathur/setup-php@2.14.0
with:
coverage: none
extensions: "mbstring, json, mongodb-1.9.0"
extensions: "mbstring, json, mongodb"
php-version: ${{ matrix.php-version }}

- name: "Cache dependencies installed with composer"
Expand All @@ -92,16 +91,16 @@ jobs:
${{ matrix.php-version }}-composer-
- name: "Install locked dependencies with composer"
run: composer install --no-interaction --no-progress --no-suggest
run: composer install --no-interaction --no-progress

- name: "Run phpstan/phpstan"
run: composer phpstan
run: make phpstan

- name: "Run psalm"
run: vendor/bin/psalm --config=psalm.xml --diff --shepherd --show-info=false --stats --threads=4 --php-version=7.4
run: make psalm

- name: "Run phpmd"
run: composer phpmd
run: make phpmd

tests:
name: "Test (PHP ${{ matrix.php-version }}, symfony ${{ matrix.symfony }}, ${{ matrix.dependencies }})"
Expand Down Expand Up @@ -131,15 +130,12 @@ jobs:
uses: shivammathur/setup-php@2.14.0
with:
coverage: none
extensions: "mbstring, json, mongodb-1.9.0"
extensions: "mbstring, json, mongodb"
php-version: ${{ matrix.php-version }}

- name: "Configuration required for PHP 8.0"
if: matrix.php-version == '8.0'
run: composer config platform.php 7.4.99

- name: 'Install Symfony Flex'
run: composer global require --prefer-dist --no-progress --no-suggest --ansi symfony/flex
run: |
composer global require --prefer-dist --no-progress --ansi symfony/flex
- name: "Cache dependencies installed with composer"
uses: actions/cache@v2.1.6
Expand All @@ -154,14 +150,14 @@ jobs:

- name: "Install lowest dependencies with composer"
if: matrix.dependencies == 'lowest'
run: composer update --no-interaction --no-progress --no-suggest --prefer-lowest
run: composer update --no-interaction --no-progress --prefer-lowest

- name: "Install highest dependencies with composer"
if: matrix.dependencies == 'highest'
run: composer update --no-interaction --no-progress --no-suggest
run: composer update --no-interaction --no-progress

- name: "Run tests with phpunit/phpunit"
run: composer test
run: make test

code-coverage:
name: "Code Coverage"
Expand All @@ -181,7 +177,7 @@ jobs:
uses: shivammathur/setup-php@2.14.0
with:
coverage: pcov
extensions: "mbstring, json, mongodb-1.9.0"
extensions: "mbstring, json, mongodb"
php-version: ${{ matrix.php-version }}

- name: "Cache dependencies installed with composer"
Expand All @@ -193,10 +189,10 @@ jobs:
php${{ matrix.php-version }}-composer-
- name: "Install locked dependencies with composer"
run: composer install --no-interaction --no-progress --no-suggest
run: composer install --no-interaction --no-progress

- name: "Collect code coverage with pcov and phpunit/phpunit"
run: composer coverage
run: make coverage

- name: "Send code coverage report to Codecov.io"
env:
Expand All @@ -221,7 +217,7 @@ jobs:
uses: shivammathur/setup-php@2.14.0
with:
coverage: pcov
extensions: "mbstring, json, mongodb-1.9.0"
extensions: "mbstring, json, mongodb"
php-version: ${{ matrix.php-version }}

- name: "Cache dependencies installed with composer"
Expand All @@ -233,10 +229,7 @@ jobs:
php${{ matrix.php-version }}-composer-
- name: "Install locked dependencies with composer"
run: composer install --no-interaction --no-progress --no-suggest

- name: "Download infection"
run: wget -O infection https://github.com/infection/infection/releases/download/0.19.0/infection.phar && chmod +x infection
run: composer install --no-interaction --no-progress

- name: "Run mutation tests with pcov and infection/infection"
run: ./infection
run: make infection
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.php-cs-fixer.cache
.php-cs-fixer.php
.phpunit.result.cache
coverage
composer.lock
phpunit.xml
/build
/build/
/vendor/
!/vendor-bin/tools/composer.lock
/vendor-bin/tools/vendor/
/vendor-bin/tools/bin/
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.PHONY: default
default: lint

.PHONY: fix
fix: cs-fix lint-fix

.PHONY: lint
lint: lint-composer

.PHONY: lint-composer
lint-composer:
composer validate --strict
composer normalize --dry-run

.PHONY: test
test: vendor-bin/tools/vendor
vendor/bin/phpunit --colors=always

.PHONY: infection
infection: vendor/bin/infection
vendor/bin/infection --threads=4

.PHONY: coverage
coverage: vendor-bin/tools/vendor
vendor/bin/phpunit --colors=always --coverage-clover=build/logs/clover.xml

.PHONY: cs
cs: vendor-bin/tools/vendor
vendor/bin/php-cs-fixer fix --verbose --diff --dry-run

.PHONY: cs-fix
cs-fix: vendor-bin/tools/vendor
vendor/bin/php-cs-fixer fix --verbose

.PHONY: psalm
psalm: vendor-bin/tools/vendor
vendor/bin/psalm --config=psalm.xml --diff --shepherd --show-info=false --stats --threads=4

.PHONY: phpstan
phpstan: vendor-bin/tools/vendor
vendor/bin/phpstan analyse

.PHONY: phpmd
phpmd: vendor-bin/tools/vendor
vendor/bin/phpmd src,tests ansi phpmd.xml

.PHONY: lint-fix
lint-fix:
find ./src \\( -name '*.xml' -or -name '*.xml.dist' -or -name '*.xlf' \\) -type f -exec xmllint --encode UTF-8 --output '{}' --format '{}' \\;
find ./src \\( -name '*.yml' -or -name '*.yaml' \\) -not -path '*/vendor/*' | xargs yaml-lint

.PHONY: check-dependencies
check-dependencies: vendor-bin/tools/vendor
vendor/bin/composer-require-checker check --config-file composer-require.json composer.json

#
# Installation tasks
#

vendor-bin/tools/vendor:
composer --working-dir=vendor-bin/tools install

vendor/bin/infection: vendor-bin/tools/vendor
wget -O vendor/bin/infection https://github.com/infection/infection/releases/latest/download/infection.phar && chmod +x vendor/bin/infection
45 changes: 12 additions & 33 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "nucleos/user-bundle",
"type": "symfony-bundle",
"description": "Lightweight user management for symfony",
"license": "MIT",
"type": "symfony-bundle",
"keywords": [
"user management",
"symfony"
],
"homepage": "https://nucleos.rocks",
"license": "MIT",
"authors": [
{
"name": "Christian Gripp",
"email": "mail@core23.de"
}
],
"homepage": "https://nucleos.rocks",
"require": {
"php": "^7.3 || ^8.0",
"ext-json": "*",
Expand Down Expand Up @@ -48,17 +48,8 @@
"symfony/validator": "^4.4 || ^5.0",
"twig/twig": "^2.14 || ^3.1"
},
"conflict": {
"doctrine/doctrine-bundle": "<1.12",
"doctrine/mongodb": "<1.6",
"doctrine/mongodb-odm": "<1.1",
"doctrine/mongodb-odm-bundle": "<4.1",
"doctrine/orm": "<2.7",
"symfony/doctrine-bridge": "<4.4"
},
"require-dev": {
"ext-mongodb": "*",
"bamarni/composer-bin-plugin": "^1.3",
"doctrine/doctrine-bundle": "^1.12 || ^2.0",
"doctrine/mongodb-odm": "^2.0",
"doctrine/mongodb-odm-bundle": "^4.1",
Expand All @@ -68,8 +59,13 @@
"symfony/doctrine-bridge": "^4.4 || ^5.0",
"symfony/yaml": "^4.4 || ^5.0"
},
"config": {
"sort-packages": true
"conflict": {
"doctrine/doctrine-bundle": "<1.12",
"doctrine/mongodb": "<1.6",
"doctrine/mongodb-odm": "<1.1",
"doctrine/mongodb-odm-bundle": "<4.1",
"doctrine/orm": "<2.7",
"symfony/doctrine-bridge": "<4.4"
},
"autoload": {
"psr-4": {
Expand All @@ -81,24 +77,7 @@
"Nucleos\\UserBundle\\Tests\\": "tests/"
}
},
"scripts": {
"post-install-cmd": [
"@composer bin all install --ansi"
],
"post-update-cmd": [
"@composer bin all install --ansi"
],
"coverage": "vendor/bin/phpunit --colors=always --coverage-clover=build/logs/clover.xml",
"cs": "PHP_CS_FIXER_IGNORE_ENV=1 && vendor/bin/php-cs-fixer fix --verbose",
"cs-diff": "PHP_CS_FIXER_IGNORE_ENV=1 && vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
"deps": "vendor/bin/composer-require-checker check --config-file composer-require.json composer.json",
"infection": "vendor/bin/infection",
"lint": [
"find ./src \\( -name '*.xml' -or -name '*.xml.dist' -or -name '*.xlf' \\) -type f -exec xmllint --encode UTF-8 --output '{}' --format '{}' \\;",
"find ./src \\( -name '*.yml' -or -name '*.yaml' \\) -not -path '*/vendor/*' | xargs yaml-lint"
],
"phpmd": "vendor/bin/phpmd src,tests ansi phpmd.xml",
"phpstan": "vendor/bin/phpstan analyse",
"test": "vendor/bin/phpunit --colors=always"
"config": {
"sort-packages": true
}
}
3 changes: 2 additions & 1 deletion vendor-bin/tools/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nucleos/dev-tools",
"type": "project",
"description": "Development tools that do not conflict the project dependencies",
"type": "project",
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"jangregor/phpstan-prophecy": "^0.8",
Expand All @@ -21,6 +21,7 @@
"vimeo/psalm": "^4.3.1"
},
"config": {
"bin-dir": "../../vendor/bin",
"platform": {
"php": "7.4"
}
Expand Down
1 change: 1 addition & 0 deletions vendor-bin/tools/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e692fb3

Please sign in to comment.