Skip to content

#187: Loading target fixed #243

#187: Loading target fixed

#187: Loading target fixed #243

name: Build and Test
on:
push:
branches: [ develop, main ]
pull_request:
branches: [ develop, main ]
jobs:
php-tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: lara_blog
MYSQL_ROOT_PASSWORD: password
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Verify MySQL connection
run: |
mysql --version
sudo apt-get install -y mysql-client
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports[3306] }} -uroot -ppassword -e "SHOW DATABASES"
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: pcov
ini-values: |
pcov.enabled=1
coverage: pcov
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-composer-${{ hashFiles('composer.json') }}
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.githubaction', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Migrate and seed
run: php artisan migrate:fresh --seed
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}
DB_CONNECTION: mysql
DB_DATABASE: lara_blog
DB_USERNAME: root
DB_PASSWORD: password
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}
DB_CONNECTION: mysql
DB_DATABASE: lara_blog
DB_USERNAME: root
DB_PASSWORD: password
run: |
php artisan test --coverage --coverage-clover clover.xml
vendor/bin/pint
- name: Generate test coverage badge
uses: timkrase/[email protected]
with:
coverage_badge_path: 'tests/coverage/badge-coverage.svg'
push_badge: true
repo_token: ${{ secrets.GITHUB_TOKEN }}