I have a written application with the support of Laravel Framework. I would like to carry out the implantation and unit test via Travis CI. Taking an example of the repository itself I was able to reach this solution:
language: php
env:
global:
- setup=stable
matrix:
fast_finish: true
include:
- php: 7.1
- php: 7.1
env: setup=lowest
- php: 7.2
- php: 7.2
env: setup=lowest
sudo: false
cache:
directories:
- $HOME/.composer/cache
services:
- memcached
- mysql
before_script:
- cp .env.example .env
- php artisan key:generate
before_install:
- phpenv config-rm xdebug.ini || true
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- travis_retry composer self-update
- mysql -e 'CREATE DATABASE homestead CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'
- mysql -e "CREATE USER 'homestead'@'127.0.0.1' IDENTIFIED BY 'secret'; GRANT ALL PRIVILEGES ON *.* TO 'homestead'@'127.0.0.1' WITH GRANT OPTION; FLUSH PRIVILEGES;"
- sudo service mysql restart
install:
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-stable --no-suggest; fi
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable --no-suggest; fi
script:
- vendor/bin/phpunit
Apparently it works perfectly, but is this approach correct against possible test / deployment patterns?
Another thing I did not understand very well was:
if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable --no-suggest;