We are working on a Magento payment module, let's call it ABC. We are using Docker for the development. So, for development, we are using a Magento image and adding the module code to the htdocs/app/code
via volumes
from docker-compose.yml
. Our Github repo contains the module code only. We have added some tests for the module under app/code/ABC/Payment/Test
folder. We want to setup a Github workflow that will run the test automatically on pull request.
The issue is some of the code depends on the Magento core classes like Magento\Framework\App\Config\ScopeConfigInterface
, Magento\Store\Model\StoreManagerInterface
and so on which won't be available in our Github repo. Is there any Github actions with which we can setup Magento, copy the module codes into it and run the module's tests?
Any help would be greatly appreciated. We are unable to figure this out.
CodePudding user response:
You could require magento using composer within your github workflow. https://github.com/marketplace/actions/composer-php-actions
If you use grumphp (https://github.com/phpro/grumphp) you can have a look at this example: https://github.com/phpro/phpro-mage2-module-translations/blob/master/.github/workflows/grumphp.yml
CodePudding user response:
You have not shared much about what precisely is making you unable to figure it out for Github Actions, however reading your question it looks to me like you already have figured out for development: Using Docker.
Now Github Actions as well supports Docker. All you need is to run the setup script for the development environment that establishes that Docker setup within the Github Action before running your tests.
You may want to add an additional environment for it, so that you can branch between the development system and Github Actions, but theoretically it should already work without.
Then after you have cloned the code, and then setup the Docker environment, execute the tests in the Github Action. The tests should run now.