Composer Plugin to prepare Drupal project for CI and/or local tests.
This package is auto-updated.
Last update: 2022-09-03 16:37:03 UTC
This project needs a new name and a new home (ideally managed by the Drupal Association). This plugin has 2 goals:
- CI template. Provide a golden path (see Spotify's definition of this term) that Drupal contrib projects can use with Gitlab CI.
- Local development. Standardize scripts and a matching codebase assembly for local Drupal development.
Together, these goals ensure that tests run on local environment have same outcome as on the Gitlab CI platform (to a large extent).
- Add a
.gitlab-ci.ymlin the project root dir. An example is KeyCDN. Commit and push the file.
- Pipelines should start running after each push. Click Gitlab's CI/CD link to see them.
- Add a phpcs.xml file to customize how phpcs checks your source code.
- You may add services to your .gitlab-ci.yml file if you want to test with memcache, elasticsearch, redis, etc.
- Optional. Add patches as per usual in composer.json if you need changes in other packages (for example).
- Optional (maintainers only). Go to CI/CD => Schedules and add any important build permutations to a weekly schedule. Example permutations would be a non-default Drupal core version, DB backend, etc. For example, see KeyCDN's schedules. See Environment Variables below.
Use the Run Pipeline button on your Pipelines listing to test any branch with alternate versions of Drupal core, PHP version, or DB driver. The recognized variables and default values are:
- DB_DRIVER recognizes
- Clone the contrib project via git
- Install this plugin (syntax depends on your shell):
- BASH or ZSH:
bash <(curl -s https://gitlab.com/drupalspoons/composer-plugin/-/raw/master/bin/setup)
bash (curl -s https://gitlab.com/drupalspoons/composer-plugin/-/raw/master/bin/setup | psub)
- BASH or ZSH:
- Configure a web server to serve the
/webdirectory as docroot. Either of these works fine:
- Setup Apache/Nginx/Other. A virtual host works fine. Any domain name works.
- Configure a database server and create a database.
- Install Drupal
composer si -- --db-url=mysql://user:pass@localhost/db. Adjust as needed.
- Run tests
- Customize these composer scripts via environment variables and args/options. See the table above.
This plugin is compatible with any Docker local development platform like DDEV, Lando, etc. Further, this plugin doesn't assume Docker so native is great too. A convenient way to set environment variables on native is Direnv (and see the .envrc file thats written into your project root). Alternatively, prefix all Composer commands with spoon like
spoon update or
spoon drush core:status
Handling project changes
- If the project's composer.json changes or if files are added/removed from project root:
- If new or updated dependencies are available
More example commands
- Run all tests -
- Run a suite:
composer unit -- --testsuite functional
- Skip slow tests:
composer unit -- --exclude-group slow
- Use a different URL:
SIMPLETEST_BASE_URL=http://example.com composer unit
How this plugin works
- This plugin writes a
composer.spoons.jsonfile that includes the specified version of Drupal core.
- The plugin assumes that
composer.spoons.jsonis in effect when running
composercommands. This is done automatically for CI. For local development,
COMPOSER=composer.spoons.jsonenvironment variable must be set. You can do that manually or via Direnv, or Docker, or spoon.
- This plugin assembles a codebase using symlinks similar to: