First of all, you have to implement the Magento Coding Standard, then you can create a Travis config file to set the PHP version that you want to test your module and the Magento version and edition, for example:
PHP 7.2
- Magento OpenSource (2.3.2, 2.3.3-p1) - Magento Commerce (2.3.2, 2.3.3-p1)
PHP 7.3
- Magento OpenSource (2.3.3-p1, 2.3.4-p2) - Magento Commerce (2.3.3-p1, 2.3.4-p2)Magento Coding Standard
To install the Magento's coding standards in your module first add the Composer package:
php bin/magento setup:di:compile
Then add these lines in your composer.json, I'm considering that you module is inside an src folder.
... "scripts": { "post-install-cmd": [ "([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)" ], "post-update-cmd": [ "([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)" ], "php": "vendor/bin/phpcs --standard=./vendor/phpcompatibility/php-compatibility/PHPCompatibility --extensions=php,phtml -d memory_limit=-1 src", "lint": "vendor/bin/phpcs --standard=Magento2 src", "fix": "vendor/bin/phpcbf --standard=Magento2 src" } ...Automated tests
In order to set up the automated tests I recommend using Travis CI with Github, to do so, you just need to create these files below. And add your Magento user and password in the Travis panel as MAGENTO_USERNAME and MAGENTO_PASSWORD.
.travis.yml