Tests #5
Workflow file for this run
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: Symfony | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
symfony-tests: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8.0 | |
env: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: test_db_test | |
MYSQL_USER: test_user | |
MYSQL_PASSWORD: test_password | |
options: >- | |
--health-cmd="mysqladmin ping --silent" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
ports: | |
- 3306:3306 | |
steps: | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' | |
extensions: mbstring, intl, pdo, pdo_mysql, ctype, iconv, gd | |
ini-values: post_max_size=256M, upload_max_filesize=256M, max_execution_time=300 | |
coverage: none | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Copy .env if not exists | |
run: php -r "file_exists('.env') || copy('.env.SAMPLE', '.env');" | |
- name: Copy .env.test.local if not exists | |
run: php -r "file_exists('.env.test.local') || copy('.env.test', '.env.test.local');" | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install Composer Dependencies | |
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: Wait for MySQL to be ready | |
run: until mysqladmin ping -h127.0.0.1 -uroot -proot --silent; do sleep 1; done | |
- name: Create Test Database | |
run: php bin/console doctrine:database:create --if-not-exists --env=test | |
env: | |
DATABASE_URL: 'mysql://test_user:test_password@127.0.0.1:3306/test_db' | |
- name: Run Database Migrations | |
run: php bin/console doctrine:migrations:migrate --no-interaction --env=test | |
env: | |
DATABASE_URL: 'mysql://test_user:test_password@127.0.0.1:3306/test_db' | |
- name: Run PHPUnit Tests | |
run: vendor/bin/phpunit --testdox | |
env: | |
DATABASE_URL: 'mysql://test_user:test_password@127.0.0.1:3306/test_db' |