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.
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
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.
Related
What is a good project setup for developing Directus extensions such as hooks and custom endpoint, while using unit testing with PHPUnit?
Directus extensions live under the same codebase as the core project itself. That's a problem for having the extension code under version control. So what I have now is a symlink from directus/public/extensions/custom/hooks to a directory outside. In there, I have the usual src/ and tests/, and I've done composer install --dev phpunit ^8 and I PHPUnit is in place, and is loading my own classes. Now, how do I bring Directus in here, because Directus is not, AFAIK, on Composer. Maybe make a lib/, checkout Directus from GitHub in there, and have it included in autoload/classmap in composer.json?
Or would it alternatively be better to fork the whole Directus, and use a close of the whole Directus repo for extension dev? How to develop more than one extension?
Or something else?
There is not native testing for directus, the only way is to have the unit testing for php and for vue. Could be so great to have like a integration testing for the modules that uses custom api points. But the idea of directus is that all is modular so nope don't think that's gonna be around soon.
We created a clone from the dev server for the jenkis CI to improve our work, we configurated it and the tests started working as we wanted. Then we find out that the git plugin in the jenkins is not liked with the project's workspace. It's a PHP REST api project, every server has it's own configuration. So we gave to the jenkins the path of the project to use that - this is the "Checkout to a sub-directiory" option. Then when a new PR is created, then jenkins is tiggered and it's start the build, and at first it's trying to delete the complete workspace.
I wouldn't think that it would be impossible to run tests on an already existing project with the jenkins, but this is ablosutly not the way how to do it. Every server has it's own configurations, so those are not part of the git repo, plus there is a base installation for the framework, and that's also not part of the git repository.
Now my question is what information are we missing, and how could we configure the git pluggin to make the jenkins start working on our existing project?
Ensure that you have the GitHub plugin and Git Pull Request Plugin installed in your jenkins workspace, now all you have check these 2 option
Also note that you have to add your public in Git which you would have done I'm guessing, now a hook will be created and you can send a request from Git and if you have a green tick ALL GOOD, else you have to debug it try this link Github webhook URL config issue? How to fix it?
I wonder if someone can help me. I've been handed in a Cake PHP app that I need to 1) add minor changes 2) deploy. I've never really worked with Cake before and was wondering whether do I need to anything in order for it to work?
For instance, With a Node app, you need to install modules npm install. With a Rails app you'll likely need to install the gems bundle install.
Is there something similar with Cake? I've set the localhost server, but when I try to access the url I get all sort of errors. Some I've fixed (missing environment settings which I just override the Redis host and port). The latest one is:
{
"exception":{
"class":"MissingControllerException",
"code":404,
"message":"Controller class Controller could not be found.",
"file":"\/Library\/WebServer\/Documents\/php\/oompbe\/vendors\/cakephp\/lib\/Cake\/Routing\/Dispatcher.php",
"line":154,
"trace":[
"#0 \.../app\/webroot\/index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))",
"#1 {main}"
]
}
}
PS: What's up with all the crazy \/\/?
PPS: Can I find out the version Cake I'm running?
CakePHP is just php. As most properly done php apps these days it comes with composer. I recommend you to read at least the basics of it's manual. Composer is an awesome tool.
git clone <repo>
cd <reponame>
composer install
If you start a new Cake application the official documentation tells you how to this as well:
composer create-project --prefer-dist cakephp/app [app_name]
If you want to automate things further composer provides you callback scripts. They'll allow you to automate tasks, basically trigger commands, after different actions. This is pretty useful to build assets after a composer update for example. I recommend you to not put lots of commands into that section but instead have dedicated script files you trigger by the callbacks.
Can I find out the version Cake I'm running?
If installed via composer it is usually in vendor/cakephp/cakephp/version.txt. Check the content of that file.
I've developed an application which uses the Symfony 2 framework. The application code resides in a Bundle, and on my local machine I just downloaded the Symfony2 Standard Distribution and added the Bundle to the src folder as the tutorials describe, before editing the config / routing files appropriately. That's served me well from a development perspective.
I'm now starting to think about how to handle the framework dependencies with regards to deploying to a production environment / a continuous integration setup. Should I continue as I have to date, using a distribution and perhaps a build tool like Phing to check out my bundle and any other dependencies? Or should I be checking out only the Symfony source from Github, and maintain a custom 'distribution' for my application?
I'm hoping someone else has had to do a similar thing and can recommend a solution that works with minimum fuss!
Thanks.
Are your tests written with PHPUnit? If so you can run the tests directly using ant, and then run Ant from jenkins. In my set-up I then have a second project that updates the git checkout in our staging environment if the test passes. I ran into a bunch of issues duck-taping this all together ( mostly around github keys, user permissions, user shell environments, etc ) but the phpqa tools work very well. I just saw this post that seems like a more recent guide on getting everything running:
http://edorian.posterous.com/setting-up-jenkins-for-php-projects
I've got this 'Hello world' project including a working build.xml that should work if ant and the PHP tools are set up correctly:
https://github.com/canuckistani/JenkinsTest
I am working on a live remote php project in eclipse. ie, I just connect the the project using RSE edit the files and save.
I have recently setup subeclipse and am wondering if there is an way to add my php files to a subversion project while still working on the live project? Or maybe there is a better way to do this and get the same result.
You can't use the live version as the subversion repository directly but a common approach is, that you run a Subversion Post-Commit hook whenever you commit to your repository. The hook is just a basic shell or batch script that gets executed after a certain event. In this hook you export the current revision from the repository to the live system. In this case, if you commit errors into subversion you will have the errors in the live system right away which might be dangerous.
The alternative would be to use a build tool like ant which does the deployment of the application from the repository for you.