UTRS 3 #1638
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-22.04 | |
strategy: | |
matrix: | |
php-versions: | |
- 8.3 | |
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@v4 | |
- name: Copy env file | |
run: cp .env.ci .env | |
- name: Cache Composer dependencies | |
uses: actions/cache@v4 | |
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@v4 | |
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 --verbose | |
env: | |
DB_PORT: ${{ job.services.mysql.ports['3306'] }} |