generated from ddev/ddev-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 13
fix: Install drush without affecting git index #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
96e8fa1
fix: Install drush without affecting git index
rfay 3fac991
Fix merge conflict
rfay 8715755
Add required git user.name etc
rfay cdc627c
@penyaskito suggestions, thanks!
rfay 793c8b2
Remove omit_containers
rfay fbb532e
rerun tests
rfay 40db936
run tests
rfay 29de965
run tests
rfay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
/sites/simpletest | ||
/sites/default/files | ||
/vendor | ||
test_output | ||
test_output | ||
*.orig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,24 +2,40 @@ 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 config --global user.email "[email protected]" | ||
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 | ||
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 +49,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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.