Run Tests #158
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
# Controls when the action will run. | |
name: Run Tests | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Triggers the workflow on push request events but only for the main branch | |
push: | |
branches: | |
- main | |
# Define the jobs to run | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
services: | |
# Define a service container for MySQL | |
mysql: | |
image: mysql:latest | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: true | |
MYSQL_DATABASE: woodless_testing | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: Set up PHP with Xdebug | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' | |
coverage: xdebug | |
- name: Install Composer dependencies | |
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-req=ext-imagick | |
working-directory: WoodLess | |
- name: Create .env.testing file | |
run: cp .env.testing.example .env.testing | |
working-directory: WoodLess | |
- name: Configure Email settings in .env | |
# We'll need to add email config to secrets later if we are to test email methods. | |
run: | | |
echo MAIL_MAILER=smtp >> .env.testing | |
echo MAIL_HOST=mailpit >> .env.testing | |
echo MAIL_PORT=1025 >> .env.testing | |
echo MAIL_USERNAME=null >> .env.testing | |
echo MAIL_PASSWORD=null >> .env.testing | |
echo MAIL_ENCRYPTION=null >> .env.testing | |
echo MAIL_FROM_ADDRESS="[email protected]" >> .env.testing | |
echo MAIL_FROM_NAME="${APP_NAME}" >> .env.testing | |
working-directory: WoodLess | |
- name: Configure Stripe settings in .env | |
# We'll need to add stripe config to secrets later if we are to test email methods. | |
run: | | |
echo STRIPE_PRIVATE_KEY=null >> .env.testing | |
echo STRIPE_PUBLIC_KEY=null >> .env.testing | |
working-directory: WoodLess | |
- name: Generate key for testing | |
run: php artisan key:generate --env=testing | |
working-directory: WoodLess | |
- name: Run database migrations for testing | |
run: php artisan migrate --env=testing --force | |
working-directory: WoodLess | |
- name: Run Laravel Tests | |
run: php artisan test --coverage | |
working-directory: WoodLess |