From 4e21b18ee9187253fc5d172d0ad1439bf304872e Mon Sep 17 00:00:00 2001 From: Damien Retzinger Date: Thu, 21 Sep 2023 08:40:58 -0400 Subject: [PATCH] feat(coding-standard): add `ignore_warnings` flag (#147) By default, `phpcs` exits with a non-zero exit code when it finds warnings. We keep that default, but allow changing it. Co-authored-by: Vitaliy Golomoziy --- .../workflows/_internal-coding-standard.yaml | 20 ++++++++++++- coding-standard/action.yml | 28 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/_internal-coding-standard.yaml b/.github/workflows/_internal-coding-standard.yaml index 10eec01..df5b927 100644 --- a/.github/workflows/_internal-coding-standard.yaml +++ b/.github/workflows/_internal-coding-standard.yaml @@ -31,11 +31,29 @@ on: required: true jobs: + compute_matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.supported-version.outputs.matrix }} + steps: + - uses: actions/checkout@v3 + - uses: ./supported-version + with: + kind: all + id: supported-version + - run: echo ${{ steps.supported-version.outputs.matrix }} + coding-standard: + needs: compute_matrix + strategy: + matrix: ${{ fromJSON(needs.compute_matrix.outputs.matrix) }} + fail-fast: false runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: './coding-standard' with: version: ${{ github.event.inputs.version || '*' }} - path: ${{ github.event.inputs.path || '_test/demo-package' }} \ No newline at end of file + path: ${{ github.event.inputs.path || '_test/demo-package' }} + composer_version: ${{ matrix.composer }} + php_version: ${{ matrix.php }} \ No newline at end of file diff --git a/coding-standard/action.yml b/coding-standard/action.yml index eb5ba35..4d4a947 100644 --- a/coding-standard/action.yml +++ b/coding-standard/action.yml @@ -37,6 +37,11 @@ inputs: default: "" description: "The minimum severity required to display an error" + ignore_warnings: + description: 'Whether or not the action should fail on warnings, defaults to false (fails on warnings)' + default: 'false' + required: false + runs: using: composite steps: @@ -57,6 +62,23 @@ runs: 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: Check if allow-plugins option is available for this version of composer + uses: mage-os/github-actions/semver-compare@main + with: + version: 2.2 + compare_against: ${{ steps.get-composer-version.outputs.version }} + id: is-allow-plugins-available + + - name: Enable dealerdirect/phpcodesniffer-composer-installer plugin + shell: bash + working-directory: standard + run: composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true --global + if: steps.is-allow-plugins-available.outputs.result < 1 + - name: Install Coding Standard shell: bash working-directory: standard @@ -67,6 +89,12 @@ runs: 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 + - name: Set ignore warnings flag + shell: bash + working-directory: standard + run: vendor/bin/phpcs --config-set ignore_warnings_on_exit 1 + if: inputs.ignore_warnings == 'true' + - name: Get Changed Files shell: bash working-directory: project