Skip to content

テスト自動化対応 #1

テスト自動化対応

テスト自動化対応 #1

Workflow file for this run

name: Laravel Unit Tests
on:
push:
branches:
- main
- develop
jobs:
unit-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: src
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }}
MYSQL_DATABASE: ${{ secrets.DB_NAME }}
MYSQL_USER: ${{ secrets.DB_USER }}
MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }}
TZ: 'Asia/Tokyo'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
options: --health-cmd "mysqladmin ping -h localhost" --health-interval 20s --health-timeout 10s --health-retries 10
steps:
- uses: actions/checkout@v3
# vendorディレクトリのキャッシュ情報
- name: Cache Vendor
id: cache
uses: actions/cache@v2
with:
path: ./src/vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP 8.2
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Install Composer
if: steps.cache.outputs.cache-hit != 'true'
run: composer install -n --prefer-dist
- name: Copy .env
run: cp .env.example .env
- name: Generate Key
run: php artisan key:generate
- name: Permit Directory
run: chmod -R 777 storage bootstrap/cache
- name: Migrate to Database
env:
DB_HOST: ${{ secrets.DB_HOST }}
DB_DATABASE: ${{ secrets.DB_NAME }}
DB_USERNAME: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: php artisan migrate
- name: Execute Unit And Feature Tests
env:
DB_HOST: ${{ secrets.DB_HOST }}
DB_DATABASE: ${{ secrets.DB_NAME }}
DB_USERNAME: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: ./vendor/bin/phpunit tests