Skip to content

Commit e9f276a

Browse files
authored
Provide docker-compose for running tests and developing Drush (#3691)
1 parent 8d18c59 commit e9f276a

File tree

5 files changed

+83
-5
lines changed

5 files changed

+83
-5
lines changed

.env.example

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This file is for customizing the Docker environment which is used to develop
2+
# Drush. If you are just using Drush to run commands, you may ignore this file
3+
# and docker-compose.yml.
4+
#
5+
# Uncomment to change versions of php and DBs
6+
# POSTGRES_TAG=
7+
# MARIADB_TAG=
8+
# PHP_TAG=
9+
#
10+
# Uncommnt to run tests against a different DB. Defaults to mysql.
11+
# UNISH_DB_URL: pgsql://unish:unish@postgres
12+
# UNISH_DB_URL: sqlite://sut/sites/default/files/.ht.sqlite
13+
#
14+
# XDebug defaults to Off in the php container.
15+
# Uncomment to enable XDebug. See https://wodby.com/stacks/drupal/docs/local/xdebug/.
16+
# When Xdebug first successfully connects back to PHPStorm, you are prompted to create a Server called unish
17+
# Then you are prompted to add path mappings (its mandatory).
18+
# PHP_XDEBUG: 1
19+
# PHP_XDEBUG_DEFAULT_ENABLE: 1
20+
# PHP_IDE_CONFIG: serverName=unish
21+
# PHP_XDEBUG_REMOTE_HOST: host.docker.internal

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Drush is built by people like you! Please [join us](https://github.com/drush-ops/drush).
22

33
## Git and Pull requests
4-
* Contributions are submitted, reviewed, and accepted using GitHub pull requests. [Read this article](https://help.github.com/articles/using-pull-requests) for some details. We use the _Fork and Pull_ model, as described there.
4+
* Contributions are submitted, reviewed, and accepted using GitHub pull requests.
55
* The latest changes are in the `master` branch. PR's should initially target this branch.
66
* Try to make clean commits that are easily readable (including descriptive commit messages!)
7-
* Test before you push. Get familiar with Unish, our test suite. See the test-specific [README.md](tests/README.md)
7+
* Test before you push. Get familiar with Unish, our test suite. See the test-specific [README.md](tests/README.md). Optionally run tests in the provided Docker containers.
88
* We maintain branches named 9.x, 8.x, etc. These are release branches. From these branches, we make new tags for patch and minor versions.
99

1010
## Coding style

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Resources
1515
* Subscribe [this atom feed](https://github.com/drush-ops/drush/releases.atom) to receive notification of new releases. Also, [Version eye](https://www.versioneye.com/).
1616
* [Drush packages available via Composer](https://packagist.org/search/?type=drupal-drush)
1717
* [A list of modules that include Drush integration](https://www.drupal.org/project/project_module?f[2]=im_vid_3%3A4654&solrsort=ds_project_latest_release+desc)
18-
* Drush comes with a [full test suite](https://github.com/drush-ops/drush/blob/master/tests/README.md) powered by [PHPUnit](https://github.com/sebastianbergmann/phpunit). Each commit gets tested by the awesome [Travis CI continuous integration service](https://travis-ci.org/drush-ops/drush).
18+
* Drush comes with a [full test suite](https://github.com/drush-ops/drush/blob/master/tests/README.md) powered by [PHPUnit](https://github.com/sebastianbergmann/phpunit). Each commit gets tested by our CI bots.
1919

2020
Support
2121
-----------

docker-compose.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: "3.1"
2+
3+
services:
4+
# More info at https://github.com/wodby/mariadb
5+
mariadb:
6+
image: wodby/mariadb:${MARIADB_TAG-10.1}
7+
container_name: ${PROJECT_NAME-unish}_mariadb
8+
stop_grace_period: 30s
9+
environment:
10+
MYSQL_ROOT_PASSWORD: password
11+
volumes:
12+
- mariadb-datavolume:/var/lib/mysql
13+
14+
# More info at https://github.com/wodby/php
15+
# We don't want their drupal-php image as that ships with a Drush inside.
16+
php:
17+
image: wodby/php:${PHP_TAG-7.2}
18+
container_name: ${PROJECT_NAME-unish}_php
19+
environment:
20+
PHP_SENDMAIL_PATH: /dev/null
21+
UNISH_DB_URL: ${UNISH_DB_URL-mysql://root:password@mariadb}
22+
UNISH_NO_TIMEOUTS: y
23+
COLUMNS: ${COLUMNS-80} # Set 80 columns for docker exec -it.
24+
## Read instructions at https://wodby.com/stacks/drupal/docs/local/xdebug/
25+
PHP_XDEBUG:
26+
PHP_XDEBUG_DEFAULT_ENABLE:
27+
PHP_IDE_CONFIG:
28+
PHP_XDEBUG_REMOTE_HOST:
29+
volumes:
30+
- ./:/var/www/html:${VOLUME_FLAGS-cached}
31+
32+
# More info at https://github.com/wodby/postgres
33+
postgres:
34+
image: wodby/postgres:${POSTGRES_TAG-10.5}
35+
container_name: unish_postgres
36+
stop_grace_period: 30s
37+
environment:
38+
POSTGRES_PASSWORD: unish
39+
POSTGRES_DB: unish_dev
40+
POSTGRES_USER: unish
41+
volumes:
42+
- postgres-datavolume:/var/lib/postgresql/data
43+
44+
#data volumes https://docs.docker.com/storage/volumes/
45+
volumes:
46+
mariadb-datavolume:
47+
postgres-datavolume:
48+

tests/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Drush's test suite is based on [PHPUnit](http://www.phpunit.de). In order to maintain
1+
Drush's test suite (aka Unish) is based on [PHPUnit](http://www.phpunit.de). In order to maintain
22
high quality, our tests are run on every push.
33

44
- Functional tests at [CircleCi](https://circleci.com/gh/drush-ops/drush)
@@ -10,8 +10,17 @@ Usage
1010
1. Review the configuration settings in [tests/phpunit.xml.dist](phpunit.xml.dist). If customization is needed, copy to phpunit.xml and edit away.
1111
1. Run test suite: `composer test`
1212

13+
Docker
14+
----------
15+
Drush's own tests may be run within provided Docker containers (see docker-compose.yml):
16+
17+
- Start containers: `docker-compose up -d`
18+
- Run a test: `docker-compose exec php composer functional -- --filter testVersionString`
19+
- To change configuration, copy .env.example to .env, edit to taste, and run `docker-compose up -d` again
20+
- See that .env.example file for help on enabling Xdebug.
21+
1322
Advanced usage
1423
---------
1524
- Run only tests matching a regex: `composer functional -- --filter testVersionString`
1625
- Skip slow tests (usually those with network usage): `composer functional -- --exclude-group slow`
17-
- XML results: `composer functional -- --log-junit results.xml`
26+
- XML results: `composer functional -- --log-junit results.xml`

0 commit comments

Comments
 (0)