From 19bfc4d650e00081ce18e7ae5f67e8dd9c6d5f78 Mon Sep 17 00:00:00 2001 From: David Lambauer Date: Fri, 6 Oct 2023 23:32:11 +0200 Subject: [PATCH 1/2] :construction_worker: Adding PHPMD --- phpmd/README.md | 32 ++++++++++++++++++++++++ phpmd/action.yml | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 phpmd/README.md create mode 100644 phpmd/action.yml diff --git a/phpmd/README.md b/phpmd/README.md new file mode 100644 index 0000000..537b26d --- /dev/null +++ b/phpmd/README.md @@ -0,0 +1,32 @@ +# PHP Mess Detector for Magento + +A GitHub Action that runs the Magento PHPMD (PHP Mess Detector). + +## Inputs + +See the [action.yml](./action.yml) + +Usage: + +```yaml +name: PHP Mess Detector + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + mess-detector: + runs-on: ubuntu-latest + steps: + - uses: mage-os/github-actions/phpmd-action@main + with: + php_version: '8.1' # PHP version used to execute PHPMD. + composer_version: '2' # Version of composer to use. + path: 'app/code' # Directory for PHPMD execution when event is not a pull request. + ruleset_path: 'dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml' # Path to the ruleset.xml file. Optional. +``` diff --git a/phpmd/action.yml b/phpmd/action.yml new file mode 100644 index 0000000..1a03133 --- /dev/null +++ b/phpmd/action.yml @@ -0,0 +1,64 @@ +name: "PHP Mess Detector" +author: "David Lambauer" +description: "A Github Action that runs the Magento PHPMD." + +inputs: + php_version: + required: true + default: "8.1" + description: "PHP version used to execute PHPMD." + + composer_version: + required: true + default: "2" + description: "The version of composer to use." + + path: + required: true + default: 'app/code' + description: "The directory (relative to the project root) in which PHPMD will be executed. Used when the event is not a pull request." + + ruleset_path: + required: false + default: 'dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml' + description: "The path to the ruleset.xml file." + +runs: + using: composite + steps: + - name: Checkout Project + uses: actions/checkout@v3 + with: + fetch-depth: 0 + path: project + + - name: Create Standard Directory + shell: bash + run: mkdir standard + + - name: Set PHP Version + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ inputs.php_version }} + tools: composer:v${{ inputs.composer_version }} + coverage: none + + - name: Get Composer Version + uses: mage-os/github-actions/get-composer-version@main + id: get-composer-version + + - name: Get Changed Files + shell: bash + working-directory: project + id: changed-files + run: echo "files=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT + if: github.event_name == 'pull_request' + + - name: Coding Standard Check + shell: bash + run: | + ../standard/vendor/bin/phpmd \ + ${{ github.event_name == 'pull_request' && steps.changed-files.outputs.files || inputs.path }} \ + github \ + ${{input.ruleset_path}} + working-directory: project From a9ee37bce794a02dd4678345b23dfde90ff7bfdc Mon Sep 17 00:00:00 2001 From: David Lambauer Date: Sun, 8 Oct 2023 21:46:26 +0200 Subject: [PATCH 2/2] Update phpmd/action.yml Co-authored-by: Simon Sprankel --- phpmd/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpmd/action.yml b/phpmd/action.yml index 1a03133..f5f399d 100644 --- a/phpmd/action.yml +++ b/phpmd/action.yml @@ -27,7 +27,7 @@ runs: using: composite steps: - name: Checkout Project - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 path: project