Hello,
I'm trying to set up automated testing with github workflows.
My problem is, that when I try to run php artisan migrate automatically via the workflow I get the error that the mysql connection is refused
SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select table_name as `name`, (data_length + index_length) as `size`, table_comment as `comment`, engine as `engine`, table_collation as `collation` from information_schema.tables where table_schema = 'todo' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)
If I go into the bash manually and execute php artisan migrate or try to connect to the mysql service everything works as expected.
My .env.ci config for the database is:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=password
and my .github/workflows/migration.yml:
on: push
name: CI
jobs:
migration:
runs-on: ubuntu-latest
container:
image: kirschbaumdevelopment/laravel-test-runner:8.2
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: test
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v4
- name: Install composer dependencies
run: |
composer install --no-scripts
- name: Prepare Laravel Application
run: |
cp .env.ci .env
php artisan key:generate
- run: ls
- name: Run Migration
run: php artisan migrate