extdn / github-actions-m2

137 stars 46 forks source link

Error: file_put_contents(/m2/app/etc/vendor_path.php): Failed to open stream: No such file or directory #115

Open mcspronko opened 4 months ago

mcspronko commented 4 months ago

The ExtDN M2 PHPStan workflow returns the below error:

Error: file_put_contents(/m2/app/etc/vendor_path.php): Failed to open stream: No such file or directory
Use the `composer fund` command to find out more!

In PluginManager.php(278) : eval()'d code line 323:

  file_put_contents(/m2/app/etc/vendor_path.php): Failed to open stream: No s  
  uch file or directory                                                        

Configuration used:

name: ExtDN M2 PHPStan
on:
    push:
        branches:
            - main
    pull_request:

jobs:
    phpstan:
        name: M2 PHPStan
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v4
            - uses: extdn/github-actions-m2/magento-phpstan/8.1@master
              with:
                  composer_name: pronko/workflow-tests-magento-module

Am I missing something in the yaml file or there is an issue with the workflow?

sprankhub commented 4 months ago

This configuration works for us: https://github.com/customgento/CustomGento_Invoice-m2/blob/3959c742e9147d7dc7afc4a05ade4dc4124d1619/.github/workflows/phpstan.yml

Could you try with a similar one?

mcspronko commented 4 months ago

Thanks @sprankhub I will try and let you know.

mcspronko commented 4 months ago

Hi @sprankhub thank you for the suggestion, works like a charm!

sprankhub commented 4 months ago

Okay, interesting :D So internally, this uses https://github.com/customgento/m2-github-actions/blob/main/.github/workflows/phpstan.yml. The only real difference I see is that it uses PHP 8.2 insteaf of PHP 8.1... :thinking:

mcspronko commented 4 months ago

Interestingly, it worked fine with the https://github.com/customgento/m2-github-actions/blob/main/.github/workflows/phpstan.yml configuration, but when I tried to add a composer_name it fails with the same error:

name: ExtDN M2 PHPStan
on: [push, pull_request]

jobs:
    phpstan:
        name: M2 PHPStan
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v4
            - uses: extdn/github-actions-m2/magento-phpstan/8.2@master
              with:
                  composer_name: pronko/workflow-tests-magento-module
Error: file_put_contents(/m2/app/etc/vendor_path.php): Failed to open stream: No such file or directory
Use the `composer fund` command to find out more!

In PluginManager.php(278) : eval()'d code line 323:

  file_put_contents(/m2/app/etc/vendor_path.php): Failed to open stream: No s  
  uch file or directory                                                        
sprankhub commented 4 months ago

Then this sounds like a bug to me :see_no_evil:

jissereitsma commented 2 months ago

I bumped into this issue myself as well. This is what I found: In the PHPStan Docker image, the Integration Testing Docker image is included. Next, specifically for the PHPStan Docker image, composer is used to install Magento https://github.com/extdn/github-actions-m2/blob/master/magento-phpstan/Dockerfile%3A8.3#L4 This should also include all of the magento2-base files that are copied from vendor/ to the application root, including the file app/etc/vendor_path.php (which is mentioned in this issue). For some reason, the end-result of the Docker image however is a filled vendor/ folder, but no additional files.

I've added a quick workaround https://github.com/extdn/github-actions-m2/blob/master/magento-phpstan/entrypoint.sh#L20 to remove the vendor/ folder and re-add it again. After this, everything works just fine for me.

Does this fix things for you as well?

sprankhub commented 2 months ago

It's an ugly one :joy: But it works: https://github.com/customgento/module-default-store-code-remover-m2/actions/runs/9380223585/job/26944378354

sprankhub commented 2 months ago

Thanks for looking into this! Do you have any idea for a nicer fix?