Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Update tools and use make to run them #603

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 26 additions & 32 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: 'Continuous Integration'

on:
create:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- "*.x"
tags:
- "**"

name: "Continuous Integration"

jobs:
webpack:
name: "Webpack build"
Expand Down Expand Up @@ -44,7 +41,7 @@ jobs:
strategy:
matrix:
php-version:
- 8.0
- 8.1

steps:
- name: "Checkout"
Expand All @@ -54,12 +51,9 @@ jobs:
uses: shivammathur/setup-php@2.16.0
with:
coverage: none
extensions: "mbstring, json"
extensions: "mbstring"
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.7
with:
Expand All @@ -69,10 +63,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 @@ -86,7 +80,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 @@ -106,7 +102,7 @@ jobs:
uses: shivammathur/setup-php@2.16.0
with:
coverage: none
extensions: "mbstring, json"
extensions: "mbstring"
php-version: ${{ matrix.php-version }}

- name: "Cache dependencies installed with composer"
Expand All @@ -118,16 +114,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
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 @@ -156,11 +152,12 @@ jobs:
uses: shivammathur/setup-php@2.16.0
with:
coverage: none
extensions: "mbstring, json"
extensions: "mbstring"
php-version: ${{ matrix.php-version }}

- 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.7
Expand All @@ -175,14 +172,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 @@ -202,7 +199,7 @@ jobs:
uses: shivammathur/setup-php@2.16.0
with:
coverage: pcov
extensions: "mbstring, json"
extensions: "mbstring"
php-version: ${{ matrix.php-version }}

- name: "Cache dependencies installed with composer"
Expand All @@ -214,10 +211,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 @@ -232,7 +229,7 @@ jobs:
strategy:
matrix:
php-version:
- 8.1
- 8.0

steps:
- name: "Checkout"
Expand All @@ -254,10 +251,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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.php-cs-fixer.cache
.php-cs-fixer.php
.phpunit.result.cache
coverage
composer.lock
Expand All @@ -8,3 +9,4 @@ phpunit.xml
/vendor/
!/vendor-bin/tools/composer.lock
/vendor-bin/tools/vendor/
/vendor-bin/tools/bin/
5 changes: 4 additions & 1 deletion .php-cs-fixer.php → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
],
'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
'no_superfluous_phpdoc_tags' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
'remove_inheritdoc' => true,
],
'static_lambda' => true,
'global_namespace_import' => [
'import_classes' => true,
Expand Down
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
69 changes: 24 additions & 45 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "nucleos/shariff-bundle",
"type": "symfony-bundle",
"description": "This bundle provides shariff integration in symfony applications",
"license": "MIT",
"type": "symfony-bundle",
"keywords": [
"symfony",
"shariff",
Expand All @@ -14,14 +15,31 @@
"widget",
"bundle"
],
"homepage": "https://nucleos.rocks",
"license": "MIT",
"authors": [
{
"name": "Christian Gripp",
"email": "mail@core23.de"
}
],
"homepage": "https://nucleos.rocks",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/core23"
},
{
"type": "opencollective",
"url": "https://opencollective.com/core23"
},
{
"type": "ko-fi",
"url": "https://ko-fi.com/core23"
},
{
"type": "other",
"url": "https://donate.core23.de"
}
],
"require": {
"php": "^8.0",
"ext-json": "*",
Expand All @@ -41,16 +59,12 @@
"symfony/twig-bundle": "^4.2 || ^5.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.3",
"ergebnis/composer-normalize": "^2.0.1",
"nyholm/psr7": "^1.0",
"symfony/browser-kit": "^4.4 || ^5.0",
"symfony/cache": "^4.2 || ^5.0",
"symfony/http-client": "^4.2 || ^5.0"
},
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"Nucleos\\ShariffBundle\\": "src/"
Expand All @@ -61,42 +75,7 @@
"Nucleos\\ShariffBundle\\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"
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/core23"
},
{
"type": "opencollective",
"url": "https://opencollective.com/core23"
},
{
"type": "ko-fi",
"url": "https://ko-fi.com/core23"
},
{
"type": "other",
"url": "https://donate.core23.de"
}
]
"config": {
"sort-packages": true
}
}
5 changes: 1 addition & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ includes:
- phpstan-baseline.neon

parameters:
level: max
level: 8

paths:
- src
- tests

bootstrapFiles:
- vendor-bin/tools/vendor/autoload.php

excludes_analyse:
- tests/bootstrap.php
Loading