Skip to content

Commit 0d8d9b1

Browse files
committed
feat: Allow installing and testing with all database types
1 parent 94b8a5d commit 0d8d9b1

File tree

7 files changed

+57
-25
lines changed

7 files changed

+57
-25
lines changed

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ This is a DDEV addon for doing Drupal core development.
44

55
We're in #ddev-for-core-dev on [Drupal Slack](https://www.drupal.org/community/contributor-guide/reference-information/talk/tools/slack) (but please try and keep work and feature requests in Issues where it's visible to all 🙏)
66

7+
`ddev drush` is fully supported, along with using or testing MariaDB, MySQL, and PostgreSQL databases (and Sqlite3)
8+
9+
710
```
811
git clone https://git.drupalcode.org/project/drupal.git drupal
912
cd drupal
10-
ddev config --project-type=drupal10
11-
ddev start
12-
ddev corepack enable
13+
ddev config --project-type=drupal
1314
ddev get justafish/ddev-drupal-core-dev
1415
ddev restart
1516
ddev composer install
17+
ddev config --update
1618
17-
# See included commands
18-
ddev drupal list
1919
2020
# Install drupal
21-
ddev drupal install
21+
ddev drush si -y --account-pass==admin
2222
2323
# Run PHPUnit tests
2424
ddev phpunit core/modules/sdc
@@ -27,6 +27,22 @@ ddev phpunit core/modules/sdc
2727
ddev nightwatch --tag core
2828
```
2929

30+
## Using various database types
31+
32+
By default, the DDEV default database type is used (MariaDB).
33+
34+
To use another supported database type,
35+
`ddev delete -Oy` and `ddev config --database=mysql:8.0` or `ddev config --database=postgres:16` for example.
36+
37+
To use Sqlite,
38+
```
39+
ddev stop
40+
ddev config --disable-settings-management --omit-containers=db
41+
rm -rf web/sites/default/settings*.php web/sites/default/files
42+
ddev start
43+
ddev drupal install
44+
```
45+
3046
## Nightwatch Examples
3147

3248
You can watch Nightwatch running in real time at https://drupal.ddev.site:7900

config.core-dev.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# #ddev-generated
2+
# This file is placed by the justafish/ddev-drupal-core-dev addon.
3+
4+
webimage_extra_packages: ["chromium-driver"]
5+
ddev_version_constraint: '>=v1.23.0'
6+
hooks:
7+
post-start:
8+
- exec: |
9+
dburl='sqlite://localhost/sites/default/files/db.sqlite'
10+
cp .ddev/core-dev/phpunit-chrome.xml core/phpunit.xml
11+
cp .ddev/core-dev/.env core/.env
12+
if ping -c 1 db >/dev/null 2>&1; then
13+
case ${DDEV_DATABASE_FAMILY:-} in
14+
mysql)
15+
# the backslash here is to prevent perl from eating the @
16+
dburl='mysql://db:db\@db/db'
17+
;;
18+
postgres)
19+
dburl='pgsql://db:db\@db/db'
20+
;;
21+
esac
22+
fi
23+
perl -pi -e "s|SIMPLETEST_DB_VALUE|${dburl}|g" core/phpunit.xml
24+
perl -pi -e "s|DRUPAL_TEST_DB_URL_VALUE|${dburl}|g" core/.env
25+
perl -pi -e "s|DRUPAL_CORE_DDEV_URL|${DDEV_PRIMARY_URL}|g" core/phpunit.xml
26+
27+
upload_dirs:
28+
# The install technique tries to remove all of sites/default/files
29+
# but with DDEV + mutagen that isn't possible.
30+
# so just redirect the upload_dirs.
31+
- .ddev/tmp

config.ddev-drupal-core-dev.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

core-dev/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DRUPAL_TEST_BASE_URL=http://web
1919

2020
# By default we use sqlite as database. Use
2121
# mysql://username:password@localhost/databasename#table_prefix for mysql.
22-
DRUPAL_TEST_DB_URL=sqlite://localhost/sites/default/files/db.sqlite
22+
DRUPAL_TEST_DB_URL=DRUPAL_TEST_DB_URL_VALUE
2323

2424
#############
2525
# Webdriver #

core-dev/phpunit-chrome.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<!-- Do not limit the amount of memory tests take to run. -->
2424
<ini name="memory_limit" value="-1"/>
2525
<env name="SIMPLETEST_BASE_URL" value="DRUPAL_CORE_DDEV_URL"/>
26-
<env name="SIMPLETEST_DB" value="mysql://db:db@db/db"/>
26+
<env name="SIMPLETEST_DB" value="SIMPLETEST_DB_VALUE"/>
2727
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/html/test_output"/>
2828
<!-- By default, browser tests will output links that use the base URL set
2929
in SIMPLETEST_BASE_URL. However, if your SIMPLETEST_BASE_URL is an internal

core-dev/phpunit-firefox.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<!-- Do not limit the amount of memory tests take to run. -->
2424
<ini name="memory_limit" value="-1"/>
2525
<env name="SIMPLETEST_BASE_URL" value="DRUPAL_CORE_DDEV_URL"/>
26-
<env name="SIMPLETEST_DB" value="mysql://db:db@db/db"/>
26+
<env name="SIMPLETEST_DB" value="SIMPLETEST_DB_VALUE"/>
2727
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/html/test_output"/>
2828
<!-- By default, browser tests will output links that use the base URL set
2929
in SIMPLETEST_BASE_URL. However, if your SIMPLETEST_BASE_URL is an internal

install.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: ddev-drupal-core-dev
44

55
project_files:
66
- web-build/Dockerfile
7-
- config.ddev-drupal-core-dev.yaml
7+
- config.core-dev.yaml
88
- docker-compose.core-dev-selenium.yaml
99
- core-dev/phpunit-firefox.xml
1010
- core-dev/phpunit-chrome.xml
@@ -23,14 +23,9 @@ project_files:
2323
- core-dev/src/Command/UninstallCommand.php
2424

2525
post_install_actions:
26-
- cp core-dev/phpunit-chrome.xml ../core/phpunit.xml
27-
- perl -pi -e "s|DRUPAL_CORE_DDEV_URL|$DDEV_PRIMARY_URL|g" ../core/phpunit.xml
28-
- cp core-dev/.env ../core/.env
2926
- cp core-dev/gitignore ../.gitignore
3027
- mkdir -p ../test_output
3128
- chmod +w ../test_output
32-
- ddev exec corepack enable
33-
- cd ../core && ddev yarn
3429

3530
removal_actions:
3631
- |

0 commit comments

Comments
 (0)