Summer Sale! All accounts are 50% off this week.

AungHtetPaing__'s avatar

Github actions for laravel dusk failing

I use example config file of laravel dusk doc. It is failing at php artisan dusk step with this [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE') error.

My failed github actions - https://github.com/ahp-sooyaa/koob/actions

dusk.yml file

name: CI
on: [push]
jobs:
 
  dusk-php:
    runs-on: ubuntu-latest
    env:
      APP_URL: "http://127.0.0.1:8000"
    steps:
      - uses: actions/checkout@v2
      - name: Prepare The Environment
        run: cp .env.example .env
      - name: Create Database
        run: |
          sudo systemctl start mysql
          mysql --user="root" --password="root" -e "CREATE DATABASE \`koob_test_db\` character set UTF8mb4 collate utf8mb4_bin;"
      - name: Install Composer Dependencies
        run: composer install --no-progress --prefer-dist --optimize-autoloader
      - name: Generate Application Key
        run: php artisan key:generate
      - name: Upgrade Chrome Driver
        run: php artisan dusk:chrome-driver `/opt/google/chrome/chrome --version | cut -d " " -f3 | cut -d "." -f1`
      - name: Start Chrome Driver
        run: ./vendor/laravel/dusk/bin/chromedriver-linux &
      - name: Run Laravel Server
        run: php artisan serve --no-reload &
      - name: Run Dusk Tests
        run: php artisan dusk
      - name: Upload Screenshots
        if: failure()
        uses: actions/upload-artifact@v2
        with:
          name: screenshots
          path: tests/Browser/screenshots
      - name: Upload Console Logs
        if: failure()
        uses: actions/upload-artifact@v2
        with:
          name: console
          path: tests/Browser/console

The .env.example file I use with github actions.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=koob_test_db
DB_USERNAME=root
DB_PASSWORD=root

In local I use .env.dusk.local with empty database password,

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=koob_test_db
DB_USERNAME=root
DB_PASSWORD=

Does anyone know how to solve it? My first time trying with github action CI so I am struggling to make it work.

0 likes
2 replies
AungHtetPaing__'s avatar
Level 22

I got it. I have to copy .env.dusk.local instead of .env.example and set password 'root. The .env.dusk.local is using when running test.

Please or to participate in this conversation.