UTRS 3 #1470
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Laravel tests | |
on: | |
push: | |
branches: | |
- master | |
pull_request: {} | |
jobs: | |
laravel-tests: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
php-versions: | |
- 7.3 # current production | |
- 8.0 # target, https://github.com/UTRS2/utrs/issues/375 | |
services: | |
mysql: | |
image: mariadb:10.5 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: false | |
MYSQL_ROOT_PASSWORD: password | |
MYSQL_DATABASE: laravel | |
ports: | |
- 3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Install PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
extensions: zip, mbstring, dom, fileinfo, mysql | |
php-version: ${{ matrix.php-versions }} | |
- uses: actions/checkout@v1 | |
- name: Copy env file | |
run: cp .env.ci .env | |
- name: Cache Composer dependencies | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-composer-dependencies | |
with: | |
path: ~/.composer/cache/files | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }} | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
- name: Cache NPM dependencies | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-dependencies | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
- name: Install Composer dependencies | |
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader | |
- name: Install NPM dependencies | |
run: npm install | |
- name: Set app key | |
run: php artisan key:generate | |
- name: Clear config cache | |
run: php${{ matrix.php }} artisan config:clear | |
- name: Run migrations | |
run: php${{ matrix.php }} artisan migrate -v --force | |
env: | |
DB_PORT: ${{ job.services.mysql.ports['3306'] }} | |
- name: Build assets | |
run: npm run production | |
- name: Run tests | |
run: composer test | |
env: | |
DB_PORT: ${{ job.services.mysql.ports['3306'] }} | |
- name: Start chromedriver | |
run: chromedriver & | |
- name: Start Laravel Server | |
run: php artisan serve & | |
env: | |
DB_PORT: ${{ job.services.mysql.ports['3306'] }} | |
- name: Run Browser Tests | |
run: php artisan dusk | |
env: | |
DB_PORT: ${{ job.services.mysql.ports['3306'] }} | |
- uses: actions/upload-artifact@v2 | |
name: Save Dusk screenshots | |
if: failure() | |
with: | |
name: dusk-screenshots | |
path: tests/Browser/screenshots/*.png |