diff --git a/README.md b/README.md index 2721e7e..f3737cf 100644 --- a/README.md +++ b/README.md @@ -4,20 +4,21 @@ This is a DDEV addon for doing Drupal core development. 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 🙏) +`ddev drush` is fully supported, along with using or testing MariaDB, MySQL, and PostgreSQL databases (and Sqlite3) + + ``` git clone https://git.drupalcode.org/project/drupal.git drupal cd drupal -ddev config --omit-containers=db --disable-settings-management -ddev start +ddev config --project-type=drupal ddev get justafish/ddev-drupal-core-dev ddev restart ddev composer install +ddev config --update -# See included commands -ddev drupal list # Install drupal -ddev drupal install +ddev drush si -y --account-pass==admin # Run PHPUnit tests ddev phpunit core/modules/sdc @@ -26,6 +27,22 @@ ddev phpunit core/modules/sdc ddev nightwatch --tag core ``` +## Using various database types + +By default, the DDEV default database type is used (MariaDB). + +To use another supported database type, +`ddev delete -Oy` and `ddev config --database=mysql:8.0` or `ddev config --database=postgres:16` for example. + +To use Sqlite, +``` +ddev stop +ddev config --disable-settings-management --omit-containers=db +rm -rf web/sites/default/settings*.php web/sites/default/files +ddev start +ddev drupal install +``` + ## Nightwatch Examples You can watch Nightwatch running in real time at https://drupal.ddev.site:7900 diff --git a/commands/web/drush b/commands/web/drush new file mode 100755 index 0000000..225729b --- /dev/null +++ b/commands/web/drush @@ -0,0 +1,14 @@ +#!/bin/bash + +#ddev-generated +## Description: Run drush CLI inside the web container, installing it if necessary +## Usage: drush [flags] [args] +## Example: "ddev drush uli" or "ddev drush sql-cli" or "ddev drush --version" +## ProjectTypes: drupal7,drupal8,drupal9,drupal10,drupal,backdrop +## ExecRaw: true + +if ! command -v drush >/dev/null; then + echo "drush is not yet installed. Installing it...'" + .ddev/core-dev/install_drush.sh +fi +drush "$@" diff --git a/config.core-dev.yaml b/config.core-dev.yaml new file mode 100644 index 0000000..1f71985 --- /dev/null +++ b/config.core-dev.yaml @@ -0,0 +1,31 @@ +# #ddev-generated +# This file is placed by the justafish/ddev-drupal-core-dev addon. + +webimage_extra_packages: ["chromium-driver"] +ddev_version_constraint: '>=v1.23.0' +hooks: + post-start: + - exec: | + dburl='sqlite://localhost/sites/default/files/db.sqlite' + cp .ddev/core-dev/phpunit-chrome.xml core/phpunit.xml + cp .ddev/core-dev/.env core/.env + if ping -c 1 db >/dev/null 2>&1; then + case ${DDEV_DATABASE_FAMILY:-} in + mysql) + # the backslash here is to prevent perl from eating the @ + dburl='mysql://db:db\@db/db' + ;; + postgres) + dburl='pgsql://db:db\@db/db' + ;; + esac + fi + perl -pi -e "s|SIMPLETEST_DB_VALUE|${dburl}|g" core/phpunit.xml + perl -pi -e "s|DRUPAL_TEST_DB_URL_VALUE|${dburl}|g" core/.env + perl -pi -e "s|DRUPAL_CORE_DDEV_URL|${DDEV_PRIMARY_URL}|g" core/phpunit.xml + +upload_dirs: + # The install technique tries to remove all of sites/default/files + # but with DDEV + mutagen that isn't possible. + # so just redirect the upload_dirs. + - .ddev/tmp diff --git a/config.ddev-drupal-core-dev.yaml b/config.ddev-drupal-core-dev.yaml index ee664a2..6c12f31 100644 --- a/config.ddev-drupal-core-dev.yaml +++ b/config.ddev-drupal-core-dev.yaml @@ -3,7 +3,6 @@ webimage_extra_packages: ["chromium-driver"] ddev_version_constraint: '>=v1.23.1' -omit_containers: ["db"] upload_dirs: # The install technique tries to remove all of sites/default/files # but with DDEV + mutagen that isn't possible. diff --git a/core-dev/.env b/core-dev/.env index 9a54fb3..2b5901d 100644 --- a/core-dev/.env +++ b/core-dev/.env @@ -19,7 +19,7 @@ DRUPAL_TEST_BASE_URL=http://web # By default we use sqlite as database. Use # mysql://username:password@localhost/databasename#table_prefix for mysql. -DRUPAL_TEST_DB_URL=sqlite://localhost/sites/default/files/db.sqlite +DRUPAL_TEST_DB_URL=DRUPAL_TEST_DB_URL_VALUE ############# # Webdriver # diff --git a/core-dev/gitignore b/core-dev/gitignore index 478bb7d..fca00cc 100644 --- a/core-dev/gitignore +++ b/core-dev/gitignore @@ -6,4 +6,5 @@ /sites/simpletest /sites/default/files /vendor -test_output \ No newline at end of file +test_output +*.orig diff --git a/core-dev/install_drush.sh b/core-dev/install_drush.sh new file mode 100755 index 0000000..0ca2ba6 --- /dev/null +++ b/core-dev/install_drush.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +#ddev-generated +# This script installs drush/drush without changing the git +# status of the Drupal checkout + +set -eu -o pipefail + +if command -v drush >/dev/null; then + echo "drush is already installed, taking no action. You can remove it if you want to reinstall" + exit +fi + +echo "Installing drush without affecting git status" + +# Make certain that we have something staged so we can create stash +touch .makedrush.txt +git add .makedrush.txt + +# Save the stash, which will include anything people were doing +# plus the .makedrush.txt. This gets us back to "no changes" +# in `git status` +git stash + +# Install drush +composer require drush/drush --with-dependencies + +# Roll back to what we started with. Cleans up +# composer.* and anything else that the drush install changes +# But vendor directory is untouched since +# it's gitignored +git reset --hard + +# Restore anything that might have been staged +# prior to the start +git stash pop + +# Get rid of our dummy file +git rm -f .makedrush.txt + +echo "drush/drush is installed in $(which drush)" diff --git a/core-dev/phpunit-chrome.xml b/core-dev/phpunit-chrome.xml index a4888bd..b4f1a5a 100644 --- a/core-dev/phpunit-chrome.xml +++ b/core-dev/phpunit-chrome.xml @@ -23,8 +23,7 @@ - - + - - +