Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates-3449631
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
automatic_updates-3449631
Commits
c98cb4a5
Commit
c98cb4a5
authored
2 years ago
by
Travis Carden
Committed by
Ted Bowman
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3307103
by tedbow: Make setup_local_dev.sh configure PHPUnit, and other enhancements
parent
e04ddbc4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
scripts/setup_local_dev.sh
+71
-33
71 additions, 33 deletions
scripts/setup_local_dev.sh
with
72 additions
and
33 deletions
.gitignore
+
1
−
0
View file @
c98cb4a5
/.idea
/auto-updates-dev
/auto-updates-dev
This diff is collapsed.
Click to expand it.
scripts/setup_local_dev.sh
+
71
−
33
View file @
c98cb4a5
...
@@ -12,28 +12,45 @@
...
@@ -12,28 +12,45 @@
# installing the module and its dependencies. It does NOT set up a web
# installing the module and its dependencies. It does NOT set up a web
# server or install Drupal in a database.
# server or install Drupal in a database.
# GNU realpath can't be depended upon to always be available. Simulate it.
# https://stackoverflow.com/questions/3572030/bash-script-absolute-path-with-os-x
safe_realpath
()
{
[[
$1
=
/
*
]]
&&
echo
"
$1
"
||
echo
"
$PWD
/
${
1
#./
}
"
}
# Customizations: set any of these environment variables in your shell (i.e.,
# Customizations: set any of these environment variables in your shell (i.e.,
# your terminal session) to override their default values.
# your terminal session) to override their default values.
# @see https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-set-environment-variables-in-linux/
# @see https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-set-environment-variables-in-linux/
# Variables beginning with an underscore (_) cannot be overridden.
DRUPAL_CORE_BRANCH
=
${
DRUPAL_CORE_BRANCH
:
=
"9.5.x"
}
DRUPAL_CORE_BRANCH
=
${
DRUPAL_CORE_BRANCH
:
=
"9.5.x"
}
DRUPAL_CORE_SHALLOW_CLONE
=
${
DRUPAL_CORE_SHALLOW_CLONE
:
=
"TRUE"
}
DRUPAL_CORE_SHALLOW_CLONE
=
${
DRUPAL_CORE_SHALLOW_CLONE
:
=
"TRUE"
}
AUTOMATIC_UPDATES_BRANCH
=
${
AUTOMATIC_UPDATES_BRANCH
:
=
"8.x-2.x"
}
AUTOMATIC_UPDATES_BRANCH
=
${
AUTOMATIC_UPDATES_BRANCH
:
=
"8.x-2.x"
}
SITE_DIRECTORY
=
${
SITE_DIRECTORY
:
=
"auto_updates_dev"
}
SITE_DIRECTORY
=
${
SITE_DIRECTORY
:
=
"auto_updates_dev"
}
SITE_HOST
=
${
SITE_HOST
:
=
"
$SITE_DIRECTORY
.test"
}
_SITE_DIRECTORY_REALPATH
=
$(
safe_realpath
"
$SITE_DIRECTORY
"
)
_SITE_DIRECTORY_BASENAME
=
$(
basename
"
$_SITE_DIRECTORY_REALPATH
"
)
# GNU realpath can't be depended upon to always be available. Simulate it.
SITE_HOST
=
${
SITE_HOST
:
=
"
$_SITE_DIRECTORY_BASENAME
.test"
}
# https://stackoverflow.com/questions/3572030/bash-script-absolute-path-with-os-x
safe_realpath
()
{
MODULE_CLONE_DIRECTORY
=
"modules/contrib/automatic_updates"
[[
$1
=
/
*
]]
&&
echo
"
$1
"
||
echo
"
$PWD
/
${
1
#./
}
"
}
# Handle command-line options. (Usable when run from a local clone.)
while
getopts
":fn"
option
;
do
SITE_DIRECTORY_REALPATH
=
$(
safe_realpath
"
$SITE_DIRECTORY
"
)
case
$option
in
f
)
# Force: delete existing site directory, if present.
FORCE
=
"TRUE"
;;
n
)
# No interaction: skip prompt and continue automatically.
NO_INTERACTION
=
"TRUE"
;;
esac
done
# Prevent the user from losing work in case the site directory already exists.
# Prevent the user from losing work in case the site directory already exists.
if
test
-e
"
$SITE_DIRECTORY
"
;
then
if
test
-e
"
$SITE_DIRECTORY
"
;
then
cat
<<
DANGER
if
test
!
"
$FORCE
"
;
then
# Exit with a warning.
cat
<<
DANGER
$(
printf
"
\e
[1;41m DANGER!
\e
[0m
\e
[33m"
)
"
$SITE_DIRECTORY_REALPATH
" already exists.
$(
printf
"
\e
[1;41m DANGER!
\e
[0m
\e
[33m"
)
"
$
_
SITE_DIRECTORY_REALPATH
" already exists.
$(
printf
"
\e
[1;41m
\e
[0m"
)
$(
printf
"
\e
[1;41m
\e
[0m"
)
$(
printf
"
\e
[1;41m
\e
[0m"
)
If you destroy it, any changes to the Automatic Updates module inside it will be lost forever.
$(
printf
"
\e
[1;41m
\e
[0m"
)
If you destroy it, any changes to the Automatic Updates module inside it will be lost forever.
$(
printf
"
\e
[1;41m
\e
[0m"
)
Consider moving the directory to another location as a backup instead.
$(
printf
"
\e
[1;41m
\e
[0m"
)
Consider moving the directory to another location as a backup instead.
...
@@ -41,25 +58,32 @@ $(printf "\e[1;41m \e[0m")
...
@@ -41,25 +58,32 @@ $(printf "\e[1;41m \e[0m")
$(
printf
"
\e
[1;41m
\e
[0m"
)
Otherwise, if you know what you're doing and still want to continue, make sure any changes you want to
$(
printf
"
\e
[1;41m
\e
[0m"
)
Otherwise, if you know what you're doing and still want to continue, make sure any changes you want to
$(
printf
"
\e
[1;41m
\e
[0m"
)
keep have been committed and pushed to an appropriate remote. Then delete the directory and try again:
$(
printf
"
\e
[1;41m
\e
[0m"
)
keep have been committed and pushed to an appropriate remote. Then delete the directory and try again:
$(
printf
"
\e
[1;41m
\e
[0m"
)
$(
printf
"
\e
[1;41m
\e
[0m"
)
$(
printf
"
\e
[1;41m
\e
[0m"
)
rm -rf "
$SITE_DIRECTORY_REALPATH
"
$(
printf
"
\e
[1;41m
\e
[0m"
)
rm -rf "
$
_
SITE_DIRECTORY_REALPATH
"
DANGER
DANGER
exit
1
exit
1
else
# Automatically delete the existing site directory.
chmod
-R
u+w
"
$_SITE_DIRECTORY_REALPATH
"
rm
-rf
"
$_SITE_DIRECTORY_REALPATH
"
fi
fi
fi
# Prompt for confirmation.
# Prompt for confirmation.
cat
<<
WARNING
if
test
!
"
$NO_INTERACTION
"
;
then
cat
<<
WARNING
You are about to create an Automatic Updates development environment at "
$SITE_DIRECTORY
". This will download
You are about to create an Automatic Updates development environment at "
$SITE_DIRECTORY
". This will download
as much as 100 MB of data and may take several minutes to complete, depending on your Internet connection.
as much as 100 MB of data and may take several minutes to complete, depending on your Internet connection.
WARNING
WARNING
read
-p
"Do you want to continue? [yN] "
-n
1
-r
read
-p
"Do you want to continue? [yN] "
-n
1
-r
echo
echo
if
[[
!
$REPLY
=
~ ^[Yy]
$
]]
;
then
if
[[
!
$REPLY
=
~ ^[Yy]
$
]]
;
then
# Exit from a function or non-interactive shell but not an interactive one.
# Exit from a function or non-interactive shell but not an interactive one.
[[
"
$0
"
=
"
$BASH_SOURCE
"
]]
&&
exit
1
||
return
1
[[
"
$0
"
=
"
$BASH_SOURCE
"
]]
&&
exit
1
||
return
1
fi
echo
fi
fi
echo
# Clone Drupal core.
# Clone Drupal core.
if
[[
"
$DRUPAL_CORE_SHALLOW_CLONE
"
==
"TRUE"
]]
;
then
if
[[
"
$DRUPAL_CORE_SHALLOW_CLONE
"
==
"TRUE"
]]
;
then
...
@@ -89,28 +113,37 @@ sites
...
@@ -89,28 +113,37 @@ sites
vendor
vendor
"
|
tee
-a
.git/info/exclude
"
|
tee
-a
.git/info/exclude
# Create default site settings.
cp
"
$_SITE_DIRECTORY_REALPATH
/sites/default/default.settings.php"
\
"
$_SITE_DIRECTORY_REALPATH
/sites/default/settings.php"
# Set trusted_host_patterns configuration.
# Set trusted_host_patterns configuration.
TRUSTED_HOST_PATTERN
=
"
${
SITE_HOST
//\./\\.
}
"
TRUSTED_HOST_PATTERN
=
"
${
SITE_HOST
//\./\\.
}
"
echo
"
echo
"
\$
settings['trusted_host_patterns'] = [
\$
settings['trusted_host_patterns'] = [
'^
$TRUSTED_HOST_PATTERN
\$
',
'^
$TRUSTED_HOST_PATTERN
\$
',
];"
\
];"
\
|
tee
-a
sites/default/
default.
settings.php
|
tee
-a
sites/default/settings.php
# Set path to Composer configuration, if possible.
# Set path to Composer configuration, if possible.
COMPOSER_PATH
=
$(
which composer
)
;
COMPOSER_PATH
=
$(
which composer
)
;
if
test
!
-z
"
$COMPOSER_PATH
"
;
then
if
test
!
-z
"
$COMPOSER_PATH
"
;
then
echo
"
echo
"
\$
config['package_manager.settings']['executables']['composer'] = '
$COMPOSER_PATH
';
\$
config['package_manager.settings']['executables']['composer'] = '
$COMPOSER_PATH
';
"
\
"
|
tee
-a
sites/default/
default.
settings.php
|
tee
-a
sites/default/settings.php
fi
fi
# Enable verbose error display in the browser.
echo
"
\$
config['system.logging']['error_level'] = 'verbose';"
\
|
tee
-a
sites/default/settings.php
# Clone the Automatic Updates repo into place. (It will still be
# Clone the Automatic Updates repo into place. (It will still be
# `composer require`d below to bring in its dependencies.)
# `composer require`d below to bring in its dependencies.)
git clone
\
git clone
\
--branch
"
$AUTOMATIC_UPDATES_BRANCH
"
--
\
--branch
"
$AUTOMATIC_UPDATES_BRANCH
"
--
\
https://git.drupalcode.org/project/automatic_updates.git
\
https://git.drupalcode.org/project/automatic_updates.git
\
modules/contrib/automatic_updates
"
$MODULE_CLONE_DIRECTORY
"
# Tell Composer to look for the package in the local clone. This is done rather
# Tell Composer to look for the package in the local clone. This is done rather
# than MERELY cloning the module so that the composer.json of the code under
# than MERELY cloning the module so that the composer.json of the code under
...
@@ -119,12 +152,10 @@ git clone \
...
@@ -119,12 +152,10 @@ git clone \
composer config
\
composer config
\
repositories.automatic_updates
\
repositories.automatic_updates
\
path
\
path
\
modules/contrib/automatic_updates
"
$MODULE_CLONE_DIRECTORY
"
# Prevent Composer from symlinking path repositories by setting their "symlink"
# Prevent Composer from symlinking path repositories.
# option to FALSE in composer.json.
export
COMPOSER_MIRROR_PATH_REPOS
=
1
JSON
=
$(
sed
's/"type": "path"/"type": "path", "options": {"symlink": false}/g'
composer.json
)
echo
"
$JSON
"
>
composer.json
# Update the Composer platform PHP requirement.
# Update the Composer platform PHP requirement.
composer config platform.php 7.4.0
composer config platform.php 7.4.0
...
@@ -135,12 +166,19 @@ composer config platform.php 7.4.0
...
@@ -135,12 +166,19 @@ composer config platform.php 7.4.0
composer config
--json
extra.drupal-core-vendor-hardening.drush/drush
'["docs"]'
composer config
--json
extra.drupal-core-vendor-hardening.drush/drush
'["docs"]'
composer config
--json
extra.drupal-core-vendor-hardening.grasmash/yaml-expander
'["scenarios"]'
composer config
--json
extra.drupal-core-vendor-hardening.grasmash/yaml-expander
'["scenarios"]'
# Require the module using the checked out dev branch, ignoring the PHP version
# Require the module using the checked out dev branch.
# requirement.
composer require
\
composer require
\
--no-ansi
\
--no-ansi
\
drupal/automatic_updates:dev-
"
$AUTOMATIC_UPDATES_BRANCH
"
drupal/automatic_updates:dev-
"
$AUTOMATIC_UPDATES_BRANCH
"
# Revert needless changes to Core Composer metapackages.
git checkout
--
"
$_SITE_DIRECTORY_REALPATH
/composer/Metapackage"
# Configure PHPUnit.
PHPUNIT_XML
=
$(
sed
's/env name="SIMPLETEST_BASE_URL" value=""/env name="SIMPLETEST_BASE_URL" value="http:\/\/'
$SITE_HOST
'"/'
"
$_SITE_DIRECTORY_REALPATH
/core/phpunit.xml.dist"
)
PHPUNIT_XML
=
$(
sed
's/env name="SIMPLETEST_DB" value=""/env name="SIMPLETEST_DB" value="sqlite:\/\/sites\/default\/files\/db.sqlite"/'
<<<
"
$PHPUNIT_XML
"
)
echo
"
$PHPUNIT_XML
"
>
"
$_SITE_DIRECTORY_REALPATH
/core/phpunit.xml"
cat
<<
DONE
cat
<<
DONE
$(
printf
"
\e
[1;34m"
)
================================================================================
$(
printf
"
\e
[1;34m"
)
================================================================================
...
@@ -160,13 +198,13 @@ $(printf "\e[0m")
...
@@ -160,13 +198,13 @@ $(printf "\e[0m")
- Point your web server at the configured site directory below. (No
- Point your web server at the configured site directory below. (No
instructions are provided for this step yet.)
instructions are provided for this step yet.)
Web root:
$SITE_DIRECTORY_REALPATH
Web root:
$
_
SITE_DIRECTORY_REALPATH
Site URL: http://
$SITE_HOST
Site URL: http://
$SITE_HOST
- Make and commit code changes to the module repository below. Changes made
- Make and commit code changes to the module repository below. Changes made
anywhere else will not be captured.
anywhere else will not be captured.
Module repo:
$SITE_DIRECTORY_REALPATH
/
modules/contrib/automatic_updates
Module repo:
$
_
SITE_DIRECTORY_REALPATH
/
$MODULE_CLONE_DIRECTORY
For information on creating issue forks and merge requests see
For information on creating issue forks and merge requests see
https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupal/creating-issue-forks-and-merge-requests
https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupal/creating-issue-forks-and-merge-requests
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment