From e29ea44597d69cf743bc172fd84b8f9f238ff3b6 Mon Sep 17 00:00:00 2001 From: Ryan Hoerr Date: Mon, 8 Jul 2024 16:19:16 -0400 Subject: [PATCH] fix: coding-standard-baseline: Run baseline test on modified files only (fixes #227) (#228) --- coding-standard-baseline/action.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/coding-standard-baseline/action.yml b/coding-standard-baseline/action.yml index 53935d2..fded724 100755 --- a/coding-standard-baseline/action.yml +++ b/coding-standard-baseline/action.yml @@ -70,6 +70,8 @@ runs: with: list-files: shell filters: | + baseline: + - modified: '**/**.{php,phtml,graphqls,less,css,html,xml,js}' phpcs: - added|modified: '**/**.{php,phtml,graphqls,less,css,html,xml,js}' @@ -78,7 +80,7 @@ runs: shell: bash run: | echo "One or more files relevant to PHPCS have changed." - echo "List all the files that have changed: ${{ steps.filter.outputs.phpcs_files }}" + echo "List all the files that have been added or changed: ${{ steps.filter.outputs.phpcs_files }}" - name: Setup PHP if: steps.filter.outputs.phpcs == 'true' @@ -115,17 +117,17 @@ runs: - name: Create phpcs.baseline.xml from base shell: bash working-directory: base - if: steps.filter.outputs.phpcs == 'true' + if: steps.filter.outputs.baseline == 'true' run: | php ${{ github.workspace }}/magento-coding-standard/vendor/bin/phpcs --standard=Magento2 \ $([ -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 }}") \ --report=\\DR\\CodeSnifferBaseline\\Reports\\Baseline --report-file=phpcs.baseline.xml \ - ${{ steps.filter.outputs.phpcs_files }} || /bin/true + ${{ steps.filter.outputs.baseline_files }} || /bin/true - name: Copy baseline to head - if: steps.filter.outputs.phpcs == 'true' + if: steps.filter.outputs.baseline == 'true' shell: bash run: | cp ${{ github.workspace }}/base/phpcs.baseline.xml ${{ github.workspace }}/magento-coding-standard/phpcs.baseline.xml @@ -133,7 +135,7 @@ runs: # Since we ran phpcs in the base folder, the files in phpcs.baseline.xml contain the base folder in the path. # We need to remove /base/ so that the phpcs can locate the correct files. - name: Remove base dir from phpcs baseline - if: steps.filter.outputs.phpcs == 'true' + if: steps.filter.outputs.baseline == 'true' shell: bash run: | sed -i "s|/base/|/|" ${{ github.workspace }}/magento-coding-standard/phpcs.baseline.xml