diff --git a/coding-standard/README.md b/coding-standard/README.md index cb708ce..ccc6fe9 100644 --- a/coding-standard/README.md +++ b/coding-standard/README.md @@ -30,4 +30,6 @@ jobs: severity: 8 # Optional, will use phpcs default of 5 if not specified. warning_severity: 4 # Optional, will use severity value if not specified. error_severity: 7 # Optional, will use severity value if not specified. + coding_standard: "Magento2" + custom_coding_standard_repo: "your/custom-repo" ``` diff --git a/coding-standard/action.yml b/coding-standard/action.yml index 4d4a947..f7af56a 100644 --- a/coding-standard/action.yml +++ b/coding-standard/action.yml @@ -21,17 +21,17 @@ inputs: version: required: false description: "The version of the coding standard to use. If not provided, will use the latest version." - + severity: required: false default: "" description: "The minimum severity required to display an error or warning (default: 5)" - + warning_severity: required: false default: "" description: "The minimum severity required to display a warning" - + error_severity: required: false default: "" @@ -42,6 +42,16 @@ inputs: default: 'false' required: false + coding_standard: + description: 'The coding standard to use, defaults to Magento2' + default: 'Magento2' + required: false + + custom_coding_standard_repo: + description: 'The repository to use for the coding standard, used if you want to use a custom coding standard' + default: '' + required: false + runs: using: composite steps: @@ -79,15 +89,21 @@ runs: run: composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true --global if: steps.is-allow-plugins-available.outputs.result < 1 - - name: Install Coding Standard + - name: Install composer require dealerdirect/phpcodesniffer-composer-installer + shell: bash + working-directory: standard + run: composer require dealerdirect/phpcodesniffer-composer-installer + + - name: Install Magento2 Coding Standard shell: bash working-directory: standard run: composer require "magento/magento-coding-standard:${{ inputs.version || '*' }}" - - name: Register Coding Standard + - name: Install Custom Coding Standard + if: ${{ inputs.custom_coding_standard_repo }} shell: bash working-directory: standard - run: vendor/bin/phpcs --config-set installed_paths ${{ github.workspace }}/standard/vendor/magento/magento-coding-standard,${{ github.workspace }}/standard/vendor/phpcompatibility/php-compatibility + run: composer require "${{ inputs.custom_coding_standard_repo }}" - name: Set ignore warnings flag shell: bash @@ -105,7 +121,8 @@ runs: - name: Coding Standard Check shell: bash run: | - ../standard/vendor/bin/phpcs --standard=Magento2 \ + ../standard/vendor/bin/phpcs \ + --standard="${{ inputs.coding_standard }}" \ $([ -n "${{ inputs.severity }}" ] && echo "--severity=${{ inputs.severity }}") \ $([ -n "${{ inputs.warning_severity }}" ] && echo "--warning-severity=${{ inputs.warning_severity }}") \ $([ -n "${{ inputs.error_severity }}" ] && echo "--error-severity=${{ inputs.error_severity }}") \