I have an issue running tests that requires DB connection. First part where pipeline is built works fine. Even `php artisan migrate` goes through.
But Test step fails when test tries to add data to database with: `could not find driver (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')` . I tried changing host to 127.0.0.1 or mysql but it doesn't change anything.
Most of my .yml file is based on example I found in bitbucket documentation so I am nt sure why its not working.
Here is my bitbucket-pipelines.yml file:
# Template PHP Build
# This template allows you to validate your PHP application.
# The workflow allows running tests and code linting on the default branch.
image: php:8.2-fpm
pipelines:
default:
- step:
script:
- apt-get update && apt-get install -y unzip zip
- apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev
- apt-get update && apt-get install -qy git curl libmcrypt-dev default-mysql-client
- docker-php-ext-install pdo pdo_mysql
- yes | pecl install mcrypt-1.0.6
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- COMPOSER_ALLOW_SUPERUSER=1 composer install
- cp .env.pipeline .env
- php artisan migrate --force
artifacts:
- storage/**
- vendor/**
- public/**
- .env
caches:
- composer
services:
- mysql
- parallel:
- step:
name: Tests
script:
- php artisan test
definitions:
services:
mysql:
image: mysql:5.7
environment:
MYSQL_DATABASE: 'homestead'
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
MYSQL_USER: 'homestead'
MYSQL_PASSWORD: 'secret'
And here is .env:
APP_ENV=local
APP_KEY=ThisIsThe32CharacterKeySecureKey
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret