fix: coding-standard-baseline: Run baseline test on modified files only (fixes #227) (#228)

This commit is contained in:
Ryan Hoerr
2024-07-08 16:19:16 -04:00
committed by GitHub
parent a3262710f1
commit e29ea44597
+7 -5
View File
@@ -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