Runs Drupal webtests and php unit tests using Docker containers. This can be used with Git webhooks but its not ready yet.
The parameters for the runtests.php script are:
- --project Project or module name
- --version Project version or branch name [optional]. The format is the same as used in Composer
- --vcs Fork url [optional]
- --profile Drupal install profile [optional]
- --patches Specifies a list of patches to be applied. See example below.
- --dependencies List of test dependencies [optional] i.e. "drupal/link:* drupal/email:^1.0"
Run tests from a released version of the AdsTxt module
docker pull marcelovani/drupalci:12-apache
docker run --name drupalci --rm marcelovani/drupalci:12-apache \
--project adstxt \
--version ^1.0.0Run tests from the a released version of AdsTxt module
docker pull marcelovani/drupalci:11-apache
docker run --name drupalci --rm marcelovani/drupalci:11-apache \
--project adstxt \
--version ^1.0.0Run tests from the a released version of AdsTxt module
docker pull marcelovani/drupalci:9-apache
docker run --name drupalci --rm marcelovani/drupalci:9-apache \
--project adstxt \
--version ^1.0.0Run tests from the a released version of Captcha Keypad module
docker pull marcelovani/drupalci:8-apache
docker run --name drupalci --rm marcelovani/drupalci:8-apache \
--project captcha_keypad \
--version ^1.0.0docker pull marcelovani/drupalci:7-apache
docker run --name drupalci --rm marcelovani/drupalci:7-apache \
--project captcha_keypad \
--version ^1.0.0The container will not run tests automatically. It is useful to perform manual tasks for the purposes of debugging.
Starting the server
docker run --rm --name drupalci -p 8080:80 -d marcelovani/drupalci:11-apache-interactiveUsing a mounted folder for a custom module, in this example we are using adstxt module
docker run --rm --name drupalci -v ~/adstxt:/var/www/html/web/modules/contrib/adstxt -p 8080:80 -d marcelovani/drupalci:11-apache-interactiveGetting into the container
docker exec -it drupalci bashRunning tests manually
cd web
sudo -u www-data php core/scripts/drupal install minimal
sudo -u www-data php core/scripts/run-tests.sh --php /usr/local/bin/php --verbose --keep-results --color --concurrency "32" --repeat "1" --types "Simpletest,PHPUnit-Unit,PHPUnit-Kernel,PHPUnit-Functional" --sqlite sites/default/files/.ht.sqlite --url http://localhost --directory "modules/contrib/adstxt"
To install the site using sql lite and Drush, use
drush si --db-url=sqlite://:memory
See more details in https://www.drush.org/12.x/commands/site_install
Opening in the browser
open http://localhost:8080Stopping the container
docker stop drupalciTo run tests from the a forked branch you can use --version with the branch. See Non feature branches. You can also specify the repository using --vcs.
docker pull marcelovani/drupalci:8-apache
docker run --name drupalci --rm marcelovani/drupalci:8-apache \
--project captcha_keypad \
--version dev-8.x-1.x \
--vcs https://github.com/marcelovani/captcha_keypad.gitYou can provide a list of patches to be applied to the project.
docker pull marcelovani/drupalci:7-apache
docker run --name drupalci --rm marcelovani/drupalci:7-apache \
--project amp \
--version dev-1.x \
--patches https://www.drupal.org/files/issues/2019-02-11/amp-initial-page-load-3031306-18.patchFor multiple patches, each Url needs to be separated by comma.
docker run --name drupalci --rm marcelovani/drupalci:7-apache \
--project captcha_keypad \
--version dev-1.x \
--patches "https://www.example.com/fix-1.patch, https://www.example.com/fix-2.patch"Used to install test dependencies or any additional package.
docker run --name drupalci --rm marcelovani/drupalci:7-apache \
--project amp \
--version dev-1.x \
--dependencies "drupal/media:* \
drupal/ctools:* \
drupal/token:* \
drupal/google_analytics:* \
drupal/dfp:* \
drupal/context:* \
drupal/adsense:*"You can mount the verbose folder using -v, then you can see the generated output.
docker run -v ~/Downloads/artifacts:/artifacts --name drupalci --rm marcelovani/drupalci:8-apache \
--project sharerich \
--version dev-1.x \
--dependencies "drupal/token:*"
ls ~/Downloads/artifactsCopy the .circleci folder into your module, remame config.yml.example to config.yml and enable Circle CI for your project. When you make commits it will automatically trigger the build an you will be able to access the verbose results via Artifacts tab on Circle CI.
Building images
make build
Building and deploying
make deploy
You can use these images on jenkins to automate your buildings
- Docker (with
docker buildxsupport) - GNU Make
- Git
drupalci/
├── Makefile # Top-level targets: build, deploy, test, test-N
├── build_all.sh # Runs every build_N.sh in order
├── build_deploy_all.sh # Pushes every image to Docker Hub
├── build_N.sh # Builds the two images for Drupal version N
├── update.sh # Copies shared files from templates/ into each N/apache/
├── update_11.sh (optional) # Version-specific overrides (sqlite.patch etc.)
├── templates/
│ ├── bootstrap.php # Shared across all versions
│ ├── entrypoint.sh # Shared across all versions
│ ├── php-overrides.ini # Shared PHP ini tweaks
│ └── N/
│ └── runtests.php # Version-specific test runner script
├── N/
│ ├── apache/
│ │ ├── Dockerfile # Main image (extends official drupal:N-phpX.Y-apache)
│ │ ├── bootstrap.php # Copied from templates/ by update.sh
│ │ ├── entrypoint.sh # Copied from templates/ by update.sh
│ │ ├── php-overrides.ini # Copied from templates/ by update.sh
│ │ ├── runtests.php # Copied from templates/N/ by update.sh
│ │ └── README.md # Copied from root README.md by update.sh
│ └── apache-interactive/
│ └── Dockerfile # Thin layer — extends marcelovani/drupalci:N-apache
└── tests/ # Chrome Driver smoke tests
update.sh is the source-of-truth copier. It pushes shared files (bootstrap.php,
entrypoint.sh, php-overrides.ini, README.md) into every N/apache/ directory,
then copies the version-specific templates/N/runtests.php to N/apache/.
Always edit templates, never the copies inside N/apache/ — they will be
overwritten next time update.sh runs (which build_all.sh calls automatically).
# Refresh all template copies first
./update.sh
# Build just Drupal 11
./build_11.sh
# Or build and tag manually
cd 11/apache
docker buildx build --force-rm -t marcelovani/drupalci:11-apache .make test-11This pulls nothing — it runs the locally-built image against a known module.
make build # ./build_all.sh (runs update.sh + every build_N.sh)
make test # smoke-tests every version
make deploy # docker push all images to Docker Hub (requires docker login)The following steps are required. Each one mirrors what was done when Drupal 11 was added alongside Drupal 10.
-
Create the directory structure
12/apache/ 12/apache-interactive/ templates/12/ -
Add
templates/12/runtests.phpCopy fromtemplates/11/runtests.phpand adjust any version-specific flags (e.g.--suppress-deprecationsstrategy, PHP constraint). -
Add
12/apache/DockerfileCopy from11/apache/Dockerfile.
Key changes:FROM drupal:12-php8.3-apache(adjust PHP version when official image is published)ENV DRUPAL_VERSION=12- Verify whether
sqlite.patchis still needed (it was introduced for D11) - Update
composer create-projectconstraint to^12
-
Add
12/apache-interactive/DockerfileCopy from11/apache-interactive/Dockerfileand replace11→12. -
Add
build_12.shCopy frombuild_11.shand replace11→12. -
Update
update.shAdd lines to copy shared templates into12/apache/:cp README.md ./12/apache cp templates/bootstrap.php ./12/apache cp templates/entrypoint.sh ./12/apache cp templates/php-overrides.ini ./12/apache cp templates/12/runtests.php ./12/apache
-
Update
build_all.shAddsh build_12.shafter thebuild_11.shcall. -
Update
build_deploy_all.shAdd push commands for12-apacheand12-apache-interactive. -
Update
Makefile- Add
make test-12target - Add
make test-12to thetest:target
- Add
-
Update
README.md- Add a Drupal 12 usage example under "Usage examples"
- Update the "Currently, there is support for..." line in Contributing
Each version of Drupal has its own Dockerfile with customisations. The templates folder contains the commands for each Drupal and bootstrap. Currently, there is support for Drupal 7, 8, 9, 10 and 11.
To build all, upgrading packages, use make build
To deploy all, use make deploy
To build and deploy all, use make build-deploy
ps: Deploy will push the image to Docker hub.
To test all, use make test
To test individual Drupal, use specific Drupal version make test-10
ps: Always test all Drupal versions before deploying.
You can use Drupal CI Chrome driver to run Functional Javascript tests.
docker run --rm --name chromedriver -p 9515:9515 -d drupalci/webdriver-chromedriver:productionAlternatively you can use Selenium, see lando/drupal#27
Starting the Chrome Driver server locally
npm install
npm startThen test if Chrome Driver is working
npm testLooking at the Chrome Driver logs
docker run --rm --name chromedriver -p 9515:9515 -d drupalci/webdriver-chromedriver:production
Alternatively you can use Selenium, see https://github.com/lando/drupal/issues/27
#### Chrome Driver - Local Development
Starting the Chrome Driver server locally
```bash
npm install
npm start
`npm start
Then test if Chrome Driver is working
npm testLooking at the Chrome Driver logs
npm run show_logs