Skip to content

Mysql not found when executing squashed migrations #40

@robbert-u

Description

@robbert-u

Hi,

In my Laravel project, I squashed my migrations which resulted in a schema.dump (sql) file which is imported when running your migrations.

I my tests we make use of the RefreshDatabase trait which makes sure you start your test with a clean database. Since I squashed our migrations, it tries to import the schema.dump via a mysql command which cannot be found.

When running my tests in GitHub I encounter the follow exception;

1) Tests\***\***\***
Symfony\Component\Process\Exception\ProcessFailedException: The command "mysql  --user="${:LARAVEL_LOAD_USER}" --*** --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --database="${:LARAVEL_LOAD_DATABASE}" < "${:LARAVEL_LOAD_PATH}"" failed.

Exit Code: 127(Command not found)

Working directory: /app

Output:
================


Error Output:
================
sh: mysql: not found

Work flow:

name: 'Run Tests'

on:
    pull_request:

jobs:
    laravel-tests:
        runs-on: ubuntu-latest
        services:
            mysql:
                image: mysql:8.0
                env:
                    MYSQL_HOST: 127.0.0.1
                    MYSQL_DATABASE: **
                    MYSQL_USER: **
                    MYSQL_PASSWORD: **
                    MYSQL_ROOT_PASSWORD: **
                    MYSQL_PORT: 3306
                options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
                ports:
                    - 3306:3306


        steps:
            - name: Verify MySQL connection
              run: |
                  mysql --version
                  mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u** -p** -e "SHOW DATABASES"


            - uses: actions/checkout@v2
            - name: Copy ENV Laravel Configuration for CI
              run: php -r "file_exists('.env') || copy('.env.ci', '.env');"


            - name: Install Dependencies
              run: |
                  composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_PASSWORD }}"
                  composer config "github-oauth.github.com" "${{ secrets.OAUTH_TOKEN_GITHUB }}"
                  composer install --no-ansi --no-interaction --no-scripts --ignore-platform-reqs


            - name: Generate key
              run: php artisan key:generate


            - name: Directory Permissions
              run: chmod -R 777 storage bootstrap/cache


            - name: PHPUnit Tests
              uses: php-actions/phpunit@v3
              env:
                  DB_CONNECTION: mysql
                  DB_USERNAME: **
                  DB_DATABASE: **
                  DB_PASSWORD: **
                  DB_HOST: **
                  DB_PORT: 3306
              with:
                  bootstrap: vendor/autoload.php
                  configuration: phpunit.xml
                  php_version: 8.0.12
                  php_extensions: pdo_mysql

            - name: Upload artifacts
              uses: actions/upload-artifact@master
              if: failure()
              with:
                  name: Logs
                  path: |
                      ./storage/logs

Shouldn't mysql be installed by default?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions