chore: Add lint, test & related workflow #4
This file contains hidden or 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: Checks | |
on: | |
push: | |
branches: | |
- main | |
- 'feature/*' | |
pull_request: | |
branches: | |
- main | |
jobs: | |
lint: | |
name: Lint with Pint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' | |
tools: composer | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction | |
- name: Run Pint | |
run: vendor/bin/pint | |
test: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8.0 | |
env: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: trakli | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd="mysqladmin ping --silent" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' | |
tools: composer | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction | |
- name: Copy .env file | |
run: cp .env.example .env | |
- name: Update .env file | |
run: | | |
echo "DB_CONNECTION=mysql" >> .env | |
echo "DB_HOST=127.0.0.1" >> .env | |
echo "DB_PORT=33306" >> .env | |
echo "DB_DATABASE=db_test" >> .env | |
echo "DB_USERNAME=root" >> .env | |
echo "DB_PASSWORD=password" >> .env | |
echo "APP_ENV=testing" >> .env | |
- name: Generate application key | |
run: php artisan key:generate | |
- name: Configure database | |
run: | | |
php artisan config:clear | |
php artisan config:cache | |
- name: Run migrations | |
run: php artisan migrate --seed | |
- name: Run tests | |
run: php artisan test |