From 4790feafe5b5e3218b077e6f9df271392b14eabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Sat, 30 Jan 2021 21:58:24 +0100 Subject: [PATCH] Replace Phing with Composer scripts --- .github/workflows/ci.yml | 29 +++---- build.xml | 57 ------------- captainhook.json | 70 ++++++++++++++-- composer.json | 11 ++- composer.lock | 174 ++++++++++++++++++--------------------- 5 files changed, 162 insertions(+), 179 deletions(-) delete mode 100644 build.xml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffdb8f6..1ff5e5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,16 +31,7 @@ jobs: - name: Install Composer dependencies run: composer install - - name: Linting code - run: ./vendor/bin/phing lint - - - name: Codesniffer - run: ./vendor/bin/phing sniff - - - name: Static code analysis - run: ./vendor/bin/phing analyse - - - name: Magerun + - name: Install Magerun if: matrix.coveralls == false run: | wget https://files.magerun.net/n98-magerun2-latest.phar @@ -48,20 +39,26 @@ jobs: ln -s $(pwd) ~/.n98-magerun2/modules/magerun2-list-api-endpoints php n98-magerun2-latest.phar help api:list:endpoints + - name: Codesniffer + run: composer cs-check + + - name: Static code analysis + run: composer analyze + - name: Unittests if: matrix.coveralls == false - run: ./vendor/bin/phing unit - - - name: Unittests with coverage - if: matrix.coveralls == true - run: ./vendor/bin/phing unit-with-coverage + run: composer test - name: Infection for added files env: INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }} run: | git fetch --depth=1 origin $GITHUB_BASE_REF - ./vendor/bin/infection -j2 --git-diff-filter=A --git-diff-base=origin/$GITHUB_BASE_REF --logger-github --ignore-msi-with-no-mutations --only-covered + ./vendor/bin/infection -j4 --git-diff-filter=A --git-diff-base=origin/$GITHUB_BASE_REF --logger-github --ignore-msi-with-no-mutations --only-covered + + - name: Unittests with coverage + if: matrix.coveralls == true + run: composer coverage - name: Coveralls report if: matrix.coveralls == true diff --git a/build.xml b/build.xml deleted file mode 100644 index 2ce03ce..0000000 --- a/build.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/captainhook.json b/captainhook.json index e53bb86..4157c93 100644 --- a/captainhook.json +++ b/captainhook.json @@ -15,12 +15,22 @@ "enabled": true, "actions": [ { - "action": "./vendor/bin/phing analyse", + "action": "composer analyze", "options": [] }, { - "action": "./vendor/bin/phing infection", + "action": "composer test", "options": [] + }, + { + "action": "\\bitExpert\\CaptainHook\\Infection\\InfectionAction", + "options": { + "args": [ + "-j4", + "--ignore-msi-with-no-mutations", + " --only-covered" + ] + } } ] }, @@ -28,16 +38,40 @@ "enabled": true, "actions": [ { - "action": "./vendor/bin/phing lint", - "options": [] + "action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting", + "options": [], + "conditions": [ + { + "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType", + "args": ["php"] + } + ] }, { - "action": "./vendor/bin/phing sniff", - "options": [] + "action": "composer cs-check {$STAGED_FILES|of-type:php|separated-by: }", + "options": [], + "conditions": [ + { + "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType", + "args": ["php"] + } + ] }, { - "action": "./vendor/bin/phing unit", - "options": [] + "action": "\\bitExpert\\CaptainHook\\Infection\\InfectionAction", + "options": { + "args": [ + "-j4", + "--ignore-msi-with-no-mutations", + " --only-covered" + ] + }, + "conditions": [ + { + "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType", + "args": ["php"] + } + ] } ] }, @@ -52,5 +86,25 @@ "post-merge": { "enabled": false, "actions": [] + }, + "post-change": { + "enabled": true, + "actions": [ + { + "action": "composer install", + "options": [], + "conditions": [ + { + "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any", + "args": [ + [ + "composer.json", + "composer.lock" + ] + ] + } + ] + } + ] } } diff --git a/composer.json b/composer.json index 21d2000..d539ded 100644 --- a/composer.json +++ b/composer.json @@ -29,14 +29,14 @@ "n98/magerun2": "^4.0.0", "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "^3.5", - "phing/phing": "^2.16", "phpstan/phpstan": "^0.12.68", "captainhook/captainhook": "^5.4", "captainhook/plugin-composer": "^5.2", "bitexpert/phpstan-magento": "^0.6.0", "phpstan/extension-installer": "^1.1", "roave/security-advisories": "dev-latest", - "infection/infection": "^0.21.0" + "infection/infection": "^0.21.0", + "bitexpert/captainhook-infection": "^0.1.0" }, "repositories": [ { @@ -59,8 +59,11 @@ "@cs-check", "@test" ], - "cs-check": "vendor/bin/phing sniff", + "cs-check": "vendor/bin/phpcs --standard=PSR2 ./src ./tests", "cs-fix": "vendor/bin/phpcbf", - "test": "vendor/bin/phing unit" + "analyze": "vendor/bin/phpstan analyze", + "test": "vendor/bin/phpunit", + "infection": "vendor/bin/infection -j4 --ignore-msi-with-no-mutations --only-covered", + "coverage": "vendor/bin/phpunit --coverage-clover clover.xml" } } diff --git a/composer.lock b/composer.lock index 1ad3faa..69aaaa9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0e9315ad1b4f62f685aff077e74afa4b", + "content-hash": "14e3d8bcf76ff4d7ad8a768598239ff7", "packages": [ { "name": "colinmollenhour/credis", @@ -6165,6 +6165,53 @@ ], "time": "2019-01-01T23:59:15+00:00" }, + { + "name": "bitexpert/captainhook-infection", + "version": "v0.1.0", + "source": { + "type": "git", + "url": "https://github.com/bitExpert/captainhook-infection.git", + "reference": "08469ffe0298df7c35e53ded40cf7c384b869bf9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bitExpert/captainhook-infection/zipball/08469ffe0298df7c35e53ded40cf7c384b869bf9", + "reference": "08469ffe0298df7c35e53ded40cf7c384b869bf9", + "shasum": "" + }, + "require": { + "captainhook/captainhook": "^5.4", + "php": "^7.4.0|^8.0.0" + }, + "require-dev": { + "captainhook/plugin-composer": "^5.2", + "infection/infection": "^0.21.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^9.5", + "roave/security-advisories": "dev-latest", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "bitExpert\\CaptainHook\\Infection\\": "src/bitExpert/CaptainHook/Infection" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Stephan Hochdörfer", + "email": "S.Hochdoerfer@bitExpert.de", + "homepage": "http://www.bitExpert.de" + } + ], + "description": "Captain Hook Plugin to run InfectionPHP only against the files of the current changeset", + "time": "2021-01-30T15:35:39+00:00" + }, { "name": "bitexpert/phpstan-magento", "version": "v0.6.0", @@ -6222,6 +6269,10 @@ } ], "description": "PHPStan Magento Extension", + "support": { + "issues": "https://github.com/bitExpert/phpstan-magento/issues", + "source": "https://github.com/bitExpert/phpstan-magento/tree/v0.6.0" + }, "time": "2021-01-22T19:07:54+00:00" }, { @@ -6294,6 +6345,10 @@ "pre-push", "prepare-commit-msg" ], + "support": { + "issues": "https://github.com/captainhookphp/captainhook/issues", + "source": "https://github.com/captainhookphp/captainhook/tree/5.4.4" + }, "funding": [ { "url": "https://github.com/sponsors/sebastianfeldmann", @@ -6351,6 +6406,10 @@ } ], "description": "Composer-Plugin handling your git-hooks", + "support": { + "issues": "https://github.com/captainhookphp/plugin-composer/issues", + "source": "https://github.com/captainhookphp/plugin-composer/tree/5.2.3" + }, "time": "2020-12-07T19:27:49+00:00" }, { @@ -6990,6 +7049,10 @@ "nette", "yaml" ], + "support": { + "issues": "https://github.com/nette/neon/issues", + "source": "https://github.com/nette/neon/tree/master" + }, "time": "2020-07-31T12:28:05+00:00" }, { @@ -7320,99 +7383,6 @@ "description": "Library for handling version information and constraints", "time": "2020-12-13T23:18:30+00:00" }, - { - "name": "phing/phing", - "version": "2.16.3", - "source": { - "type": "git", - "url": "https://github.com/phingofficial/phing.git", - "reference": "b34c2bf9cd6abd39b4287dee31e68673784c8567" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phingofficial/phing/zipball/b34c2bf9cd6abd39b4287dee31e68673784c8567", - "reference": "b34c2bf9cd6abd39b4287dee31e68673784c8567", - "shasum": "" - }, - "require": { - "php": ">=5.2.0" - }, - "require-dev": { - "ext-pdo_sqlite": "*", - "mikey179/vfsstream": "^1.6", - "pdepend/pdepend": "2.x", - "pear/archive_tar": "1.4.x", - "pear/http_request2": "dev-trunk", - "pear/net_growl": "dev-trunk", - "pear/pear-core-minimal": "1.10.1", - "pear/versioncontrol_git": "@dev", - "pear/versioncontrol_svn": "~0.5", - "phpdocumentor/phpdocumentor": "2.x", - "phploc/phploc": "~2.0.6", - "phpmd/phpmd": "~2.2", - "phpunit/phpunit": ">=3.7", - "sebastian/git": "~1.0", - "sebastian/phpcpd": "2.x", - "siad007/versioncontrol_hg": "^1.0", - "simpletest/simpletest": "^1.1", - "squizlabs/php_codesniffer": "~2.2", - "symfony/yaml": "^2.8 || ^3.1 || ^4.0" - }, - "suggest": { - "pdepend/pdepend": "PHP version of JDepend", - "pear/archive_tar": "Tar file management class", - "pear/versioncontrol_git": "A library that provides OO interface to handle Git repository", - "pear/versioncontrol_svn": "A simple OO-style interface for Subversion, the free/open-source version control system", - "phpdocumentor/phpdocumentor": "Documentation Generator for PHP", - "phploc/phploc": "A tool for quickly measuring the size of a PHP project", - "phpmd/phpmd": "PHP version of PMD tool", - "phpunit/php-code-coverage": "Library that provides collection, processing, and rendering functionality for PHP code coverage information", - "phpunit/phpunit": "The PHP Unit Testing Framework", - "sebastian/phpcpd": "Copy/Paste Detector (CPD) for PHP code", - "siad007/versioncontrol_hg": "A library for interfacing with Mercurial repositories.", - "tedivm/jshrink": "Javascript Minifier built in PHP" - }, - "bin": [ - "bin/phing" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.16.x-dev" - } - }, - "autoload": { - "classmap": [ - "classes/phing/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "classes" - ], - "license": [ - "LGPL-3.0-only" - ], - "authors": [ - { - "name": "Michiel Rook", - "email": "mrook@php.net" - }, - { - "name": "Phing Community", - "homepage": "https://www.phing.info/trac/wiki/Development/Contributors" - } - ], - "description": "PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.", - "homepage": "https://www.phing.info/", - "keywords": [ - "build", - "phing", - "task", - "tool" - ], - "time": "2020-02-03T18:50:54+00:00" - }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", @@ -7661,6 +7631,10 @@ "MIT" ], "description": "Composer plugin for automatic installation of PHPStan extensions", + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.1.0" + }, "time": "2020-12-13T13:06:13+00:00" }, { @@ -9565,6 +9539,10 @@ "file system", "path" ], + "support": { + "issues": "https://github.com/sebastianfeldmann/camino/issues", + "source": "https://github.com/sebastianfeldmann/camino/tree/0.9.4" + }, "funding": [ { "url": "https://github.com/sebastianfeldmann", @@ -9619,6 +9597,10 @@ "keywords": [ "cli" ], + "support": { + "issues": "https://github.com/sebastianfeldmann/cli/issues", + "source": "https://github.com/sebastianfeldmann/cli/tree/3.3.1" + }, "funding": [ { "url": "https://github.com/sebastianfeldmann", @@ -9673,6 +9655,10 @@ "keywords": [ "git" ], + "support": { + "issues": "https://github.com/sebastianfeldmann/git/issues", + "source": "https://github.com/sebastianfeldmann/git/tree/3.4.1" + }, "funding": [ { "url": "https://github.com/sebastianfeldmann",