test workflow #8
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
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
name: Symfony | ||
on: | ||
push: | ||
branches: [ "structureDB" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
permissions: | ||
contents: read | ||
jobs: | ||
symfony-tests: | ||
runs-on: ubuntu-latest | ||
services: | ||
mariadb: | ||
image: mariadb:latest | ||
ports: | ||
- 3307:3307 | ||
options: >- | ||
--health-cmd="mysqladmin ping --silent" | ||
--health-interval=10s | ||
--health-timeout=5s | ||
--health-retries=3 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
MYSQL_DATABASE: fphp8 | ||
MYSQL_USER: test_user | ||
MYSQL_PASSWORD: test_password | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Copy .env.test.local | ||
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 Dependencies | ||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | ||
- name: Wait for MariaDB | ||
run: until mysqladmin ping -h"127.0.0.1" --silent; do echo 'waiting for mariadb...'; sleep 5; done | ||
- name: Create Database and Tables | ||
run: | | ||
mysql -u test_user -ptest_password -h 127.0.0.1 fphp8 < path/to/your/schema.sql | ||
- name: Execute tests (Unit and Feature tests) via PHPUnit | ||
env: | ||
DATABASE_URL: mysql://test_user:[email protected]:3306/fphp8 | ||
run: vendor/bin/phpunit |