Created
November 20, 2020 15:32
-
-
Save nasrulhazim/b46944ac0707ba54f3a055aeae333a68 to your computer and use it in GitHub Desktop.
GitHub Action - MySQL Service for Laravel with Multiple Databases
This file contains hidden or 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
name: Unit Test | |
on: | |
push: | |
branches: [develop] | |
pull_request: | |
branches: [master, develop] | |
jobs: | |
PHPUnit: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8.0.21 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
MYSQL_DATABASE: unittest | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Verify unittest DB exists | |
run: mysql --host 127.0.0.1 --port 3306 -uroot -e "SHOW DATABASES LIKE 'unittest'" | |
- name: Create 2nd Database | |
run: mysql --host 127.0.0.1 --port 3306 -uroot -e "CREATE DATABASE IF NOT EXISTS unittest_second;" | |
- name: Verify unittest_second DB exists | |
run: mysql --host 127.0.0.1 --port 3306 -uroot -e "SHOW DATABASES LIKE 'unittest_second'" | |
- name: Copy the .env | |
run: cp .env.example .env | |
- name: Install dependencies | |
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: Configrue Storage Permission | |
run: chmod -R 777 storage bootstrap/cache | |
- name: Generate Application Key | |
run: php artisan key:generate | |
- name: Clear Configuration | |
run: php artisan config:clear | |
- name: Configure Application | |
run: | |
- name: Execute tests (Unit and Feature tests) via PHPUnit | |
env: | |
DB_CONNECTION: mysql | |
DB_PORT: 3306 | |
DB_USER: root | |
DB_PASSWORD: "" | |
DB_DATABASE: unittest | |
run: vendor/bin/phpunit |
this isn't working, keep getting this error,
Illuminate\Database\QueryException: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')
it's been 2 years, might not up-to-date. You may check with latest Github Action setup.
@nasrulhazim found the issue, there should by one more line to update the authentication of MySQL to password by default its something else maybe authentication with socket. so i changed the authentication to password by adding following command and now its working fine.
- name: change authentication method
run: mysql --host 127.0.0.1 --port 3306 -uroot -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'";
in my yaml i am using password so i change the password to root.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this isn't working, keep getting this error,
Illuminate\Database\QueryException: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')