Skip to content

Add an optional MySQL or MariaDB service to the Laravel CI - #15

Merged
PavlosIsaris merged 1 commit into
mainfrom
feat/database-service
Oct 23, 2026
Merged

PavlosIsaris merged 1 commit into
mainfrom
feat/database-service

Conversation

@PavlosIsaris

Copy link
Copy Markdown
Member

Summary

laravel-ci.yml had no database service, so a repository whose tests need MySQL or MariaDB could not use it. Mentorship-matching-backend is one example: a migration drops a primary key column, and its filter SQL uses MySQL date arithmetic. This PR adds an optional service.

  • database-image (new input), for example mariadb:11.8 or mysql:8.4. The Backend tests and Browser tests jobs start it as a service on 127.0.0.1:3306 and wait for its health check. An empty value means no service, as before. SQLite needs none.
  • database-name (new input, default testing): the database that the service creates.
  • First step in both test jobs: it exports DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and DB_PASSWORD. It stops with a clear message for an image that is not MySQL or MariaDB, and GitHub starts no container for such an image. pdo_mysql is added to the PHP extensions.
  • DB_CONNECTION still comes from the caller's phpunit.xml or env file.
  • New smoke jobs: laravel-mariadb and laravel-mysql run migrations against the service. They check the server, the version and the exported values with db:show --json.
  • Docs: the guide, the template, AGENTS.md and the fixtures README describe the inputs. PostgreSQL is not supported.

GitHub documents the empty-image behaviour: "If jobs.<job_id>.services.<service_id>.image is assigned an empty string, the service will not start."

Related issues

None.

Checklist

  • The change is limited to the topic in the title.
  • Local checks pass: scripts/check-workflow-docs.py. actionlint and shellcheck run in the Self-check Lint job.
  • Tests cover the new behaviour: the laravel-mariadb and laravel-mysql smoke jobs.
  • Documentation is updated where the behaviour changed.
  • No secrets or personal data are included.

Repositories whose tests need MySQL or MariaDB could not use laravel-ci.yml:
it had no database service, so they kept their own CI.

- New input database-image (for example mariadb:11.8 or mysql:8.4). The
  Backend tests and Browser tests jobs start it as a service on
  127.0.0.1:3306 and wait for its health check. Empty means no service,
  as before; SQLite needs none.
- New input database-name (default testing): the database that the
  service creates.
- A first step exports DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and
  DB_PASSWORD for every later step, and fails with a message for an image
  that is not MySQL or MariaDB. pdo_mysql is added to the PHP extensions.
- The caller's phpunit.xml or env file still chooses DB_CONNECTION.
- Self-check: laravel-mariadb and laravel-mysql run migrations against the
  service and check the server, version and exported values with
  db:show --json.
- Guide, template, AGENTS.md and the fixtures README describe the inputs.
  PostgreSQL is not supported.
@PavlosIsaris
PavlosIsaris merged commit 41c7303 into main Oct 23, 2026
36 checks passed
@PavlosIsaris
PavlosIsaris deleted the feat/database-service branch October 23, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant