All migrations ran successfully. But when executing phpunit I am getting error "SQLSTATE[HY000] [2002] No such file or directory (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')".
I even tried replacing DB_HOST=mysql with DB_HOST=127.0.0.1 and localhost. Migrations didn't run successfully and faced an errro "SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = my_db and table_name = migrations and table_type = 'BASE TABLE')"
I am working around with this for 2 days. Any help would be highly appreciated.
gitlab-ci.yml
stages:
- build
- test
variables:
MYSQL_DATABASE: $MYSQL_DATABASE
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
MYSQL_PASSWORD: $MYSQL_ROOT_PASSWORD
DB_HOST: mysql
DB_DATABASE: $MYSQL_DATABASE
DB_USERNAME: $MYSQL_USER
DB_PASSWORD: $MYSQL_ROOT_PASSWORD
cache:
paths:
- vendor/
- .env
image: lorisleiva/laravel-docker:latest
composer:
stage: build
script:
- composer update --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- cp .env.example .env
- php artisan key:generate
artifacts:
paths:
- vendor/
- .env
expire_in: 2 days
when: always
cache:
key: ${CI_COMMIT_REF_SLUG}-composer
paths:
- vendor/
phpunit:
stage: test
services:
- mysql:5.7
dependencies:
- composer
script:
- composer dump-autoload
- php artisan config:clear
- php artisan migrate
- php ./vendor/bin/phpunit --testsuite=Feature
artifacts:
paths:
- ./storage/logs # for debugging
expire_in: 1 days
when: on_failure