From 96e8fa114770b2dcdad0c081b1b3a7bb815520af Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Wed, 1 May 2024 15:45:00 -0600 Subject: [PATCH 1/8] fix: Install drush without affecting git index --- commands/web/drush | 14 +++++++++++++ core-dev/install_drush.sh | 41 +++++++++++++++++++++++++++++++++++++++ install.yaml | 2 ++ 3 files changed, 57 insertions(+) create mode 100755 commands/web/drush create mode 100755 core-dev/install_drush.sh 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/core-dev/install_drush.sh b/core-dev/install_drush.sh new file mode 100755 index 0000000..f8d9e03 --- /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 + +# 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 apply + +# Get rid of our dummy file +git rm -f .makedrush.txt + +echo "drush/drush is installed in $(which drush)" diff --git a/install.yaml b/install.yaml index 35cf024..2424d76 100644 --- a/install.yaml +++ b/install.yaml @@ -8,8 +8,10 @@ project_files: - core-dev/phpunit-firefox.xml - core-dev/phpunit-chrome.xml - commands/web/drupal + - commands/web/drush - commands/web/phpunit - commands/web/nightwatch + - core-dev/install_drush.sh - core-dev/gitignore - core-dev/.env - core-dev/src/Command/AdminLoginCommand.php From 3fac99170cb9502e91f210e338a7ad59f39ae1aa Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Thu, 23 May 2024 13:07:24 -0600 Subject: [PATCH 2/8] Fix merge conflict --- core-dev/gitignore | 3 ++- tests/test.bats | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) 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/tests/test.bats b/tests/test.bats index 09b4304..5e05f83 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -2,24 +2,38 @@ setup() { set -eu -o pipefail export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.." export TESTDIR=~/tmp/test-ddev-drupal-core-dev - mkdir -p $TESTDIR - export PROJNAME=ddev-drupal-core-dev + rm -rf ${TESTDIR} + mkdir -p ${TESTDIR} + export PROJNAME=test-ddev-drupal-core-dev export DDEV_NON_INTERACTIVE=true ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 || true curl -L -o /tmp/drupal.tar.gz https://ftp.drupal.org/files/projects/drupal-11.x-dev.tar.gz tar --strip-components 1 -zxf /tmp/drupal.tar.gz -C ${TESTDIR} cd "${TESTDIR}" + mv vendor /tmp/vendor.bak + git init && git add . >/dev/null && git commit -m "current" >/dev/null + mv /tmp/vendor.bak vendor ddev config --project-name=${PROJNAME} --upload-dirs=.ddev/tmp ddev config --update ddev start -y >/dev/null + ddev composer install >/dev/null } -health_checks() { - ddev exec "curl -s chrome:7900" | grep "noVNC" - ddev exec "curl -s firefox:7901" | grep "noVNC" +base_checks() { + ddev exec "curl -s chrome:7900" | grep "noVNC" >/dev/null + ddev exec "curl -s firefox:7901" | grep "noVNC" >/dev/null ddev phpunit core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php } +drush_checks() { + # Make sure there's nothing in the git index before drush install + git diff --cached --quiet + ddev drush st + # Make sure there's nothing after the drush install + git diff --cached --quiet || (echo "git index has been touched" && exit 2) + ddev drush si -y --account-pass=admin +} + teardown() { set -eu -o pipefail cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) @@ -33,7 +47,8 @@ teardown() { echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 ddev get ${DIR} ddev restart - health_checks + base_checks + drush_checks } #TODO: Re-enable release tests after the add-on has a release with DDEV v1.23.0 support From 87157555b1154f333b4fc0e73335f23e3e4f5061 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Wed, 1 May 2024 17:25:59 -0600 Subject: [PATCH 3/8] Add required git user.name etc --- tests/test.bats | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test.bats b/tests/test.bats index 5e05f83..11e4241 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -11,6 +11,8 @@ setup() { tar --strip-components 1 -zxf /tmp/drupal.tar.gz -C ${TESTDIR} cd "${TESTDIR}" mv vendor /tmp/vendor.bak + git config --global user.email "example@example.com" + git config --global user.name "Example Example" git init && git add . >/dev/null && git commit -m "current" >/dev/null mv /tmp/vendor.bak vendor ddev config --project-name=${PROJNAME} --upload-dirs=.ddev/tmp From cdc627c480732f375a47586821460f861573119f Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Wed, 1 May 2024 18:37:24 -0600 Subject: [PATCH 4/8] @penyaskito suggestions, thanks! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Christian López Espínola --- core-dev/install_drush.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-dev/install_drush.sh b/core-dev/install_drush.sh index f8d9e03..0ca2ba6 100755 --- a/core-dev/install_drush.sh +++ b/core-dev/install_drush.sh @@ -23,7 +23,7 @@ git add .makedrush.txt git stash # Install drush -composer require drush/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 @@ -33,7 +33,7 @@ git reset --hard # Restore anything that might have been staged # prior to the start -git stash apply +git stash pop # Get rid of our dummy file git rm -f .makedrush.txt From 793c8b27b1284b67e1eba18dd79ed7d74bfe7bdb Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Thu, 23 May 2024 13:25:43 -0600 Subject: [PATCH 5/8] Remove omit_containers --- config.ddev-drupal-core-dev.yaml | 1 - 1 file changed, 1 deletion(-) 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. From fbb532e78006c0e82614d91d7e42a2c2623fac95 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Thu, 23 May 2024 13:34:47 -0600 Subject: [PATCH 6/8] rerun tests From 40db93613110091f915284019e3c3424423fc1ac Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Fri, 24 May 2024 07:57:12 -0600 Subject: [PATCH 7/8] run tests From 29de965362378d10b9ed2da1534c787da98797db Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Sun, 26 May 2024 07:10:49 -0600 Subject: [PATCH 8/8] run tests