Repository navigation
Add an optional MySQL or MariaDB service to the Laravel CI - #15
Merged
Merged
Conversation
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
laravel-ci.ymlhad 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 examplemariadb:11.8ormysql:8.4. TheBackend testsandBrowser testsjobs start it as a service on127.0.0.1:3306and wait for its health check. An empty value means no service, as before. SQLite needs none.database-name(new input, defaulttesting): the database that the service creates.DB_HOST,DB_PORT,DB_DATABASE,DB_USERNAMEandDB_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_mysqlis added to the PHP extensions.DB_CONNECTIONstill comes from the caller'sphpunit.xmlor env file.laravel-mariadbandlaravel-mysqlrun migrations against the service. They check the server, the version and the exported values withdb:show --json.AGENTS.mdand the fixtures README describe the inputs. PostgreSQL is not supported.GitHub documents the empty-image behaviour: "If
jobs.<job_id>.services.<service_id>.imageis assigned an empty string, the service will not start."Related issues
None.
Checklist
scripts/check-workflow-docs.py. actionlint and shellcheck run in the Self-checkLintjob.laravel-mariadbandlaravel-mysqlsmoke jobs.