Skip to content

Commit 4e21b18

Browse files
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 <vitaliy.golomoziy@gmail.com>
1 parent 01e4ccb commit 4e21b18

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

.github/workflows/_internal-coding-standard.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,29 @@ on:
3131
required: true
3232

3333
jobs:
34+
compute_matrix:
35+
runs-on: ubuntu-latest
36+
outputs:
37+
matrix: ${{ steps.supported-version.outputs.matrix }}
38+
steps:
39+
- uses: actions/checkout@v3
40+
- uses: ./supported-version
41+
with:
42+
kind: all
43+
id: supported-version
44+
- run: echo ${{ steps.supported-version.outputs.matrix }}
45+
3446
coding-standard:
47+
needs: compute_matrix
48+
strategy:
49+
matrix: ${{ fromJSON(needs.compute_matrix.outputs.matrix) }}
50+
fail-fast: false
3551
runs-on: ubuntu-latest
3652
steps:
3753
- uses: actions/checkout@v3
3854
- uses: './coding-standard'
3955
with:
4056
version: ${{ github.event.inputs.version || '*' }}
41-
path: ${{ github.event.inputs.path || '_test/demo-package' }}
57+
path: ${{ github.event.inputs.path || '_test/demo-package' }}
58+
composer_version: ${{ matrix.composer }}
59+
php_version: ${{ matrix.php }}

coding-standard/action.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ inputs:
3737
default: ""
3838
description: "The minimum severity required to display an error"
3939

40+
ignore_warnings:
41+
description: 'Whether or not the action should fail on warnings, defaults to false (fails on warnings)'
42+
default: 'false'
43+
required: false
44+
4045
runs:
4146
using: composite
4247
steps:
@@ -57,6 +62,23 @@ runs:
5762
tools: composer:v${{ inputs.composer_version }}
5863
coverage: none
5964

65+
- name: Get Composer Version
66+
uses: mage-os/github-actions/get-composer-version@main
67+
id: get-composer-version
68+
69+
- name: Check if allow-plugins option is available for this version of composer
70+
uses: mage-os/github-actions/semver-compare@main
71+
with:
72+
version: 2.2
73+
compare_against: ${{ steps.get-composer-version.outputs.version }}
74+
id: is-allow-plugins-available
75+
76+
- name: Enable dealerdirect/phpcodesniffer-composer-installer plugin
77+
shell: bash
78+
working-directory: standard
79+
run: composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true --global
80+
if: steps.is-allow-plugins-available.outputs.result < 1
81+
6082
- name: Install Coding Standard
6183
shell: bash
6284
working-directory: standard
@@ -67,6 +89,12 @@ runs:
6789
working-directory: standard
6890
run: vendor/bin/phpcs --config-set installed_paths ${{ github.workspace }}/standard/vendor/magento/magento-coding-standard,${{ github.workspace }}/standard/vendor/phpcompatibility/php-compatibility
6991

92+
- name: Set ignore warnings flag
93+
shell: bash
94+
working-directory: standard
95+
run: vendor/bin/phpcs --config-set ignore_warnings_on_exit 1
96+
if: inputs.ignore_warnings == 'true'
97+
7098
- name: Get Changed Files
7199
shell: bash
72100
working-directory: project

0 commit comments

Comments
 (0)