Example .gitlab-ci.yml for Laravel 12 with MariaDB that seeds database before running php artisan test

1 week ago 4
ARTICLE AD BOX

I’m setting up a GitLab Runner for a Laravel 12 project and I want my CI pipeline to do the following:

Spin up a MariaDB service for the tests Run php artisan migrate:fresh --seed to seed the database Finally run php artisan test

I’ve already registered my runner and can run jobs, but I’m not sure how to correctly structure the .gitlab-ci.yml file so that the database is available and seeded before the tests execute. I wasted a lot of hours for this.

Question: Does anyone have a working example of a .gitlab-ci.yml file that only runs php artisan test for a Laravel 12 app with MariaDB, ensuring the database is seeded first with php artisan migrate:fresh --seed?

Read Entire Article