Closed diazwatson closed 4 months ago
@diazwatson could you provide details of your github action. Your log shows installed_paths
was triggered.
If you could include reproducer it would good.
Sure
This is the version I initially used (the one that generated the reported error)
name: "Magento 2 Coding Standard"
on:
push:
jobs:
coding-standard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Depth is needed for PR violation reports
- name: Setup PHP with composer
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: composer:2.3, phpcs:3.6
- name: Run coding standard analysis
uses: codemanufacture/magento-coding-standard-action@v1
This is the version I am currently using: It is somehow working as I can see the warnings and errors but for some reason it scans the whole source code rather than only the files files changed.
name: "Magento 2 Coding Standard"
on:
push:
jobs:
coding-standard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Depth is needed for PR violation reports
- name: Setup PHP with composer
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: composer:2.3, phpcs:3.6
- name: Install PHPCompatibility
run: composer global require phpcompatibility/php-compatibility
- name: Set PHPCompatibility path
run: phpcs --config-set installed_paths ~/.composer/vendor/phpcompatibility/php-compatibility
- name: Run coding standard analysis
uses: codemanufacture/magento-coding-standard-action@v1
with:
extensions: "php,phtml"
file_list: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
Apparently in newer versions of magento https://github.com/magento/PHPCompatibilityFork is used so the install path is magento/php-compatibility-fork
instead of phpcompatibility/php-compatibility
.
I'll check if there is a way to detect it.
How about using what the Magento repo being tested comes with rather than installing magento/coding-standards
and magento/php-compatibility-fork
separately?
For example:
If I add the action to a repo containing Magento 2.2, 2.3 or 2.4, then the action will scan the code using what ever version of magento/coding-standards
is present in that Magento
For newest version of magento/coding-standards (v33) installed_paths
should be:
composer global -- exec phpcs --config-set installed_paths ~/.composer/vendor/magento/magento-coding-standard/,~/.composer/vendor/magento/php-compatibility-fork
v32 works correctly without this fix.
If your repo already has coding standards installed via vendor: you can set:
- name: Run coding standard analysis
uses: codemanufacture/magento-coding-standard-action@v1
with:
install_coding_standard: false
It would attempt to install a separate global package.
You get all file scanned because the condition in action is set based on:
if: inputs.pr_modified_files_only && github.event_name == 'pull_request'
Looks like you trigger it on a branch push event.
You should have the fix for installed_paths with:
uses: codemanufacture/magento-coding-standard-action@main
I'm going to prepare a tagged release next week.
Probably related to this: https://magento.stackexchange.com/a/357223/4659