Skip to content
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

Fix tests for the 4.x / "lite" changes #172

Merged
merged 15 commits into from
Oct 15, 2021
Merged
29 changes: 9 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
working_directory: ~/example
docker:
- image: circleci/php:7.3-node-browsers
- image: circleci/php:7.4-node-browsers
- image: circleci/mysql:5.7-ram
command: --max_allowed_packet=16M
environment:
Expand All @@ -16,23 +16,14 @@ jobs:

environment:
- PALANTIR_ENVIRONMENT: circleci
- DRUPAL_ROOT: web
- NODE_VERSION: 8
- DRUPAL_ROOT: docroot

steps:
- run:
name: Install packages
command: |
sudo apt-get update
sudo apt-get install -y libpng-dev default-mysql-client
- run:
name: Install nvm
command: |
set +e
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
touch $BASH_ENV
echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
- run:
name: Install PHP extensions
command: sudo docker-php-ext-install pdo_mysql gd
Expand All @@ -46,7 +37,7 @@ jobs:
command: mkdir /tmp/artifacts
- run:
name: Configure URL in /etc/hosts
command: echo 127.0.0.1 ${CIRCLE_PROJECT_REPONAME}.local | sudo tee -a /etc/hosts
command: echo 127.0.0.1 example.ddev.site | sudo tee -a /etc/hosts

# Note: phing and drupal-check have mutually exclusive requirements.
# It'd be better to add drupal-check as a dependency of the drupal project
Expand All @@ -57,10 +48,8 @@ jobs:
- run:
name: Install drupal-check
command: |
curl -O -L https://github.com/mglaman/drupal-check/releases/download/1.0.9/drupal-check.phar
mkdir --parents ~/bin
mv drupal-check.phar ~/bin/drupal-check
chmod +x ~/bin/drupal-check
composer global require mglaman/drupal-check
ln -s ~/.config/composer/vendor/bin ~/bin

# Composer package cache
- restore_cache:
Expand All @@ -75,7 +64,7 @@ jobs:
# Create a new project using the drupal-skeleton project
- run:
name: Create a new Drupal project
command: composer create-project palantirnet/drupal-skeleton example --no-interaction
command: composer create-project palantirnet/drupal-skeleton example dev-develop --no-interaction
working_directory: ~/

# Use this copy of the-build
Expand All @@ -95,7 +84,7 @@ jobs:
# Install the-build
- run:
name: Install the-build in the project
command: printf 'http://the-build.local\nother\nn' | vendor/bin/the-build-installer
command: printf '\n\n\nn' | vendor/bin/the-build-installer

- run:
name: Wait for DB
Expand All @@ -119,12 +108,12 @@ jobs:
# Add a multisite
- run:
name: Add a multisite to the project
command: printf 'intranet\nintranet.the-build.local' | vendor/bin/phing drupal-add-multisite
command: printf 'intranet\nintranet.example.ddev.site' | vendor/bin/phing drupal-add-multisite

- run:
name: Run Behat tests
command: |
nohup php -S ${CIRCLE_PROJECT_REPONAME}.local:8000 -t $(pwd)/${DRUPAL_ROOT}/ > /tmp/artifacts/phpd.log 2>&1 &
nohup php -S example.ddev.site:8000 -t $(pwd)/${DRUPAL_ROOT}/ > /tmp/artifacts/phpd.log 2>&1 &
vendor/bin/phing test -Dbuild.env=circleci

- store_artifacts:
Expand Down
247 changes: 127 additions & 120 deletions targets/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,95 @@
<!-- Copy defaults to fill in the sites array. -->
<copyproperties fromPrefix="drupal.sites._defaults" toPrefix="drupal.sites.default" override="false" />

<!-- Write the default properties file. -->
<copy file="${phing.dir.install}/../defaults/install/the-build/build.yml" tofile="${application.startdir}/.the-build/build.yml" overwrite="true">
<filterchain>
<expandproperties />
</filterchain>
</copy>

<phingcall target="setup-web-root" />
<phingcall target="setup-templates" />
<phingcall target="setup-host" />

<!-- Run the first build. -->
<phing dir="${application.startdir}" target="build" inheritAll="false" />

<!-- If Drupal has a database connection available, offer to install Drupal. -->
<trycatch>
<try>
<!-- The 'haltonfailure' attribute seems to have the opposite behavior
from what is described in the Phing documentation. -->
<phing dir="${application.startdir}" target="drupal-has-database-connection" inheritAll="false" haltonfailure="true" />

<!-- This code will run only when a database connection is available. -->
<input propertyName="install_now" validArgs="y,n" message="Install Drupal now " promptChar="?" />
<if>
<equals arg1="${install_now}" arg2="y" />
<then>
<phing dir="${application.startdir}" target="drupal-first-install" inheritAll="false" />
</then>
</if>
</try>
<catch>
<!-- Drupal will be installed later, if not manually then by the 'install'
target in the default build.xml. -->
<echo>Skipping Drupal installation, since the database is not available.

From within a development environment, you can run `phing install` to install Drupal.
</echo>
</catch>
</trycatch>

<!-- Whitespace is intentional. -->
<echo>

Successfully installed the-build. Next, you may want to run:

$> phing list
$> phing install
$> phing test</echo>
</target>


<!-- Target: setup-web-root

If the drupal.root directory doesn't exist, then we need to move it from the other location (web /
docroot).-->
<target name="setup-web-root" depends="set-site">
<available file="${build.dir}/${drupal.root}" type="dir" property="drupal.root.exists" value="true" />

<if>
<not><equals arg1="${drupal.root.exists}" arg2="1" /></not>
<then>
<!-- The one that's available is the location we're moving from. -->
<available file="${build.dir}/web" type="dir" property="drupal.root.old" value="web" />
<available file="${build.dir}/docroot" type="dir" property="drupal.root.old" value="docroot" />

<echo msg="Moving the ${drupal.root.old}/ directory to ${drupal.root}/" />
<exec command="mv ${drupal.root.old} ${drupal.root}" dir="${build.dir}" checkreturn="true" logoutput="true" />

<echo msg="Editing your composer.json to install Drupal in ${drupal.root}/" />
<reflexive>
<fileset dir="${build.dir}" includes="composer.json" />
<filterchain>
<replaceregexp>
<regexp pattern='"${drupal.root.old}/(core|libraries|modules|profiles|themes)' replace='"${drupal.root}/\1' />
<regexp pattern='"web-root": "${drupal.root.old}/"' replace='"web-root": "${drupal.root}/"' />
</replaceregexp>
</filterchain>
</reflexive>

<echo msg="Updating your composer.lock hash" />
<exec command="composer update --lock" dir="${application.startdir}" />

</then>
</if>
</target>


<!-- Target: setup-templates -->
<target name="setup-templates" depends="set-site">
<!-- Copy the build file template.

This doesn't do any property substitution except for the "projectname",
Expand All @@ -95,59 +183,18 @@
</filterchain>
</copy>

<!-- Create the default properties file. -->
<copy file="${phing.dir.install}/../defaults/install/the-build/build.yml" tofile="${application.startdir}/.the-build/build.yml" overwrite="true">
<filterchain>
<expandproperties />
</filterchain>
</copy>

<!-- Set up the drupal.site.* properties the way that the set-site target usually
does, so that we can use them below. -->
<property name="build.site" value="default" />
<!-- Copy defaults in first. -->
<copyproperties fromPrefix="drupal.sites._defaults" toPrefix="drupal.site" override="true" />
<!-- Override defaults with any site-specific values. -->
<copyproperties fromPrefix="drupal.sites.${build.site}" toPrefix="drupal.site" override="true" />

<!-- If the drupal.root directory doesn't exist, then we need to move it from the other location (web /
docroot). -->
<available file="${build.dir}/${drupal.root}" type="dir" property="drupal.root.exists" value="true" />

<if>
<not><equals arg1="${drupal.root.exists}" arg2="1" /></not>
<then>
<!-- The one that's available is the location we're moving from. -->
<available file="${build.dir}/web" type="dir" property="drupal.root.old" value="web" />
<available file="${build.dir}/docroot" type="dir" property="drupal.root.old" value="docroot" />

<echo msg="Moving the ${drupal.root.old}/ directory to ${drupal.root}/" />
<exec command="mv ${drupal.root.old} ${drupal.root}" dir="${build.dir}" checkreturn="true" logoutput="true" />

<echo msg="Editing your composer.json to install Drupal in ${drupal.root}/" />
<reflexive>
<fileset dir="${build.dir}" includes="composer.json" />
<filterchain>
<replaceregexp>
<regexp pattern='"${drupal.root.old}/(core|libraries|modules|profiles|themes)' replace='"${drupal.root}/\1' />
<regexp pattern='"web-root": "${drupal.root.old}/"' replace='"web-root": "${drupal.root}/"' />
</replaceregexp>
</filterchain>
</reflexive>

<echo msg="Updating your composer.lock hash" />
<exec command="composer update --lock" dir="${application.startdir}" />

</then>
</if>

<!-- Copy templates into place.
<!-- Copy other templates into place.
These copy commands use <expandproperties /> for property substitution.
-->
<!-- Copy the behat template. -->
<copy file="${phing.dir.install}/../defaults/install/behat.yml" tofile="${application.startdir}/behat.yml" overwrite="true">
<filterchain>
<expandproperties />
<!-- Sometimes behat has issues with HTTPS, especially when
using the php built-in webserver on CI. -->
<replaceregexp>
<regexp pattern="https:" replace="http:" />
</replaceregexp>
</filterchain>
</copy>

Expand All @@ -162,9 +209,6 @@
<!-- Copy the CircleCI properties. -->
<copy file="${phing.dir.install}/../defaults/install/the-build/build.circleci.yml" tofile="${application.startdir}/.the-build/build.circleci.yml" overwrite="true" />

<!-- Add host-specific configuration files. -->
<phingcall target="configure-host" />

<!-- Copy Drush configuration and aliases file templates. -->
<copy file="${phing.dir.install}/../defaults/install/drush/drush.yml" tofile="${application.startdir}/drush/drush.yml" overwrite="true">
<filterchain>
Expand All @@ -184,83 +228,46 @@
<mkdir dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}" />
<chmod mode="750" file="${build.dir}/${drupal.root}/sites/default/" />
<mkdir dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}/files" />
</target>

<!-- Run the first build. -->
<phing dir="${application.startdir}" target="build" inheritAll="false" />

<!-- If Drupal has a database connection available, offer to install Drupal. -->
<trycatch>
<try>
<!-- The 'haltonfailure' attribute seems to have the opposite behavior
from what is described in the Phing documentation. -->
<phing dir="${application.startdir}" target="drupal-has-database-connection" inheritAll="false" haltonfailure="true" />
<!-- Target: setup-host -->
<target name="setup-host" depends="set-site" description="Add host-specific configuration files.">
<fail unless="build.host"/>

<!-- This code will run only when a database connection is available. -->
<input propertyName="install_now" validArgs="y,n" message="Install Drupal now " promptChar="?" />
<if>
<equals arg1="${install_now}" arg2="y" />
<then>
<phing dir="${application.startdir}" target="drupal-first-install" inheritAll="false" />
</then>
</if>
</try>
<catch>
<!-- Drupal will be installed later, if not manually then by the 'install'
target in the default build.xml. -->
<echo>Skipping Drupal installation, since the database is not available.
<switch value="${build.host}">
<case value="acquia">
<!-- Site-level setup -->
<!-- @see https://docs.acquia.com/cloud-platform/performance/memcached/enable/ -->
<httpget url="https://docs.acquia.com/_downloads/cloud-memcache-d8+.php" dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}" filename="settings.acquia-memcache.php"/>
</case>

From within a development environment, you can run `phing install` to install Drupal.
</echo>
</catch>
</trycatch>
<case value="pantheon">
<!-- Project-level setup -->
<copy file="${build.thebuild.dir}/defaults/install/pantheon.yml" todir="${application.startdir}" overwrite="true"/>

<!-- Whitespace is intentional. -->
<echo>
<!-- Site-level setup -->
<httpget url="https://raw.githubusercontent.com/pantheon-systems/drops-8/default/sites/default/settings.pantheon.php" dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}"/>
</case>

Successfully installed the-build. Next, you may want to run:
<case value="platformsh">
<!-- Project-level setup -->
<copy file="${build.thebuild.dir}/defaults/install/.platform.app.yaml" todir="${application.startdir}" overwrite="true"/>
<copy todir="${application.startdir}/.platform" overwrite="true">
<fileset dir="${build.thebuild.dir}/defaults/install/.platform"/>
</copy>
<httpget url="https://raw.githubusercontent.com/platformsh/template-drupal8/master/.environment" dir="${build.dir}/"/>

<!-- Site-level setup -->
<composer command="require" composer="${composer.composer}">
<arg line="--working-dir ${application.startdir}"/>
<arg value="platformsh/config-reader:^2.1"/>
</composer>
<httpget url="https://raw.githubusercontent.com/platformsh/template-drupal8/master/web/sites/default/settings.platformsh.php" dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}"/>
</case>

$> phing list
$> phing install
$> phing test</echo>
<default/>
</switch>
</target>

<target name="configure-host" description="Add host-specific configuration files.">
<fail unless="build.host" />

<switch value="${build.host}">
<case value="acquia">
<!-- Site-level setup -->
<!-- @see https://docs.acquia.com/cloud-platform/performance/memcached/enable/ -->
<httpget url="https://docs.acquia.com/_downloads/cloud-memcache-d8+.php" dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}" filename="settings.acquia-memcache.php" />
</case>

<case value="pantheon">
<!-- Project-level setup -->
<copy file="${build.thebuild.dir}/defaults/install/pantheon.yml" todir="${application.startdir}" overwrite="true" />

<!-- Site-level setup -->
<httpget url="https://raw.githubusercontent.com/pantheon-systems/drops-8/default/sites/default/settings.pantheon.php" dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}" />
</case>

<case value="platformsh">
<!-- Project-level setup -->
<copy file="${build.thebuild.dir}/defaults/install/.platform.app.yaml" todir="${application.startdir}" overwrite="true" />
<copy todir="${application.startdir}/.platform" overwrite="true">
<fileset dir="${build.thebuild.dir}/defaults/install/.platform" />
</copy>
<httpget url="https://raw.githubusercontent.com/platformsh/template-drupal8/master/.environment" dir="${build.dir}/" />

<!-- Site-level setup -->
<composer command="require" composer="${composer.composer}">
<arg line="--working-dir ${application.startdir}" />
<arg value="platformsh/config-reader:^2.1" />
</composer>
<httpget url="https://raw.githubusercontent.com/platformsh/template-drupal8/master/web/sites/default/settings.platformsh.php" dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}" />
</case>

<default />
</switch>

</target>

</project>