From b826d9070d83da0699341e62a8dc18a9c7b409df Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Sun, 18 Sep 2022 16:13:00 -0400 Subject: [PATCH 001/172] feat: Add an initial Tugboat scaffold --- .github/workflows/validate-tugboat.yml | 20 +++++ scaffold/tugboat/config.example.yml | 102 +++++++++++++++++++++++++ src/ScaffoldInstallerPlugin.php | 8 ++ 3 files changed, 130 insertions(+) create mode 100644 .github/workflows/validate-tugboat.yml create mode 100644 scaffold/tugboat/config.example.yml diff --git a/.github/workflows/validate-tugboat.yml b/.github/workflows/validate-tugboat.yml new file mode 100644 index 000000000..bf01d2990 --- /dev/null +++ b/.github/workflows/validate-tugboat.yml @@ -0,0 +1,20 @@ +name: Validate example Tugboat configuration +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + Validate-Example-Tugboat-Configuration: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '18' + - run: | + curl -O https://dashboard.tugboatqa.com/cli/linux/tugboat.tar.gz + tar xzvf tugboat.tar.gz + ./tugboat validate scaffold/tugboat/config.example.yml diff --git a/scaffold/tugboat/config.example.yml b/scaffold/tugboat/config.example.yml new file mode 100644 index 000000000..cec1cc473 --- /dev/null +++ b/scaffold/tugboat/config.example.yml @@ -0,0 +1,102 @@ +# This serves as a Tugboat configuration file for Drupal websites. It sets up: +# +# 1. PHP 8.1 with Apache as the web server. +# 2. MariaDB 10 for the database. +# 3. drush-launcher +# 4. Enables the PHP opcache and required Apache extensions. +services: + + # What to call the service hosting the site. + php: + # Only allow access via https. + http: false + + # Use PHP 8.1 with Apache + image: tugboatqa/php:8.1-apache-bullseye + + # Set this as the default service. This does a few things + # 1. Clones the git repository into the service container + # 2. Exposes port 80 to the Tugboat HTTP proxy + # 3. Routes requests to the preview URL to this service + default: true + + # Wait until the mariadb service is done building + depends: + - mariadb + + # A set of commands to run while building this service + commands: + + # Commands that set up the basic preview infrastructure + init: | + set -eux + echo "Initializing..." + # Install prerequisite packages + apt-get update + apt-get install -y mariadb-client libldap2-dev + + # Install drush-launcher + wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar + chmod +x /usr/local/bin/drush + + # Link the document root to the expected path. Tugboat uses /docroot + # by default. So, if Drupal is located at any other path in your git + # repository, change that here. This example links /web to the docroot + [ -d "${DOCROOT}" ] || ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" + + docker-php-ext-install opcache + a2enmod headers rewrite + + # Commands that import files, databases, or other assets. When an + # existing preview is refreshed, the build workflow starts here, + # skipping the init step, because the results of that step will + # already be present. + update: | + set -eux + echo "Updating..." + + # We intentionally do not set up syncing of static assets, as we have + # decided to always use Stage File Proxy: + # https://architecture.lullabot.com/adr/20210729-stage-file-proxy/ + + # Set up permissions for the files directories. + chgrp -R www-data "${DOCROOT}/sites/default/files" + chmod -R g+w "${DOCROOT}/sites/default/files" + chmod 2775 "${DOCROOT}/sites/default/files" + + composer install + + # Install Drupal using the standard profile. + vendor/bin/task drupal:install + + # To use an existing site, add the appropriate environment variables + # as document at and instead run: + # vendor/bin/task :fetch-db + # vendor/bin/task drupal:import-db + + # Commands that build the site. This is where you would add things + # like feature reverts or any other drush commands required to + # set up or configure the site. When a preview is built from a + # base preview, the build workflow starts here, skipping the init + # and update steps, because the results of those are inherited + # from the base preview. + build: | + set -eux + vendor/bin/task drupal:update + vendor/bin/drush user:login + + # What to call the service hosting MySQL. This name also acts as the + # hostname to access the service by from the php service. + mariadb: + + image: tugboatqa/mariadb:10 + + # A set of commands to run while building this service + commands: + + # Commands that import files, databases, or other assets. When an + # existing preview is refreshed, the build workflow starts here, + # skipping the init step, because the results of that step will + # already be present. + update: + - echo "Nothing to do as we import databases from the Drupal service." diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index f227fe636..b8c68d357 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -249,5 +249,13 @@ private function installCICommands(): void } } } + + // Tugboat + if (isset($this->extra['drainpipe']['tugboat']) && is_array($this->extra['drainpipe']['tugboat'])) { + if (!file_exists('./.tugboat/config.yml')) { + $fs->ensureDirectoryExists('./.tugboat'); + $fs->copy("$scaffoldPath/tugboat/config.example.yml", './.tugboat/config.yml'); + } + } } } From 0aafc67964120153113529e62553b4f3a7ef386a Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Mon, 26 Sep 2022 15:38:42 -0400 Subject: [PATCH 002/172] Force a new commit / build --- .github/workflows/validate-tugboat.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validate-tugboat.yml b/.github/workflows/validate-tugboat.yml index bf01d2990..a9f1dc4c8 100644 --- a/.github/workflows/validate-tugboat.yml +++ b/.github/workflows/validate-tugboat.yml @@ -17,4 +17,5 @@ jobs: - run: | curl -O https://dashboard.tugboatqa.com/cli/linux/tugboat.tar.gz tar xzvf tugboat.tar.gz + echo "Validating tugboat configuration..." ./tugboat validate scaffold/tugboat/config.example.yml From ea62b57be8f809942ac8b72a51e95bc825ec5ade Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Mon, 26 Sep 2022 15:46:54 -0400 Subject: [PATCH 003/172] Print env variable names --- .github/workflows/validate-tugboat.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validate-tugboat.yml b/.github/workflows/validate-tugboat.yml index a9f1dc4c8..bbc386ec3 100644 --- a/.github/workflows/validate-tugboat.yml +++ b/.github/workflows/validate-tugboat.yml @@ -17,5 +17,6 @@ jobs: - run: | curl -O https://dashboard.tugboatqa.com/cli/linux/tugboat.tar.gz tar xzvf tugboat.tar.gz + declare | awk -F= '{print $1}' echo "Validating tugboat configuration..." ./tugboat validate scaffold/tugboat/config.example.yml From b0d99d6653bf1bd2ed59cbb82d7470cd561a0c14 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Mon, 26 Sep 2022 15:58:19 -0400 Subject: [PATCH 004/172] expose TUGBOAT_API_KEY --- .github/workflows/validate-tugboat.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validate-tugboat.yml b/.github/workflows/validate-tugboat.yml index bbc386ec3..44d272180 100644 --- a/.github/workflows/validate-tugboat.yml +++ b/.github/workflows/validate-tugboat.yml @@ -12,6 +12,8 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 + env: + TUGBOAT_API_KEY: ${{ secrets.TUGBOAT_API_KEY }} with: node-version: '18' - run: | From 31247c17e61ca0bc5d62ada0dcb28769fbf0992a Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Mon, 26 Sep 2022 16:13:41 -0400 Subject: [PATCH 005/172] Fix name --- .github/workflows/validate-tugboat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-tugboat.yml b/.github/workflows/validate-tugboat.yml index 44d272180..467d014d5 100644 --- a/.github/workflows/validate-tugboat.yml +++ b/.github/workflows/validate-tugboat.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 env: - TUGBOAT_API_KEY: ${{ secrets.TUGBOAT_API_KEY }} + TUGBOAT_API_TOKEN: ${{ secrets.TUGBOAT_API_TOKEN }} with: node-version: '18' - run: | From 52876bfb18e20a3d11ff86f8f5db9c4ea03bd2fd Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Mon, 26 Sep 2022 16:31:38 -0400 Subject: [PATCH 006/172] Try pushing up to the job --- .github/workflows/validate-tugboat.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-tugboat.yml b/.github/workflows/validate-tugboat.yml index 467d014d5..7d9ad3fe3 100644 --- a/.github/workflows/validate-tugboat.yml +++ b/.github/workflows/validate-tugboat.yml @@ -9,11 +9,11 @@ on: jobs: Validate-Example-Tugboat-Configuration: runs-on: ubuntu-22.04 + env: + TUGBOAT_API_TOKEN: ${{ secrets.TUGBOAT_API_TOKEN }} steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 - env: - TUGBOAT_API_TOKEN: ${{ secrets.TUGBOAT_API_TOKEN }} with: node-version: '18' - run: | From 97906d895aef51a042c7ae36b55541208e5fdf8b Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Mon, 26 Sep 2022 16:50:45 -0400 Subject: [PATCH 007/172] update settings.php for tugboat --- scaffold/tugboat/settings.tugboat.php | 14 ++++++++++++++ src/ScaffoldInstallerPlugin.php | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 scaffold/tugboat/settings.tugboat.php diff --git a/scaffold/tugboat/settings.tugboat.php b/scaffold/tugboat/settings.tugboat.php new file mode 100644 index 000000000..229057351 --- /dev/null +++ b/scaffold/tugboat/settings.tugboat.php @@ -0,0 +1,14 @@ + 'tugboat', + 'username' => 'tugboat', + 'password' => 'tugboat', + 'prefix' => '', + 'host' => 'mariadb', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', + ]; +} diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index b8c68d357..4f707658e 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -255,6 +255,19 @@ private function installCICommands(): void if (!file_exists('./.tugboat/config.yml')) { $fs->ensureDirectoryExists('./.tugboat'); $fs->copy("$scaffoldPath/tugboat/config.example.yml", './.tugboat/config.yml'); + if (!file_exists('./web/sites/default/settings.tugboat.php')) { + $fs->copy("$scaffoldPath/pantheon/settings.tugboat.php", './web/sites/default/settings.tugboat.php'); + $this->io->write("๐Ÿช  [Drainpipe] sites/default/settings.tugboat.php installed. Please commit this file."); + if (file_exists('./web/sites/default/settings.php')) { + $include=<<io->write("๐Ÿช  [Drainpipe] sites/default/settings.php modified to include settings.tugboat.php. Please commit this file."); + } } } } From 581da3eafb5da2729d070da75f9fd2ca6a6c76d4 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Mon, 26 Sep 2022 16:51:01 -0400 Subject: [PATCH 008/172] Remove debugging prints --- .github/workflows/validate-tugboat.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/validate-tugboat.yml b/.github/workflows/validate-tugboat.yml index 7d9ad3fe3..6cdbe4998 100644 --- a/.github/workflows/validate-tugboat.yml +++ b/.github/workflows/validate-tugboat.yml @@ -19,6 +19,4 @@ jobs: - run: | curl -O https://dashboard.tugboatqa.com/cli/linux/tugboat.tar.gz tar xzvf tugboat.tar.gz - declare | awk -F= '{print $1}' - echo "Validating tugboat configuration..." ./tugboat validate scaffold/tugboat/config.example.yml From a1b02b1c99aad771bc2be3dad3ab846a9cd7b7ce Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Mon, 26 Sep 2022 19:33:16 -0400 Subject: [PATCH 009/172] Fix tugboat path --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 4f707658e..15b601e86 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -256,7 +256,7 @@ private function installCICommands(): void $fs->ensureDirectoryExists('./.tugboat'); $fs->copy("$scaffoldPath/tugboat/config.example.yml", './.tugboat/config.yml'); if (!file_exists('./web/sites/default/settings.tugboat.php')) { - $fs->copy("$scaffoldPath/pantheon/settings.tugboat.php", './web/sites/default/settings.tugboat.php'); + $fs->copy("$scaffoldPath/tugboat/settings.tugboat.php", './web/sites/default/settings.tugboat.php'); $this->io->write("๐Ÿช  [Drainpipe] sites/default/settings.tugboat.php installed. Please commit this file."); if (file_exists('./web/sites/default/settings.php')) { $include=<< Date: Mon, 26 Sep 2022 19:38:00 -0400 Subject: [PATCH 010/172] Tell users tugboat config is installed --- src/ScaffoldInstallerPlugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 15b601e86..8c734b919 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -255,6 +255,7 @@ private function installCICommands(): void if (!file_exists('./.tugboat/config.yml')) { $fs->ensureDirectoryExists('./.tugboat'); $fs->copy("$scaffoldPath/tugboat/config.example.yml", './.tugboat/config.yml'); + $this->io->write("๐Ÿช  [Drainpipe] .tugboat/config.yml installed. Please commit this file."); if (!file_exists('./web/sites/default/settings.tugboat.php')) { $fs->copy("$scaffoldPath/tugboat/settings.tugboat.php", './web/sites/default/settings.tugboat.php'); $this->io->write("๐Ÿช  [Drainpipe] sites/default/settings.tugboat.php installed. Please commit this file."); From c44ecd2babe4b2409c166af488f81e711300b445 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Mon, 26 Sep 2022 19:38:19 -0400 Subject: [PATCH 011/172] Fix paths for settings.php --- src/ScaffoldInstallerPlugin.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 8c734b919..797a18e1f 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -258,16 +258,19 @@ private function installCICommands(): void $this->io->write("๐Ÿช  [Drainpipe] .tugboat/config.yml installed. Please commit this file."); if (!file_exists('./web/sites/default/settings.tugboat.php')) { $fs->copy("$scaffoldPath/tugboat/settings.tugboat.php", './web/sites/default/settings.tugboat.php'); - $this->io->write("๐Ÿช  [Drainpipe] sites/default/settings.tugboat.php installed. Please commit this file."); + $this->io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.tugboat.php installed. Please commit this file."); if (file_exists('./web/sites/default/settings.php')) { $include=<<io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.php modified to include settings.tugboat.php. Please commit this file."); + } + else { + $this->io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.php does not exist. Please include tugboat.settings.php from your settings.php files."); } - $this->io->write("๐Ÿช  [Drainpipe] sites/default/settings.php modified to include settings.tugboat.php. Please commit this file."); } } } From 2f640a1ab05649ad6375865c207f5cb6003122ec Mon Sep 17 00:00:00 2001 From: Eduardo telaya Date: Thu, 27 Oct 2022 12:32:30 -0500 Subject: [PATCH 012/172] configre tugboat --- README.md | 36 ++++++ scaffold/tugboat/config.example.yml | 119 ++++++++++++++++++ scaffold/tugboat/settings.tugboat.php | 14 +++ scaffold/tugboat/tugboat.acquia-example.yml | 115 +++++++++++++++++ scaffold/tugboat/tugboat.pantheon-example.yml | 104 +++++++++++++++ src/ScaffoldInstallerPlugin.php | 51 ++++++-- 6 files changed, 431 insertions(+), 8 deletions(-) create mode 100644 scaffold/tugboat/config.example.yml create mode 100644 scaffold/tugboat/settings.tugboat.php create mode 100644 scaffold/tugboat/tugboat.acquia-example.yml create mode 100644 scaffold/tugboat/tugboat.pantheon-example.yml diff --git a/README.md b/README.md index eb0235288..d7fd87e78 100644 --- a/README.md +++ b/README.md @@ -186,3 +186,39 @@ Requires `GITLAB_ACCESS_TOKEN` variable to be set, which is an access token with - `SSH_PRIVATE_KEY` A private key of a user which can push to Pantheon - `SSH_KNOWN_HOSTS` The result of running `ssh-keyscan -H codeserver.dev.$PANTHEON_SITE_ID.drush.in` - `TERMINUS_PLUGINS` Comma-separated list of Terminus plugins to be available (optional) + +## Tugboat Integration + +Add the following to `composer.json` for Tugboat helpers: +```json +"extra": { + "drainpipe": { + "tugboat": [] + } +} +``` + +This will import [`./.tugboat/config.example.yml`](./.tugboat/config.example.yml), +and import [`./web/sites/default/settings.php`](./web/sites/default/settings.php). + +### Acquia +```json +"extra": { + "drainpipe": { + "gitlab": ["acquia"] + } +} +``` +This will import [`./.tugboat/tugboat.acquia-example.yml`](./.tugboat/tugboat.acquia-example.yml), +this file includes memcached. + +### Pantheon +```json +"extra": { + "drainpipe": { + "gitlab": ["pantheon"] + } +} +``` +This will import [`./.tugboat/tugboat.pantheon-example.yml`](./.tugboat/tugboat.pantheon-example.yml), +this file includes redis. diff --git a/scaffold/tugboat/config.example.yml b/scaffold/tugboat/config.example.yml new file mode 100644 index 000000000..abd5d98b3 --- /dev/null +++ b/scaffold/tugboat/config.example.yml @@ -0,0 +1,119 @@ +# This serves as a Tugboat configuration file for Drupal websites. It sets up: +# +# 1. PHP 8.1 with Apache as the web server. +# 2. MariaDB 10 for the database. +# 3. drush-launcher +# 4. Enables the PHP opcache and required Apache extensions. +services: + + # What to call the service hosting the site. + php: + # Only allow access via https. + http: false + + # Use PHP 8.1 with Apache + image: tugboatqa/php:8.1-apache-bullseye + + # Set this as the default service. This does a few things + # 1. Clones the git repository into the service container + # 2. Exposes port 80 to the Tugboat HTTP proxy + # 3. Routes requests to the preview URL to this service + default: true + + # Wait until the mariadb service is done building + depends: + - mariadb + + # A set of commands to run while building this service + commands: + + # Commands that set up the basic preview infrastructure + init: | + set -eux + echo "Initializing..." + # Install prerequisite packages + apt-get update + apt-get install -y mariadb-client libldap2-dev + + # Install drush-launcher + wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar + chmod +x /usr/local/bin/drush + + # Link the document root to the expected path. Tugboat uses /docroot + # by default. So, if Drupal is located at any other path in your git + # repository, change that here. This example links /web to the docroot + [ -d "${DOCROOT}" ] || ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" + + docker-php-ext-install opcache + a2enmod headers rewrite + + # WebP + apt-get install -y libwebp-dev libwebp6 webp libmagickwand-dev + docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp + docker-php-ext-install gd + + # Configure GD + apt-get update && apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev + docker-php-ext-configure gd --with-jpeg --with-freetype && docker-php-ext-install gd + + # Install drush-launcher, if desired. + wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar + chmod +x /usr/local/bin/drush + + # Commands that import files, databases, or other assets. When an + # existing preview is refreshed, the build workflow starts here, + # skipping the init step, because the results of that step will + # already be present. + update: | + set -eux + echo "Updating..." + + # We intentionally do not set up syncing of static assets, as we have + # decided to always use Stage File Proxy: + # https://architecture.lullabot.com/adr/20210729-stage-file-proxy/ + + # Set up permissions for the files directories. + chgrp -R www-data "${TUGBOAT_ROOT}/web/sites/default/files" + chmod -R g+w "${TUGBOAT_ROOT}/web/sites/default/files" + chmod 2775 "${TUGBOAT_ROOT}/web/sites/default/files" + + composer install + + # Install Drupal using the standard profile. + vendor/bin/task drupal:install + + # To use an existing site, add the appropriate environment variables + # as document at and instead run: + # vendor/bin/task :fetch-db + # vendor/bin/task drupal:import-db + + # Install + echo "Install drush" + drush site:install + + # Commands that build the site. This is where you would add things + # like feature reverts or any other drush commands required to + # set up or configure the site. When a preview is built from a + # base preview, the build workflow starts here, skipping the init + # and update steps, because the results of those are inherited + # from the base preview. + build: | + set -eux + vendor/bin/task drupal:update + vendor/bin/drush user:login + + # What to call the service hosting MySQL. This name also acts as the + # hostname to access the service by from the php service. + mariadb: + + image: tugboatqa/mariadb:10 + + # A set of commands to run while building this service + commands: + + # Commands that import files, databases, or other assets. When an + # existing preview is refreshed, the build workflow starts here, + # skipping the init step, because the results of that step will + # already be present. + update: + - echo "Nothing to do as we import databases from the Drupal service." diff --git a/scaffold/tugboat/settings.tugboat.php b/scaffold/tugboat/settings.tugboat.php new file mode 100644 index 000000000..229057351 --- /dev/null +++ b/scaffold/tugboat/settings.tugboat.php @@ -0,0 +1,14 @@ + 'tugboat', + 'username' => 'tugboat', + 'password' => 'tugboat', + 'prefix' => '', + 'host' => 'mariadb', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', + ]; +} diff --git a/scaffold/tugboat/tugboat.acquia-example.yml b/scaffold/tugboat/tugboat.acquia-example.yml new file mode 100644 index 000000000..66589705c --- /dev/null +++ b/scaffold/tugboat/tugboat.acquia-example.yml @@ -0,0 +1,115 @@ +# This serves as a Tugboat configuration file for Drupal websites. It sets up: +# +# 1. PHP 8.1 with Apache as the web server. +# 2. MariaDB 10 for the database. +# 3. drush-launcher +# 4. Enables the PHP opcache and required Apache extensions. +services: + + # What to call the service hosting the site. + php: + # Only allow access via https. + http: false + + # Use PHP 8.1 with Apache + image: tugboatqa/php:8.1-apache-bullseye + + # Set this as the default service. This does a few things + # 1. Clones the git repository into the service container + # 2. Exposes port 80 to the Tugboat HTTP proxy + # 3. Routes requests to the preview URL to this service + default: true + + # Wait until the mariadb service is done building + depends: + - mariadb + + # A set of commands to run while building this service + commands: + + # Commands that set up the basic preview infrastructure + init: | + set -eux + echo "Initializing..." + # Install prerequisite packages + apt-get update + apt-get install -y mariadb-client libldap2-dev + + # Install drush-launcher + wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar + chmod +x /usr/local/bin/drush + + # Link the document root to the expected path. Tugboat uses /docroot + # by default. So, if Drupal is located at any other path in your git + # repository, change that here. This example links /web to the docroot + [ -d "${DOCROOT}" ] || ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" + + docker-php-ext-install opcache + a2enmod headers rewrite + + # Commands that import files, databases, or other assets. When an + # existing preview is refreshed, the build workflow starts here, + # skipping the init step, because the results of that step will + # already be present. + update: | + set -eux + echo "Updating..." + + # We intentionally do not set up syncing of static assets, as we have + # decided to always use Stage File Proxy: + # https://architecture.lullabot.com/adr/20210729-stage-file-proxy/ + + # Set up permissions for the files directories. + chgrp -R www-data "${DOCROOT}/sites/default/files" + chmod -R g+w "${DOCROOT}/sites/default/files" + chmod 2775 "${DOCROOT}/sites/default/files" + + composer install + + # Install Drupal using the standard profile. + vendor/bin/task drupal:install + + # To use an existing site, add the appropriate environment variables + # as document at and instead run: + # vendor/bin/task :fetch-db + # vendor/bin/task drupal:import-db + + # Commands that build the site. This is where you would add things + # like feature reverts or any other drush commands required to + # set up or configure the site. When a preview is built from a + # base preview, the build workflow starts here, skipping the init + # and update steps, because the results of those are inherited + # from the base preview. + build: | + set -eux + vendor/bin/task drupal:update + vendor/bin/drush user:login + + # What to call the service hosting MySQL. This name also acts as the + # hostname to access the service by from the php service. + mariadb: + + image: tugboatqa/mariadb:10 + + # A set of commands to run while building this service + commands: + + # Commands that import files, databases, or other assets. When an + # existing preview is refreshed, the build workflow starts here, + # skipping the init step, because the results of that step will + # already be present. + update: + - echo "Nothing to do as we import databases from the Drupal service." + + memcached: + + image: tugboatqa/memcached:1 + +# commands: +# +# update: | +# +# if [[ "tugboatqa/memcached:1" == "NULL" ]]; then +# echo -e "FATAL ERROR: Not installed" +# exit 1 +# fi diff --git a/scaffold/tugboat/tugboat.pantheon-example.yml b/scaffold/tugboat/tugboat.pantheon-example.yml new file mode 100644 index 000000000..58cc91a96 --- /dev/null +++ b/scaffold/tugboat/tugboat.pantheon-example.yml @@ -0,0 +1,104 @@ +# This serves as a Tugboat configuration file for Drupal websites. It sets up: +# +# 1. PHP 8.1 with Apache as the web server. +# 2. MariaDB 10 for the database. +# 3. drush-launcher +# 4. Enables the PHP opcache and required Apache extensions. +services: + + # What to call the service hosting the site. + php: + # Only allow access via https. + http: false + + # Use PHP 8.1 with Apache + image: tugboatqa/php:8.1-apache-bullseye + + # Set this as the default service. This does a few things + # 1. Clones the git repository into the service container + # 2. Exposes port 80 to the Tugboat HTTP proxy + # 3. Routes requests to the preview URL to this service + default: true + + # Wait until the mariadb service is done building + depends: + - mariadb + + # A set of commands to run while building this service + commands: + + # Commands that set up the basic preview infrastructure + init: | + set -eux + echo "Initializing..." + # Install prerequisite packages + apt-get update + apt-get install -y mariadb-client libldap2-dev + # Install drush-launcher + wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar + chmod +x /usr/local/bin/drush + # Link the document root to the expected path. Tugboat uses /docroot + # by default. So, if Drupal is located at any other path in your git + # repository, change that here. This example links /web to the docroot + [ -d "${DOCROOT}" ] || ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" + docker-php-ext-install opcache + a2enmod headers rewrite + # Commands that import files, databases, or other assets. When an + # existing preview is refreshed, the build workflow starts here, + # skipping the init step, because the results of that step will + # already be present. + update: | + set -eux + echo "Updating..." + # We intentionally do not set up syncing of static assets, as we have + # decided to always use Stage File Proxy: + # https://architecture.lullabot.com/adr/20210729-stage-file-proxy/ + # Set up permissions for the files directories. + chgrp -R www-data "${DOCROOT}/sites/default/files" + chmod -R g+w "${DOCROOT}/sites/default/files" + chmod 2775 "${DOCROOT}/sites/default/files" + composer install + # Install Drupal using the standard profile. + vendor/bin/task drupal:install + # To use an existing site, add the appropriate environment variables + # as document at and instead run: + # vendor/bin/task :fetch-db + # vendor/bin/task drupal:import-db + # Commands that build the site. This is where you would add things + # like feature reverts or any other drush commands required to + # set up or configure the site. When a preview is built from a + # base preview, the build workflow starts here, skipping the init + # and update steps, because the results of those are inherited + # from the base preview. + build: | + set -eux + vendor/bin/task drupal:update + vendor/bin/drush user:login + # What to call the service hosting MySQL. This name also acts as the + # hostname to access the service by from the php service. + mariadb: + + image: tugboatqa/mariadb:10 + + # A set of commands to run while building this service + commands: + + # Commands that import files, databases, or other assets. When an + # existing preview is refreshed, the build workflow starts here, + # skipping the init step, because the results of that step will + # already be present. + update: + - echo "Nothing to do as we import databases from the Drupal service." + + redis: + + image: tugboatqa/redis:7 + +# commands: +# +# update: | +# +# if [[ "tugboatqa/redis:7" == "NULL" ]]; then +# echo -e "FATAL ERROR: Not installed" +# exit 1 +# fi diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 6f67acdb7..f9ef5b812 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -152,7 +152,7 @@ private function installGitignore(): void if (strpos($contents, '.task') === false) { $this->io->warning( sprintf( - '.gitignore does not contain drainpipe ignores. Compare .gitignore in the root of your repository with %s and update as needed.', + '.gitignore does not contain drainpipe ignores. Compare .gitignore in the root of your repository with %s and update as needed.', $gitignorePath ) ); @@ -161,7 +161,7 @@ private function installGitignore(): void } /** - * Install DDEV Commands. + * */ private function installDdevCommand(): void { @@ -171,12 +171,6 @@ private function installDdevCommand(): void $fs = new Filesystem(); $fs->ensureDirectoryExists('./.ddev/commands/web'); $fs->copy($ddevCommandPath, './.ddev/commands/web/task'); - - # Enable .env file support via docker-composer web environment. - $fs->copy($vendor.'/lullabot/drainpipe/scaffold/ddev/docker-compose-.env-file.yaml', './.ddev'); - if (!is_file('./.env')) { - $fs->copy($vendor.'/lullabot/drainpipe/scaffold/ddev/env', './.env'); - } } } @@ -255,5 +249,46 @@ private function installCICommands(): void } } } + + // Tugboat + if (isset($this->extra['drainpipe']['tugboat']) && is_array($this->extra['drainpipe']['tugboat'])) { + if (!file_exists('./.tugboat/config.yml')) { + $fs->ensureDirectoryExists('./.tugboat'); + $fs->copy("$scaffoldPath/tugboat/config.example.yml", './.tugboat/config.yml'); + $this->io->write("๐Ÿช  [Drainpipe] .tugboat/config.yml installed. Please commit this file."); + if (!file_exists('./web/sites/default/settings.tugboat.php')) { + $fs->copy("$scaffoldPath/tugboat/settings.tugboat.php", './web/sites/default/settings.tugboat.php'); + $this->io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.tugboat.php installed. Please commit this file."); + if (file_exists('./web/sites/default/settings.php')) { + $include=<<io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.php modified to include settings.tugboat.php. Please commit this file."); + } + else { + $this->io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.php does not exist. Please include tugboat.settings.php from your settings.php files."); + } + } + } + foreach ($this->extra['drainpipe']['tugboat'] as $provider) { + if ($provider === 'acquia') { + if (!file_exists('./.tugboat/tugboat.acquia-example.yml')) { + $fs->ensureDirectoryExists('./.tugboat'); + $fs->copy("$scaffoldPath/tugboat/tugboat.acquia-example.yml", './.tugboat/tugboat.acquia-example.yml'); + $this->io->write("๐Ÿช  [Drainpipe] .tugboat/tugboat.acquia-example.yml installed. Please commit this file."); + } + } + if ($provider === 'pantheon') { + if (!file_exists('./.tugboat/tugboat.pantheon-example.yml')) { + $fs->ensureDirectoryExists('./.tugboat'); + $fs->copy("$scaffoldPath/tugboat/tugboat.pantheon-example.yml", './.tugboat/tugboat.pantheon-example.yml'); + $this->io->write("๐Ÿช  [Drainpipe] .tugboat/tugboat.pantheon-example.yml installed. Please commit this file."); + } + } + } + } } } From 7af541ee9db0430cba93a5312deb5790b826632e Mon Sep 17 00:00:00 2001 From: Hawkeye Tenderwolf <1264248+hawkeyetwolf@users.noreply.github.com> Date: Sun, 30 Oct 2022 11:29:58 -0400 Subject: [PATCH 013/172] Override default $DOCROOT symlink (#140) By default in the current Tugboat image, `/var/www/html` is a symlink to `/var/www/html.original`, so the `[ -d ]` (is file) shell test prevents the new symlink from being created. Let's just always go ahead and create the symlink, removing the shell test to abort when an existing symlink is found. --- scaffold/tugboat/config.example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/config.example.yml b/scaffold/tugboat/config.example.yml index cec1cc473..123f57990 100644 --- a/scaffold/tugboat/config.example.yml +++ b/scaffold/tugboat/config.example.yml @@ -42,7 +42,7 @@ services: # Link the document root to the expected path. Tugboat uses /docroot # by default. So, if Drupal is located at any other path in your git # repository, change that here. This example links /web to the docroot - [ -d "${DOCROOT}" ] || ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" + ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" docker-php-ext-install opcache a2enmod headers rewrite From d93b263f4fbb81d247c041e6a2c82013a928957d Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 09:51:27 -0500 Subject: [PATCH 014/172] Directly require twig/twig --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0d1370645..e0566e4b3 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ "php": "^7.3||^8.0", "composer-plugin-api": "^2.0", "drush/drush": "^10|^11", - "symfony/yaml": "^3|^4" + "symfony/yaml": "^3|^4", + "twig/twig": "^3.4" }, "require-dev": { "composer/composer": "^2.0", From 19f66f998599d015be227336b7e83c2de8051faf Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 09:52:00 -0500 Subject: [PATCH 015/172] Use twig to render tugboat templates --- .github/workflows/validate-tugboat.yml | 4 +- scaffold/tugboat/config.example.yml | 119 ------------------ scaffold/tugboat/config.yml.twig | 27 ++++ scaffold/tugboat/settings.tugboat.php | 14 --- scaffold/tugboat/settings.tugboat.php.twig | 37 ++++++ scaffold/tugboat/steps/build.sh | 5 + scaffold/tugboat/steps/init.sh | 34 +++++ scaffold/tugboat/steps/update.sh | 27 ++++ scaffold/tugboat/tugboat.acquia-example.yml | 115 ----------------- scaffold/tugboat/tugboat.pantheon-example.yml | 104 --------------- src/ProviderInterface.php | 14 +++ src/ScaffoldInstallerPlugin.php | 31 ++--- src/TugboatConfig.php | 74 +++++++++++ 13 files changed, 234 insertions(+), 371 deletions(-) delete mode 100644 scaffold/tugboat/config.example.yml create mode 100644 scaffold/tugboat/config.yml.twig delete mode 100644 scaffold/tugboat/settings.tugboat.php create mode 100644 scaffold/tugboat/settings.tugboat.php.twig create mode 100644 scaffold/tugboat/steps/build.sh create mode 100644 scaffold/tugboat/steps/init.sh create mode 100644 scaffold/tugboat/steps/update.sh delete mode 100644 scaffold/tugboat/tugboat.acquia-example.yml delete mode 100644 scaffold/tugboat/tugboat.pantheon-example.yml create mode 100644 src/ProviderInterface.php create mode 100644 src/TugboatConfig.php diff --git a/.github/workflows/validate-tugboat.yml b/.github/workflows/validate-tugboat.yml index 6cdbe4998..7cf7e8d38 100644 --- a/.github/workflows/validate-tugboat.yml +++ b/.github/workflows/validate-tugboat.yml @@ -19,4 +19,6 @@ jobs: - run: | curl -O https://dashboard.tugboatqa.com/cli/linux/tugboat.tar.gz tar xzvf tugboat.tar.gz - ./tugboat validate scaffold/tugboat/config.example.yml + ./tugboat validate scaffold/tugboat/config.generic.yml + ./tugboat validate scaffold/tugboat/config.acquia.yml + ./tugboat validate scaffold/tugboat/config.pantheon.yml diff --git a/scaffold/tugboat/config.example.yml b/scaffold/tugboat/config.example.yml deleted file mode 100644 index abd5d98b3..000000000 --- a/scaffold/tugboat/config.example.yml +++ /dev/null @@ -1,119 +0,0 @@ -# This serves as a Tugboat configuration file for Drupal websites. It sets up: -# -# 1. PHP 8.1 with Apache as the web server. -# 2. MariaDB 10 for the database. -# 3. drush-launcher -# 4. Enables the PHP opcache and required Apache extensions. -services: - - # What to call the service hosting the site. - php: - # Only allow access via https. - http: false - - # Use PHP 8.1 with Apache - image: tugboatqa/php:8.1-apache-bullseye - - # Set this as the default service. This does a few things - # 1. Clones the git repository into the service container - # 2. Exposes port 80 to the Tugboat HTTP proxy - # 3. Routes requests to the preview URL to this service - default: true - - # Wait until the mariadb service is done building - depends: - - mariadb - - # A set of commands to run while building this service - commands: - - # Commands that set up the basic preview infrastructure - init: | - set -eux - echo "Initializing..." - # Install prerequisite packages - apt-get update - apt-get install -y mariadb-client libldap2-dev - - # Install drush-launcher - wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar - chmod +x /usr/local/bin/drush - - # Link the document root to the expected path. Tugboat uses /docroot - # by default. So, if Drupal is located at any other path in your git - # repository, change that here. This example links /web to the docroot - [ -d "${DOCROOT}" ] || ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" - - docker-php-ext-install opcache - a2enmod headers rewrite - - # WebP - apt-get install -y libwebp-dev libwebp6 webp libmagickwand-dev - docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp - docker-php-ext-install gd - - # Configure GD - apt-get update && apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev - docker-php-ext-configure gd --with-jpeg --with-freetype && docker-php-ext-install gd - - # Install drush-launcher, if desired. - wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar - chmod +x /usr/local/bin/drush - - # Commands that import files, databases, or other assets. When an - # existing preview is refreshed, the build workflow starts here, - # skipping the init step, because the results of that step will - # already be present. - update: | - set -eux - echo "Updating..." - - # We intentionally do not set up syncing of static assets, as we have - # decided to always use Stage File Proxy: - # https://architecture.lullabot.com/adr/20210729-stage-file-proxy/ - - # Set up permissions for the files directories. - chgrp -R www-data "${TUGBOAT_ROOT}/web/sites/default/files" - chmod -R g+w "${TUGBOAT_ROOT}/web/sites/default/files" - chmod 2775 "${TUGBOAT_ROOT}/web/sites/default/files" - - composer install - - # Install Drupal using the standard profile. - vendor/bin/task drupal:install - - # To use an existing site, add the appropriate environment variables - # as document at and instead run: - # vendor/bin/task :fetch-db - # vendor/bin/task drupal:import-db - - # Install - echo "Install drush" - drush site:install - - # Commands that build the site. This is where you would add things - # like feature reverts or any other drush commands required to - # set up or configure the site. When a preview is built from a - # base preview, the build workflow starts here, skipping the init - # and update steps, because the results of those are inherited - # from the base preview. - build: | - set -eux - vendor/bin/task drupal:update - vendor/bin/drush user:login - - # What to call the service hosting MySQL. This name also acts as the - # hostname to access the service by from the php service. - mariadb: - - image: tugboatqa/mariadb:10 - - # A set of commands to run while building this service - commands: - - # Commands that import files, databases, or other assets. When an - # existing preview is refreshed, the build workflow starts here, - # skipping the init step, because the results of that step will - # already be present. - update: - - echo "Nothing to do as we import databases from the Drupal service." diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig new file mode 100644 index 000000000..dbcdc538e --- /dev/null +++ b/scaffold/tugboat/config.yml.twig @@ -0,0 +1,27 @@ +services: + php: + http: false + image: tugboatqa/php:{{ php_version }}-apache-bullseye + default: true + + depends: + - {{ database_type }} + {% if memory_cache_type %} + - {{ memory_cache_type }} + {% endif %} + + commands: + init: ./.tugboat/scripts/init.sh + update: ./.tugboat/scripts/update.sh + build: ./.tugboat/scripts/build.sh + + mariadb: + image: tugboatqa/{{ database_type }}:{{ database_version }} + commands: + update: + - echo "Nothing to do as we import databases from the Drupal service." + +{% if memory_cache_type %} + {{ memory_cache_type }}: + image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} +{% endif %} diff --git a/scaffold/tugboat/settings.tugboat.php b/scaffold/tugboat/settings.tugboat.php deleted file mode 100644 index 229057351..000000000 --- a/scaffold/tugboat/settings.tugboat.php +++ /dev/null @@ -1,14 +0,0 @@ - 'tugboat', - 'username' => 'tugboat', - 'password' => 'tugboat', - 'prefix' => '', - 'host' => 'mariadb', - 'port' => '3306', - 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', - 'driver' => 'mysql', - ]; -} diff --git a/scaffold/tugboat/settings.tugboat.php.twig b/scaffold/tugboat/settings.tugboat.php.twig new file mode 100644 index 000000000..b7165ba78 --- /dev/null +++ b/scaffold/tugboat/settings.tugboat.php.twig @@ -0,0 +1,37 @@ + 'tugboat', + 'username' => 'tugboat', + 'password' => 'tugboat', + 'prefix' => '', + 'host' => {{ database_type }}, + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', + ]; +}} + +{% if memory_cache_type == "redis" %} +$redis_config = 'modules/contrib/redis/example.services.yml'; +if (file_exists($redis_config) && is_readable($redis_config)) { + $settings['container_yamls'][] = $redis_config; + $settings['redis.connection']['interface'] = 'PhpRedis'; + $settings['redis.connection']['host'] = 'redis'; + $settings['cache']['default'] = 'cache.backend.redis'; +} +else { + error_log("This project is configured to use Redis for caching. Please download and install the Drupal Redis module. See https://architecture.lullabot.com/adr/20220906-identical-cache-backends/."); +} +{% endif %} + +{% if memory_cache_type == "memcached" %} +if (file_exists('modules/contrib/memcache/memcache.info.yml') { + $settings['memcache']['servers'] = ['memcached:11211' => 'default']; + $settings['cache']['default'] = 'cache.backend.memcache'; +} +else { + error_log("This project is configured to use Memcached for caching. Please download and install the Drupal Memcache module. See https://architecture.lullabot.com/adr/20220906-identical-cache-backends/."); +} +{% endif %} diff --git a/scaffold/tugboat/steps/build.sh b/scaffold/tugboat/steps/build.sh new file mode 100644 index 000000000..0bcbb904f --- /dev/null +++ b/scaffold/tugboat/steps/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -eux +vendor/bin/task drupal:update +vendor/bin/drush user:login diff --git a/scaffold/tugboat/steps/init.sh b/scaffold/tugboat/steps/init.sh new file mode 100644 index 000000000..355a352d7 --- /dev/null +++ b/scaffold/tugboat/steps/init.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -eux +echo "Initializing..." +# Install prerequisite packages +apt-get update +apt-get install -y mariadb-client libldap2-dev + +# Install drush-launcher +wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar +chmod +x /usr/local/bin/drush + +# Link the document root to the expected path. Tugboat uses /docroot +# by default. So, if Drupal is located at any other path in your git +# repository, change that here. This example links /web to the docroot +[ -d "${DOCROOT}" ] || ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" + +docker-php-ext-install opcache +a2enmod headers rewrite + +docker-php-ext-install memcache + +# WebP +apt-get install -y libwebp-dev libwebp6 webp libmagickwand-dev +docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp +docker-php-ext-install gd + +# Configure GD +apt-get update && apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev +docker-php-ext-configure gd --with-jpeg --with-freetype && docker-php-ext-install gd + +# Install drush-launcher, if desired. +wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar +chmod +x /usr/local/bin/drush diff --git a/scaffold/tugboat/steps/update.sh b/scaffold/tugboat/steps/update.sh new file mode 100644 index 000000000..048c9574e --- /dev/null +++ b/scaffold/tugboat/steps/update.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -eux +echo "Updating..." + +# We intentionally do not set up syncing of static assets, as we have +# decided to always use Stage File Proxy: +# https://architecture.lullabot.com/adr/20210729-stage-file-proxy/ + +# Set up permissions for the files directories. +chgrp -R www-data "${TUGBOAT_ROOT}/web/sites/default/files" +chmod -R g+w "${TUGBOAT_ROOT}/web/sites/default/files" +chmod 2775 "${TUGBOAT_ROOT}/web/sites/default/files" + +composer install + +# Install Drupal using the standard profile. +vendor/bin/task drupal:install + +# To use an existing site, add the appropriate environment variables +# as document at and instead run: +# vendor/bin/task :fetch-db +# vendor/bin/task drupal:import-db + +# Install +echo "Install drush" +drush site:install diff --git a/scaffold/tugboat/tugboat.acquia-example.yml b/scaffold/tugboat/tugboat.acquia-example.yml deleted file mode 100644 index 66589705c..000000000 --- a/scaffold/tugboat/tugboat.acquia-example.yml +++ /dev/null @@ -1,115 +0,0 @@ -# This serves as a Tugboat configuration file for Drupal websites. It sets up: -# -# 1. PHP 8.1 with Apache as the web server. -# 2. MariaDB 10 for the database. -# 3. drush-launcher -# 4. Enables the PHP opcache and required Apache extensions. -services: - - # What to call the service hosting the site. - php: - # Only allow access via https. - http: false - - # Use PHP 8.1 with Apache - image: tugboatqa/php:8.1-apache-bullseye - - # Set this as the default service. This does a few things - # 1. Clones the git repository into the service container - # 2. Exposes port 80 to the Tugboat HTTP proxy - # 3. Routes requests to the preview URL to this service - default: true - - # Wait until the mariadb service is done building - depends: - - mariadb - - # A set of commands to run while building this service - commands: - - # Commands that set up the basic preview infrastructure - init: | - set -eux - echo "Initializing..." - # Install prerequisite packages - apt-get update - apt-get install -y mariadb-client libldap2-dev - - # Install drush-launcher - wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar - chmod +x /usr/local/bin/drush - - # Link the document root to the expected path. Tugboat uses /docroot - # by default. So, if Drupal is located at any other path in your git - # repository, change that here. This example links /web to the docroot - [ -d "${DOCROOT}" ] || ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" - - docker-php-ext-install opcache - a2enmod headers rewrite - - # Commands that import files, databases, or other assets. When an - # existing preview is refreshed, the build workflow starts here, - # skipping the init step, because the results of that step will - # already be present. - update: | - set -eux - echo "Updating..." - - # We intentionally do not set up syncing of static assets, as we have - # decided to always use Stage File Proxy: - # https://architecture.lullabot.com/adr/20210729-stage-file-proxy/ - - # Set up permissions for the files directories. - chgrp -R www-data "${DOCROOT}/sites/default/files" - chmod -R g+w "${DOCROOT}/sites/default/files" - chmod 2775 "${DOCROOT}/sites/default/files" - - composer install - - # Install Drupal using the standard profile. - vendor/bin/task drupal:install - - # To use an existing site, add the appropriate environment variables - # as document at and instead run: - # vendor/bin/task :fetch-db - # vendor/bin/task drupal:import-db - - # Commands that build the site. This is where you would add things - # like feature reverts or any other drush commands required to - # set up or configure the site. When a preview is built from a - # base preview, the build workflow starts here, skipping the init - # and update steps, because the results of those are inherited - # from the base preview. - build: | - set -eux - vendor/bin/task drupal:update - vendor/bin/drush user:login - - # What to call the service hosting MySQL. This name also acts as the - # hostname to access the service by from the php service. - mariadb: - - image: tugboatqa/mariadb:10 - - # A set of commands to run while building this service - commands: - - # Commands that import files, databases, or other assets. When an - # existing preview is refreshed, the build workflow starts here, - # skipping the init step, because the results of that step will - # already be present. - update: - - echo "Nothing to do as we import databases from the Drupal service." - - memcached: - - image: tugboatqa/memcached:1 - -# commands: -# -# update: | -# -# if [[ "tugboatqa/memcached:1" == "NULL" ]]; then -# echo -e "FATAL ERROR: Not installed" -# exit 1 -# fi diff --git a/scaffold/tugboat/tugboat.pantheon-example.yml b/scaffold/tugboat/tugboat.pantheon-example.yml deleted file mode 100644 index 58cc91a96..000000000 --- a/scaffold/tugboat/tugboat.pantheon-example.yml +++ /dev/null @@ -1,104 +0,0 @@ -# This serves as a Tugboat configuration file for Drupal websites. It sets up: -# -# 1. PHP 8.1 with Apache as the web server. -# 2. MariaDB 10 for the database. -# 3. drush-launcher -# 4. Enables the PHP opcache and required Apache extensions. -services: - - # What to call the service hosting the site. - php: - # Only allow access via https. - http: false - - # Use PHP 8.1 with Apache - image: tugboatqa/php:8.1-apache-bullseye - - # Set this as the default service. This does a few things - # 1. Clones the git repository into the service container - # 2. Exposes port 80 to the Tugboat HTTP proxy - # 3. Routes requests to the preview URL to this service - default: true - - # Wait until the mariadb service is done building - depends: - - mariadb - - # A set of commands to run while building this service - commands: - - # Commands that set up the basic preview infrastructure - init: | - set -eux - echo "Initializing..." - # Install prerequisite packages - apt-get update - apt-get install -y mariadb-client libldap2-dev - # Install drush-launcher - wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar - chmod +x /usr/local/bin/drush - # Link the document root to the expected path. Tugboat uses /docroot - # by default. So, if Drupal is located at any other path in your git - # repository, change that here. This example links /web to the docroot - [ -d "${DOCROOT}" ] || ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" - docker-php-ext-install opcache - a2enmod headers rewrite - # Commands that import files, databases, or other assets. When an - # existing preview is refreshed, the build workflow starts here, - # skipping the init step, because the results of that step will - # already be present. - update: | - set -eux - echo "Updating..." - # We intentionally do not set up syncing of static assets, as we have - # decided to always use Stage File Proxy: - # https://architecture.lullabot.com/adr/20210729-stage-file-proxy/ - # Set up permissions for the files directories. - chgrp -R www-data "${DOCROOT}/sites/default/files" - chmod -R g+w "${DOCROOT}/sites/default/files" - chmod 2775 "${DOCROOT}/sites/default/files" - composer install - # Install Drupal using the standard profile. - vendor/bin/task drupal:install - # To use an existing site, add the appropriate environment variables - # as document at and instead run: - # vendor/bin/task :fetch-db - # vendor/bin/task drupal:import-db - # Commands that build the site. This is where you would add things - # like feature reverts or any other drush commands required to - # set up or configure the site. When a preview is built from a - # base preview, the build workflow starts here, skipping the init - # and update steps, because the results of those are inherited - # from the base preview. - build: | - set -eux - vendor/bin/task drupal:update - vendor/bin/drush user:login - # What to call the service hosting MySQL. This name also acts as the - # hostname to access the service by from the php service. - mariadb: - - image: tugboatqa/mariadb:10 - - # A set of commands to run while building this service - commands: - - # Commands that import files, databases, or other assets. When an - # existing preview is refreshed, the build workflow starts here, - # skipping the init step, because the results of that step will - # already be present. - update: - - echo "Nothing to do as we import databases from the Drupal service." - - redis: - - image: tugboatqa/redis:7 - -# commands: -# -# update: | -# -# if [[ "tugboatqa/redis:7" == "NULL" ]]; then -# echo -e "FATAL ERROR: Not installed" -# exit 1 -# fi diff --git a/src/ProviderInterface.php b/src/ProviderInterface.php new file mode 100644 index 000000000..ed9563b34 --- /dev/null +++ b/src/ProviderInterface.php @@ -0,0 +1,14 @@ +extra['drainpipe']['tugboat']) && is_array($this->extra['drainpipe']['tugboat'])) { if (!file_exists('./.tugboat/config.yml')) { $fs->ensureDirectoryExists('./.tugboat'); - $fs->copy("$scaffoldPath/tugboat/config.example.yml", './.tugboat/config.yml'); + if (!empty($this->extra['drainpipe']['tugboat'])) { + $provider = $this->extra['drainpipe']['tugboat'][0]; + } + else { + $provider = TugboatConfig::PROVIDER_UNKNOWN; + } + + $tugboatConfig = new TugboatConfig(); + $tugboatConfig->writeFile('config.yml.twig', './.tugboat/', $provider); + $this->io->write("๐Ÿช  [Drainpipe] .tugboat/config.yml installed. Please commit this file."); if (!file_exists('./web/sites/default/settings.tugboat.php')) { - $fs->copy("$scaffoldPath/tugboat/settings.tugboat.php", './web/sites/default/settings.tugboat.php'); + $tugboatConfig = new TugboatConfig(); + $tugboatConfig->writeFile('settings.tugboat.php.twig', './web/sites/default/', $provider); + $this->io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.tugboat.php installed. Please commit this file."); if (file_exists('./web/sites/default/settings.php')) { $include=<<extra['drainpipe']['tugboat'] as $provider) { - if ($provider === 'acquia') { - if (!file_exists('./.tugboat/tugboat.acquia-example.yml')) { - $fs->ensureDirectoryExists('./.tugboat'); - $fs->copy("$scaffoldPath/tugboat/tugboat.acquia-example.yml", './.tugboat/tugboat.acquia-example.yml'); - $this->io->write("๐Ÿช  [Drainpipe] .tugboat/tugboat.acquia-example.yml installed. Please commit this file."); - } - } - if ($provider === 'pantheon') { - if (!file_exists('./.tugboat/tugboat.pantheon-example.yml')) { - $fs->ensureDirectoryExists('./.tugboat'); - $fs->copy("$scaffoldPath/tugboat/tugboat.pantheon-example.yml", './.tugboat/tugboat.pantheon-example.yml'); - $this->io->write("๐Ÿช  [Drainpipe] .tugboat/tugboat.pantheon-example.yml installed. Please commit this file."); - } - } - } } } } diff --git a/src/TugboatConfig.php b/src/TugboatConfig.php new file mode 100644 index 000000000..c60075613 --- /dev/null +++ b/src/TugboatConfig.php @@ -0,0 +1,74 @@ +twig = new Environment($loader); + } + + public function render( + string $name, + string $provider = self::PROVIDER_UNKNOWN + ): string { + switch ($provider) { + case self::PROVIDER_ACQUIA: + return $this->renderAcquia($name); + case self::PROVIDER_PANTHEON: + return $this->renderPantheon($name); + default: + return $this->renderUnknown($name); + } + } + + public function writeFile( + string $name, + string $path, + string $provider = self::PROVIDER_UNKNOWN + ): void { + file_put_contents($path, $this->render($name, $provider)); + } + + private function renderAcquia(string $name): string + { + return $this->twig->render($name, [ + 'database_type' => 'mysql', + 'database_version' => '5.7', + 'memory_cache_type' => 'memcached', + 'memory_cache_version' => 1, + ]); + } + + private function renderPantheon(string $name): string + { + return $this->twig->render($name, [ + 'database_type' => 'mariadb', + 'database_version' => '10.6', + 'memory_cache_type' => 'redis', + 'memory_cache_version' => 7, + ]); + } + + private function renderUnknown(string $name): string + { + return $this->twig->render($name, [ + 'database_type' => 'mariadb', + 'database_version' => '10.6', + ]); + } + +} From 5425c9a25e2ab160414bf375913d54c9efd410d4 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 10:50:22 -0500 Subject: [PATCH 016/172] Downgrade to Twig 2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e0566e4b3..2bd1e6ff5 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "composer-plugin-api": "^2.0", "drush/drush": "^10|^11", "symfony/yaml": "^3|^4", - "twig/twig": "^3.4" + "twig/twig": "^2.0" }, "require-dev": { "composer/composer": "^2.0", From 634950b19d9927ce27e18d9c70e5dabfa5ff0ee9 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 10:55:40 -0500 Subject: [PATCH 017/172] Set PHP version based on composer constraints --- src/ScaffoldInstallerPlugin.php | 17 ++++++++++++++++- src/TugboatConfig.php | 18 ++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 9a8b21454..b9c859b55 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -35,12 +35,18 @@ class ScaffoldInstallerPlugin implements PluginInterface, EventSubscriberInterfa */ protected $extra; + /** + * @var \Composer\Package\Link[] + */ + private $platformRequirements; + /** * {@inheritDoc} */ public function activate(Composer $composer, IOInterface $io) { $this->io = $io; + $this->platformRequirements = $composer->getLocker()->getPlatformRequirements(); $this->config = $composer->getConfig(); $this->extra = $composer->getPackage()->getExtra(); } @@ -77,6 +83,7 @@ public static function getSubscribedEvents() */ public function onPostInstallCmd(Event $event) { + $this->platformRequirements = $event->getComposer()->getLocker()->getPlatformRequirements(); $this->installTaskfile(); $this->installGitignore(); $this->installDdevCommand(); @@ -90,6 +97,7 @@ public function onPostInstallCmd(Event $event) */ public function onPostUpdateCmd(Event $event) { + $this->platformRequirements = $event->getComposer()->getLocker()->getPlatformRequirements(); $this->installTaskfile(); $this->installGitignore(); $this->installDdevCommand(); @@ -257,6 +265,13 @@ private function installCICommands(): void // Tugboat if (isset($this->extra['drainpipe']['tugboat']) && is_array($this->extra['drainpipe']['tugboat'])) { + $php = '8.1'; + foreach ($this->platformRequirements as $link) { + if ($link->getTarget() === "php") { + $lower = $link->getConstraint()->getLowerBound()->getVersion(); + $php = substr($lower, 0, 3); + } + } if (!file_exists('./.tugboat/config.yml')) { $fs->ensureDirectoryExists('./.tugboat'); if (!empty($this->extra['drainpipe']['tugboat'])) { @@ -266,7 +281,7 @@ private function installCICommands(): void $provider = TugboatConfig::PROVIDER_UNKNOWN; } - $tugboatConfig = new TugboatConfig(); + $tugboatConfig = new TugboatConfig($php); $tugboatConfig->writeFile('config.yml.twig', './.tugboat/', $provider); $this->io->write("๐Ÿช  [Drainpipe] .tugboat/config.yml installed. Please commit this file."); diff --git a/src/TugboatConfig.php b/src/TugboatConfig.php index c60075613..99f0085ec 100644 --- a/src/TugboatConfig.php +++ b/src/TugboatConfig.php @@ -15,10 +15,16 @@ final class TugboatConfig implements ProviderInterface */ private $twig; - public function __construct() + /** + * @var string + */ + private $phpVersion; + + public function __construct(string $phpVersion) { - $loader = new FilesystemLoader(__DIR__.'../scaffold/tugboat'); + $loader = new FilesystemLoader(__DIR__.'/../scaffold/tugboat'); $this->twig = new Environment($loader); + $this->phpVersion = $phpVersion; } public function render( @@ -40,12 +46,14 @@ public function writeFile( string $path, string $provider = self::PROVIDER_UNKNOWN ): void { - file_put_contents($path, $this->render($name, $provider)); + $basename = basename($name, '.twig'); + file_put_contents($path . "/$basename", $this->render($name, $provider)); } private function renderAcquia(string $name): string { return $this->twig->render($name, [ + 'php_version' => $this->phpVersion, 'database_type' => 'mysql', 'database_version' => '5.7', 'memory_cache_type' => 'memcached', @@ -56,6 +64,7 @@ private function renderAcquia(string $name): string private function renderPantheon(string $name): string { return $this->twig->render($name, [ + 'php_version' => $this->phpVersion, 'database_type' => 'mariadb', 'database_version' => '10.6', 'memory_cache_type' => 'redis', @@ -66,8 +75,9 @@ private function renderPantheon(string $name): string private function renderUnknown(string $name): string { return $this->twig->render($name, [ + 'php_version' => $this->phpVersion, 'database_type' => 'mariadb', - 'database_version' => '10.6', + 'database_version' => '10.4', ]); } From 526ba3775cde3ebd8ba15fbaf85eef3c776f9568 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 11:27:05 -0500 Subject: [PATCH 018/172] Support configuring if you downsync or do a site install --- .../steps/{update.sh => update.sh.twig} | 14 ++---- src/ProviderInterface.php | 6 +-- src/ScaffoldInstallerPlugin.php | 48 +++++++++++++------ src/TugboatConfig.php | 32 ++++++++----- 4 files changed, 62 insertions(+), 38 deletions(-) rename scaffold/tugboat/steps/{update.sh => update.sh.twig} (69%) diff --git a/scaffold/tugboat/steps/update.sh b/scaffold/tugboat/steps/update.sh.twig similarity index 69% rename from scaffold/tugboat/steps/update.sh rename to scaffold/tugboat/steps/update.sh.twig index 048c9574e..7a7a1cd1c 100644 --- a/scaffold/tugboat/steps/update.sh +++ b/scaffold/tugboat/steps/update.sh.twig @@ -14,14 +14,10 @@ chmod 2775 "${TUGBOAT_ROOT}/web/sites/default/files" composer install +{% if downsync %} +vendor/bin/task {{ host }}:fetch-db +vendor/bin/task drupal:import-db +{% else %} # Install Drupal using the standard profile. vendor/bin/task drupal:install - -# To use an existing site, add the appropriate environment variables -# as document at and instead run: -# vendor/bin/task :fetch-db -# vendor/bin/task drupal:import-db - -# Install -echo "Install drush" -drush site:install +{% endif %} diff --git a/src/ProviderInterface.php b/src/ProviderInterface.php index ed9563b34..f39848644 100644 --- a/src/ProviderInterface.php +++ b/src/ProviderInterface.php @@ -5,10 +5,10 @@ interface ProviderInterface { - public const PROVIDER_PANTHEON = 'pantheon'; + public const HOST_PANTHEON = 'pantheon'; - public const PROVIDER_ACQUIA = 'acquia'; + public const HOST_ACQUIA = 'acquia'; - public const PROVIDER_UNKNOWN = 'unknown'; + public const HOST_UNKNOWN = 'unknown'; } diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index b9c859b55..683181e82 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -265,29 +265,32 @@ private function installCICommands(): void // Tugboat if (isset($this->extra['drainpipe']['tugboat']) && is_array($this->extra['drainpipe']['tugboat'])) { - $php = '8.1'; - foreach ($this->platformRequirements as $link) { - if ($link->getTarget() === "php") { - $lower = $link->getConstraint()->getLowerBound()->getVersion(); - $php = substr($lower, 0, 3); - } - } + $php = $this->getPhpVersion(); if (!file_exists('./.tugboat/config.yml')) { $fs->ensureDirectoryExists('./.tugboat'); - if (!empty($this->extra['drainpipe']['tugboat'])) { - $provider = $this->extra['drainpipe']['tugboat'][0]; + $provider = $this->extra['drainpipe']['tugboat']['provider']; + if (!empty($provider)) { + $host = $this->extra['drainpipe']['tugboat']['provider']['host']; } else { - $provider = TugboatConfig::PROVIDER_UNKNOWN; + $host = ProviderInterface::HOST_UNKNOWN; } $tugboatConfig = new TugboatConfig($php); - $tugboatConfig->writeFile('config.yml.twig', './.tugboat/', $provider); + $downsync = $this->extra['drainpipe']['tugboat']['provider']['downsync'] ?? false; + $tugboatConfig->writeFile('config.yml.twig', './.tugboat/', $host, + $downsync + ); + $fs->ensureDirectoryExists('./.tugboat/steps'); + $fs->copy("$scaffoldPath/tugboat/steps/init.sh", './.tugboat/steps/init.sh'); + $fs->copy("$scaffoldPath/tugboat/steps/build.sh", './.tugboat/steps/build.sh'); + $tugboatConfig->writeFile('steps/update.sh.twig', './.tugboat/steps/', $host, + $downsync + ); - $this->io->write("๐Ÿช  [Drainpipe] .tugboat/config.yml installed. Please commit this file."); + $this->io->write("๐Ÿช  [Drainpipe] .tugboat/ directory installed. Please commit this directory."); if (!file_exists('./web/sites/default/settings.tugboat.php')) { - $tugboatConfig = new TugboatConfig(); - $tugboatConfig->writeFile('settings.tugboat.php.twig', './web/sites/default/', $provider); + $tugboatConfig->writeFile('settings.tugboat.php.twig', './web/sites/default/', $host); $this->io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.tugboat.php installed. Please commit this file."); if (file_exists('./web/sites/default/settings.php')) { @@ -306,4 +309,21 @@ private function installCICommands(): void } } } + + /** + * @return string + */ + private function getPhpVersion(): string + { + $php = '8.1'; + foreach ($this->platformRequirements as $link) { + if ($link->getTarget() === "php") { + $lower = $link->getConstraint()->getLowerBound()->getVersion(); + $php = substr($lower, 0, 3); + } + } + + return $php; + } + } diff --git a/src/TugboatConfig.php b/src/TugboatConfig.php index 99f0085ec..bf9068ca9 100644 --- a/src/TugboatConfig.php +++ b/src/TugboatConfig.php @@ -29,28 +29,30 @@ public function __construct(string $phpVersion) public function render( string $name, - string $provider = self::PROVIDER_UNKNOWN + string $host = self::HOST_UNKNOWN, + bool $downsync = false ): string { - switch ($provider) { - case self::PROVIDER_ACQUIA: - return $this->renderAcquia($name); - case self::PROVIDER_PANTHEON: - return $this->renderPantheon($name); + switch ($host) { + case self::HOST_ACQUIA: + return $this->renderAcquia($name, $downsync); + case self::HOST_PANTHEON: + return $this->renderPantheon($name, $downsync); default: - return $this->renderUnknown($name); + return $this->renderUnknown($name, $host, $downsync); } } public function writeFile( string $name, string $path, - string $provider = self::PROVIDER_UNKNOWN + string $host = self::HOST_UNKNOWN, + bool $downsync = false ): void { $basename = basename($name, '.twig'); - file_put_contents($path . "/$basename", $this->render($name, $provider)); + file_put_contents($path . "/$basename", $this->render($name, $host, $downsync)); } - private function renderAcquia(string $name): string + private function renderAcquia(string $name, bool $downsync): string { return $this->twig->render($name, [ 'php_version' => $this->phpVersion, @@ -58,10 +60,12 @@ private function renderAcquia(string $name): string 'database_version' => '5.7', 'memory_cache_type' => 'memcached', 'memory_cache_version' => 1, + 'host' => 'acquia', + 'downsync' => $downsync, ]); } - private function renderPantheon(string $name): string + private function renderPantheon(string $name, bool $downsync): string { return $this->twig->render($name, [ 'php_version' => $this->phpVersion, @@ -69,15 +73,19 @@ private function renderPantheon(string $name): string 'database_version' => '10.6', 'memory_cache_type' => 'redis', 'memory_cache_version' => 7, + 'host' => 'pantheon', + 'downsync' => $downsync, ]); } - private function renderUnknown(string $name): string + private function renderUnknown(string $name, string $host, bool $downsync): string { return $this->twig->render($name, [ 'php_version' => $this->phpVersion, 'database_type' => 'mariadb', 'database_version' => '10.4', + 'host' => $host, + 'downsync' => $downsync, ]); } From 79d9db2900d538ca3008cad7b63e527b0e9768d7 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 11:28:21 -0500 Subject: [PATCH 019/172] Add a reminder about environment variables --- scaffold/tugboat/steps/update.sh.twig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scaffold/tugboat/steps/update.sh.twig b/scaffold/tugboat/steps/update.sh.twig index 7a7a1cd1c..30a6f58b5 100644 --- a/scaffold/tugboat/steps/update.sh.twig +++ b/scaffold/tugboat/steps/update.sh.twig @@ -15,6 +15,8 @@ chmod 2775 "${TUGBOAT_ROOT}/web/sites/default/files" composer install {% if downsync %} +# Remember to set any required environment variables for the fetch-db task, +# such as PANTHEON_TOKEN. vendor/bin/task {{ host }}:fetch-db vendor/bin/task drupal:import-db {% else %} From 015749bac34cd6362a1c46815756c228064894ad Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 11:48:14 -0500 Subject: [PATCH 020/172] Set permissions on copied files --- src/ScaffoldInstallerPlugin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 683181e82..84b2bb45d 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -265,7 +265,6 @@ private function installCICommands(): void // Tugboat if (isset($this->extra['drainpipe']['tugboat']) && is_array($this->extra['drainpipe']['tugboat'])) { - $php = $this->getPhpVersion(); if (!file_exists('./.tugboat/config.yml')) { $fs->ensureDirectoryExists('./.tugboat'); $provider = $this->extra['drainpipe']['tugboat']['provider']; @@ -276,17 +275,20 @@ private function installCICommands(): void $host = ProviderInterface::HOST_UNKNOWN; } - $tugboatConfig = new TugboatConfig($php); + $tugboatConfig = new TugboatConfig($this->getPhpVersion()); $downsync = $this->extra['drainpipe']['tugboat']['provider']['downsync'] ?? false; $tugboatConfig->writeFile('config.yml.twig', './.tugboat/', $host, $downsync ); $fs->ensureDirectoryExists('./.tugboat/steps'); $fs->copy("$scaffoldPath/tugboat/steps/init.sh", './.tugboat/steps/init.sh'); + chmod('./.tugboat/steps/init.sh', 0755); $fs->copy("$scaffoldPath/tugboat/steps/build.sh", './.tugboat/steps/build.sh'); + chmod('./.tugboat/steps/build.sh', 0755); $tugboatConfig->writeFile('steps/update.sh.twig', './.tugboat/steps/', $host, $downsync ); + chmod('./.tugboat/steps/update.sh', 0755); $this->io->write("๐Ÿช  [Drainpipe] .tugboat/ directory installed. Please commit this directory."); if (!file_exists('./web/sites/default/settings.tugboat.php')) { From aeecf231ef92ed360c0a2babd64dbeb397eabff2 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 11:48:33 -0500 Subject: [PATCH 021/172] Update README --- README.md | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index d7fd87e78..0019eb0ea 100644 --- a/README.md +++ b/README.md @@ -189,36 +189,51 @@ Requires `GITLAB_ACCESS_TOKEN` variable to be set, which is an access token with ## Tugboat Integration -Add the following to `composer.json` for Tugboat helpers: +Add the following to `composer.json` to add Tugboat configuration: + ```json -"extra": { - "drainpipe": { - "tugboat": [] - } +{ + "extra": { + "drainpipe": { + "tugboat": {} + } + } } ``` -This will import [`./.tugboat/config.example.yml`](./.tugboat/config.example.yml), -and import [`./web/sites/default/settings.php`](./web/sites/default/settings.php). +The PHP version is autodetected based on the composer requirements. + +A `provider` object allows the upstream host to be determined and to determine +if Tugboat downsyncs from the provider or does a fresh Drupal site install. ### Acquia ```json -"extra": { - "drainpipe": { - "gitlab": ["acquia"] +{ + "extra": { + "drainpipe": { + "tugboat": { + "provider": { + "host": "acquia", + "downsync": true + } + } + } } } ``` -This will import [`./.tugboat/tugboat.acquia-example.yml`](./.tugboat/tugboat.acquia-example.yml), -this file includes memcached. ### Pantheon ```json -"extra": { - "drainpipe": { - "gitlab": ["pantheon"] +{ + "extra": { + "drainpipe": { + "tugboat": { + "provider": { + "host": "pantheon", + "downsync": true + } + } + } } } ``` -This will import [`./.tugboat/tugboat.pantheon-example.yml`](./.tugboat/tugboat.pantheon-example.yml), -this file includes redis. From da76c66e11408ab330e4ba549b28bb762012d948 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 11:51:29 -0500 Subject: [PATCH 022/172] Fix overwriting webp configuration --- scaffold/tugboat/steps/init.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scaffold/tugboat/steps/init.sh b/scaffold/tugboat/steps/init.sh index 355a352d7..d92411a79 100644 --- a/scaffold/tugboat/steps/init.sh +++ b/scaffold/tugboat/steps/init.sh @@ -18,16 +18,17 @@ chmod +x /usr/local/bin/drush docker-php-ext-install opcache a2enmod headers rewrite -docker-php-ext-install memcache +# GD dependencies +apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev -# WebP +# WebP dependencies apt-get install -y libwebp-dev libwebp6 webp libmagickwand-dev + +# Build and install gd docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp docker-php-ext-install gd -# Configure GD -apt-get update && apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev -docker-php-ext-configure gd --with-jpeg --with-freetype && docker-php-ext-install gd +docker-php-ext-install memcache # Install drush-launcher, if desired. wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar From fddc1095c453d865850219e03fece398ab3bf875 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 11:57:01 -0500 Subject: [PATCH 023/172] Fix hardcoding the database type --- scaffold/tugboat/config.yml.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index dbcdc538e..c91df57eb 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -15,7 +15,7 @@ services: update: ./.tugboat/scripts/update.sh build: ./.tugboat/scripts/build.sh - mariadb: + {{ database_type }}: image: tugboatqa/{{ database_type }}:{{ database_version }} commands: update: From 7491fdd79de0e2a99ec865c4fad122d3400d625d Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 12:01:00 -0500 Subject: [PATCH 024/172] Fix indentation --- scaffold/tugboat/config.yml.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index c91df57eb..7ea1fb99a 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -6,9 +6,9 @@ services: depends: - {{ database_type }} - {% if memory_cache_type %} +{% if memory_cache_type %} - {{ memory_cache_type }} - {% endif %} +{% endif %} commands: init: ./.tugboat/scripts/init.sh From 3f744c147f018e92c42151a6203faf5fd0696967 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 12:11:29 -0500 Subject: [PATCH 025/172] Only install memcached extension if needed --- scaffold/tugboat/steps/{init.sh => init.sh.twig} | 2 ++ src/ScaffoldInstallerPlugin.php | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) rename scaffold/tugboat/steps/{init.sh => init.sh.twig} (95%) diff --git a/scaffold/tugboat/steps/init.sh b/scaffold/tugboat/steps/init.sh.twig similarity index 95% rename from scaffold/tugboat/steps/init.sh rename to scaffold/tugboat/steps/init.sh.twig index d92411a79..3ae307c3e 100644 --- a/scaffold/tugboat/steps/init.sh +++ b/scaffold/tugboat/steps/init.sh.twig @@ -28,7 +28,9 @@ apt-get install -y libwebp-dev libwebp6 webp libmagickwand-dev docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp docker-php-ext-install gd +{% if memory_cache_type == "memcached" %} docker-php-ext-install memcache +{% endif %} # Install drush-launcher, if desired. wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 84b2bb45d..67ff3f465 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -281,7 +281,9 @@ private function installCICommands(): void $downsync ); $fs->ensureDirectoryExists('./.tugboat/steps'); - $fs->copy("$scaffoldPath/tugboat/steps/init.sh", './.tugboat/steps/init.sh'); + $tugboatConfig->writeFile('steps/init.sh.twig', './.tugboat/steps/', $host, + $downsync + ); chmod('./.tugboat/steps/init.sh', 0755); $fs->copy("$scaffoldPath/tugboat/steps/build.sh", './.tugboat/steps/build.sh'); chmod('./.tugboat/steps/build.sh', 0755); From bd7881bfb7f0c2d64013163d30ae9f641246b60d Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 12:34:09 -0500 Subject: [PATCH 026/172] Fix using unset variable --- src/ScaffoldInstallerPlugin.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 67ff3f465..077690f3b 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -267,8 +267,7 @@ private function installCICommands(): void if (isset($this->extra['drainpipe']['tugboat']) && is_array($this->extra['drainpipe']['tugboat'])) { if (!file_exists('./.tugboat/config.yml')) { $fs->ensureDirectoryExists('./.tugboat'); - $provider = $this->extra['drainpipe']['tugboat']['provider']; - if (!empty($provider)) { + if (!empty($this->extra['drainpipe']['tugboat']['provider'])) { $host = $this->extra['drainpipe']['tugboat']['provider']['host']; } else { From a86219699b0babd977697ca3aa880306f51532b3 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 13:01:01 -0500 Subject: [PATCH 027/172] Simplify syntax --- src/ScaffoldInstallerPlugin.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 077690f3b..234cd51d5 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -267,12 +267,7 @@ private function installCICommands(): void if (isset($this->extra['drainpipe']['tugboat']) && is_array($this->extra['drainpipe']['tugboat'])) { if (!file_exists('./.tugboat/config.yml')) { $fs->ensureDirectoryExists('./.tugboat'); - if (!empty($this->extra['drainpipe']['tugboat']['provider'])) { - $host = $this->extra['drainpipe']['tugboat']['provider']['host']; - } - else { - $host = ProviderInterface::HOST_UNKNOWN; - } + $host = $this->extra['drainpipe']['tugboat']['provider']['host'] ?? ProviderInterface::HOST_UNKNOWN; $tugboatConfig = new TugboatConfig($this->getPhpVersion()); $downsync = $this->extra['drainpipe']['tugboat']['provider']['downsync'] ?? false; From ce04c586fc60547bd04505f8ca4037b269114535 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 13:04:46 -0500 Subject: [PATCH 028/172] Add a newline --- src/ScaffoldInstallerPlugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 234cd51d5..bfc513046 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -295,6 +295,7 @@ private function installCICommands(): void $include=<< Date: Fri, 11 Nov 2022 13:06:13 -0500 Subject: [PATCH 029/172] Use PHP_EOL instead --- src/ScaffoldInstallerPlugin.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index bfc513046..971695a49 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -295,10 +295,9 @@ private function installCICommands(): void $include=<<io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.php modified to include settings.tugboat.php. Please commit this file."); } else { From 9cd15e75de0a09fbc2377d4b0a131bc5b7e9c3f6 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 13:09:00 -0500 Subject: [PATCH 030/172] Fix script path --- scaffold/tugboat/config.yml.twig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index 7ea1fb99a..e3a8c78e9 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -11,9 +11,9 @@ services: {% endif %} commands: - init: ./.tugboat/scripts/init.sh - update: ./.tugboat/scripts/update.sh - build: ./.tugboat/scripts/build.sh + init: ./.tugboat/steps/init.sh + update: ./.tugboat/steps/update.sh + build: ./.tugboat/steps/build.sh {{ database_type }}: image: tugboatqa/{{ database_type }}:{{ database_version }} From 4b6f794fa4db2355035364209404d0aa3ed79b20 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 13:15:07 -0500 Subject: [PATCH 031/172] Add fixing mkdir --- scaffold/tugboat/steps/update.sh.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/scaffold/tugboat/steps/update.sh.twig b/scaffold/tugboat/steps/update.sh.twig index 30a6f58b5..8be40adf8 100644 --- a/scaffold/tugboat/steps/update.sh.twig +++ b/scaffold/tugboat/steps/update.sh.twig @@ -8,6 +8,7 @@ echo "Updating..." # https://architecture.lullabot.com/adr/20210729-stage-file-proxy/ # Set up permissions for the files directories. +mkdir -p "${TUGBOAT_ROOT}/web/sites/default/files" chgrp -R www-data "${TUGBOAT_ROOT}/web/sites/default/files" chmod -R g+w "${TUGBOAT_ROOT}/web/sites/default/files" chmod 2775 "${TUGBOAT_ROOT}/web/sites/default/files" From 75f34b7c53fa2929fd84d8cd3dd9fa7ae0c692aa Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 13:18:54 -0500 Subject: [PATCH 032/172] Fix double }} --- scaffold/tugboat/settings.tugboat.php.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/settings.tugboat.php.twig b/scaffold/tugboat/settings.tugboat.php.twig index b7165ba78..06c3c04e0 100644 --- a/scaffold/tugboat/settings.tugboat.php.twig +++ b/scaffold/tugboat/settings.tugboat.php.twig @@ -11,7 +11,7 @@ if (getenv('TUGBOAT_REPO') !== FALSE) { 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', ]; -}} +} {% if memory_cache_type == "redis" %} $redis_config = 'modules/contrib/redis/example.services.yml'; From 4bdc4de582c3ce7e7b299758486dc90b70c62f15 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 13:20:11 -0500 Subject: [PATCH 033/172] Clean up spacing --- scaffold/tugboat/settings.tugboat.php.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scaffold/tugboat/settings.tugboat.php.twig b/scaffold/tugboat/settings.tugboat.php.twig index 06c3c04e0..e39881846 100644 --- a/scaffold/tugboat/settings.tugboat.php.twig +++ b/scaffold/tugboat/settings.tugboat.php.twig @@ -12,8 +12,8 @@ if (getenv('TUGBOAT_REPO') !== FALSE) { 'driver' => 'mysql', ]; } - {% if memory_cache_type == "redis" %} + $redis_config = 'modules/contrib/redis/example.services.yml'; if (file_exists($redis_config) && is_readable($redis_config)) { $settings['container_yamls'][] = $redis_config; @@ -25,8 +25,8 @@ else { error_log("This project is configured to use Redis for caching. Please download and install the Drupal Redis module. See https://architecture.lullabot.com/adr/20220906-identical-cache-backends/."); } {% endif %} - {% if memory_cache_type == "memcached" %} + if (file_exists('modules/contrib/memcache/memcache.info.yml') { $settings['memcache']['servers'] = ['memcached:11211' => 'default']; $settings['cache']['default'] = 'cache.backend.memcache'; From 58d3e047fdb8a6acbb11b6fff9e8b245b60a4db6 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 13:23:25 -0500 Subject: [PATCH 034/172] Fix missing quotes --- scaffold/tugboat/settings.tugboat.php.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/settings.tugboat.php.twig b/scaffold/tugboat/settings.tugboat.php.twig index e39881846..51749b31c 100644 --- a/scaffold/tugboat/settings.tugboat.php.twig +++ b/scaffold/tugboat/settings.tugboat.php.twig @@ -6,7 +6,7 @@ if (getenv('TUGBOAT_REPO') !== FALSE) { 'username' => 'tugboat', 'password' => 'tugboat', 'prefix' => '', - 'host' => {{ database_type }}, + 'host' => '{{ database_type }}', 'port' => '3306', 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', From 7e218f2f7e14832673605933d061edcc739fa416 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 14:17:02 -0500 Subject: [PATCH 035/172] Fix guard --- scaffold/tugboat/steps/init.sh.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/steps/init.sh.twig b/scaffold/tugboat/steps/init.sh.twig index 3ae307c3e..0be25c6c8 100644 --- a/scaffold/tugboat/steps/init.sh.twig +++ b/scaffold/tugboat/steps/init.sh.twig @@ -13,7 +13,7 @@ chmod +x /usr/local/bin/drush # Link the document root to the expected path. Tugboat uses /docroot # by default. So, if Drupal is located at any other path in your git # repository, change that here. This example links /web to the docroot -[ -d "${DOCROOT}" ] || ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" +ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" docker-php-ext-install opcache a2enmod headers rewrite From 625f9f1e3367b1582f52e0721f8599faf1ce77de Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Fri, 11 Nov 2022 14:24:19 -0500 Subject: [PATCH 036/172] Only trigger caching in tugboat --- scaffold/tugboat/settings.tugboat.php.twig | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/scaffold/tugboat/settings.tugboat.php.twig b/scaffold/tugboat/settings.tugboat.php.twig index 51749b31c..1b66f59f7 100644 --- a/scaffold/tugboat/settings.tugboat.php.twig +++ b/scaffold/tugboat/settings.tugboat.php.twig @@ -11,27 +11,27 @@ if (getenv('TUGBOAT_REPO') !== FALSE) { 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', ]; -} {% if memory_cache_type == "redis" %} -$redis_config = 'modules/contrib/redis/example.services.yml'; -if (file_exists($redis_config) && is_readable($redis_config)) { - $settings['container_yamls'][] = $redis_config; - $settings['redis.connection']['interface'] = 'PhpRedis'; - $settings['redis.connection']['host'] = 'redis'; - $settings['cache']['default'] = 'cache.backend.redis'; -} -else { - error_log("This project is configured to use Redis for caching. Please download and install the Drupal Redis module. See https://architecture.lullabot.com/adr/20220906-identical-cache-backends/."); -} + $redis_config = 'modules/contrib/redis/example.services.yml'; + if (file_exists($redis_config) && is_readable($redis_config)) { + $settings['container_yamls'][] = $redis_config; + $settings['redis.connection']['interface'] = 'PhpRedis'; + $settings['redis.connection']['host'] = 'redis'; + $settings['cache']['default'] = 'cache.backend.redis'; + } + else { + error_log("This project is configured to use Redis for caching. Please download and install the Drupal Redis module. See https://architecture.lullabot.com/adr/20220906-identical-cache-backends/."); + } {% endif %} {% if memory_cache_type == "memcached" %} -if (file_exists('modules/contrib/memcache/memcache.info.yml') { - $settings['memcache']['servers'] = ['memcached:11211' => 'default']; - $settings['cache']['default'] = 'cache.backend.memcache'; -} -else { - error_log("This project is configured to use Memcached for caching. Please download and install the Drupal Memcache module. See https://architecture.lullabot.com/adr/20220906-identical-cache-backends/."); -} + if (file_exists('modules/contrib/memcache/memcache.info.yml') { + $settings['memcache']['servers'] = ['memcached:11211' => 'default']; + $settings['cache']['default'] = 'cache.backend.memcache'; + } + else { + error_log("This project is configured to use Memcached for caching. Please download and install the Drupal Memcache module. See https://architecture.lullabot.com/adr/20220906-identical-cache-backends/."); + } {% endif %} +} From 408f88c466a1079a89e7f38e8de858f949f9532b Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 16:15:59 -0500 Subject: [PATCH 037/172] Clean up the init script --- scaffold/tugboat/steps/init.sh.twig | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/scaffold/tugboat/steps/init.sh.twig b/scaffold/tugboat/steps/init.sh.twig index 0be25c6c8..1c9d95201 100644 --- a/scaffold/tugboat/steps/init.sh.twig +++ b/scaffold/tugboat/steps/init.sh.twig @@ -2,36 +2,43 @@ set -eux echo "Initializing..." -# Install prerequisite packages -apt-get update -apt-get install -y mariadb-client libldap2-dev -# Install drush-launcher -wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar -chmod +x /usr/local/bin/drush +# Install mysql or mariadb client. +apt-get update +apt-get install -y {{ database_type }}-client # Link the document root to the expected path. Tugboat uses /docroot # by default. So, if Drupal is located at any other path in your git # repository, change that here. This example links /web to the docroot ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" -docker-php-ext-install opcache +# Enable mod_rewrite so clean URLs work. a2enmod headers rewrite -# GD dependencies +# Install the PHP opcache as it's not included by default and needed for +# decent performance. +docker-php-ext-install opcache + +# GD dependencies. apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev -# WebP dependencies +# WebP dependencies. apt-get install -y libwebp-dev libwebp6 webp libmagickwand-dev -# Build and install gd +# Build and install gd. docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp docker-php-ext-install gd +# Install ImageMagick. This is recommended by both Acquia and Pantheon instead +# of GD. Lullabot will likely be publishing an ADR recommending it too. +apt-get install -y imagemagick + {% if memory_cache_type == "memcached" %} +# Install the PHP memcache extension. The Drupal Redis module recommends +# phpredis so no PHP extension is required. docker-php-ext-install memcache {% endif %} -# Install drush-launcher, if desired. -wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar +# Install drush-launcher +wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar chmod +x /usr/local/bin/drush From dcb81dc0887697f75a71d7a6519a733f217f6e39 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 16:19:42 -0500 Subject: [PATCH 038/172] Pin to a released ubuntu version --- .github/workflows/test-production-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-production-build.yml b/.github/workflows/test-production-build.yml index 5321f4369..23b8fc26d 100644 --- a/.github/workflows/test-production-build.yml +++ b/.github/workflows/test-production-build.yml @@ -8,7 +8,7 @@ on: jobs: Test-Production-Build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: php-version: [7.3, 7.4, 8.0] From 853fea05c29c499098b1bbd81a53febcbd154864 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 16:19:53 -0500 Subject: [PATCH 039/172] Give a chance to do any dev dependency work --- scaffold/tugboat/steps/update.sh.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/scaffold/tugboat/steps/update.sh.twig b/scaffold/tugboat/steps/update.sh.twig index 8be40adf8..90451779e 100644 --- a/scaffold/tugboat/steps/update.sh.twig +++ b/scaffold/tugboat/steps/update.sh.twig @@ -14,6 +14,7 @@ chmod -R g+w "${TUGBOAT_ROOT}/web/sites/default/files" chmod 2775 "${TUGBOAT_ROOT}/web/sites/default/files" composer install +vendor/bin/task drupal:composer:development {% if downsync %} # Remember to set any required environment variables for the fetch-db task, From 3afd84b637d06e37d1b44d2286a3ef8916f8d9ca Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 16:51:17 -0500 Subject: [PATCH 040/172] Add initial tests for config rendering --- .github/workflows/test-production-build.yml | 42 ++++++- .github/workflows/validate-tugboat.yml | 24 ---- .../fixtures.drainpipe-tugboat/composer.json | 111 ++++++++++++++++++ 3 files changed, 152 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/validate-tugboat.yml create mode 100644 tests/fixtures.drainpipe-tugboat/composer.json diff --git a/.github/workflows/test-production-build.yml b/.github/workflows/test-production-build.yml index 23b8fc26d..1b93f842b 100644 --- a/.github/workflows/test-production-build.yml +++ b/.github/workflows/test-production-build.yml @@ -16,6 +16,9 @@ jobs: - php-version: 7.3 composer-flags: --prefer-lowest --prefer-stable + env: + TUGBOAT_API_TOKEN: ${{ secrets.TUGBOAT_API_TOKEN }} + steps: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 @@ -40,7 +43,44 @@ jobs: cp ${GITHUB_WORKSPACE}/tests/fixtures.drainpipe-test-build/composer.json . cp ${GITHUB_WORKSPACE}/tests/fixtures.drainpipe-test-build/Taskfile.yml . composer update ${{ matrix.composer-flags }} - - name: Run static tests + - name: Build a production Drupal site run: | cd ../drupal ./vendor/bin/task build + + - uses: actions/setup-node@v2 + with: + node-version: '18' + - name: Install Tugboat CLI for validation + run: | + cd /usr/local/bin + curl -O https://dashboard.tugboatqa.com/cli/linux/tugboat.tar.gz + tar xzvf tugboat.tar.gz + - name: Validate Tugboat file generation + run: | + cd ../ + mkdir drupal-tugboat + cd drupal-tugboat + cp ${GITHUB_WORKSPACE}/tests/fixtures.drainpipe-tugboat/composer.json . + composer update ${{ matrix.composer-flags }} + tugboat validate .tugboat/config.yml + grep -q 'image: tugboatqa/php:${{ matrix.php-version }}-apache-bullseye' .tugboat/config.yml + grep -q 'image: tugboatqa/mariadb:10.4' .tugboat/config.yml + + rm -rf .tugboat web/sites/default/settings.tugboat.php + + composer config extra.drainpipe --json '{"tugboat": {"provider": { "host": "acquia" }}}' + composer update ${{ matrix.composer-flags }} + tugboat validate .tugboat/config.yml + grep -q 'image: tugboatqa/php:${{ matrix.php-version }}-apache-bullseye' .tugboat/config.yml + grep -q 'image: tugboatqa/mysql:5.7' .tugboat/config.yml + grep -q 'image: tugboatqa/memcached:1' .tugboat/config.yml + + rm -rf .tugboat web/sites/default/settings.tugboat.php + + composer config extra.drainpipe --json '{"tugboat": {"provider": { "host": "pantheon" }}}' + composer update ${{ matrix.composer-flags }} + tugboat validate .tugboat/config.yml + grep -q 'image: tugboatqa/php:${{ matrix.php-version }}-apache-bullseye' .tugboat/config.yml + grep -q 'image: tugboatqa/mariadb:10.6' .tugboat/config.yml + grep -q 'image: tugboatqa/redis:7' .tugboat/config.yml diff --git a/.github/workflows/validate-tugboat.yml b/.github/workflows/validate-tugboat.yml deleted file mode 100644 index 7cf7e8d38..000000000 --- a/.github/workflows/validate-tugboat.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Validate example Tugboat configuration -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] - -jobs: - Validate-Example-Tugboat-Configuration: - runs-on: ubuntu-22.04 - env: - TUGBOAT_API_TOKEN: ${{ secrets.TUGBOAT_API_TOKEN }} - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '18' - - run: | - curl -O https://dashboard.tugboatqa.com/cli/linux/tugboat.tar.gz - tar xzvf tugboat.tar.gz - ./tugboat validate scaffold/tugboat/config.generic.yml - ./tugboat validate scaffold/tugboat/config.acquia.yml - ./tugboat validate scaffold/tugboat/config.pantheon.yml diff --git a/tests/fixtures.drainpipe-tugboat/composer.json b/tests/fixtures.drainpipe-tugboat/composer.json new file mode 100644 index 000000000..944b841e5 --- /dev/null +++ b/tests/fixtures.drainpipe-tugboat/composer.json @@ -0,0 +1,111 @@ +{ + "name": "drupal/recommended-project", + "description": "Project template for Drupal 9 projects with a relocated document root", + "type": "project", + "license": "GPL-2.0-or-later", + "homepage": "https://www.drupal.org/project/drupal", + "support": { + "docs": "https://www.drupal.org/docs/user_guide/en/index.html", + "chat": "https://www.drupal.org/node/314178" + }, + "repositories": [ + { + "type": "path", + "url": "../drainpipe", + "options": { + "symlink": false + } + }, + { + "type": "composer", + "url": "https://packages.drupal.org/8" + } + ], + "require": { + "composer/installers": "^1.9", + "drupal/core-composer-scaffold": "^9.4", + "drupal/core-project-message": "^9.4", + "drupal/core-recommended": "^9.4", + "lullabot/drainpipe": "*" + }, + "conflict": { + "drupal/drupal": "*" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "allow-plugins": { + "composer/installers": true, + "drupal/core-composer-scaffold": true, + "drupal/core-project-message": true, + "dealerdirect/phpcodesniffer-composer-installer": true, + "lullabot/drainpipe": true + }, + "sort-packages": true + }, + "extra": { + "drainpipe": { + "tugboat": { + "provider": { + "host": "acquia", + "downsync": true + } + } + }, + "drupal-scaffold": { + "locations": { + "web-root": "web/" + } + }, + "installer-paths": { + "web/core": [ + "type:drupal-core" + ], + "web/libraries/{$name}": [ + "type:drupal-library" + ], + "web/modules/contrib/{$name}": [ + "type:drupal-module" + ], + "web/profiles/contrib/{$name}": [ + "type:drupal-profile" + ], + "web/themes/contrib/{$name}": [ + "type:drupal-theme" + ], + "drush/Commands/contrib/{$name}": [ + "type:drupal-drush" + ], + "web/modules/custom/{$name}": [ + "type:drupal-custom-module" + ], + "web/profiles/custom/{$name}": [ + "type:drupal-custom-profile" + ], + "web/themes/custom/{$name}": [ + "type:drupal-custom-theme" + ] + }, + "drupal-core-project-message": { + "include-keys": [ + "homepage", + "support" + ], + "post-create-project-cmd-message": [ + " ", + " Congratulations, youโ€™ve installed the Drupal codebase ", + " from the drupal/recommended-project template! ", + " ", + "", + "Next steps:", + " * Install the site: https://www.drupal.org/docs/8/install", + " * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html", + " * Get support: https://www.drupal.org/support", + " * Get involved with the Drupal community:", + " https://www.drupal.org/getting-involved", + " * Remove the plugin that prints this message:", + " composer remove drupal/core-project-message" + ] + } + } +} From 143bcad471300f833f784ae1852fa11d351fa14f Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 16:51:31 -0500 Subject: [PATCH 041/172] Use a newer mariadb version when unknown --- src/TugboatConfig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TugboatConfig.php b/src/TugboatConfig.php index bf9068ca9..b48e9af07 100644 --- a/src/TugboatConfig.php +++ b/src/TugboatConfig.php @@ -83,7 +83,7 @@ private function renderUnknown(string $name, string $host, bool $downsync): stri return $this->twig->render($name, [ 'php_version' => $this->phpVersion, 'database_type' => 'mariadb', - 'database_version' => '10.4', + 'database_version' => '10.6', 'host' => $host, 'downsync' => $downsync, ]); From a87d4058b90ebabdbf5f60c9bdc257be972bd456 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 18:49:01 -0500 Subject: [PATCH 042/172] Add a script to install mysql 5.7 on debian --- scaffold/tugboat/steps/init.sh.twig | 7 ++ .../tugboat/steps/install-mysql-client.sh | 71 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100755 scaffold/tugboat/steps/install-mysql-client.sh diff --git a/scaffold/tugboat/steps/init.sh.twig b/scaffold/tugboat/steps/init.sh.twig index 1c9d95201..aaaf53429 100644 --- a/scaffold/tugboat/steps/init.sh.twig +++ b/scaffold/tugboat/steps/init.sh.twig @@ -5,7 +5,14 @@ echo "Initializing..." # Install mysql or mariadb client. apt-get update +{% if database_type == "mysql" %} +# mysql was replaced by mariadb in Debian, so we have to install it manually. +# https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/#repo-qg-apt-repo-manual-setup +# apt-key is also deprecated, so here we install the key manually. +./.tugboat/steps/install-mysql-client.sh +{% else %} apt-get install -y {{ database_type }}-client +{% endif %} # Link the document root to the expected path. Tugboat uses /docroot # by default. So, if Drupal is located at any other path in your git diff --git a/scaffold/tugboat/steps/install-mysql-client.sh b/scaffold/tugboat/steps/install-mysql-client.sh new file mode 100755 index 000000000..c8ab8920b --- /dev/null +++ b/scaffold/tugboat/steps/install-mysql-client.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# apt-key is deprecated! We follow the guide at https://askubuntu.com/a/1307181 +mkdir -p /etc/apt/keyrings +cd /etc/apt/keyrings + +cat > mysql.txt << EOD +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: SKS 1.1.6 +Comment: Hostname: pgp.mit.edu + +mQINBGG4urcBEACrbsRa7tSSyxSfFkB+KXSbNM9rxYqoB78u107skReefq4/+Y72TpDvlDZL +mdv/lK0IpLa3bnvsM9IE1trNLrfi+JES62kaQ6hePPgn2RqxyIirt2seSi3Z3n3jlEg+mSdh +AvW+b+hFnqxo+TY0U+RBwDi4oO0YzHefkYPSmNPdlxRPQBMv4GPTNfxERx6XvVSPcL1+jQ4R +2cQFBryNhidBFIkoCOszjWhm+WnbURsLheBp757lqEyrpCufz77zlq2gEi+wtPHItfqsx3rz +xSRqatztMGYZpNUHNBJkr13npZtGW+kdN/xu980QLZxN+bZ88pNoOuzD6dKcpMJ0LkdUmTx5 +z9ewiFiFbUDzZ7PECOm2g3veJrwr79CXDLE1+39Hr8rDM2kDhSr9tAlPTnHVDcaYIGgSNIBc +YfLmt91133klHQHBIdWCNVtWJjq5YcLQJ9TxG9GQzgABPrm6NDd1t9j7w1L7uwBvMB1wgpir +RTPVfnUSCd+025PEF+wTcBhfnzLtFj5xD7mNsmDmeHkF/sDfNOfAzTE1v2wq0ndYU60xbL6/ +yl/Nipyr7WiQjCG0m3WfkjjVDTfs7/DXUqHFDOu4WMF9v+oqwpJXmAeGhQTWZC/QhWtrjrNJ +AgwKpp263gDSdW70ekhRzsok1HJwX1SfxHJYCMFs2aH6ppzNsQARAQABtDZNeVNRTCBSZWxl +YXNlIEVuZ2luZWVyaW5nIDxteXNxbC1idWlsZEBvc3Mub3JhY2xlLmNvbT6JAlQEEwEIAD4W +IQSFm+jXxYb1OEMLGcJGe5QtOnm9KQUCYbi6twIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgID +AQIeAQIXgAAKCRBGe5QtOnm9KUewD/992sS31WLGoUQ6NoL7qOB4CErkqXtMzpJAKKg2jtBG +G3rKE1/0VAg1D8AwEK4LcCO407wohnH0hNiUbeDck5x20pgS5SplQpuXX1K9vPzHeL/WNTb9 +8S3H2Mzj4o9obED6Ey52tTupttMF8pC9TJ93LxbJlCHIKKwCA1cXud3GycRN72eqSqZfJGds +aeWLmFmHf6oee27d8XLoNjbyAxna/4jdWoTqmp8oT3bgv/TBco23NzqUSVPi+7ljS1hHvcJu +oJYqaztGrAEf/lWIGdfl/kLEh8IYx8OBNUojh9mzCDlwbs83CBqoUdlzLNDdwmzu34Aw7xK1 +4RAVinGFCpo/7EWoX6weyB/zqevUIIE89UABTeFoGih/hx2jdQV/NQNthWTW0jH0hmPnajBV +AJPYwAuO82rx2pnZCxDATMn0elOkTue3PCmzHBF/GT6c65aQC4aojj0+Veh787QllQ9FrWbw +nTz+4fNzU/MBZtyLZ4JnsiWUs9eJ2V1g/A+RiIKu357Qgy1ytLqlgYiWfzHFlYjdtbPYKjDa +ScnvtY8VO2Rktm7XiV4zKFKiaWp+vuVYpR0/7Adgnlj5Jt9lQQGOr+Z2VYx8SvBcC+by3XAt +YkRHtX5u4MLlVS3gcoWfDiWwCpvqdK21EsXjQJxRr3dbSn0HaVj4FJZX0QQ7WZm6WLkCDQRh +uLq3ARAA6RYjqfC0YcLGKvHhoBnsX29vy9Wn1y2JYpEnPUIB8X0VOyz5/ALv4Hqtl4THkH+m +mMuhtndoq2BkCCk508jWBvKS1S+Bd2esB45BDDmIhuX3ozu9Xza4i1FsPnLkQ0uMZJv30ls2 +pXFmskhYyzmo6aOmH2536LdtPSlXtywfNV1HEr69V/AHbrEzfoQkJ/qvPzELBOjfjwtDPDeP +iVgW9LhktzVzn/BjO7XlJxw4PGcxJG6VApsXmM3t2fPN9eIHDUq8ocbHdJ4en8/bJDXZd9eb +QoILUuCg46hE3p6nTXfnPwSRnIRnsgCzeAz4rxDR4/Gv1Xpzv5wqpL21XQi3nvZKlcv7J1IR +VdphK66De9GpVQVTqC102gqJUErdjGmxmyCA1OOORqEPfKTrXz5YUGsWwpH+4xCuNQP0qmre +Rw3ghrH8potIr0iOVXFic5vJfBTgtcuEB6E6ulAN+3jqBGTaBML0jxgj3Z5VC5HKVbpg2DbB +/wMrLwFHNAbzV5hj2Os5Zmva0ySP1YHB26pAW8dwB38GBaQvfZq3ezM4cRAo/iJ/GsVE98dZ +EBO+Ml+0KYj+ZG+vyxzo20sweun7ZKT+9qZM90f6cQ3zqX6IfXZHHmQJBNv73mcZWNhDQOHs +4wBoq+FGQWNqLU9xaZxdXw80r1viDAwOy13EUtcVbTkAEQEAAYkCPAQYAQgAJhYhBIWb6NfF +hvU4QwsZwkZ7lC06eb0pBQJhuLq3AhsMBQkDwmcAAAoJEEZ7lC06eb0pSi8P/iy+dNnxrtiE +Nn9vkkA7AmZ8RsvPXYVeDCDSsL7UfhbS77r2L1qTa2aB3gAZUDIOXln51lSxMeeLtOequLME +V2Xi5km70rdtnja5SmWfc9fyExunXnsOhg6UG872At5CGEZU0c2Nt/hlGtOR3xbt3O/Uwl+d +ErQPA4BUbW5K1T7OC6oPvtlKfF4bGZFloHgt2yE9YSNWZsTPe6XJSapemHZLPOxJLnhs3VBi +rWE31QS0bRl5AzlO/fg7ia65vQGMOCOTLpgChTbcZHtozeFqva4IeEgE4xN+6r8WtgSYeGGD +RmeMEVjPM9dzQObf+SvGd58u2z9f2agPK1H32c69RLoA0mHRe7Wkv4izeJUc5tumUY0e8Ojd +enZZjT3hjLh6tM+mrp2oWnQIoed4LxUw1dhMOj0rYXv6laLGJ1FsW5eSke7ohBLcfBBTKnMC +BohROHy2E63Wggfsdn3UYzfqZ8cfbXetkXuLS/OM3MXbiNjg+ElYzjgWrkayu7yLakZx+mx6 +sHPIJYm2hzkniMG29d5mGl7ZT9emP9b+CfqGUxoXJkjs0gnDl44bwGJ0dmIBu3ajVAaHODXy +Y/zdDMGjskfEYbNXCAY2FRZSE58tgTvPKD++Kd2KGplMU2EIFT7JYfKhHAB5DGMkx92HUMid +sTSKHe+QnnnoFmu4gnmDU31i +=Xqbo +-----END PGP PUBLIC KEY BLOCK----- +EOD + +apt-get update +apt-get -y install gnupg + +gpg --no-default-keyring --keyring ./temp-keyring.gpg --import mysql.txt +gpg --no-default-keyring --keyring ./temp-keyring.gpg --export --output mysql.gpg +rm temp-keyring.gpg + +# Oracle / MySQL still doesn't support Debian 11, even on newer versions of +# MySQL. However, buster packages still work. +echo 'deb [signed-by=/etc/apt/keyrings/mysql.gpg] http://repo.mysql.com/apt/debian/ buster mysql-5.7' > /etc/apt/sources.list.d/mysql.list +apt-get update + +apt-get -y install mysql-client From c1ef2b72bf38ae376141d91998b13da79c27f44d Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 18:53:37 -0500 Subject: [PATCH 043/172] Copy the mysql client install script --- src/ScaffoldInstallerPlugin.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 40ad7975a..edc12e850 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -304,6 +304,11 @@ private function installCICommands(): void ); chmod('./.tugboat/steps/update.sh', 0755); + if ($this->extra['drainpipe']['provider']['host'] == 'acquia') { + $fs->copy("$scaffoldPath/tugboat/steps/install-mysql-client.sh", './.tugboat/steps/install-mysql-client.sh'); + chmod('./.tugboat/steps/install-mysql-content.sh', 0755); + } + $this->io->write("๐Ÿช  [Drainpipe] .tugboat/ directory installed. Please commit this directory."); if (!file_exists('./web/sites/default/settings.tugboat.php')) { $tugboatConfig->writeFile('settings.tugboat.php.twig', './web/sites/default/', $host); From 41c553a1e80050b95e4e0c5c30f6ab78d8f48b3c Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 18:57:10 -0500 Subject: [PATCH 044/172] Log shell commands as they run --- .github/workflows/test-production-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-production-build.yml b/.github/workflows/test-production-build.yml index 1b93f842b..d939bed00 100644 --- a/.github/workflows/test-production-build.yml +++ b/.github/workflows/test-production-build.yml @@ -58,6 +58,7 @@ jobs: tar xzvf tugboat.tar.gz - name: Validate Tugboat file generation run: | + set -x cd ../ mkdir drupal-tugboat cd drupal-tugboat From 1fe9afef6a086c24083016e5861c2d36f9adc578 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 18:58:59 -0500 Subject: [PATCH 045/172] Fix if provider isn't set --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index edc12e850..1d1fee1f4 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -304,7 +304,7 @@ private function installCICommands(): void ); chmod('./.tugboat/steps/update.sh', 0755); - if ($this->extra['drainpipe']['provider']['host'] == 'acquia') { + if ($this->extra['drainpipe']['provider']['host'] ?? 'unknown' == 'acquia') { $fs->copy("$scaffoldPath/tugboat/steps/install-mysql-client.sh", './.tugboat/steps/install-mysql-client.sh'); chmod('./.tugboat/steps/install-mysql-content.sh', 0755); } From da125a0ee997230c18c04fbb1331e08ceeaad1c4 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 19:00:05 -0500 Subject: [PATCH 046/172] We already had a var --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 1d1fee1f4..705d2b6ba 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -304,7 +304,7 @@ private function installCICommands(): void ); chmod('./.tugboat/steps/update.sh', 0755); - if ($this->extra['drainpipe']['provider']['host'] ?? 'unknown' == 'acquia') { + if ($host == 'acquia') { $fs->copy("$scaffoldPath/tugboat/steps/install-mysql-client.sh", './.tugboat/steps/install-mysql-client.sh'); chmod('./.tugboat/steps/install-mysql-content.sh', 0755); } From 68189dc71a0d23558c7685c7131f81496d8ccc36 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 19:02:28 -0500 Subject: [PATCH 047/172] Make a strict comparison --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 705d2b6ba..4adaa22ef 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -304,7 +304,7 @@ private function installCICommands(): void ); chmod('./.tugboat/steps/update.sh', 0755); - if ($host == 'acquia') { + if ($host === 'acquia') { $fs->copy("$scaffoldPath/tugboat/steps/install-mysql-client.sh", './.tugboat/steps/install-mysql-client.sh'); chmod('./.tugboat/steps/install-mysql-content.sh', 0755); } From 11e2b791ad8c03f7f23047c1547fbe6fef8c1f88 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 19:03:16 -0500 Subject: [PATCH 048/172] Fix chmod typo --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 4adaa22ef..c63300c4a 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -306,7 +306,7 @@ private function installCICommands(): void if ($host === 'acquia') { $fs->copy("$scaffoldPath/tugboat/steps/install-mysql-client.sh", './.tugboat/steps/install-mysql-client.sh'); - chmod('./.tugboat/steps/install-mysql-content.sh', 0755); + chmod('./.tugboat/steps/install-mysql-client.sh', 0755); } $this->io->write("๐Ÿช  [Drainpipe] .tugboat/ directory installed. Please commit this directory."); From f333b68b5bafbf5cd20380e339b5119366353290 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 19:07:57 -0500 Subject: [PATCH 049/172] Fix assuming PHP 8.1 if undetected --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index c63300c4a..3c5b63738 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -336,7 +336,7 @@ private function installCICommands(): void */ private function getPhpVersion(): string { - $php = '8.1'; + $php = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION; foreach ($this->platformRequirements as $link) { if ($link->getTarget() === "php") { $lower = $link->getConstraint()->getLowerBound()->getVersion(); From 687a4a224031a51ac75e71553974133add665d6c Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 19:09:49 -0500 Subject: [PATCH 050/172] Fix wrong mariadb version --- .github/workflows/test-production-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-production-build.yml b/.github/workflows/test-production-build.yml index d939bed00..d65314b01 100644 --- a/.github/workflows/test-production-build.yml +++ b/.github/workflows/test-production-build.yml @@ -66,7 +66,7 @@ jobs: composer update ${{ matrix.composer-flags }} tugboat validate .tugboat/config.yml grep -q 'image: tugboatqa/php:${{ matrix.php-version }}-apache-bullseye' .tugboat/config.yml - grep -q 'image: tugboatqa/mariadb:10.4' .tugboat/config.yml + grep -q 'image: tugboatqa/mariadb:10.6' .tugboat/config.yml rm -rf .tugboat web/sites/default/settings.tugboat.php From 52082f5b98c1209ef334568acce329da47f19219 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 19:14:09 -0500 Subject: [PATCH 051/172] Fix hardcoding Acquia in tests --- tests/fixtures.drainpipe-tugboat/composer.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/fixtures.drainpipe-tugboat/composer.json b/tests/fixtures.drainpipe-tugboat/composer.json index 944b841e5..1a3b7d9fa 100644 --- a/tests/fixtures.drainpipe-tugboat/composer.json +++ b/tests/fixtures.drainpipe-tugboat/composer.json @@ -46,10 +46,6 @@ "extra": { "drainpipe": { "tugboat": { - "provider": { - "host": "acquia", - "downsync": true - } } }, "drupal-scaffold": { From 8896b02898bfcc9b8da0a2a92978f1352a234cb1 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 19:17:50 -0500 Subject: [PATCH 052/172] Switch php version to strings so .0 isn't dropped --- .github/workflows/test-production-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-production-build.yml b/.github/workflows/test-production-build.yml index d65314b01..f809f9892 100644 --- a/.github/workflows/test-production-build.yml +++ b/.github/workflows/test-production-build.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - php-version: [7.3, 7.4, 8.0] + php-version: ["7.3", "7.4", "8.0"] include: - - php-version: 7.3 + - php-version: "7.3" composer-flags: --prefer-lowest --prefer-stable env: From 81d8a753c1fbff95d84141f954eadba0f8b1be9c Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 19:18:03 -0500 Subject: [PATCH 053/172] Purge mariadb if needed --- scaffold/tugboat/steps/install-mysql-client.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scaffold/tugboat/steps/install-mysql-client.sh b/scaffold/tugboat/steps/install-mysql-client.sh index c8ab8920b..839ecc072 100755 --- a/scaffold/tugboat/steps/install-mysql-client.sh +++ b/scaffold/tugboat/steps/install-mysql-client.sh @@ -68,4 +68,6 @@ rm temp-keyring.gpg echo 'deb [signed-by=/etc/apt/keyrings/mysql.gpg] http://repo.mysql.com/apt/debian/ buster mysql-5.7' > /etc/apt/sources.list.d/mysql.list apt-get update +# Purge mariadb if installed +apt-get -y --autoremove purge 'mariadb*' apt-get -y install mysql-client From 4a3394a60d55d787d724bcc3dff478d88662c78b Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 19:48:48 -0500 Subject: [PATCH 054/172] memcache isn't directly available --- scaffold/tugboat/steps/init.sh.twig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scaffold/tugboat/steps/init.sh.twig b/scaffold/tugboat/steps/init.sh.twig index aaaf53429..d685d98e8 100644 --- a/scaffold/tugboat/steps/init.sh.twig +++ b/scaffold/tugboat/steps/init.sh.twig @@ -43,7 +43,9 @@ apt-get install -y imagemagick {% if memory_cache_type == "memcached" %} # Install the PHP memcache extension. The Drupal Redis module recommends # phpredis so no PHP extension is required. -docker-php-ext-install memcache +apt-get install -y zlib1g-dev +pecl install memcache +echo 'extension=memcache.so' > /usr/local/etc/php/conf.d/memcache.ini {% endif %} # Install drush-launcher From 1981cb92b3a27f69789d7d4ddfbf1b0425679a11 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 22 Nov 2022 19:54:58 -0500 Subject: [PATCH 055/172] Fix missing ) --- scaffold/tugboat/settings.tugboat.php.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/settings.tugboat.php.twig b/scaffold/tugboat/settings.tugboat.php.twig index 1b66f59f7..3fcaeca25 100644 --- a/scaffold/tugboat/settings.tugboat.php.twig +++ b/scaffold/tugboat/settings.tugboat.php.twig @@ -26,7 +26,7 @@ if (getenv('TUGBOAT_REPO') !== FALSE) { {% endif %} {% if memory_cache_type == "memcached" %} - if (file_exists('modules/contrib/memcache/memcache.info.yml') { + if (file_exists('modules/contrib/memcache/memcache.info.yml')) { $settings['memcache']['servers'] = ['memcached:11211' => 'default']; $settings['cache']['default'] = 'cache.backend.memcache'; } From 15f80b7e85e9640e4e65f1c7b1bec7d4b9635887 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 12 Jun 2023 17:41:32 +0100 Subject: [PATCH 056/172] WIP --- .github/workflows/test-production-build.yml | 56 +++--------- README.md | 4 +- src/ProviderInterface.php | 14 --- src/ScaffoldInstallerPlugin.php | 94 +++++++-------------- src/TugboatConfig.php | 92 -------------------- 5 files changed, 45 insertions(+), 215 deletions(-) delete mode 100644 src/ProviderInterface.php delete mode 100644 src/TugboatConfig.php diff --git a/.github/workflows/test-production-build.yml b/.github/workflows/test-production-build.yml index f809f9892..4423842d4 100644 --- a/.github/workflows/test-production-build.yml +++ b/.github/workflows/test-production-build.yml @@ -8,33 +8,34 @@ on: jobs: Test-Production-Build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: - php-version: ["7.3", "7.4", "8.0"] + php-version: [7.3, 7.4, 8.0] include: - - php-version: "7.3" + - php-version: 7.3 composer-flags: --prefer-lowest --prefer-stable - env: - TUGBOAT_API_TOKEN: ${{ secrets.TUGBOAT_API_TOKEN }} - steps: - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} tools: composer:v2 extensions: gd + - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- + - name: Install Drupal run: | cd ../ @@ -43,45 +44,8 @@ jobs: cp ${GITHUB_WORKSPACE}/tests/fixtures.drainpipe-test-build/composer.json . cp ${GITHUB_WORKSPACE}/tests/fixtures.drainpipe-test-build/Taskfile.yml . composer update ${{ matrix.composer-flags }} - - name: Build a production Drupal site + + - name: Run static tests run: | cd ../drupal ./vendor/bin/task build - - - uses: actions/setup-node@v2 - with: - node-version: '18' - - name: Install Tugboat CLI for validation - run: | - cd /usr/local/bin - curl -O https://dashboard.tugboatqa.com/cli/linux/tugboat.tar.gz - tar xzvf tugboat.tar.gz - - name: Validate Tugboat file generation - run: | - set -x - cd ../ - mkdir drupal-tugboat - cd drupal-tugboat - cp ${GITHUB_WORKSPACE}/tests/fixtures.drainpipe-tugboat/composer.json . - composer update ${{ matrix.composer-flags }} - tugboat validate .tugboat/config.yml - grep -q 'image: tugboatqa/php:${{ matrix.php-version }}-apache-bullseye' .tugboat/config.yml - grep -q 'image: tugboatqa/mariadb:10.6' .tugboat/config.yml - - rm -rf .tugboat web/sites/default/settings.tugboat.php - - composer config extra.drainpipe --json '{"tugboat": {"provider": { "host": "acquia" }}}' - composer update ${{ matrix.composer-flags }} - tugboat validate .tugboat/config.yml - grep -q 'image: tugboatqa/php:${{ matrix.php-version }}-apache-bullseye' .tugboat/config.yml - grep -q 'image: tugboatqa/mysql:5.7' .tugboat/config.yml - grep -q 'image: tugboatqa/memcached:1' .tugboat/config.yml - - rm -rf .tugboat web/sites/default/settings.tugboat.php - - composer config extra.drainpipe --json '{"tugboat": {"provider": { "host": "pantheon" }}}' - composer update ${{ matrix.composer-flags }} - tugboat validate .tugboat/config.yml - grep -q 'image: tugboatqa/php:${{ matrix.php-version }}-apache-bullseye' .tugboat/config.yml - grep -q 'image: tugboatqa/mariadb:10.6' .tugboat/config.yml - grep -q 'image: tugboatqa/redis:7' .tugboat/config.yml diff --git a/README.md b/README.md index 69cef86af..94496ed1e 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,9 @@ Add the following to `composer.json` to add Tugboat configuration: { "extra": { "drainpipe": { - "tugboat": {} + "tugboat": [{ + "provider": "pantheon" + }] } } } diff --git a/src/ProviderInterface.php b/src/ProviderInterface.php deleted file mode 100644 index f39848644..000000000 --- a/src/ProviderInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -io = $io; - $this->platformRequirements = $composer->getLocker()->getPlatformRequirements(); $this->config = $composer->getConfig(); $this->extra = $composer->getPackage()->getExtra(); } @@ -83,7 +79,6 @@ public static function getSubscribedEvents() */ public function onPostInstallCmd(Event $event) { - $this->platformRequirements = $event->getComposer()->getLocker()->getPlatformRequirements(); $this->installTaskfile(); $this->installGitignore(); $this->installDdevCommand(); @@ -98,7 +93,6 @@ public function onPostInstallCmd(Event $event) */ public function onPostUpdateCmd(Event $event) { - $this->platformRequirements = $event->getComposer()->getLocker()->getPlatformRequirements(); $this->installTaskfile(); $this->installGitignore(); $this->installDdevCommand(); @@ -283,68 +277,44 @@ private function installCICommands(): void // Tugboat if (isset($this->extra['drainpipe']['tugboat']) && is_array($this->extra['drainpipe']['tugboat'])) { - if (!file_exists('./.tugboat/config.yml')) { - $fs->ensureDirectoryExists('./.tugboat'); - $host = $this->extra['drainpipe']['tugboat']['provider']['host'] ?? ProviderInterface::HOST_UNKNOWN; - - $tugboatConfig = new TugboatConfig($this->getPhpVersion()); - $downsync = $this->extra['drainpipe']['tugboat']['provider']['downsync'] ?? false; - $tugboatConfig->writeFile('config.yml.twig', './.tugboat/', $host, - $downsync - ); - $fs->ensureDirectoryExists('./.tugboat/steps'); - $tugboatConfig->writeFile('steps/init.sh.twig', './.tugboat/steps/', $host, - $downsync - ); + $fs->ensureDirectoryExists('./.tugboat'); + $fs->ensureDirectoryExists('./.tugboat/steps'); + $hosting_providers = array_map(function ($provider) { + return $provider['provider']; + }, $this->extra['drainpipe']['tugboat']); + $loader = new FilesystemLoader(__DIR__ . '/../scaffold/tugboat'); + $twig = new Environment($loader); + // Pantheon + if (in_array('pantheon', $hosting_providers)) { + $pantheonConfig = Yaml::parseFile('./pantheon.yml'); + $composerJson = file_get_contents('composer.json'); + $composerFullConfig = json_decode($composerJson, true); + $tugboatConfig = [ + 'php_version' => $pantheonConfig['php_version'], + 'database_type' => 'mariadb', + 'database_version' => $pantheonConfig['database']['version'], + ]; + if (!empty($composerFullConfig['require']) && in_array(array_keys($composerFullConfig['require']), 'drupal/redis')) { + $tugboatConfig['memory_cache_type'] = 'redis'; + $tugboatConfig['memory_cache_version'] = 7; + } + file_put_contents('./.tugboat/config.yml', $twig->render('config.yml.twig', $tugboatConfig)); + file_put_contents('./.tugboat/steps/init.sh', $twig->render('steps/init.sh.twig', $tugboatConfig)); + file_put_contents('./.tugboat/steps/build.sh', $twig->render('steps/build.sh.twig', $tugboatConfig)); + file_put_contents('./.tugboat/steps/update.sh', $twig->render('steps/update.sh.twig', $tugboatConfig)); chmod('./.tugboat/steps/init.sh', 0755); - $fs->copy("$scaffoldPath/tugboat/steps/build.sh", './.tugboat/steps/build.sh'); chmod('./.tugboat/steps/build.sh', 0755); - $tugboatConfig->writeFile('steps/update.sh.twig', './.tugboat/steps/', $host, - $downsync - ); chmod('./.tugboat/steps/update.sh', 0755); - - if ($host === 'acquia') { - $fs->copy("$scaffoldPath/tugboat/steps/install-mysql-client.sh", './.tugboat/steps/install-mysql-client.sh'); - chmod('./.tugboat/steps/install-mysql-client.sh', 0755); - } - - $this->io->write("๐Ÿช  [Drainpipe] .tugboat/ directory installed. Please commit this directory."); - if (!file_exists('./web/sites/default/settings.tugboat.php')) { - $tugboatConfig->writeFile('settings.tugboat.php.twig', './web/sites/default/', $host); - - $this->io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.tugboat.php installed. Please commit this file."); - if (file_exists('./web/sites/default/settings.php')) { - $include=<<render('settings.tugboat.php.twig', $tugboatConfig)); + $settings = file_get_contents('./web/sites/default/settings.php'); + if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { + $include = <<io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.php modified to include settings.tugboat.php. Please commit this file."); - } - else { - $this->io->write("๐Ÿช  [Drainpipe] web/sites/default/settings.php does not exist. Please include tugboat.settings.php from your settings.php files."); - } + file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); } } } } - - /** - * @return string - */ - private function getPhpVersion(): string - { - $php = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION; - foreach ($this->platformRequirements as $link) { - if ($link->getTarget() === "php") { - $lower = $link->getConstraint()->getLowerBound()->getVersion(); - $php = substr($lower, 0, 3); - } - } - - return $php; - } - } diff --git a/src/TugboatConfig.php b/src/TugboatConfig.php deleted file mode 100644 index b48e9af07..000000000 --- a/src/TugboatConfig.php +++ /dev/null @@ -1,92 +0,0 @@ -twig = new Environment($loader); - $this->phpVersion = $phpVersion; - } - - public function render( - string $name, - string $host = self::HOST_UNKNOWN, - bool $downsync = false - ): string { - switch ($host) { - case self::HOST_ACQUIA: - return $this->renderAcquia($name, $downsync); - case self::HOST_PANTHEON: - return $this->renderPantheon($name, $downsync); - default: - return $this->renderUnknown($name, $host, $downsync); - } - } - - public function writeFile( - string $name, - string $path, - string $host = self::HOST_UNKNOWN, - bool $downsync = false - ): void { - $basename = basename($name, '.twig'); - file_put_contents($path . "/$basename", $this->render($name, $host, $downsync)); - } - - private function renderAcquia(string $name, bool $downsync): string - { - return $this->twig->render($name, [ - 'php_version' => $this->phpVersion, - 'database_type' => 'mysql', - 'database_version' => '5.7', - 'memory_cache_type' => 'memcached', - 'memory_cache_version' => 1, - 'host' => 'acquia', - 'downsync' => $downsync, - ]); - } - - private function renderPantheon(string $name, bool $downsync): string - { - return $this->twig->render($name, [ - 'php_version' => $this->phpVersion, - 'database_type' => 'mariadb', - 'database_version' => '10.6', - 'memory_cache_type' => 'redis', - 'memory_cache_version' => 7, - 'host' => 'pantheon', - 'downsync' => $downsync, - ]); - } - - private function renderUnknown(string $name, string $host, bool $downsync): string - { - return $this->twig->render($name, [ - 'php_version' => $this->phpVersion, - 'database_type' => 'mariadb', - 'database_version' => '10.6', - 'host' => $host, - 'downsync' => $downsync, - ]); - } - -} From f52d05f1160e52ab9f3e4de764557076772ec2d3 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Wed, 21 Jun 2023 17:07:54 +0100 Subject: [PATCH 057/172] wip --- .github/workflows/TestTugboat.yml | 60 ++++++++++ .tugboat/config.yml | 20 ++++ .tugboat/steps/build.sh | 20 ++++ .tugboat/steps/init.sh | 31 +++++ .tugboat/steps/update.sh | 7 ++ README.md | 4 +- composer.json | 2 +- scaffold/Taskfile.yml | 8 ++ .../tugboat/steps/{build.sh => build.sh.twig} | 0 scaffold/tugboat/steps/init.sh.twig | 4 - src/ScaffoldInstallerPlugin.php | 25 ++-- .../fixtures.drainpipe-tugboat/composer.json | 107 ------------------ tests/fixtures/tugboat/Taskfile.yml | 0 13 files changed, 164 insertions(+), 124 deletions(-) create mode 100644 .github/workflows/TestTugboat.yml create mode 100644 .tugboat/config.yml create mode 100755 .tugboat/steps/build.sh create mode 100755 .tugboat/steps/init.sh create mode 100755 .tugboat/steps/update.sh rename scaffold/tugboat/steps/{build.sh => build.sh.twig} (100%) delete mode 100644 tests/fixtures.drainpipe-tugboat/composer.json create mode 100644 tests/fixtures/tugboat/Taskfile.yml diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml new file mode 100644 index 000000000..d69c25797 --- /dev/null +++ b/.github/workflows/TestTugboat.yml @@ -0,0 +1,60 @@ +name: "Test GitHub Actions" + +on: + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + Test-Tugboat-Pantheon: + runs-on: ubuntu-latest + steps: + - name: Create a Drupal project + run: composer create-project drupal/recommended-project . --ignore-platform-req=ext-gd + + - uses: actions/checkout@v3 + with: + path: drainpipe + + - uses: ./drainpipe/scaffold/github/actions/common/set-env + + - name: Install DDEV + uses: ./drainpipe/scaffold/github/actions/common/ddev + with: + git-name: Drainpipe Bot + git-email: no-reply@example.com + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Create pantheon.yml + run: | + echo "api_version: 1" >> pantheon.yml + echo "php_version: 8.1" >> pantheon.yml + echo "database:" >> pantheon.yml + echo " version: 10.6" >> pantheon.yml + + - name: Setup Project + run: | + ddev config --auto + ddev start + ddev composer config extra.drupal-scaffold.gitignore true + ddev composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] + ddev composer config --no-plugins allow-plugins.composer/installers true + ddev composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true + ddev composer config --no-plugins allow-plugins.lullabot/drainpipe true + ddev composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": false}}' + ddev composer config minimum-stability dev + ddev composer config extra.drainpipe --json '{"tugboat": {"host": "pantheon"}}' + ddev composer require lullabot/drainpipe --with-all-dependencies + + # Compare the generated files to the ones used to build this repository + # preview - they should be the same. + - name: Test Generated Files + run: | + cmp --silent -- "drainpipe/.tugboat/config.yml" ".tugboat/config.yml" + cmp --silent -- "drainpipe/.tugboat/steps/build.sh" ".tugboat/steps/build.sh" + cmp --silent -- "drainpipe/.tugboat/steps/init.sh" ".tugboat/steps/init.sh" + cmp --silent -- "drainpipe/.tugboat/steps/update.sh" ".tugboat/steps/update`.sh" + diff --git a/.tugboat/config.yml b/.tugboat/config.yml new file mode 100644 index 000000000..4c4c2f08e --- /dev/null +++ b/.tugboat/config.yml @@ -0,0 +1,20 @@ +services: + php: + http: false + image: tugboatqa/php:8.1-fpm + default: true + + depends: + - mariadb + + commands: + init: ./.tugboat/steps/init.sh + update: ./.tugboat/steps/update.sh + build: ./.tugboat/steps/build.sh + + mariadb: + image: tugboatqa/mariadb:10.6 + commands: + update: + - echo "Nothing to do as we import databases from the Drupal service." + diff --git a/.tugboat/steps/build.sh b/.tugboat/steps/build.sh new file mode 100755 index 000000000..acfb2e9c5 --- /dev/null +++ b/.tugboat/steps/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -eux +# drainpipe-start +# This is necessary for testing as this repository doesn't hold a Drupal site. +mkdir drainpipe +mv * drainpipe/ 2>/dev/null +composer create-project drupal/recommended-project . +composer config extra.drupal-scaffold.gitignore true +composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] +composer config --no-plugins allow-plugins.composer/installers true +composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true +composer config --no-plugins allow-plugins.lullabot/drainpipe true +composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": false}}' +composer config minimum-stability dev +composer require lullabot/drainpipe --with-all-dependencies +# drainpipe-end +composer install +./vendor/bin/task sync +./vendor/bin/task drupal:update diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh new file mode 100755 index 000000000..19bb023da --- /dev/null +++ b/.tugboat/steps/init.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -eux +echo "Initializing..." + +# Install mysql or mariadb client. +apt-get update +apt-get install -y mariadb-client + +# Link the document root to the expected path. Tugboat uses /docroot +# by default. So, if Drupal is located at any other path in your git +# repository, change that here. This example links /web to the docroot +ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" + +# Install the PHP opcache as it's not included by default and needed for +# decent performance. +docker-php-ext-install opcache + +# GD dependencies. +apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev + +# WebP dependencies. +apt-get install -y libwebp-dev libwebp6 webp libmagickwand-dev + +# Build and install gd. +docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp +docker-php-ext-install gd + +# Install ImageMagick. This is recommended by both Acquia and Pantheon instead +# of GD. Lullabot will likely be publishing an ADR recommending it too. +apt-get install -y imagemagick diff --git a/.tugboat/steps/update.sh b/.tugboat/steps/update.sh new file mode 100755 index 000000000..66d313f4c --- /dev/null +++ b/.tugboat/steps/update.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -eux +echo "Updating..." + +composer install +./vendor/bin task drupal:update diff --git a/README.md b/README.md index 858810595..dfb884906 100644 --- a/README.md +++ b/README.md @@ -439,9 +439,9 @@ Add the following to `composer.json` to add Tugboat configuration: { "extra": { "drainpipe": { - "tugboat": [{ + "tugboat": { "provider": "pantheon" - }] + } } } } diff --git a/composer.json b/composer.json index 44e872c7a..6624c9d57 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "composer-plugin-api": "^2.0", "drush/drush": "^10|^11", "symfony/yaml": "^3|^4|^5|^6", - "twig/twig": "^2.0", + "twig/twig": "^2|^3", "vlucas/phpdotenv": "^4|^5", "ext-json": "*" }, diff --git a/scaffold/Taskfile.yml b/scaffold/Taskfile.yml index 0c0c5299f..12ec78672 100644 --- a/scaffold/Taskfile.yml +++ b/scaffold/Taskfile.yml @@ -35,3 +35,11 @@ tasks: # assets:watch: # desc: "Builds assets such as CSS & JS, and watches them for changes" # deps: [sass:watch, javascript:watch] + sync: + desc: "Sync a database from production and import it" + cmds: + # Replace this with a command to fetch your datbase. + - task: drush site:install -y + - echo "๐Ÿงน Sanitising database" + - ./vendor/bin/drush sql:sanitize --yes + diff --git a/scaffold/tugboat/steps/build.sh b/scaffold/tugboat/steps/build.sh.twig similarity index 100% rename from scaffold/tugboat/steps/build.sh rename to scaffold/tugboat/steps/build.sh.twig diff --git a/scaffold/tugboat/steps/init.sh.twig b/scaffold/tugboat/steps/init.sh.twig index d685d98e8..579cef704 100644 --- a/scaffold/tugboat/steps/init.sh.twig +++ b/scaffold/tugboat/steps/init.sh.twig @@ -47,7 +47,3 @@ apt-get install -y zlib1g-dev pecl install memcache echo 'extension=memcache.so' > /usr/local/etc/php/conf.d/memcache.ini {% endif %} - -# Install drush-launcher -wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.10.1/drush.phar -chmod +x /usr/local/bin/drush diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index b53d93877..f0cd70067 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -278,16 +278,12 @@ private function installCICommands(): void } // Tugboat - if (isset($this->extra['drainpipe']['tugboat']) && is_array($this->extra['drainpipe']['tugboat'])) { - $fs->ensureDirectoryExists('./.tugboat'); - $fs->ensureDirectoryExists('./.tugboat/steps'); - $hosting_providers = array_map(function ($provider) { - return $provider['provider']; - }, $this->extra['drainpipe']['tugboat']); - $loader = new FilesystemLoader(__DIR__ . '/../scaffold/tugboat'); - $twig = new Environment($loader); + $fs->removeDirectory('./.tugboat'); + if (!empty($this->extra['drainpipe']['tugboat']['host'])) { + $tugboatConfig = []; + // Pantheon - if (in_array('pantheon', $hosting_providers)) { + if ($this->extra['drainpipe']['tugboat']['host'] === 'pantheon') { $pantheonConfig = Yaml::parseFile('./pantheon.yml'); $composerJson = file_get_contents('composer.json'); $composerFullConfig = json_decode($composerJson, true); @@ -296,10 +292,17 @@ private function installCICommands(): void 'database_type' => 'mariadb', 'database_version' => $pantheonConfig['database']['version'], ]; - if (!empty($composerFullConfig['require']) && in_array(array_keys($composerFullConfig['require']), 'drupal/redis')) { + if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) { $tugboatConfig['memory_cache_type'] = 'redis'; $tugboatConfig['memory_cache_version'] = 7; } + } + + if (count($tugboatConfig) > 0) { + $fs->ensureDirectoryExists('./.tugboat'); + $fs->ensureDirectoryExists('./.tugboat/steps'); + $loader = new FilesystemLoader(__DIR__ . '/../scaffold/tugboat'); + $twig = new Environment($loader); file_put_contents('./.tugboat/config.yml', $twig->render('config.yml.twig', $tugboatConfig)); file_put_contents('./.tugboat/steps/init.sh', $twig->render('steps/init.sh.twig', $tugboatConfig)); file_put_contents('./.tugboat/steps/build.sh', $twig->render('steps/build.sh.twig', $tugboatConfig)); @@ -307,6 +310,8 @@ private function installCICommands(): void chmod('./.tugboat/steps/init.sh', 0755); chmod('./.tugboat/steps/build.sh', 0755); chmod('./.tugboat/steps/update.sh', 0755); + + // settings.php file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); $settings = file_get_contents('./web/sites/default/settings.php'); if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { diff --git a/tests/fixtures.drainpipe-tugboat/composer.json b/tests/fixtures.drainpipe-tugboat/composer.json deleted file mode 100644 index 1a3b7d9fa..000000000 --- a/tests/fixtures.drainpipe-tugboat/composer.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "name": "drupal/recommended-project", - "description": "Project template for Drupal 9 projects with a relocated document root", - "type": "project", - "license": "GPL-2.0-or-later", - "homepage": "https://www.drupal.org/project/drupal", - "support": { - "docs": "https://www.drupal.org/docs/user_guide/en/index.html", - "chat": "https://www.drupal.org/node/314178" - }, - "repositories": [ - { - "type": "path", - "url": "../drainpipe", - "options": { - "symlink": false - } - }, - { - "type": "composer", - "url": "https://packages.drupal.org/8" - } - ], - "require": { - "composer/installers": "^1.9", - "drupal/core-composer-scaffold": "^9.4", - "drupal/core-project-message": "^9.4", - "drupal/core-recommended": "^9.4", - "lullabot/drainpipe": "*" - }, - "conflict": { - "drupal/drupal": "*" - }, - "minimum-stability": "dev", - "prefer-stable": true, - "config": { - "allow-plugins": { - "composer/installers": true, - "drupal/core-composer-scaffold": true, - "drupal/core-project-message": true, - "dealerdirect/phpcodesniffer-composer-installer": true, - "lullabot/drainpipe": true - }, - "sort-packages": true - }, - "extra": { - "drainpipe": { - "tugboat": { - } - }, - "drupal-scaffold": { - "locations": { - "web-root": "web/" - } - }, - "installer-paths": { - "web/core": [ - "type:drupal-core" - ], - "web/libraries/{$name}": [ - "type:drupal-library" - ], - "web/modules/contrib/{$name}": [ - "type:drupal-module" - ], - "web/profiles/contrib/{$name}": [ - "type:drupal-profile" - ], - "web/themes/contrib/{$name}": [ - "type:drupal-theme" - ], - "drush/Commands/contrib/{$name}": [ - "type:drupal-drush" - ], - "web/modules/custom/{$name}": [ - "type:drupal-custom-module" - ], - "web/profiles/custom/{$name}": [ - "type:drupal-custom-profile" - ], - "web/themes/custom/{$name}": [ - "type:drupal-custom-theme" - ] - }, - "drupal-core-project-message": { - "include-keys": [ - "homepage", - "support" - ], - "post-create-project-cmd-message": [ - " ", - " Congratulations, youโ€™ve installed the Drupal codebase ", - " from the drupal/recommended-project template! ", - " ", - "", - "Next steps:", - " * Install the site: https://www.drupal.org/docs/8/install", - " * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html", - " * Get support: https://www.drupal.org/support", - " * Get involved with the Drupal community:", - " https://www.drupal.org/getting-involved", - " * Remove the plugin that prints this message:", - " composer remove drupal/core-project-message" - ] - } - } -} diff --git a/tests/fixtures/tugboat/Taskfile.yml b/tests/fixtures/tugboat/Taskfile.yml new file mode 100644 index 000000000..e69de29bb From 5703baa5faf2e3fc0bf1473b8872151151a56839 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 12:35:25 +0100 Subject: [PATCH 058/172] Add nodejs support --- .tugboat/steps/build.sh | 1 + scaffold/tugboat/steps/build.sh.twig | 6 ++++-- scaffold/tugboat/steps/init.sh.twig | 6 ++++++ src/ScaffoldInstallerPlugin.php | 9 +++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.tugboat/steps/build.sh b/.tugboat/steps/build.sh index acfb2e9c5..8661c4833 100755 --- a/.tugboat/steps/build.sh +++ b/.tugboat/steps/build.sh @@ -17,4 +17,5 @@ composer require lullabot/drainpipe --with-all-dependencies # drainpipe-end composer install ./vendor/bin/task sync +./vendor/bin/task build ./vendor/bin/task drupal:update diff --git a/scaffold/tugboat/steps/build.sh.twig b/scaffold/tugboat/steps/build.sh.twig index 0bcbb904f..e299cea54 100644 --- a/scaffold/tugboat/steps/build.sh.twig +++ b/scaffold/tugboat/steps/build.sh.twig @@ -1,5 +1,7 @@ #!/bin/bash set -eux -vendor/bin/task drupal:update -vendor/bin/drush user:login +composer install +./vendor/bin/task sync +./vendor/bin/task build +./vendor/bin/task drupal:update diff --git a/scaffold/tugboat/steps/init.sh.twig b/scaffold/tugboat/steps/init.sh.twig index 579cef704..6dd0305f9 100644 --- a/scaffold/tugboat/steps/init.sh.twig +++ b/scaffold/tugboat/steps/init.sh.twig @@ -47,3 +47,9 @@ apt-get install -y zlib1g-dev pecl install memcache echo 'extension=memcache.so' > /usr/local/etc/php/conf.d/memcache.ini {% endif %} + +# Install node +curl -fsSL https://deb.nodesource.com/setup_{{ node_version }}.x | bash - +apt-get install -y nodejs +# This only works for node > 16, but that version is unsupported now anyway. +corepack enable diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index f0cd70067..11151bb6c 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -291,7 +291,16 @@ private function installCICommands(): void 'php_version' => $pantheonConfig['php_version'], 'database_type' => 'mariadb', 'database_version' => $pantheonConfig['database']['version'], + 'nodejs_version' => '18', ]; + + if (file_exists('./.ddev/config.yml')) { + $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); + if (!empty($ddevConfig['nodejs_version'])) { + $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; + } + } + if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) { $tugboatConfig['memory_cache_type'] = 'redis'; $tugboatConfig['memory_cache_version'] = 7; From d1388821b26d791f8a674ce1830a0141c5e422b8 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 12:40:32 +0100 Subject: [PATCH 059/172] Switch to apache buster --- .tugboat/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index 4c4c2f08e..b2fce2d21 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -1,7 +1,7 @@ services: php: http: false - image: tugboatqa/php:8.1-fpm + image: tugboatqa/php:8.1-apache-buster default: true depends: From c7d53666c5776f2a939f8f53c04750e64a672dd9 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 12:55:37 +0100 Subject: [PATCH 060/172] Fix scripts --- .tugboat/steps/build.sh | 17 +---------------- .tugboat/steps/init.sh | 14 ++++++++++++++ .tugboat/steps/update.sh | 4 +--- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.tugboat/steps/build.sh b/.tugboat/steps/build.sh index 8661c4833..1d176c3d0 100755 --- a/.tugboat/steps/build.sh +++ b/.tugboat/steps/build.sh @@ -1,21 +1,6 @@ #!/bin/bash set -eux -# drainpipe-start -# This is necessary for testing as this repository doesn't hold a Drupal site. -mkdir drainpipe -mv * drainpipe/ 2>/dev/null -composer create-project drupal/recommended-project . -composer config extra.drupal-scaffold.gitignore true -composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] -composer config --no-plugins allow-plugins.composer/installers true -composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true -composer config --no-plugins allow-plugins.lullabot/drainpipe true -composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": false}}' -composer config minimum-stability dev -composer require lullabot/drainpipe --with-all-dependencies -# drainpipe-end -composer install -./vendor/bin/task sync + ./vendor/bin/task build ./vendor/bin/task drupal:update diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 19bb023da..fe7b6d423 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -29,3 +29,17 @@ docker-php-ext-install gd # Install ImageMagick. This is recommended by both Acquia and Pantheon instead # of GD. Lullabot will likely be publishing an ADR recommending it too. apt-get install -y imagemagick +# drainpipe-start +# This is necessary for testing as this repository doesn't hold a Drupal site. +mkdir drainpipe +mv * drainpipe/ 2>/dev/null +composer create-project drupal/recommended-project . +composer config extra.drupal-scaffold.gitignore true +composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] +composer config --no-plugins allow-plugins.composer/installers true +composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true +composer config --no-plugins allow-plugins.lullabot/drainpipe true +composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": false}}' +composer config minimum-stability dev +composer require lullabot/drainpipe --with-all-dependencies +# drainpipe-end diff --git a/.tugboat/steps/update.sh b/.tugboat/steps/update.sh index 66d313f4c..1166882ae 100755 --- a/.tugboat/steps/update.sh +++ b/.tugboat/steps/update.sh @@ -1,7 +1,5 @@ #!/bin/bash set -eux -echo "Updating..." -composer install -./vendor/bin task drupal:update +./vendor/bin/task sync From c44567c12b80abc107188509136ffea4d92fd22e Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 13:21:53 +0100 Subject: [PATCH 061/172] Fix file moves --- .tugboat/steps/init.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index fe7b6d423..12a8a4337 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -31,8 +31,12 @@ docker-php-ext-install gd apt-get install -y imagemagick # drainpipe-start # This is necessary for testing as this repository doesn't hold a Drupal site. -mkdir drainpipe -mv * drainpipe/ 2>/dev/null +CURRENT_DIR=$(pwd) +mkdir ../drainpipe-tmp +cd ../ +mv `ls -1 $CURRENT_DIR` drainpipe-tmp +mv drainpipe-tmp $CURRENT_DIR/drainpipe +cd $CURRENT_DIR composer create-project drupal/recommended-project . composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] From ee9568f98a58d1b1a7ed9e01ddfd1162d78e65b6 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 13:34:43 +0100 Subject: [PATCH 062/172] Fix file moves --- .tugboat/steps/init.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 12a8a4337..5a1079d09 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -31,12 +31,9 @@ docker-php-ext-install gd apt-get install -y imagemagick # drainpipe-start # This is necessary for testing as this repository doesn't hold a Drupal site. -CURRENT_DIR=$(pwd) -mkdir ../drainpipe-tmp -cd ../ -mv `ls -1 $CURRENT_DIR` drainpipe-tmp -mv drainpipe-tmp $CURRENT_DIR/drainpipe -cd $CURRENT_DIR +shopt -s extglob +mkdir drainpipe +mv !(drainpipe) drainpipe composer create-project drupal/recommended-project . composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] From 6af582153c1f12f12868cdfa59d9d5b3286fe299 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 13:38:04 +0100 Subject: [PATCH 063/172] Fix file moves --- .tugboat/steps/init.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 5a1079d09..a7d69b2d0 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -34,7 +34,9 @@ apt-get install -y imagemagick shopt -s extglob mkdir drainpipe mv !(drainpipe) drainpipe +mv drainpipe ../drainpipe-tmp composer create-project drupal/recommended-project . +mv ../drainpipe-tmp drainpipe composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true From 0afd79b812f31627599f34ec5c98f7a12c75b73b Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 13:44:31 +0100 Subject: [PATCH 064/172] Fix file moves --- .tugboat/steps/init.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index a7d69b2d0..98f345706 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -31,12 +31,11 @@ docker-php-ext-install gd apt-get install -y imagemagick # drainpipe-start # This is necessary for testing as this repository doesn't hold a Drupal site. -shopt -s extglob -mkdir drainpipe -mv !(drainpipe) drainpipe -mv drainpipe ../drainpipe-tmp +shopt -s dotglob +mkdir ../drainpipe-tmp +mv * ../drainpipe-tmp/ composer create-project drupal/recommended-project . -mv ../drainpipe-tmp drainpipe +mv ../drainpipe-tmp/* . composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true From 06e9f82d01353c604f2bfd41d003f84ae736f2ec Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 13:59:02 +0100 Subject: [PATCH 065/172] Fix file moves --- .tugboat/steps/init.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 98f345706..2024e4923 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -35,7 +35,8 @@ shopt -s dotglob mkdir ../drainpipe-tmp mv * ../drainpipe-tmp/ composer create-project drupal/recommended-project . -mv ../drainpipe-tmp/* . +mkdir drainpipe +mv ../drainpipe-tmp/* ./drainpipe/ composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true From c95f7e5843f42895646a779c4e3080a7ccd08f42 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 14:02:40 +0100 Subject: [PATCH 066/172] Fix file moves --- .tugboat/steps/init.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 2024e4923..240f1499d 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -37,6 +37,7 @@ mv * ../drainpipe-tmp/ composer create-project drupal/recommended-project . mkdir drainpipe mv ../drainpipe-tmp/* ./drainpipe/ +cp -R ./drainpipe/.tugboat . composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true From 4be3e3ae058f2fb49affdafdf1e2bf262d3d5609 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 14:05:46 +0100 Subject: [PATCH 067/172] Fix file moves --- .tugboat/steps/init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 240f1499d..25ba77094 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -37,7 +37,7 @@ mv * ../drainpipe-tmp/ composer create-project drupal/recommended-project . mkdir drainpipe mv ../drainpipe-tmp/* ./drainpipe/ -cp -R ./drainpipe/.tugboat . +mv ./drainpipe/.tugboat . composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true From b220d18a836b02e4e84c2105a811913fb0cdcb58 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 14:17:27 +0100 Subject: [PATCH 068/172] . --- .tugboat/steps/init.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 25ba77094..47e34f88c 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -38,6 +38,8 @@ composer create-project drupal/recommended-project . mkdir drainpipe mv ../drainpipe-tmp/* ./drainpipe/ mv ./drainpipe/.tugboat . +ls -lha +ls -lha .tugboat composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true From e0812d6cb7c3947fafe2f4c3ccd3f10f3cabd3f9 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 14:40:51 +0100 Subject: [PATCH 069/172] . --- .tugboat/steps/init.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 47e34f88c..f9fd7eb7f 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -38,8 +38,6 @@ composer create-project drupal/recommended-project . mkdir drainpipe mv ../drainpipe-tmp/* ./drainpipe/ mv ./drainpipe/.tugboat . -ls -lha -ls -lha .tugboat composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true @@ -49,3 +47,4 @@ composer config repositories.drainpipe --json '{"type": "path", "url": "drainpip composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies # drainpipe-end +cat ./.tugboat/steps/update.sh From 187a4bd13dc0d58471ec3dacd31e76b021851db2 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 14:43:48 +0100 Subject: [PATCH 070/172] . --- .tugboat/steps/init.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index f9fd7eb7f..f36e1f85d 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -47,4 +47,6 @@ composer config repositories.drainpipe --json '{"type": "path", "url": "drainpip composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies # drainpipe-end +ls -lha .tugboat +ls -lha .tugboat/steps cat ./.tugboat/steps/update.sh From 75eca65141071f86cae6f666274aa18d0d4e019c Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 14:54:59 +0100 Subject: [PATCH 071/172] . --- .tugboat/steps/init.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index f36e1f85d..c6c8862a4 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -35,18 +35,19 @@ shopt -s dotglob mkdir ../drainpipe-tmp mv * ../drainpipe-tmp/ composer create-project drupal/recommended-project . +mv ../drainpipe-tmp/.tugboat . mkdir drainpipe mv ../drainpipe-tmp/* ./drainpipe/ -mv ./drainpipe/.tugboat . composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true composer config --no-plugins allow-plugins.lullabot/drainpipe true -composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": false}}' +composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": true}}' composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies # drainpipe-end +ls -lha ls -lha .tugboat ls -lha .tugboat/steps cat ./.tugboat/steps/update.sh From 15d044e6acbde6eee194ce316f52905fbf0e8757 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 16:08:03 +0100 Subject: [PATCH 072/172] . --- .tugboat/steps/init.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index c6c8862a4..b3d5db682 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -36,8 +36,8 @@ mkdir ../drainpipe-tmp mv * ../drainpipe-tmp/ composer create-project drupal/recommended-project . mv ../drainpipe-tmp/.tugboat . -mkdir drainpipe -mv ../drainpipe-tmp/* ./drainpipe/ +mv ../drainpipe-tmp drainpipe +ls -lha composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true From fdf3df4b690a90ff3ab5f781abda491f7b7951dd Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 16:16:53 +0100 Subject: [PATCH 073/172] . --- .tugboat/steps/init.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index b3d5db682..281a6ae55 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -35,9 +35,6 @@ shopt -s dotglob mkdir ../drainpipe-tmp mv * ../drainpipe-tmp/ composer create-project drupal/recommended-project . -mv ../drainpipe-tmp/.tugboat . -mv ../drainpipe-tmp drainpipe -ls -lha composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true @@ -46,8 +43,5 @@ composer config --no-plugins allow-plugins.lullabot/drainpipe true composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": true}}' composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies +mv drainpipe/.tugboat . # drainpipe-end -ls -lha -ls -lha .tugboat -ls -lha .tugboat/steps -cat ./.tugboat/steps/update.sh From 8cf53ea37357ea1f2919925c08e413be3405d79d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 16:20:40 +0100 Subject: [PATCH 074/172] . --- .tugboat/steps/init.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 281a6ae55..9ff96e886 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -35,6 +35,7 @@ shopt -s dotglob mkdir ../drainpipe-tmp mv * ../drainpipe-tmp/ composer create-project drupal/recommended-project . +mv ../drainpipe-tmp drainpipe composer config extra.drupal-scaffold.gitignore true composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] composer config --no-plugins allow-plugins.composer/installers true From c826bf74f096e0770261d109b74f9cebe3c8deda Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 16:30:30 +0100 Subject: [PATCH 075/172] . --- scaffold/Taskfile.yml | 2 +- tests/fixtures/tugboat/Taskfile.yml | 0 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 tests/fixtures/tugboat/Taskfile.yml diff --git a/scaffold/Taskfile.yml b/scaffold/Taskfile.yml index 12ec78672..27cfcc9ca 100644 --- a/scaffold/Taskfile.yml +++ b/scaffold/Taskfile.yml @@ -39,7 +39,7 @@ tasks: desc: "Sync a database from production and import it" cmds: # Replace this with a command to fetch your datbase. - - task: drush site:install -y + - ./vendor/bin/drush site:install -y - echo "๐Ÿงน Sanitising database" - ./vendor/bin/drush sql:sanitize --yes diff --git a/tests/fixtures/tugboat/Taskfile.yml b/tests/fixtures/tugboat/Taskfile.yml deleted file mode 100644 index e69de29bb..000000000 From 16c9e16dde8fe4c9ab798b4c6434742eec4f45ac Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 16:35:23 +0100 Subject: [PATCH 076/172] . --- .tugboat/settings.tugboat.php | 14 ++++++++++++++ .tugboat/steps/init.sh | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 .tugboat/settings.tugboat.php diff --git a/.tugboat/settings.tugboat.php b/.tugboat/settings.tugboat.php new file mode 100644 index 000000000..aa44bed82 --- /dev/null +++ b/.tugboat/settings.tugboat.php @@ -0,0 +1,14 @@ + 'tugboat', + 'username' => 'tugboat', + 'password' => 'tugboat', + 'prefix' => '', + 'host' => '{{ database_type }}', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', + ]; +} diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 9ff96e886..7d061f177 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -45,4 +45,6 @@ composer config repositories.drainpipe --json '{"type": "path", "url": "drainpip composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies mv drainpipe/.tugboat . +cp .tugboat/settings.tugboat.php web/sites/default/settings.tugboat.php +echo "include __DIR__ . '/settings.tugboat.php';" >> web/sites/default/settings.php # drainpipe-end From a8e1ca5b0507aa949d55dfcdd379159f1ac38619 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 16:39:40 +0100 Subject: [PATCH 077/172] . --- .tugboat/steps/init.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/init.sh index 7d061f177..a4226115d 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/init.sh @@ -45,6 +45,7 @@ composer config repositories.drainpipe --json '{"type": "path", "url": "drainpip composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies mv drainpipe/.tugboat . +cp web/sites/default/default.settings.php web/sites/default/settings.php cp .tugboat/settings.tugboat.php web/sites/default/settings.tugboat.php echo "include __DIR__ . '/settings.tugboat.php';" >> web/sites/default/settings.php # drainpipe-end From 062acbc04f6036f1954c94d82bedf659af01e5bc Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 16:42:24 +0100 Subject: [PATCH 078/172] . --- .tugboat/settings.tugboat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tugboat/settings.tugboat.php b/.tugboat/settings.tugboat.php index aa44bed82..9cba8624e 100644 --- a/.tugboat/settings.tugboat.php +++ b/.tugboat/settings.tugboat.php @@ -6,7 +6,7 @@ 'username' => 'tugboat', 'password' => 'tugboat', 'prefix' => '', - 'host' => '{{ database_type }}', + 'host' => 'mariadb', 'port' => '3306', 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', From e8fcaa1d6082bf7d9fdd8d3737ceff89162d4040 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 16:50:54 +0100 Subject: [PATCH 079/172] . --- .tugboat/steps/update.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.tugboat/steps/update.sh b/.tugboat/steps/update.sh index 1166882ae..60278fc79 100755 --- a/.tugboat/steps/update.sh +++ b/.tugboat/steps/update.sh @@ -2,4 +2,7 @@ set -eux +# drainpipe-start +./vendor/bin/drush config:export --yes +# drainpipe-end ./vendor/bin/task sync From 3d169879b4c2b1325aac5dabe33bf8f3c1fbc435 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 16:53:55 +0100 Subject: [PATCH 080/172] . --- .tugboat/steps/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tugboat/steps/update.sh b/.tugboat/steps/update.sh index 60278fc79..8b5b8e2bc 100755 --- a/.tugboat/steps/update.sh +++ b/.tugboat/steps/update.sh @@ -2,7 +2,7 @@ set -eux +./vendor/bin/task sync # drainpipe-start ./vendor/bin/drush config:export --yes # drainpipe-end -./vendor/bin/task sync From 3317c74971e6e8c704497957fbff32b04001786c Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 6 Jul 2023 17:18:34 +0100 Subject: [PATCH 081/172] Fix file append --- .github/workflows/TestTugboat.yml | 2 +- src/ScaffoldInstallerPlugin.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml index d69c25797..778db51ba 100644 --- a/.github/workflows/TestTugboat.yml +++ b/.github/workflows/TestTugboat.yml @@ -1,4 +1,4 @@ -name: "Test GitHub Actions" +name: "Test Tugboat" on: pull_request: diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 11151bb6c..f3a8bb533 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -324,10 +324,7 @@ private function installCICommands(): void file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); $settings = file_get_contents('./web/sites/default/settings.php'); if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { - $include = << Date: Fri, 7 Jul 2023 14:44:36 +0100 Subject: [PATCH 082/172] Don't remove the .tugboat directory if Drainpipe isn't controlling Tugboat --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index f3a8bb533..2b6af8123 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -278,8 +278,8 @@ private function installCICommands(): void } // Tugboat - $fs->removeDirectory('./.tugboat'); if (!empty($this->extra['drainpipe']['tugboat']['host'])) { + $fs->removeDirectory('./.tugboat'); $tugboatConfig = []; // Pantheon From df74bcd8345f2571137e14aa23cac73f682bbfc3 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 7 Jul 2023 14:53:40 +0100 Subject: [PATCH 083/172] Revert scaffold installer plugin --- src/ScaffoldInstallerPlugin.php | 59 ++------------------------------- 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 2b6af8123..2099478c9 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -13,8 +13,6 @@ use Composer\Script\ScriptEvents; use Composer\Util\Filesystem; use Symfony\Component\Yaml\Yaml; -use Twig\Environment; -use Twig\Loader\FilesystemLoader; class ScaffoldInstallerPlugin implements PluginInterface, EventSubscriberInterface { @@ -156,7 +154,7 @@ private function installGitignore(): void if (strpos($contents, '.task') === false) { $this->io->warning( sprintf( - '.gitignore does not contain drainpipe ignores. Compare .gitignore in the root of your repository with %s and update as needed.', + '.gitignore does not contain drainpipe ignores. Compare .gitignore in the root of your repository with %s and update as needed.', $gitignorePath ) ); @@ -186,7 +184,7 @@ private function installEnvSupport(): void } /** - * + * Install DDEV Commands. */ private function installDdevCommand(): void { @@ -276,58 +274,5 @@ private function installCICommands(): void } } } - - // Tugboat - if (!empty($this->extra['drainpipe']['tugboat']['host'])) { - $fs->removeDirectory('./.tugboat'); - $tugboatConfig = []; - - // Pantheon - if ($this->extra['drainpipe']['tugboat']['host'] === 'pantheon') { - $pantheonConfig = Yaml::parseFile('./pantheon.yml'); - $composerJson = file_get_contents('composer.json'); - $composerFullConfig = json_decode($composerJson, true); - $tugboatConfig = [ - 'php_version' => $pantheonConfig['php_version'], - 'database_type' => 'mariadb', - 'database_version' => $pantheonConfig['database']['version'], - 'nodejs_version' => '18', - ]; - - if (file_exists('./.ddev/config.yml')) { - $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); - if (!empty($ddevConfig['nodejs_version'])) { - $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; - } - } - - if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) { - $tugboatConfig['memory_cache_type'] = 'redis'; - $tugboatConfig['memory_cache_version'] = 7; - } - } - - if (count($tugboatConfig) > 0) { - $fs->ensureDirectoryExists('./.tugboat'); - $fs->ensureDirectoryExists('./.tugboat/steps'); - $loader = new FilesystemLoader(__DIR__ . '/../scaffold/tugboat'); - $twig = new Environment($loader); - file_put_contents('./.tugboat/config.yml', $twig->render('config.yml.twig', $tugboatConfig)); - file_put_contents('./.tugboat/steps/init.sh', $twig->render('steps/init.sh.twig', $tugboatConfig)); - file_put_contents('./.tugboat/steps/build.sh', $twig->render('steps/build.sh.twig', $tugboatConfig)); - file_put_contents('./.tugboat/steps/update.sh', $twig->render('steps/update.sh.twig', $tugboatConfig)); - chmod('./.tugboat/steps/init.sh', 0755); - chmod('./.tugboat/steps/build.sh', 0755); - chmod('./.tugboat/steps/update.sh', 0755); - - // settings.php - file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); - $settings = file_get_contents('./web/sites/default/settings.php'); - if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { - $include = 'include __DIR__ . "/settings.tugboat.php";'; - file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); - } - } - } } } From 9cac1ed9b1e45afdf20b0335a53ee9d016a1a804 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 7 Jul 2023 15:03:46 +0100 Subject: [PATCH 084/172] Add dependencies --- src/ScaffoldInstallerPlugin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 2099478c9..de271ae83 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -13,6 +13,8 @@ use Composer\Script\ScriptEvents; use Composer\Util\Filesystem; use Symfony\Component\Yaml\Yaml; +use Twig\Environment; +use Twig\Loader\FilesystemLoader; class ScaffoldInstallerPlugin implements PluginInterface, EventSubscriberInterface { @@ -154,7 +156,7 @@ private function installGitignore(): void if (strpos($contents, '.task') === false) { $this->io->warning( sprintf( - '.gitignore does not contain drainpipe ignores. Compare .gitignore in the root of your repository with %s and update as needed.', + '.gitignore does not contain drainpipe ignores. Compare .gitignore in the root of your repository with %s and update as needed.', $gitignorePath ) ); @@ -184,7 +186,7 @@ private function installEnvSupport(): void } /** - * Install DDEV Commands. + * */ private function installDdevCommand(): void { From c7b7a819fb0561a264b1a7896448f7d654f085bb Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 7 Jul 2023 15:16:38 +0100 Subject: [PATCH 085/172] . --- src/ScaffoldInstallerPlugin.php | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index de271ae83..b13409565 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -276,5 +276,58 @@ private function installCICommands(): void } } } + + // Tugboat + if (!empty($this->extra['drainpipe']['tugboat']['host'])) { + // $fs->removeDirectory('./.tugboat'); + // $tugboatConfig = []; + + // // Pantheon + // if ($this->extra['drainpipe']['tugboat']['host'] === 'pantheon') { + // $pantheonConfig = Yaml::parseFile('./pantheon.yml'); + // $composerJson = file_get_contents('composer.json'); + // $composerFullConfig = json_decode($composerJson, true); + // $tugboatConfig = [ + // 'php_version' => $pantheonConfig['php_version'], + // 'database_type' => 'mariadb', + // 'database_version' => $pantheonConfig['database']['version'], + // 'nodejs_version' => '18', + // ]; + + // if (file_exists('./.ddev/config.yml')) { + // $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); + // if (!empty($ddevConfig['nodejs_version'])) { + // $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; + // } + // } + + // if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) { + // $tugboatConfig['memory_cache_type'] = 'redis'; + // $tugboatConfig['memory_cache_version'] = 7; + // } + // } + + // if (count($tugboatConfig) > 0) { + // $fs->ensureDirectoryExists('./.tugboat'); + // $fs->ensureDirectoryExists('./.tugboat/steps'); + // $loader = new FilesystemLoader(__DIR__ . '/../scaffold/tugboat'); + // $twig = new Environment($loader); + // file_put_contents('./.tugboat/config.yml', $twig->render('config.yml.twig', $tugboatConfig)); + // file_put_contents('./.tugboat/steps/init.sh', $twig->render('steps/init.sh.twig', $tugboatConfig)); + // file_put_contents('./.tugboat/steps/build.sh', $twig->render('steps/build.sh.twig', $tugboatConfig)); + // file_put_contents('./.tugboat/steps/update.sh', $twig->render('steps/update.sh.twig', $tugboatConfig)); + // chmod('./.tugboat/steps/init.sh', 0755); + // chmod('./.tugboat/steps/build.sh', 0755); + // chmod('./.tugboat/steps/update.sh', 0755); + + // // settings.php + // file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); + // $settings = file_get_contents('./web/sites/default/settings.php'); + // if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { + // $include = 'include __DIR__ . "/settings.tugboat.php";'; + // file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); + // } + // } + // } } } From 6b206bad2d2b1e56cae496397413b2be161bfbb2 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 7 Jul 2023 15:31:09 +0100 Subject: [PATCH 086/172] . --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index b13409565..a2315eae0 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -328,6 +328,6 @@ private function installCICommands(): void // file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); // } // } - // } + } } } From dd426c3eacc72409f0c24e138f9bdb145fe225f5 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 09:30:21 +0100 Subject: [PATCH 087/172] . --- src/ScaffoldInstallerPlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index a2315eae0..bfa03cd1e 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -279,8 +279,8 @@ private function installCICommands(): void // Tugboat if (!empty($this->extra['drainpipe']['tugboat']['host'])) { - // $fs->removeDirectory('./.tugboat'); - // $tugboatConfig = []; + $fs->removeDirectory('./.tugboat'); + $tugboatConfig = []; // // Pantheon // if ($this->extra['drainpipe']['tugboat']['host'] === 'pantheon') { From 8b4aa478b704b4cfb8b62b4efa3bdd7481843e00 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 09:33:36 +0100 Subject: [PATCH 088/172] . --- src/ScaffoldInstallerPlugin.php | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index bfa03cd1e..be54e34f1 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -283,29 +283,29 @@ private function installCICommands(): void $tugboatConfig = []; // // Pantheon - // if ($this->extra['drainpipe']['tugboat']['host'] === 'pantheon') { - // $pantheonConfig = Yaml::parseFile('./pantheon.yml'); - // $composerJson = file_get_contents('composer.json'); - // $composerFullConfig = json_decode($composerJson, true); - // $tugboatConfig = [ - // 'php_version' => $pantheonConfig['php_version'], - // 'database_type' => 'mariadb', - // 'database_version' => $pantheonConfig['database']['version'], - // 'nodejs_version' => '18', - // ]; + if ($this->extra['drainpipe']['tugboat']['host'] === 'pantheon') { + $pantheonConfig = Yaml::parseFile('./pantheon.yml'); + $composerJson = file_get_contents('composer.json'); + $composerFullConfig = json_decode($composerJson, true); + $tugboatConfig = [ + 'php_version' => $pantheonConfig['php_version'], + 'database_type' => 'mariadb', + 'database_version' => $pantheonConfig['database']['version'], + 'nodejs_version' => '18', + ]; - // if (file_exists('./.ddev/config.yml')) { - // $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); - // if (!empty($ddevConfig['nodejs_version'])) { - // $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; - // } - // } + if (file_exists('./.ddev/config.yml')) { + $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); + if (!empty($ddevConfig['nodejs_version'])) { + $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; + } + } - // if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) { - // $tugboatConfig['memory_cache_type'] = 'redis'; - // $tugboatConfig['memory_cache_version'] = 7; - // } - // } + if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) { + $tugboatConfig['memory_cache_type'] = 'redis'; + $tugboatConfig['memory_cache_version'] = 7; + } + } // if (count($tugboatConfig) > 0) { // $fs->ensureDirectoryExists('./.tugboat'); From 19fb92b14c1e098a23ab8102231a3c2336a1974d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 09:37:27 +0100 Subject: [PATCH 089/172] . --- src/ScaffoldInstallerPlugin.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index be54e34f1..58692c0f2 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -307,18 +307,18 @@ private function installCICommands(): void } } - // if (count($tugboatConfig) > 0) { - // $fs->ensureDirectoryExists('./.tugboat'); - // $fs->ensureDirectoryExists('./.tugboat/steps'); - // $loader = new FilesystemLoader(__DIR__ . '/../scaffold/tugboat'); - // $twig = new Environment($loader); - // file_put_contents('./.tugboat/config.yml', $twig->render('config.yml.twig', $tugboatConfig)); - // file_put_contents('./.tugboat/steps/init.sh', $twig->render('steps/init.sh.twig', $tugboatConfig)); - // file_put_contents('./.tugboat/steps/build.sh', $twig->render('steps/build.sh.twig', $tugboatConfig)); - // file_put_contents('./.tugboat/steps/update.sh', $twig->render('steps/update.sh.twig', $tugboatConfig)); - // chmod('./.tugboat/steps/init.sh', 0755); - // chmod('./.tugboat/steps/build.sh', 0755); - // chmod('./.tugboat/steps/update.sh', 0755); + if (count($tugboatConfig) > 0) { + $fs->ensureDirectoryExists('./.tugboat'); + $fs->ensureDirectoryExists('./.tugboat/steps'); + $loader = new FilesystemLoader(__DIR__ . '/../scaffold/tugboat'); + $twig = new Environment($loader); + file_put_contents('./.tugboat/config.yml', $twig->render('config.yml.twig', $tugboatConfig)); + file_put_contents('./.tugboat/steps/init.sh', $twig->render('steps/init.sh.twig', $tugboatConfig)); + file_put_contents('./.tugboat/steps/build.sh', $twig->render('steps/build.sh.twig', $tugboatConfig)); + file_put_contents('./.tugboat/steps/update.sh', $twig->render('steps/update.sh.twig', $tugboatConfig)); + chmod('./.tugboat/steps/init.sh', 0755); + chmod('./.tugboat/steps/build.sh', 0755); + chmod('./.tugboat/steps/update.sh', 0755); // // settings.php // file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); @@ -327,7 +327,7 @@ private function installCICommands(): void // $include = 'include __DIR__ . "/settings.tugboat.php";'; // file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); // } - // } + } } } } From 8c7a0d8107c73e1c959dc9c7e156a87b3dd80276 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 09:39:47 +0100 Subject: [PATCH 090/172] . --- src/ScaffoldInstallerPlugin.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 58692c0f2..35198c7e7 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -320,13 +320,12 @@ private function installCICommands(): void chmod('./.tugboat/steps/build.sh', 0755); chmod('./.tugboat/steps/update.sh', 0755); - // // settings.php - // file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); - // $settings = file_get_contents('./web/sites/default/settings.php'); - // if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { - // $include = 'include __DIR__ . "/settings.tugboat.php";'; - // file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); - // } + file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); + $settings = file_get_contents('./web/sites/default/settings.php'); + if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { + $include = 'include __DIR__ . "/settings.tugboat.php";'; + file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); + } } } } From aaf8b45815893b8797233e4fb47ba79bf93feb96 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 09:43:41 +0100 Subject: [PATCH 091/172] . --- src/ScaffoldInstallerPlugin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 35198c7e7..48c73059f 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -322,10 +322,10 @@ private function installCICommands(): void file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); $settings = file_get_contents('./web/sites/default/settings.php'); - if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { - $include = 'include __DIR__ . "/settings.tugboat.php";'; - file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); - } + //if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { + // $include = 'include __DIR__ . "/settings.tugboat.php";'; + // file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); + //} } } } From 9f3d945f29be2461e76293e27d1c03ab9fc9fbb7 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 10:26:46 +0100 Subject: [PATCH 092/172] . --- src/ScaffoldInstallerPlugin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 48c73059f..b7dbc79c9 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -322,10 +322,10 @@ private function installCICommands(): void file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); $settings = file_get_contents('./web/sites/default/settings.php'); - //if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { - // $include = 'include __DIR__ . "/settings.tugboat.php";'; - // file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); - //} + if (file_exists('./web/sites/default/settings.php') && !str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { + $include = 'include __DIR__ . "/settings.tugboat.php";'; + file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); + } } } } From fe93b7046fe2d6c52aa3986fba391e8e7e726b69 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 10:34:28 +0100 Subject: [PATCH 093/172] . --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index b7dbc79c9..ad3f09486 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -324,7 +324,7 @@ private function installCICommands(): void $settings = file_get_contents('./web/sites/default/settings.php'); if (file_exists('./web/sites/default/settings.php') && !str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { $include = 'include __DIR__ . "/settings.tugboat.php";'; - file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); + //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); } } } From fb017be67ca06e874947ea700b8dab1767f22973 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 11:20:33 +0100 Subject: [PATCH 094/172] . --- src/ScaffoldInstallerPlugin.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index ad3f09486..2eecee65a 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -321,10 +321,12 @@ private function installCICommands(): void chmod('./.tugboat/steps/update.sh', 0755); file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); - $settings = file_get_contents('./web/sites/default/settings.php'); - if (file_exists('./web/sites/default/settings.php') && !str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { - $include = 'include __DIR__ . "/settings.tugboat.php";'; - //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); + if (file_exists('./web/sites/default/settings.php')) { + $settings = file_get_contents('./web/sites/default/settings.php'); + if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { + $include = 'include __DIR__ . "/settings.tugboat.php";'; + file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); + } } } } From 717e7efb5484c47fe2dd8e1d35ea98132c550634 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 11:31:15 +0100 Subject: [PATCH 095/172] . --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 2eecee65a..6e6fe4cf6 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -325,7 +325,7 @@ private function installCICommands(): void $settings = file_get_contents('./web/sites/default/settings.php'); if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { $include = 'include __DIR__ . "/settings.tugboat.php";'; - file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); + //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); } } } From 5478997bac820ccac37bb95541f5654a9ba5658b Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 11:37:12 +0100 Subject: [PATCH 096/172] . --- src/ScaffoldInstallerPlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 6e6fe4cf6..5e06de423 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -323,10 +323,10 @@ private function installCICommands(): void file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); if (file_exists('./web/sites/default/settings.php')) { $settings = file_get_contents('./web/sites/default/settings.php'); - if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { + //if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { $include = 'include __DIR__ . "/settings.tugboat.php";'; //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); - } + //} } } } From f7ae436332a21fe973691c6e60a267072ab94b72 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 11:43:48 +0100 Subject: [PATCH 097/172] . --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 5e06de423..891f7df06 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -320,7 +320,7 @@ private function installCICommands(): void chmod('./.tugboat/steps/build.sh', 0755); chmod('./.tugboat/steps/update.sh', 0755); - file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); + //file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); if (file_exists('./web/sites/default/settings.php')) { $settings = file_get_contents('./web/sites/default/settings.php'); //if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { From 1bfe50586c5bf4c8e990ec37e79399a7f3d50f61 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 11:47:30 +0100 Subject: [PATCH 098/172] . --- src/ScaffoldInstallerPlugin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 891f7df06..9d5f59c80 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -320,11 +320,11 @@ private function installCICommands(): void chmod('./.tugboat/steps/build.sh', 0755); chmod('./.tugboat/steps/update.sh', 0755); - //file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); - if (file_exists('./web/sites/default/settings.php')) { - $settings = file_get_contents('./web/sites/default/settings.php'); + file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); + //if (file_exists('./web/sites/default/settings.php')) { + //$settings = file_get_contents('./web/sites/default/settings.php'); //if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { - $include = 'include __DIR__ . "/settings.tugboat.php";'; + //$include = 'include __DIR__ . "/settings.tugboat.php";'; //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); //} } From abb2909b245ebd73b69d2396540241ae51a4e178 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 12:13:39 +0100 Subject: [PATCH 099/172] . --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 9d5f59c80..c6147084b 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -320,7 +320,7 @@ private function installCICommands(): void chmod('./.tugboat/steps/build.sh', 0755); chmod('./.tugboat/steps/update.sh', 0755); - file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); + //file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); //if (file_exists('./web/sites/default/settings.php')) { //$settings = file_get_contents('./web/sites/default/settings.php'); //if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { From f6f0f2836cc2983475b8ec88e9a23ec4a6467955 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 12:16:12 +0100 Subject: [PATCH 100/172] . --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index c6147084b..fe039db1f 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -327,7 +327,7 @@ private function installCICommands(): void //$include = 'include __DIR__ . "/settings.tugboat.php";'; //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); //} - } + //} } } } From 679eb4ba97b394282733ec85504e52d9e62f03ed Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 12:18:53 +0100 Subject: [PATCH 101/172] . --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index fe039db1f..fac7be45c 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -320,7 +320,7 @@ private function installCICommands(): void chmod('./.tugboat/steps/build.sh', 0755); chmod('./.tugboat/steps/update.sh', 0755); - //file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); + file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); //if (file_exists('./web/sites/default/settings.php')) { //$settings = file_get_contents('./web/sites/default/settings.php'); //if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { From 7a9718fb12d7405f827140922b9f00953fa21c3d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 12:22:26 +0100 Subject: [PATCH 102/172] . --- src/ScaffoldInstallerPlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index fac7be45c..f8a8eb021 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -321,13 +321,13 @@ private function installCICommands(): void chmod('./.tugboat/steps/update.sh', 0755); file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); - //if (file_exists('./web/sites/default/settings.php')) { + if (file_exists('./web/sites/default/settings.php')) { //$settings = file_get_contents('./web/sites/default/settings.php'); //if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { //$include = 'include __DIR__ . "/settings.tugboat.php";'; //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); //} - //} + } } } } From ed22e7666974b6491db89068d0da8b06edc9183d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 12:26:47 +0100 Subject: [PATCH 103/172] . --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index f8a8eb021..f2c012d37 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -322,7 +322,7 @@ private function installCICommands(): void file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); if (file_exists('./web/sites/default/settings.php')) { - //$settings = file_get_contents('./web/sites/default/settings.php'); + $settings = file_get_contents('./web/sites/default/settings.php'); //if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { //$include = 'include __DIR__ . "/settings.tugboat.php";'; //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); From 25b03b8afc6a31aaa35390ab19ff938834d23e50 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 12:39:58 +0100 Subject: [PATCH 104/172] . --- src/ScaffoldInstallerPlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index f2c012d37..15ca3f453 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -323,10 +323,10 @@ private function installCICommands(): void file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); if (file_exists('./web/sites/default/settings.php')) { $settings = file_get_contents('./web/sites/default/settings.php'); - //if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { + if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { //$include = 'include __DIR__ . "/settings.tugboat.php";'; //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); - //} + } } } } From 92e9d045dca46b9075bdb62b4c9a949f9d63c75f Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 12:53:57 +0100 Subject: [PATCH 105/172] . --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 15ca3f453..97ea29656 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -323,7 +323,7 @@ private function installCICommands(): void file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); if (file_exists('./web/sites/default/settings.php')) { $settings = file_get_contents('./web/sites/default/settings.php'); - if (!str_contains($settings, 'include __DIR__ . "/settings.tugboat.php";')) { + if (strpos($settings, 'include __DIR__ . "/settings.tugboat.php";') !== false) { //$include = 'include __DIR__ . "/settings.tugboat.php";'; //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); } From b0a5b0f01ddd78568dc4c4b126efa0e8bf1c8f6a Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 13:00:28 +0100 Subject: [PATCH 106/172] . --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 97ea29656..4211352ea 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -323,7 +323,7 @@ private function installCICommands(): void file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); if (file_exists('./web/sites/default/settings.php')) { $settings = file_get_contents('./web/sites/default/settings.php'); - if (strpos($settings, 'include __DIR__ . "/settings.tugboat.php";') !== false) { + if (strpos($settings, 'settings.tugboat.php') === false) { //$include = 'include __DIR__ . "/settings.tugboat.php";'; //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); } From 142b9bafa14addacb2e24dc3790bbcf0f4c86d93 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 13:02:52 +0100 Subject: [PATCH 107/172] . --- src/ScaffoldInstallerPlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 4211352ea..3771f5796 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -324,8 +324,8 @@ private function installCICommands(): void if (file_exists('./web/sites/default/settings.php')) { $settings = file_get_contents('./web/sites/default/settings.php'); if (strpos($settings, 'settings.tugboat.php') === false) { - //$include = 'include __DIR__ . "/settings.tugboat.php";'; - //file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); + $include = 'include __DIR__ . "/settings.tugboat.php";'; + file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); } } } From 84e0284eb95419b54c66a0ffb7261503e2224ead Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 13:32:50 +0100 Subject: [PATCH 108/172] . --- src/ScaffoldInstallerPlugin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 3771f5796..afffefa1b 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -324,7 +324,9 @@ private function installCICommands(): void if (file_exists('./web/sites/default/settings.php')) { $settings = file_get_contents('./web/sites/default/settings.php'); if (strpos($settings, 'settings.tugboat.php') === false) { - $include = 'include __DIR__ . "/settings.tugboat.php";'; + $include = <<<'EOT' +include __DIR__ . "/settings.tugboat.php"; +EOT; file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); } } From efa8c7bf183f810a999f9ca7df2e98a5b220af56 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 14:13:28 +0100 Subject: [PATCH 109/172] Update Tugboat test --- .github/workflows/TestTugboat.yml | 8 ++++++++ .tugboat/config.yml | 6 +++--- .tugboat/steps/{init.sh => 1-init.sh} | 11 +++++++++-- .tugboat/steps/{update.sh => 2-update.sh} | 0 .tugboat/steps/{build.sh => 3-build.sh} | 0 5 files changed, 20 insertions(+), 5 deletions(-) rename .tugboat/steps/{init.sh => 1-init.sh} (89%) rename .tugboat/steps/{update.sh => 2-update.sh} (100%) rename .tugboat/steps/{build.sh => 3-build.sh} (100%) diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml index 778db51ba..c8641cda3 100644 --- a/.github/workflows/TestTugboat.yml +++ b/.github/workflows/TestTugboat.yml @@ -38,6 +38,7 @@ jobs: - name: Setup Project run: | ddev config --auto + ddev config --nodejs-version "18" ddev start ddev composer config extra.drupal-scaffold.gitignore true ddev composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] @@ -55,6 +56,13 @@ jobs: run: | cmp --silent -- "drainpipe/.tugboat/config.yml" ".tugboat/config.yml" cmp --silent -- "drainpipe/.tugboat/steps/build.sh" ".tugboat/steps/build.sh" + sed -i '/#drainpipe-start/,/#drainpipe-end/d' .tugboat/steps/1-init.sh cmp --silent -- "drainpipe/.tugboat/steps/init.sh" ".tugboat/steps/init.sh" cmp --silent -- "drainpipe/.tugboat/steps/update.sh" ".tugboat/steps/update`.sh" + - name: Upload test artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: .tugboat + path: .tugboat diff --git a/.tugboat/config.yml b/.tugboat/config.yml index b2fce2d21..e405dc70a 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -8,9 +8,9 @@ services: - mariadb commands: - init: ./.tugboat/steps/init.sh - update: ./.tugboat/steps/update.sh - build: ./.tugboat/steps/build.sh + init: ./.tugboat/steps/1-init.sh + update: ./.tugboat/steps/2-update.sh + build: ./.tugboat/steps/3-build.sh mariadb: image: tugboatqa/mariadb:10.6 diff --git a/.tugboat/steps/init.sh b/.tugboat/steps/1-init.sh similarity index 89% rename from .tugboat/steps/init.sh rename to .tugboat/steps/1-init.sh index a4226115d..a0fca0035 100755 --- a/.tugboat/steps/init.sh +++ b/.tugboat/steps/1-init.sh @@ -29,7 +29,14 @@ docker-php-ext-install gd # Install ImageMagick. This is recommended by both Acquia and Pantheon instead # of GD. Lullabot will likely be publishing an ADR recommending it too. apt-get install -y imagemagick -# drainpipe-start + +# Install node +curl -fsSL https://deb.nodesource.com/setup_18.x | bash - +apt-get install -y nodejs +# This only works for node > 16, but that version is unsupported now anyway. +corepack enable + +#drainpipe-start # This is necessary for testing as this repository doesn't hold a Drupal site. shopt -s dotglob mkdir ../drainpipe-tmp @@ -48,4 +55,4 @@ mv drainpipe/.tugboat . cp web/sites/default/default.settings.php web/sites/default/settings.php cp .tugboat/settings.tugboat.php web/sites/default/settings.tugboat.php echo "include __DIR__ . '/settings.tugboat.php';" >> web/sites/default/settings.php -# drainpipe-end +#drainpipe-end diff --git a/.tugboat/steps/update.sh b/.tugboat/steps/2-update.sh similarity index 100% rename from .tugboat/steps/update.sh rename to .tugboat/steps/2-update.sh diff --git a/.tugboat/steps/build.sh b/.tugboat/steps/3-build.sh similarity index 100% rename from .tugboat/steps/build.sh rename to .tugboat/steps/3-build.sh From 7563bd9fd500e184fff181a0e5bfb2da6291c018 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 14:34:17 +0100 Subject: [PATCH 110/172] Fix file names --- .github/workflows/TestTugboat.yml | 6 +++--- scaffold/tugboat/config.yml.twig | 6 +++--- .../tugboat/steps/{init.sh.twig => 1-init.sh.twig} | 0 .../steps/{update.sh.twig => 2-update.sh.twig} | 0 .../tugboat/steps/{build.sh.twig => 3-build.sh.twig} | 0 src/ScaffoldInstallerPlugin.php | 12 ++++++------ 6 files changed, 12 insertions(+), 12 deletions(-) rename scaffold/tugboat/steps/{init.sh.twig => 1-init.sh.twig} (100%) rename scaffold/tugboat/steps/{update.sh.twig => 2-update.sh.twig} (100%) rename scaffold/tugboat/steps/{build.sh.twig => 3-build.sh.twig} (100%) diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml index c8641cda3..e8efcaeda 100644 --- a/.github/workflows/TestTugboat.yml +++ b/.github/workflows/TestTugboat.yml @@ -55,10 +55,10 @@ jobs: - name: Test Generated Files run: | cmp --silent -- "drainpipe/.tugboat/config.yml" ".tugboat/config.yml" - cmp --silent -- "drainpipe/.tugboat/steps/build.sh" ".tugboat/steps/build.sh" sed -i '/#drainpipe-start/,/#drainpipe-end/d' .tugboat/steps/1-init.sh - cmp --silent -- "drainpipe/.tugboat/steps/init.sh" ".tugboat/steps/init.sh" - cmp --silent -- "drainpipe/.tugboat/steps/update.sh" ".tugboat/steps/update`.sh" + cmp --silent -- "drainpipe/.tugboat/steps/1-init.sh" ".tugboat/steps/1-init.sh" + cmp --silent -- "drainpipe/.tugboat/steps/2-build.sh" ".tugboat/steps/2-build.sh" + cmp --silent -- "drainpipe/.tugboat/steps/3-update.sh" ".tugboat/steps/3-update`.sh" - name: Upload test artifacts if: ${{ always() }} diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index e3a8c78e9..e2cffee45 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -11,9 +11,9 @@ services: {% endif %} commands: - init: ./.tugboat/steps/init.sh - update: ./.tugboat/steps/update.sh - build: ./.tugboat/steps/build.sh + init: ./.tugboat/steps/1-init.sh + update: ./.tugboat/steps/2-update.sh + build: ./.tugboat/steps/3-build.sh {{ database_type }}: image: tugboatqa/{{ database_type }}:{{ database_version }} diff --git a/scaffold/tugboat/steps/init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig similarity index 100% rename from scaffold/tugboat/steps/init.sh.twig rename to scaffold/tugboat/steps/1-init.sh.twig diff --git a/scaffold/tugboat/steps/update.sh.twig b/scaffold/tugboat/steps/2-update.sh.twig similarity index 100% rename from scaffold/tugboat/steps/update.sh.twig rename to scaffold/tugboat/steps/2-update.sh.twig diff --git a/scaffold/tugboat/steps/build.sh.twig b/scaffold/tugboat/steps/3-build.sh.twig similarity index 100% rename from scaffold/tugboat/steps/build.sh.twig rename to scaffold/tugboat/steps/3-build.sh.twig diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index afffefa1b..f5d400522 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -313,12 +313,12 @@ private function installCICommands(): void $loader = new FilesystemLoader(__DIR__ . '/../scaffold/tugboat'); $twig = new Environment($loader); file_put_contents('./.tugboat/config.yml', $twig->render('config.yml.twig', $tugboatConfig)); - file_put_contents('./.tugboat/steps/init.sh', $twig->render('steps/init.sh.twig', $tugboatConfig)); - file_put_contents('./.tugboat/steps/build.sh', $twig->render('steps/build.sh.twig', $tugboatConfig)); - file_put_contents('./.tugboat/steps/update.sh', $twig->render('steps/update.sh.twig', $tugboatConfig)); - chmod('./.tugboat/steps/init.sh', 0755); - chmod('./.tugboat/steps/build.sh', 0755); - chmod('./.tugboat/steps/update.sh', 0755); + file_put_contents('./.tugboat/steps/1-init.sh', $twig->render('steps/1-init.sh.twig', $tugboatConfig)); + file_put_contents('./.tugboat/steps/2-build.sh', $twig->render('steps/2-build.sh.twig', $tugboatConfig)); + file_put_contents('./.tugboat/steps/3-update.sh', $twig->render('steps/3-update.sh.twig', $tugboatConfig)); + chmod('./.tugboat/steps/1-init.sh', 0755); + chmod('./.tugboat/steps/2-build.sh', 0755); + chmod('./.tugboat/steps/3-update.sh', 0755); file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); if (file_exists('./web/sites/default/settings.php')) { From 57e7996772d5807f767c4af4d65e45d7616ddce2 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 15:00:12 +0100 Subject: [PATCH 111/172] Fix file names --- src/ScaffoldInstallerPlugin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index f5d400522..03929c0c8 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -314,11 +314,11 @@ private function installCICommands(): void $twig = new Environment($loader); file_put_contents('./.tugboat/config.yml', $twig->render('config.yml.twig', $tugboatConfig)); file_put_contents('./.tugboat/steps/1-init.sh', $twig->render('steps/1-init.sh.twig', $tugboatConfig)); - file_put_contents('./.tugboat/steps/2-build.sh', $twig->render('steps/2-build.sh.twig', $tugboatConfig)); - file_put_contents('./.tugboat/steps/3-update.sh', $twig->render('steps/3-update.sh.twig', $tugboatConfig)); + file_put_contents('./.tugboat/steps/2-update.sh', $twig->render('steps/2-update.sh.twig', $tugboatConfig)); + file_put_contents('./.tugboat/steps/3-build.sh', $twig->render('steps/3-build.sh.twig', $tugboatConfig)); chmod('./.tugboat/steps/1-init.sh', 0755); - chmod('./.tugboat/steps/2-build.sh', 0755); - chmod('./.tugboat/steps/3-update.sh', 0755); + chmod('./.tugboat/steps/2-update.sh', 0755); + chmod('./.tugboat/steps/3-build.sh', 0755); file_put_contents('./web/sites/default/settings.tugboat.php', $twig->render('settings.tugboat.php.twig', $tugboatConfig)); if (file_exists('./web/sites/default/settings.php')) { From eb3c7576d07549bbde345e7117d534aef8b86476 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 15:03:57 +0100 Subject: [PATCH 112/172] Fix image name --- .tugboat/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index e405dc70a..a73aaf873 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -1,7 +1,7 @@ services: php: http: false - image: tugboatqa/php:8.1-apache-buster + image: tugboatqa/php:8.1-apache-bullseye default: true depends: From 05b5f64e3795e420af34469349127171f6324db1 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 10 Jul 2023 15:25:28 +0100 Subject: [PATCH 113/172] remove linespace --- .tugboat/config.yml | 1 - README.md | 51 ++++++--------------------------- src/ScaffoldInstallerPlugin.php | 16 +++++------ 3 files changed, 17 insertions(+), 51 deletions(-) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index a73aaf873..fd84e7305 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -17,4 +17,3 @@ services: commands: update: - echo "Nothing to do as we import databases from the Drupal service." - diff --git a/README.md b/README.md index 9e7d95077..d2aaefd06 100644 --- a/README.md +++ b/README.md @@ -436,7 +436,13 @@ Requires `GITLAB_ACCESS_TOKEN` variable to be set, which is an access token with - `SSH_KNOWN_HOSTS` The result of running `ssh-keyscan -H codeserver.dev.$PANTHEON_SITE_ID.drush.in` - `TERMINUS_PLUGINS` Comma-separated list of Terminus plugins to be available (optional) -## Tugboat Integration +This will setup Merge Request deployment to Pantheon Multidev environments. See +[scaffold/gitlab/gitlab-ci.example.yml] for an example. You can also just +include which will give you helpers that you can include and reference for tasks +such as setting up [Terminus](https://pantheon.io/docs/terminus). See +[scaffold/gitlab/Pantheon.gitlab-ci.yml](scaffold/gitlab/Pantheon.gitlab-ci.yml). + +### Tugboat Add the following to `composer.json` to add Tugboat configuration: @@ -452,44 +458,5 @@ Add the following to `composer.json` to add Tugboat configuration: } ``` -The PHP version is autodetected based on the composer requirements. - -A `provider` object allows the upstream host to be determined and to determine -if Tugboat downsyncs from the provider or does a fresh Drupal site install. - -### Acquia -```json -{ - "extra": { - "drainpipe": { - "tugboat": { - "provider": { - "host": "acquia", - "downsync": true - } - } - } - } -} -``` - -### Pantheon -```json -{ - "extra": { - "drainpipe": { - "tugboat": { - "provider": { - "host": "pantheon", - "downsync": true - } - } - } - } -} -``` -This will setup Merge Request deployment to Pantheon Multidev environments. See -[scaffold/gitlab/gitlab-ci.example.yml] for an example. You can also just -include which will give you helpers that you can include and reference for tasks -such as setting up [Terminus](https://pantheon.io/docs/terminus). See -[scaffold/gitlab/Pantheon.gitlab-ci.yml](scaffold/gitlab/Pantheon.gitlab-ci.yml). +The PHP and database version is autodetected based on your `pantheon.yml`, with +the nodejs version being derived from DDEV settings. diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 03929c0c8..dc00ada0f 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -282,7 +282,14 @@ private function installCICommands(): void $fs->removeDirectory('./.tugboat'); $tugboatConfig = []; - // // Pantheon + if (file_exists('./.ddev/config.yml')) { + $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); + if (!empty($ddevConfig['nodejs_version'])) { + $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; + } + } + + // Pantheon if ($this->extra['drainpipe']['tugboat']['host'] === 'pantheon') { $pantheonConfig = Yaml::parseFile('./pantheon.yml'); $composerJson = file_get_contents('composer.json'); @@ -294,13 +301,6 @@ private function installCICommands(): void 'nodejs_version' => '18', ]; - if (file_exists('./.ddev/config.yml')) { - $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); - if (!empty($ddevConfig['nodejs_version'])) { - $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; - } - } - if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) { $tugboatConfig['memory_cache_type'] = 'redis'; $tugboatConfig['memory_cache_version'] = 7; From 8ca393f88e00e47ef681172b571795c835c8b269 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 10:33:48 +0100 Subject: [PATCH 114/172] Fix extra newline --- scaffold/tugboat/config.yml.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index e2cffee45..d316b8269 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -20,8 +20,8 @@ services: commands: update: - echo "Nothing to do as we import databases from the Drupal service." - {% if memory_cache_type %} {{ memory_cache_type }}: + image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} {% endif %} From 71ebf9a91e01186fb43863df9fbaa83dce2c7542 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 10:44:16 +0100 Subject: [PATCH 115/172] fix cmps --- .github/workflows/TestTugboat.yml | 10 ++++++---- .tugboat/steps/2-update.sh | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml index e8efcaeda..ed41aeb12 100644 --- a/.github/workflows/TestTugboat.yml +++ b/.github/workflows/TestTugboat.yml @@ -54,11 +54,13 @@ jobs: # preview - they should be the same. - name: Test Generated Files run: | - cmp --silent -- "drainpipe/.tugboat/config.yml" ".tugboat/config.yml" + cmp -b drainpipe/.tugboat/config.yml .tugboat/config.yml sed -i '/#drainpipe-start/,/#drainpipe-end/d' .tugboat/steps/1-init.sh - cmp --silent -- "drainpipe/.tugboat/steps/1-init.sh" ".tugboat/steps/1-init.sh" - cmp --silent -- "drainpipe/.tugboat/steps/2-build.sh" ".tugboat/steps/2-build.sh" - cmp --silent -- "drainpipe/.tugboat/steps/3-update.sh" ".tugboat/steps/3-update`.sh" + sed -i '/#drainpipe-start/,/#drainpipe-end/d' .tugboat/steps/2-update.sh + sed -i '/#drainpipe-start/,/#drainpipe-end/d' .tugboat/steps/3-build.sh + cmp -b drainpipe/.tugboat/steps/1-init.sh .tugboat/steps/1-init.sh + cmp -b drainpipe/.tugboat/steps/2-update.sh .tugboat/steps/2-update.sh + cmp -b drainpipe/.tugboat/steps/3-build.sh .tugboat/steps/3-build.sh - name: Upload test artifacts if: ${{ always() }} diff --git a/.tugboat/steps/2-update.sh b/.tugboat/steps/2-update.sh index 8b5b8e2bc..b355b61e5 100755 --- a/.tugboat/steps/2-update.sh +++ b/.tugboat/steps/2-update.sh @@ -3,6 +3,7 @@ set -eux ./vendor/bin/task sync + # drainpipe-start ./vendor/bin/drush config:export --yes # drainpipe-end From 9672a662326e9ab6a511d7edb7c1155eef17b8a7 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 11:15:07 +0100 Subject: [PATCH 116/172] . --- .tugboat/steps/1-init.sh | 4 +++- .tugboat/steps/2-update.sh | 2 +- .tugboat/steps/3-build.sh | 1 + scaffold/tugboat/steps/1-init.sh.twig | 6 +++--- scaffold/tugboat/steps/2-update.sh.twig | 23 +---------------------- scaffold/tugboat/steps/3-build.sh.twig | 4 ++-- 6 files changed, 11 insertions(+), 29 deletions(-) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index a0fca0035..6b4cc221e 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -35,7 +35,6 @@ curl -fsSL https://deb.nodesource.com/setup_18.x | bash - apt-get install -y nodejs # This only works for node > 16, but that version is unsupported now anyway. corepack enable - #drainpipe-start # This is necessary for testing as this repository doesn't hold a Drupal site. shopt -s dotglob @@ -56,3 +55,6 @@ cp web/sites/default/default.settings.php web/sites/default/settings.php cp .tugboat/settings.tugboat.php web/sites/default/settings.tugboat.php echo "include __DIR__ . '/settings.tugboat.php';" >> web/sites/default/settings.php #drainpipe-end + +# Needed to bring in task +composer install diff --git a/.tugboat/steps/2-update.sh b/.tugboat/steps/2-update.sh index b355b61e5..07241708f 100755 --- a/.tugboat/steps/2-update.sh +++ b/.tugboat/steps/2-update.sh @@ -1,9 +1,9 @@ #!/bin/bash set -eux +echo "Updating..." ./vendor/bin/task sync - # drainpipe-start ./vendor/bin/drush config:export --yes # drainpipe-end diff --git a/.tugboat/steps/3-build.sh b/.tugboat/steps/3-build.sh index 1d176c3d0..0c089ec96 100755 --- a/.tugboat/steps/3-build.sh +++ b/.tugboat/steps/3-build.sh @@ -1,6 +1,7 @@ #!/bin/bash set -eux +echo "Building..." ./vendor/bin/task build ./vendor/bin/task drupal:update diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index 6dd0305f9..2cb27700e 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -19,9 +19,6 @@ apt-get install -y {{ database_type }}-client # repository, change that here. This example links /web to the docroot ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" -# Enable mod_rewrite so clean URLs work. -a2enmod headers rewrite - # Install the PHP opcache as it's not included by default and needed for # decent performance. docker-php-ext-install opcache @@ -53,3 +50,6 @@ curl -fsSL https://deb.nodesource.com/setup_{{ node_version }}.x | bash - apt-get install -y nodejs # This only works for node > 16, but that version is unsupported now anyway. corepack enable + +# Needed to bring in task +composer install diff --git a/scaffold/tugboat/steps/2-update.sh.twig b/scaffold/tugboat/steps/2-update.sh.twig index 90451779e..e22bfe864 100644 --- a/scaffold/tugboat/steps/2-update.sh.twig +++ b/scaffold/tugboat/steps/2-update.sh.twig @@ -3,25 +3,4 @@ set -eux echo "Updating..." -# We intentionally do not set up syncing of static assets, as we have -# decided to always use Stage File Proxy: -# https://architecture.lullabot.com/adr/20210729-stage-file-proxy/ - -# Set up permissions for the files directories. -mkdir -p "${TUGBOAT_ROOT}/web/sites/default/files" -chgrp -R www-data "${TUGBOAT_ROOT}/web/sites/default/files" -chmod -R g+w "${TUGBOAT_ROOT}/web/sites/default/files" -chmod 2775 "${TUGBOAT_ROOT}/web/sites/default/files" - -composer install -vendor/bin/task drupal:composer:development - -{% if downsync %} -# Remember to set any required environment variables for the fetch-db task, -# such as PANTHEON_TOKEN. -vendor/bin/task {{ host }}:fetch-db -vendor/bin/task drupal:import-db -{% else %} -# Install Drupal using the standard profile. -vendor/bin/task drupal:install -{% endif %} +./vendor/bin/task sync diff --git a/scaffold/tugboat/steps/3-build.sh.twig b/scaffold/tugboat/steps/3-build.sh.twig index e299cea54..0c089ec96 100644 --- a/scaffold/tugboat/steps/3-build.sh.twig +++ b/scaffold/tugboat/steps/3-build.sh.twig @@ -1,7 +1,7 @@ #!/bin/bash set -eux -composer install -./vendor/bin/task sync +echo "Building..." + ./vendor/bin/task build ./vendor/bin/task drupal:update From 7e4d2771a6961181bd84b6b17170229bba6aab4f Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 12:21:39 +0100 Subject: [PATCH 117/172] Fix newline --- scaffold/tugboat/steps/1-init.sh.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index 2cb27700e..ac18f03cb 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -36,10 +36,10 @@ docker-php-ext-install gd # Install ImageMagick. This is recommended by both Acquia and Pantheon instead # of GD. Lullabot will likely be publishing an ADR recommending it too. apt-get install -y imagemagick - {% if memory_cache_type == "memcached" %} # Install the PHP memcache extension. The Drupal Redis module recommends # phpredis so no PHP extension is required. + apt-get install -y zlib1g-dev pecl install memcache echo 'extension=memcache.so' > /usr/local/etc/php/conf.d/memcache.ini From 0f792186281d8d4e007ff92d01298e8d249ef56c Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 12:30:01 +0100 Subject: [PATCH 118/172] Fix nodejs installer --- scaffold/tugboat/steps/1-init.sh.twig | 2 +- src/ScaffoldInstallerPlugin.php | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index ac18f03cb..3e3d037a3 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -46,7 +46,7 @@ echo 'extension=memcache.so' > /usr/local/etc/php/conf.d/memcache.ini {% endif %} # Install node -curl -fsSL https://deb.nodesource.com/setup_{{ node_version }}.x | bash - +curl -fsSL https://deb.nodesource.com/setup_{{ nodejs_version }}.x | bash - apt-get install -y nodejs # This only works for node > 16, but that version is unsupported now anyway. corepack enable diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index dc00ada0f..b600e4a87 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -280,7 +280,12 @@ private function installCICommands(): void // Tugboat if (!empty($this->extra['drainpipe']['tugboat']['host'])) { $fs->removeDirectory('./.tugboat'); - $tugboatConfig = []; + $tugboatConfig = [ + 'nodejs_version' => '18', + 'database_type' => 'mariadb', + 'database_version' => '10.6', + 'php_version' => '8.1', + ]; if (file_exists('./.ddev/config.yml')) { $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); @@ -294,12 +299,9 @@ private function installCICommands(): void $pantheonConfig = Yaml::parseFile('./pantheon.yml'); $composerJson = file_get_contents('composer.json'); $composerFullConfig = json_decode($composerJson, true); - $tugboatConfig = [ - 'php_version' => $pantheonConfig['php_version'], - 'database_type' => 'mariadb', - 'database_version' => $pantheonConfig['database']['version'], - 'nodejs_version' => '18', - ]; + + $tugboatConfig['php_version'] = $pantheonConfig['php_version']; + $tugboatConfig['database_version'] = $pantheonConfig['database']['version']; if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) { $tugboatConfig['memory_cache_type'] = 'redis'; From 57de4a32d213a056b989fb8a7e0bf55ec12f8314 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 13:21:54 +0100 Subject: [PATCH 119/172] Remove space --- .tugboat/steps/2-update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tugboat/steps/2-update.sh b/.tugboat/steps/2-update.sh index 07241708f..3e1523a3b 100755 --- a/.tugboat/steps/2-update.sh +++ b/.tugboat/steps/2-update.sh @@ -4,6 +4,6 @@ set -eux echo "Updating..." ./vendor/bin/task sync -# drainpipe-start +#drainpipe-start ./vendor/bin/drush config:export --yes -# drainpipe-end +#drainpipe-end From 0a86a796392e6c69c5a5ab67cf83c9cb304f63da Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 13:46:42 +0100 Subject: [PATCH 120/172] debugging --- .github/workflows/TestTugboat.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml index ed41aeb12..dff3213a9 100644 --- a/.github/workflows/TestTugboat.yml +++ b/.github/workflows/TestTugboat.yml @@ -50,6 +50,9 @@ jobs: ddev composer config extra.drainpipe --json '{"tugboat": {"host": "pantheon"}}' ddev composer require lullabot/drainpipe --with-all-dependencies + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + # Compare the generated files to the ones used to build this repository # preview - they should be the same. - name: Test Generated Files From 2e4d9af10ba5ffdad849075a95fbadd7bf29d5f6 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 13:53:51 +0100 Subject: [PATCH 121/172] sed the right filesW --- .github/workflows/TestTugboat.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml index dff3213a9..e11ee4062 100644 --- a/.github/workflows/TestTugboat.yml +++ b/.github/workflows/TestTugboat.yml @@ -58,9 +58,9 @@ jobs: - name: Test Generated Files run: | cmp -b drainpipe/.tugboat/config.yml .tugboat/config.yml - sed -i '/#drainpipe-start/,/#drainpipe-end/d' .tugboat/steps/1-init.sh - sed -i '/#drainpipe-start/,/#drainpipe-end/d' .tugboat/steps/2-update.sh - sed -i '/#drainpipe-start/,/#drainpipe-end/d' .tugboat/steps/3-build.sh + sed -i '/#drainpipe-start/,/#drainpipe-end/d' drainpipe/.tugboat/steps/1-init.sh + sed -i '/#drainpipe-start/,/#drainpipe-end/d' drainpipe/.tugboat/steps/2-update.sh + sed -i '/#drainpipe-start/,/#drainpipe-end/d' drainpipe/.tugboat/steps/3-build.sh cmp -b drainpipe/.tugboat/steps/1-init.sh .tugboat/steps/1-init.sh cmp -b drainpipe/.tugboat/steps/2-update.sh .tugboat/steps/2-update.sh cmp -b drainpipe/.tugboat/steps/3-build.sh .tugboat/steps/3-build.sh From 0f78a6e7e4c530051162510e7b078a1c60cc9705 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 13:58:08 +0100 Subject: [PATCH 122/172] Remove debugging and switch to php-fpm image --- .github/workflows/TestTugboat.yml | 3 --- .tugboat/config.yml | 2 +- scaffold/tugboat/config.yml.twig | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml index e11ee4062..17e4a31ab 100644 --- a/.github/workflows/TestTugboat.yml +++ b/.github/workflows/TestTugboat.yml @@ -50,9 +50,6 @@ jobs: ddev composer config extra.drainpipe --json '{"tugboat": {"host": "pantheon"}}' ddev composer require lullabot/drainpipe --with-all-dependencies - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - # Compare the generated files to the ones used to build this repository # preview - they should be the same. - name: Test Generated Files diff --git a/.tugboat/config.yml b/.tugboat/config.yml index fd84e7305..7d8709634 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -1,7 +1,7 @@ services: php: http: false - image: tugboatqa/php:8.1-apache-bullseye + image: tugboatqa/php-nginx:8.1-fpm default: true depends: diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index d316b8269..b20fd5020 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -1,7 +1,7 @@ services: php: http: false - image: tugboatqa/php:{{ php_version }}-apache-bullseye + image: tugboatqa/php-nginx:{{ php_version }}-fpm default: true depends: From 662ce893730832657cc6dee6c7c03dd25d92a589 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 14:43:51 +0100 Subject: [PATCH 123/172] bump libwebp --- .tugboat/steps/1-init.sh | 2 +- scaffold/tugboat/steps/1-init.sh.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index 6b4cc221e..b100242e1 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -20,7 +20,7 @@ docker-php-ext-install opcache apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev # WebP dependencies. -apt-get install -y libwebp-dev libwebp6 webp libmagickwand-dev +apt-get install -y libwebp-dev libwebp7 webp libmagickwand-dev # Build and install gd. docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index 3e3d037a3..7b685ee40 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -27,7 +27,7 @@ docker-php-ext-install opcache apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev # WebP dependencies. -apt-get install -y libwebp-dev libwebp6 webp libmagickwand-dev +apt-get install -y libwebp-dev libwebp7 webp libmagickwand-dev # Build and install gd. docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp From d168100aac27179db9cefc4ba88f76d182827132 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 16:10:41 +0100 Subject: [PATCH 124/172] Get all the Tugboat info out of the ddev configuration --- README.md | 14 +++++++------- scaffold/tugboat/config.yml.twig | 2 +- src/ScaffoldInstallerPlugin.php | 29 +++++++++++++++-------------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index d2aaefd06..1c03afd60 100644 --- a/README.md +++ b/README.md @@ -442,7 +442,7 @@ include which will give you helpers that you can include and reference for tasks such as setting up [Terminus](https://pantheon.io/docs/terminus). See [scaffold/gitlab/Pantheon.gitlab-ci.yml](scaffold/gitlab/Pantheon.gitlab-ci.yml). -### Tugboat +## Tugboat Add the following to `composer.json` to add Tugboat configuration: @@ -450,13 +450,13 @@ Add the following to `composer.json` to add Tugboat configuration: { "extra": { "drainpipe": { - "tugboat": { - "provider": "pantheon" - } + "tugboat": {} } } } ``` - -The PHP and database version is autodetected based on your `pantheon.yml`, with -the nodejs version being derived from DDEV settings. +The following will be autodetected based on your `.ddev/config.yml`: +- PHP version +- Database type and version +- nodejs version +- Redis (Obtained with `ddev get ddev/ddev-redis`) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index b20fd5020..5fe5fbf06 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -1,7 +1,7 @@ services: php: http: false - image: tugboatqa/php-nginx:{{ php_version }}-fpm + image: tugboatqa/{{ webserver_image }}:{{ php_version }}-fpm default: true depends: diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index b600e4a87..aa081fd52 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -278,10 +278,11 @@ private function installCICommands(): void } // Tugboat - if (!empty($this->extra['drainpipe']['tugboat']['host'])) { + if (isset($this->extra['drainpipe']['tugboat'])) { $fs->removeDirectory('./.tugboat'); $tugboatConfig = [ 'nodejs_version' => '18', + 'webserver_image' => 'php-nginx', 'database_type' => 'mariadb', 'database_version' => '10.6', 'php_version' => '8.1', @@ -289,24 +290,24 @@ private function installCICommands(): void if (file_exists('./.ddev/config.yml')) { $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); + $tugboatConfig = [ + 'database_type' => $ddevConfig['database']['type'], + 'database_version' => $ddevConfig['database']['version'], + 'php_version' => $ddevConfig['php_version'], + ]; if (!empty($ddevConfig['nodejs_version'])) { $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; } + if (!empty($ddevConfig['webserver_type']) && $ddevConfig['webserver_type'] === 'apache-fpm') { + $tugboatConfig['webserver_image'] = 'php'; + } } - // Pantheon - if ($this->extra['drainpipe']['tugboat']['host'] === 'pantheon') { - $pantheonConfig = Yaml::parseFile('./pantheon.yml'); - $composerJson = file_get_contents('composer.json'); - $composerFullConfig = json_decode($composerJson, true); - - $tugboatConfig['php_version'] = $pantheonConfig['php_version']; - $tugboatConfig['database_version'] = $pantheonConfig['database']['version']; - - if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) { - $tugboatConfig['memory_cache_type'] = 'redis'; - $tugboatConfig['memory_cache_version'] = 7; - } + if (file_exists('./.ddev/docker-compose.redis.yaml')) { + $redisConfig = Yaml::parseFile('.ddev/docker-compose.redis.yaml'); + $redisImage = explode(':', $redisConfig['services']['redis']['image']); + $tugboatConfig['memory_cache_type'] = 'redis'; + $tugboatConfig['memory_cache_version'] = array_pop($redisImage); } if (count($tugboatConfig) > 0) { From 39325db79cb844816cbb7e4f4978f3f95b9d4716 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 17:14:49 +0100 Subject: [PATCH 125/172] Add a build:tugboat command --- .github/workflows/TestTugboat.yml | 14 ++++++++++++-- README.md | 9 +++++++++ scaffold/tugboat/steps/1-init.sh.twig | 4 ++++ scaffold/tugboat/steps/3-build.sh.twig | 2 +- src/ScaffoldInstallerPlugin.php | 8 ++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml index 17e4a31ab..35ec8fde8 100644 --- a/.github/workflows/TestTugboat.yml +++ b/.github/workflows/TestTugboat.yml @@ -9,7 +9,7 @@ concurrency: cancel-in-progress: true jobs: - Test-Tugboat-Pantheon: + Test-Tugboat: runs-on: ubuntu-latest steps: - name: Create a Drupal project @@ -47,7 +47,7 @@ jobs: ddev composer config --no-plugins allow-plugins.lullabot/drainpipe true ddev composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": false}}' ddev composer config minimum-stability dev - ddev composer config extra.drainpipe --json '{"tugboat": {"host": "pantheon"}}' + ddev composer config extra.drainpipe --json '{"tugboat": {}}' ddev composer require lullabot/drainpipe --with-all-dependencies # Compare the generated files to the ones used to build this repository @@ -62,6 +62,16 @@ jobs: cmp -b drainpipe/.tugboat/steps/2-update.sh .tugboat/steps/2-update.sh cmp -b drainpipe/.tugboat/steps/3-build.sh .tugboat/steps/3-build.sh + - name: Add a build:tugboat step + run: | + echo " build:tugboat:" >> Taskfile.yml + echo " cmds:" >> Taskfile.yml + echo " - echo \"Tugboat build\"" >> Taskfile.yml + ddev composer install + if ! grep -q './vendor/bin/task build:tugboat' .tugboat/steps/3-build.sh; then + exit 1 + fi + - name: Upload test artifacts if: ${{ always() }} uses: actions/upload-artifact@v3 diff --git a/README.md b/README.md index 1c03afd60..57b14d3ca 100644 --- a/README.md +++ b/README.md @@ -455,8 +455,17 @@ Add the following to `composer.json` to add Tugboat configuration: } } ``` + The following will be autodetected based on your `.ddev/config.yml`: - PHP version - Database type and version - nodejs version - Redis (Obtained with `ddev get ddev/ddev-redis`) + +It is assumed the following tasks exist: +- `build` +- `sync` + +The `build` task can be overridden with a `build:tugboat` task if required (you +will need to re-run `composer install` to regenerate the Tugboat scripts if you +are adding this task to your `Taskfile.yml` for the first time) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index 7b685ee40..791f7330c 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -50,6 +50,10 @@ curl -fsSL https://deb.nodesource.com/setup_{{ nodejs_version }}.x | bash - apt-get install -y nodejs # This only works for node > 16, but that version is unsupported now anyway. corepack enable +{% if webserver_image == "php" %} +# Apache +a2enmod headers rewrite +{% endif %} # Needed to bring in task composer install diff --git a/scaffold/tugboat/steps/3-build.sh.twig b/scaffold/tugboat/steps/3-build.sh.twig index 0c089ec96..d99a38ae3 100644 --- a/scaffold/tugboat/steps/3-build.sh.twig +++ b/scaffold/tugboat/steps/3-build.sh.twig @@ -3,5 +3,5 @@ set -eux echo "Building..." -./vendor/bin/task build +./vendor/bin/task {{ build_command }} ./vendor/bin/task drupal:update diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index aa081fd52..27feada7b 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -286,6 +286,7 @@ private function installCICommands(): void 'database_type' => 'mariadb', 'database_version' => '10.6', 'php_version' => '8.1', + 'build_command' => 'build', ]; if (file_exists('./.ddev/config.yml')) { @@ -310,6 +311,13 @@ private function installCICommands(): void $tugboatConfig['memory_cache_version'] = array_pop($redisImage); } + if (file_exists('Taskfile.yml')) { + $taskfile = Yaml::parseFile('./Taskfile.yml'); + if (isset($taskfile['tasks']['build:tugboat'])) { + $tugboatConfig['build_command'] = 'build:tugboat'; + } + } + if (count($tugboatConfig) > 0) { $fs->ensureDirectoryExists('./.tugboat'); $fs->ensureDirectoryExists('./.tugboat/steps'); From 46a0e790a58298136d637154d1e6c149faf11750 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 18:11:10 +0100 Subject: [PATCH 126/172] Update readme --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 57b14d3ca..ec3585e6e 100644 --- a/README.md +++ b/README.md @@ -468,4 +468,7 @@ It is assumed the following tasks exist: The `build` task can be overridden with a `build:tugboat` task if required (you will need to re-run `composer install` to regenerate the Tugboat scripts if you -are adding this task to your `Taskfile.yml` for the first time) +are adding this task to your `Taskfile.yml` for the first time). + +`composer install` should also be re-run if any chances are made to the DDEV +configuration. From 18ee8f651085178efe66a5335a90843fecf63128 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 18:30:51 +0100 Subject: [PATCH 127/172] Use a lower version of mariadb from the default to test tugboat config is being written correctly --- .github/workflows/TestTugboat.yml | 1 + .tugboat/config.yml | 2 +- src/ScaffoldInstallerPlugin.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml index 35ec8fde8..4b9f88f4d 100644 --- a/.github/workflows/TestTugboat.yml +++ b/.github/workflows/TestTugboat.yml @@ -39,6 +39,7 @@ jobs: run: | ddev config --auto ddev config --nodejs-version "18" + ddev config --database=mariadb:10.4 ddev start ddev composer config extra.drupal-scaffold.gitignore true ddev composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] diff --git a/.tugboat/config.yml b/.tugboat/config.yml index 7d8709634..261ed4a8b 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -13,7 +13,7 @@ services: build: ./.tugboat/steps/3-build.sh mariadb: - image: tugboatqa/mariadb:10.6 + image: tugboatqa/mariadb:10.4 commands: update: - echo "Nothing to do as we import databases from the Drupal service." diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 27feada7b..ddf88e5bb 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -289,8 +289,8 @@ private function installCICommands(): void 'build_command' => 'build', ]; - if (file_exists('./.ddev/config.yml')) { - $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); + if (file_exists('./.ddev/config.yaml')) { + $ddevConfig = Yaml::parseFile('./.ddev/config.yaml'); $tugboatConfig = [ 'database_type' => $ddevConfig['database']['type'], 'database_version' => $ddevConfig['database']['version'], From d55754ca4168e0842a7eff5b3c423cb85159f543 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 18:58:11 +0100 Subject: [PATCH 128/172] Don't overrwite all tugboat config --- src/ScaffoldInstallerPlugin.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index ddf88e5bb..3a5426a13 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -291,11 +291,10 @@ private function installCICommands(): void if (file_exists('./.ddev/config.yaml')) { $ddevConfig = Yaml::parseFile('./.ddev/config.yaml'); - $tugboatConfig = [ - 'database_type' => $ddevConfig['database']['type'], - 'database_version' => $ddevConfig['database']['version'], - 'php_version' => $ddevConfig['php_version'], - ]; + $tugboatConfig['database_type'] = $ddevConfig['database']['type']; + $tugboatConfig['database_version'] = $ddevConfig['database']['version']; + $tugboatConfig['php_version'] = $ddevConfig['php_version']; + if (!empty($ddevConfig['nodejs_version'])) { $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; } From 8300daba28977ceb11d271d9cc4b29ba0eb14c1e Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 19:30:28 +0100 Subject: [PATCH 129/172] Fix webserver image name --- scaffold/tugboat/config.yml.twig | 2 +- src/ScaffoldInstallerPlugin.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index 5fe5fbf06..4a03c7e51 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -1,7 +1,7 @@ services: php: http: false - image: tugboatqa/{{ webserver_image }}:{{ php_version }}-fpm + image: {{ webserver_image }} default: true depends: diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 3a5426a13..0d8817f88 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -282,7 +282,7 @@ private function installCICommands(): void $fs->removeDirectory('./.tugboat'); $tugboatConfig = [ 'nodejs_version' => '18', - 'webserver_image' => 'php-nginx', + 'webserver_image' => 'tugboatqa/php-nginx:8.1-fpm', 'database_type' => 'mariadb', 'database_version' => '10.6', 'php_version' => '8.1', @@ -293,13 +293,13 @@ private function installCICommands(): void $ddevConfig = Yaml::parseFile('./.ddev/config.yaml'); $tugboatConfig['database_type'] = $ddevConfig['database']['type']; $tugboatConfig['database_version'] = $ddevConfig['database']['version']; - $tugboatConfig['php_version'] = $ddevConfig['php_version']; + $tugboatConfig['webserver_image'] = 'tugboatqa/php-nginx:' . $ddevConfig['php_version'] . '-fpm'; if (!empty($ddevConfig['nodejs_version'])) { $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; } if (!empty($ddevConfig['webserver_type']) && $ddevConfig['webserver_type'] === 'apache-fpm') { - $tugboatConfig['webserver_image'] = 'php'; + $tugboatConfig['webserver_image'] = 'tugboatqa/php:' . $ddevConfig['php_version'] . '-apache'; } } From b636ad9e97816c4ced7888d81ec2c0ccf2ec6e69 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 11 Jul 2023 19:39:55 +0100 Subject: [PATCH 130/172] Check apache image --- scaffold/tugboat/steps/1-init.sh.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index 791f7330c..a07178bb0 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -50,7 +50,7 @@ curl -fsSL https://deb.nodesource.com/setup_{{ nodejs_version }}.x | bash - apt-get install -y nodejs # This only works for node > 16, but that version is unsupported now anyway. corepack enable -{% if webserver_image == "php" %} +{% if 'apache' in webserver_image %} # Apache a2enmod headers rewrite {% endif %} From 49c387fa845309dcd380d3521679b7da74dc38b2 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 18 Jul 2023 11:17:24 +0100 Subject: [PATCH 131/172] Add file comment --- scaffold/tugboat/settings.tugboat.php.twig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scaffold/tugboat/settings.tugboat.php.twig b/scaffold/tugboat/settings.tugboat.php.twig index 3fcaeca25..3fb996dbe 100644 --- a/scaffold/tugboat/settings.tugboat.php.twig +++ b/scaffold/tugboat/settings.tugboat.php.twig @@ -1,5 +1,10 @@ 'tugboat', From 550d3641f829fcbfbb9e0324ae25ee82490e4c97 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 18 Jul 2023 11:53:57 +0100 Subject: [PATCH 132/172] install task and allow hooks into tugboat steps --- .tugboat/config.yml | 8 +++++--- .tugboat/steps/1-init.sh | 1 - scaffold/tugboat/config.yml.twig | 11 ++++++++--- scaffold/tugboat/steps/1-init.sh.twig | 5 ++++- scaffold/tugboat/steps/2-update.sh.twig | 1 + src/BinaryInstallerPlugin.php | 10 ++++++++++ src/ScaffoldInstallerPlugin.php | 11 +++++++++++ 7 files changed, 39 insertions(+), 8 deletions(-) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index 261ed4a8b..55e7e80cc 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -8,12 +8,14 @@ services: - mariadb commands: - init: ./.tugboat/steps/1-init.sh + init: + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v3.24.0/install-task.sh)" -- -d + - ./.tugboat/steps/1-init.sh update: ./.tugboat/steps/2-update.sh build: ./.tugboat/steps/3-build.sh mariadb: image: tugboatqa/mariadb:10.4 commands: - update: - - echo "Nothing to do as we import databases from the Drupal service." + init: + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v3.24.0/install-task.sh)" -- -d diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index b100242e1..2449df0a4 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -56,5 +56,4 @@ cp .tugboat/settings.tugboat.php web/sites/default/settings.tugboat.php echo "include __DIR__ . '/settings.tugboat.php';" >> web/sites/default/settings.php #drainpipe-end -# Needed to bring in task composer install diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index 4a03c7e51..fddce775a 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -11,15 +11,20 @@ services: {% endif %} commands: - init: ./.tugboat/steps/1-init.sh + init: + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d + - ./.tugboat/steps/1-init.sh update: ./.tugboat/steps/2-update.sh build: ./.tugboat/steps/3-build.sh {{ database_type }}: image: tugboatqa/{{ database_type }}:{{ database_version }} + {% if mysql_init %} commands: - update: - - echo "Nothing to do as we import databases from the Drupal service." + init: + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d + - task tugboat:mysql:init + {% endif %} {% if memory_cache_type %} {{ memory_cache_type }}: diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index a07178bb0..d273cb2ea 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -54,6 +54,9 @@ corepack enable # Apache a2enmod headers rewrite {% endif %} +{% if php_init %} + +task tugboat:php:init +{% endif %} -# Needed to bring in task composer install diff --git a/scaffold/tugboat/steps/2-update.sh.twig b/scaffold/tugboat/steps/2-update.sh.twig index e22bfe864..87d09cf2e 100644 --- a/scaffold/tugboat/steps/2-update.sh.twig +++ b/scaffold/tugboat/steps/2-update.sh.twig @@ -3,4 +3,5 @@ set -eux echo "Updating..." +composer install ./vendor/bin/task sync diff --git a/src/BinaryInstallerPlugin.php b/src/BinaryInstallerPlugin.php index 20ce65331..ef71289c7 100644 --- a/src/BinaryInstallerPlugin.php +++ b/src/BinaryInstallerPlugin.php @@ -34,4 +34,14 @@ class BinaryInstallerPlugin extends BinaryInstaller 'version' => '3.24.0', ], ]; + + /** + * Gets the version for a binary. + * + * @param $binary + * @return mixed|string + */ + public function getBinaryVersion($binary) { + return $this->binaries[$binary]['version']; + } } diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 0d8817f88..6000baa7d 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -280,6 +280,7 @@ private function installCICommands(): void // Tugboat if (isset($this->extra['drainpipe']['tugboat'])) { $fs->removeDirectory('./.tugboat'); + $binaryInstallerPlugin = new BinaryInstallerPlugin(); $tugboatConfig = [ 'nodejs_version' => '18', 'webserver_image' => 'tugboatqa/php-nginx:8.1-fpm', @@ -287,6 +288,9 @@ private function installCICommands(): void 'database_version' => '10.6', 'php_version' => '8.1', 'build_command' => 'build', + 'php_init' => false, + 'mysql_init' => false, + 'task_version' => $binaryInstallerPlugin->getBinaryVersion('task'), ]; if (file_exists('./.ddev/config.yaml')) { @@ -311,10 +315,17 @@ private function installCICommands(): void } if (file_exists('Taskfile.yml')) { + // Get steps out of the Taskfile. $taskfile = Yaml::parseFile('./Taskfile.yml'); if (isset($taskfile['tasks']['build:tugboat'])) { $tugboatConfig['build_command'] = 'build:tugboat'; } + if (isset($taskfile['tasks']['tugboat:php:init'])) { + $tugboatConfig['php_init'] = true; + } + if (isset($taskfile['tasks']['tugboat:mysql:init'])) { + $tugboatConfig['mysql_init'] = true; + } } if (count($tugboatConfig) > 0) { From a71bbda9c3d85ab0c106281bf9ceb25cd2195d02 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Wed, 19 Jul 2023 14:56:41 +0100 Subject: [PATCH 133/172] Install into /usr/local/bin --- .tugboat/config.yml | 4 ++-- scaffold/tugboat/config.yml.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index 55e7e80cc..5d9070780 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -9,7 +9,7 @@ services: commands: init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v3.24.0/install-task.sh)" -- -d + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v3.24.0/install-task.sh)" -- -d -b /usr/local/bin - ./.tugboat/steps/1-init.sh update: ./.tugboat/steps/2-update.sh build: ./.tugboat/steps/3-build.sh @@ -18,4 +18,4 @@ services: image: tugboatqa/mariadb:10.4 commands: init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v3.24.0/install-task.sh)" -- -d + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v3.24.0/install-task.sh)" -- -d -b /usr/local/bin diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index fddce775a..532df5dcc 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -12,7 +12,7 @@ services: commands: init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - ./.tugboat/steps/1-init.sh update: ./.tugboat/steps/2-update.sh build: ./.tugboat/steps/3-build.sh @@ -22,7 +22,7 @@ services: {% if mysql_init %} commands: init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - task tugboat:mysql:init {% endif %} {% if memory_cache_type %} From 94814e2fbb40200884a35f8b84b80ca39e1093d7 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Wed, 19 Jul 2023 15:30:53 +0100 Subject: [PATCH 134/172] bring in tasks --- scaffold/tugboat/steps/1-init.sh.twig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index d273cb2ea..e04971e92 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -53,9 +53,12 @@ corepack enable {% if 'apache' in webserver_image %} # Apache a2enmod headers rewrite +service apache2 restart {% endif %} {% if php_init %} +# Bring in tasks. +composer install --ignore-platform-reqs task tugboat:php:init {% endif %} From 33e564713354e72c2ddc3c755faae58bce5cda8e Mon Sep 17 00:00:00 2001 From: Sally Young Date: Wed, 19 Jul 2023 15:41:31 +0100 Subject: [PATCH 135/172] tidy up --- .tugboat/config.yml | 4 +--- .tugboat/steps/1-init.sh | 3 +++ scaffold/tugboat/config.yml.twig | 4 +--- scaffold/tugboat/steps/1-init.sh.twig | 3 +++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index 5d9070780..51e20b2a4 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -8,9 +8,7 @@ services: - mariadb commands: - init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v3.24.0/install-task.sh)" -- -d -b /usr/local/bin - - ./.tugboat/steps/1-init.sh + init: ./.tugboat/steps/1-init.sh update: ./.tugboat/steps/2-update.sh build: ./.tugboat/steps/3-build.sh diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index 2449df0a4..9979d00d4 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -3,6 +3,9 @@ set -eux echo "Initializing..." +# Install task +sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v3.24.0/install-task.sh)" -- -d -b /usr/local/bin + # Install mysql or mariadb client. apt-get update apt-get install -y mariadb-client diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index 532df5dcc..e4bbc4bf5 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -11,9 +11,7 @@ services: {% endif %} commands: - init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - - ./.tugboat/steps/1-init.sh + init: ./.tugboat/steps/1-init.sh update: ./.tugboat/steps/2-update.sh build: ./.tugboat/steps/3-build.sh diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index e04971e92..7b5e0171c 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -3,6 +3,9 @@ set -eux echo "Initializing..." +# Install task +sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v3.24.0/install-task.sh)" -- -d -b /usr/local/bin + # Install mysql or mariadb client. apt-get update {% if database_type == "mysql" %} From 8cdf8e499c42b5ab7a96013c9352e8dd8dbb54ad Mon Sep 17 00:00:00 2001 From: Sally Young Date: Wed, 19 Jul 2023 15:59:50 +0100 Subject: [PATCH 136/172] don't restart --- scaffold/tugboat/steps/1-init.sh.twig | 1 - 1 file changed, 1 deletion(-) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index 7b5e0171c..a06c81ec7 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -56,7 +56,6 @@ corepack enable {% if 'apache' in webserver_image %} # Apache a2enmod headers rewrite -service apache2 restart {% endif %} {% if php_init %} From 61d6516f2e52c0dc38866b56b9a9061fe30585ef Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 10:08:25 +0100 Subject: [PATCH 137/172] Add documentation --- README.md | 15 ++++++++++++++- scaffold/tugboat/config.yml.twig | 6 ++++++ src/ScaffoldInstallerPlugin.php | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ec3585e6e..3c2cd213b 100644 --- a/README.md +++ b/README.md @@ -470,5 +470,18 @@ The `build` task can be overridden with a `build:tugboat` task if required (you will need to re-run `composer install` to regenerate the Tugboat scripts if you are adding this task to your `Taskfile.yml` for the first time). -`composer install` should also be re-run if any chances are made to the DDEV +>>> +๐Ÿ’ก +`composer install` should be re-run if any changes are made to the DDEV configuration. +>>> + +You can hook into the `init` step of images by adding them to your +`Taskfile.yml`, e.g. + +``` +tugboat:php:init: + cmds: + - apt-get install -y libldap2-dev + - docker-php-ext-install ldap +``` diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index e4bbc4bf5..f676a5bc1 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -27,4 +27,10 @@ services: {{ memory_cache_type }}: image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} + {% if redis_init %} + commands: + init: + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin + - task tugboat:redis:init + {% endif %} {% endif %} diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 6000baa7d..6d677bf56 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -290,6 +290,7 @@ private function installCICommands(): void 'build_command' => 'build', 'php_init' => false, 'mysql_init' => false, + 'redis_init' => false, 'task_version' => $binaryInstallerPlugin->getBinaryVersion('task'), ]; @@ -326,6 +327,9 @@ private function installCICommands(): void if (isset($taskfile['tasks']['tugboat:mysql:init'])) { $tugboatConfig['mysql_init'] = true; } + if (isset($taskfile['tasks']['tugboat:redis:init'])) { + $tugboatConfig['redis_init'] = true; + } } if (count($tugboatConfig) > 0) { From 870cdf5624fd888410fdfd8dcdc33832d6d36a60 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 11:42:56 +0100 Subject: [PATCH 138/172] Add sync override support --- README.md | 7 ++++--- scaffold/tugboat/config.yml.twig | 4 ++-- scaffold/tugboat/steps/1-init.sh.twig | 2 +- scaffold/tugboat/steps/2-update.sh.twig | 2 +- src/ScaffoldInstallerPlugin.php | 14 ++++++++------ 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3c2cd213b..767759497 100644 --- a/README.md +++ b/README.md @@ -466,9 +466,10 @@ It is assumed the following tasks exist: - `build` - `sync` -The `build` task can be overridden with a `build:tugboat` task if required (you -will need to re-run `composer install` to regenerate the Tugboat scripts if you -are adding this task to your `Taskfile.yml` for the first time). +The `build` and `sync` tasks can be overridden with a `build:tugboat` and +`sync:tugboat` task if required (you will need to re-run `composer install` to +regenerate the Tugboat scripts if you are adding this task to your +`Taskfile.yml` for the first time). >>> ๐Ÿ’ก diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index f676a5bc1..fa661ccad 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -17,7 +17,7 @@ services: {{ database_type }}: image: tugboatqa/{{ database_type }}:{{ database_version }} - {% if mysql_init %} + {% if init.mysql %} commands: init: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin @@ -27,7 +27,7 @@ services: {{ memory_cache_type }}: image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} - {% if redis_init %} + {% if init.redis %} commands: init: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index a06c81ec7..b4c514da1 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -57,7 +57,7 @@ corepack enable # Apache a2enmod headers rewrite {% endif %} -{% if php_init %} +{% if init.php %} # Bring in tasks. composer install --ignore-platform-reqs diff --git a/scaffold/tugboat/steps/2-update.sh.twig b/scaffold/tugboat/steps/2-update.sh.twig index 87d09cf2e..b1e19f946 100644 --- a/scaffold/tugboat/steps/2-update.sh.twig +++ b/scaffold/tugboat/steps/2-update.sh.twig @@ -4,4 +4,4 @@ set -eux echo "Updating..." composer install -./vendor/bin/task sync +./vendor/bin/task {{ sync_command }} diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 6d677bf56..599a0ebe5 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -288,9 +288,8 @@ private function installCICommands(): void 'database_version' => '10.6', 'php_version' => '8.1', 'build_command' => 'build', - 'php_init' => false, - 'mysql_init' => false, - 'redis_init' => false, + 'sync_command' => 'sync', + 'init' => [], 'task_version' => $binaryInstallerPlugin->getBinaryVersion('task'), ]; @@ -321,14 +320,17 @@ private function installCICommands(): void if (isset($taskfile['tasks']['build:tugboat'])) { $tugboatConfig['build_command'] = 'build:tugboat'; } + if (isset($taskfile['tasks']['sync:tugboat'])) { + $tugboatConfig['build_command'] = 'sync:tugboat'; + } if (isset($taskfile['tasks']['tugboat:php:init'])) { - $tugboatConfig['php_init'] = true; + $tugboatConfig['init']['php'] = true; } if (isset($taskfile['tasks']['tugboat:mysql:init'])) { - $tugboatConfig['mysql_init'] = true; + $tugboatConfig['init']['mysql'] = true; } if (isset($taskfile['tasks']['tugboat:redis:init'])) { - $tugboatConfig['redis_init'] = true; + $tugboatConfig['init']['redis'] = true; } } From 7b0229bf4ddfecb441898dd66895a3cf001d9faf Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 12:00:21 +0100 Subject: [PATCH 139/172] tidy up --- scaffold/Taskfile.yml | 3 ++- scaffold/tugboat/config.yml.twig | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scaffold/Taskfile.yml b/scaffold/Taskfile.yml index 27cfcc9ca..58ec8e05c 100644 --- a/scaffold/Taskfile.yml +++ b/scaffold/Taskfile.yml @@ -38,7 +38,8 @@ tasks: sync: desc: "Sync a database from production and import it" cmds: - # Replace this with a command to fetch your datbase. + # Replace this with a command to fetch your data + base. - ./vendor/bin/drush site:install -y - echo "๐Ÿงน Sanitising database" - ./vendor/bin/drush sql:sanitize --yes diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index fa661ccad..de1b01d60 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -25,7 +25,6 @@ services: {% endif %} {% if memory_cache_type %} {{ memory_cache_type }}: - image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} {% if init.redis %} commands: From 5d1be2d943491599d6038b9501c003b0709c2b2e Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 12:15:33 +0100 Subject: [PATCH 140/172] fix spacing --- scaffold/tugboat/config.yml.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index de1b01d60..a467dd583 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -24,7 +24,7 @@ services: - task tugboat:mysql:init {% endif %} {% if memory_cache_type %} - {{ memory_cache_type }}: +{{ memory_cache_type }}: image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} {% if init.redis %} commands: From c8313fa263fa15767d35e5c349e425666cea62bf Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 12:18:08 +0100 Subject: [PATCH 141/172] fix spacing --- scaffold/tugboat/config.yml.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index a467dd583..de1b01d60 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -24,7 +24,7 @@ services: - task tugboat:mysql:init {% endif %} {% if memory_cache_type %} -{{ memory_cache_type }}: + {{ memory_cache_type }}: image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} {% if init.redis %} commands: From 1bbbf6685aafaeaa85a7f5608e11b1adef09026b Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 13:54:28 +0100 Subject: [PATCH 142/172] fix spacing --- scaffold/tugboat/config.yml.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index de1b01d60..ac8f51133 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -23,7 +23,7 @@ services: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - task tugboat:mysql:init {% endif %} -{% if memory_cache_type %} + {% if memory_cache_type %} {{ memory_cache_type }}: image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} {% if init.redis %} @@ -32,4 +32,4 @@ services: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - task tugboat:redis:init {% endif %} -{% endif %} + {% endif %} From 1778bcddd485d9c32dc1583b004e6f6704288aa3 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 13:55:22 +0100 Subject: [PATCH 143/172] fix spacing --- scaffold/tugboat/config.yml.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index ac8f51133..1b85d7981 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -24,6 +24,7 @@ services: - task tugboat:mysql:init {% endif %} {% if memory_cache_type %} + {{ memory_cache_type }}: image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} {% if init.redis %} From 519d7e5fb62e70346cfb865f38c8d24d3eaf329d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 14:48:27 +0100 Subject: [PATCH 144/172] fix spacing --- scaffold/tugboat/config.yml.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index 1b85d7981..81bf28cb9 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -18,7 +18,7 @@ services: {{ database_type }}: image: tugboatqa/{{ database_type }}:{{ database_version }} {% if init.mysql %} - commands: + commands: init: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - task tugboat:mysql:init From 050997fd556fc4bf153b88619f39c8b0844b4317 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 15:03:52 +0100 Subject: [PATCH 145/172] fix spacing --- scaffold/tugboat/config.yml.twig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index 81bf28cb9..b34494b0b 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -18,19 +18,19 @@ services: {{ database_type }}: image: tugboatqa/{{ database_type }}:{{ database_version }} {% if init.mysql %} - commands: - init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - - task tugboat:mysql:init +commands: + init: + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin + task tugboat:mysql:init {% endif %} {% if memory_cache_type %} {{ memory_cache_type }}: image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} {% if init.redis %} - commands: - init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - - task tugboat:redis:init +commands: + init: + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin + - task tugboat:redis:init {% endif %} {% endif %} From 03d0532810fccb70b708604d8feaef226be48f93 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 15:05:04 +0100 Subject: [PATCH 146/172] fix spacing --- scaffold/tugboat/config.yml.twig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index b34494b0b..004318ca3 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -19,9 +19,9 @@ services: image: tugboatqa/{{ database_type }}:{{ database_version }} {% if init.mysql %} commands: - init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - task tugboat:mysql:init + init: + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin + task tugboat:mysql:init {% endif %} {% if memory_cache_type %} @@ -29,8 +29,8 @@ commands: image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} {% if init.redis %} commands: - init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - - task tugboat:redis:init + init: + - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin + - task tugboat:redis:init {% endif %} {% endif %} From 6b02ae6bb118a44b96e69988495a64576bb77b01 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 17:56:26 +0100 Subject: [PATCH 147/172] Add missing - --- scaffold/tugboat/config.yml.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index 004318ca3..ab276b8e8 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -21,7 +21,7 @@ services: commands: init: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - task tugboat:mysql:init + - task tugboat:mysql:init {% endif %} {% if memory_cache_type %} From a915f547c96ae71ac002018271cb7524df620e6d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 18:01:51 +0100 Subject: [PATCH 148/172] Check items out in other images --- scaffold/tugboat/config.yml.twig | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index ab276b8e8..8047d4b96 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -17,20 +17,22 @@ services: {{ database_type }}: image: tugboatqa/{{ database_type }}:{{ database_version }} - {% if init.mysql %} -commands: +{% if init.mysql %} + checkout: true + commands: init: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - task tugboat:mysql:init - {% endif %} - {% if memory_cache_type %} +{% endif %} +{% if memory_cache_type %} {{ memory_cache_type }}: image: tugboatqa/{{ memory_cache_type }}:{{ memory_cache_version }} - {% if init.redis %} -commands: +{% if init.redis %} + checkout: true + commands: init: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - task tugboat:redis:init - {% endif %} - {% endif %} +{% endif %} +{% endif %} From 96b61da918e2a0af951c54e030d2ae52d2933a4e Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 18:02:57 +0100 Subject: [PATCH 149/172] spacing --- scaffold/tugboat/config.yml.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index 8047d4b96..64b261492 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -18,8 +18,8 @@ services: {{ database_type }}: image: tugboatqa/{{ database_type }}:{{ database_version }} {% if init.mysql %} - checkout: true - commands: + checkout: true + commands: init: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin - task tugboat:mysql:init From b6e1d312c45d093c0af4466311ba4af50253934d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 18:13:36 +0100 Subject: [PATCH 150/172] Delete includes in redis and mysql --- scaffold/tugboat/config.yml.twig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index 64b261492..76f19d049 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -22,6 +22,8 @@ services: commands: init: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin + - wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq + - yq -i 'del(."includes")' Taskfile.yml - task tugboat:mysql:init {% endif %} {% if memory_cache_type %} @@ -33,6 +35,8 @@ services: commands: init: - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v{{ task_version }}/install-task.sh)" -- -d -b /usr/local/bin + - wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq + - yq -i 'del(."includes")' Taskfile.yml - task tugboat:redis:init {% endif %} {% endif %} From 235b0b668225ab8f32ccdac4503bece8ca4317ca Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 20 Jul 2023 18:24:36 +0100 Subject: [PATCH 151/172] zip extension --- .tugboat/steps/1-init.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index 9979d00d4..976ef00b1 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -19,6 +19,9 @@ ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" # decent performance. docker-php-ext-install opcache +# Zip extension. +docker-php-ext-install zip + # GD dependencies. apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev From b31ad15a2bcb25fbb20430eaaf250cfce1a831b0 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 21 Jul 2023 16:23:45 +0100 Subject: [PATCH 152/172] Tugboat settings --- .tugboat/steps/1-init.sh | 3 -- scaffold/tugboat/settings.tugboat.php.twig | 45 +++++----------------- 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index 976ef00b1..9979d00d4 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -19,9 +19,6 @@ ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" # decent performance. docker-php-ext-install opcache -# Zip extension. -docker-php-ext-install zip - # GD dependencies. apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev diff --git a/scaffold/tugboat/settings.tugboat.php.twig b/scaffold/tugboat/settings.tugboat.php.twig index 3fb996dbe..a8eade1f6 100644 --- a/scaffold/tugboat/settings.tugboat.php.twig +++ b/scaffold/tugboat/settings.tugboat.php.twig @@ -5,38 +5,13 @@ * Tugboat Drupal settings. */ -if (getenv('TUGBOAT_REPO') !== FALSE) { - $databases['default']['default'] = [ - 'database' => 'tugboat', - 'username' => 'tugboat', - 'password' => 'tugboat', - 'prefix' => '', - 'host' => '{{ database_type }}', - 'port' => '3306', - 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', - 'driver' => 'mysql', - ]; -{% if memory_cache_type == "redis" %} - - $redis_config = 'modules/contrib/redis/example.services.yml'; - if (file_exists($redis_config) && is_readable($redis_config)) { - $settings['container_yamls'][] = $redis_config; - $settings['redis.connection']['interface'] = 'PhpRedis'; - $settings['redis.connection']['host'] = 'redis'; - $settings['cache']['default'] = 'cache.backend.redis'; - } - else { - error_log("This project is configured to use Redis for caching. Please download and install the Drupal Redis module. See https://architecture.lullabot.com/adr/20220906-identical-cache-backends/."); - } -{% endif %} -{% if memory_cache_type == "memcached" %} - - if (file_exists('modules/contrib/memcache/memcache.info.yml')) { - $settings['memcache']['servers'] = ['memcached:11211' => 'default']; - $settings['cache']['default'] = 'cache.backend.memcache'; - } - else { - error_log("This project is configured to use Memcached for caching. Please download and install the Drupal Memcache module. See https://architecture.lullabot.com/adr/20220906-identical-cache-backends/."); - } -{% endif %} -} +$databases['default']['default'] = [ + 'database' => 'tugboat', + 'username' => 'tugboat', + 'password' => 'tugboat', + 'prefix' => '', + 'host' => '{{ database_type }}', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', +]; From 74e18486df3ea3b2adffb9a65036cb56a0151c66 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 21 Jul 2023 18:10:14 +0100 Subject: [PATCH 153/172] Create files directory --- .tugboat/steps/1-init.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index 9979d00d4..d4769368a 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -15,6 +15,11 @@ apt-get install -y mariadb-client # repository, change that here. This example links /web to the docroot ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" +# Create the Drupal private and public files directories if they aren't +# already present. +mkdir -p "${DOCROOT}/sites/default/files" +chmod 777 "${DOCROOT}/sites/default/files" + # Install the PHP opcache as it's not included by default and needed for # decent performance. docker-php-ext-install opcache From 5cd5e0d6ddbaf18265317d98cc37ba605ec3e116 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 21 Jul 2023 18:12:15 +0100 Subject: [PATCH 154/172] Create files directory --- scaffold/tugboat/steps/1-init.sh.twig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index b4c514da1..9856470a9 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -22,6 +22,11 @@ apt-get install -y {{ database_type }}-client # repository, change that here. This example links /web to the docroot ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" +# Create the Drupal private and public files directories if they aren't +# already present. +mkdir -p "${DOCROOT}/sites/default/files" +chmod 777 "${DOCROOT}/sites/default/files" + # Install the PHP opcache as it's not included by default and needed for # decent performance. docker-php-ext-install opcache From d148f923543364f42efe3a354d0d49268617ccc5 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 21 Jul 2023 20:47:58 +0100 Subject: [PATCH 155/172] Fix nodejs version --- scaffold/tugboat/steps/1-init.sh.twig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index 9856470a9..9f0775dea 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -54,8 +54,10 @@ echo 'extension=memcache.so' > /usr/local/etc/php/conf.d/memcache.ini {% endif %} # Install node -curl -fsSL https://deb.nodesource.com/setup_{{ nodejs_version }}.x | bash - +curl -fsSL https://deb.nodesource.com/setup_current.x | bash - apt-get install -y nodejs +npm install -g n +n {{ nodejs_version }} # This only works for node > 16, but that version is unsupported now anyway. corepack enable {% if 'apache' in webserver_image %} From 9567de24b0a50f8cb1827ba55b2a21797d349c59 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 21 Jul 2023 20:56:04 +0100 Subject: [PATCH 156/172] rm dir --- src/ScaffoldInstallerPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 599a0ebe5..b4c499d1f 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -279,7 +279,7 @@ private function installCICommands(): void // Tugboat if (isset($this->extra['drainpipe']['tugboat'])) { - $fs->removeDirectory('./.tugboat'); + $fs->removeDirectory('.tugboat'); $binaryInstallerPlugin = new BinaryInstallerPlugin(); $tugboatConfig = [ 'nodejs_version' => '18', From e023607486cb0d0aca753f5fc0b12e7729148d3c Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 21 Jul 2023 22:11:54 +0100 Subject: [PATCH 157/172] Add Terminus support --- scaffold/tugboat/steps/1-init.sh.twig | 9 +++++++++ src/ScaffoldInstallerPlugin.php | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index 9f0775dea..184750e15 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -64,6 +64,15 @@ corepack enable # Apache a2enmod headers rewrite {% endif %} +{% if pantheon %} + +# Pantheon +mkdir -p ~/terminus && cd ~/terminus +curl -L https://github.com/pantheon-systems/terminus/releases/download/3.2.1/terminus.phar --output terminus +chmod +x terminus +./terminus self:update +sudo ln -s ~/terminus/terminus /usr/local/bin/terminus +{% endif %} {% if init.php %} # Bring in tasks. diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index b4c499d1f..7d039ece1 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -279,7 +279,7 @@ private function installCICommands(): void // Tugboat if (isset($this->extra['drainpipe']['tugboat'])) { - $fs->removeDirectory('.tugboat'); + $fs->removeDirectory('./.tugboat'); $binaryInstallerPlugin = new BinaryInstallerPlugin(); $tugboatConfig = [ 'nodejs_version' => '18', @@ -291,6 +291,7 @@ private function installCICommands(): void 'sync_command' => 'sync', 'init' => [], 'task_version' => $binaryInstallerPlugin->getBinaryVersion('task'), + 'pantheon' => isset($this->extra['drainpipe']['tugboat']['pantheon']), ]; if (file_exists('./.ddev/config.yaml')) { From ac7bde9083578cbc3189b141b4b59eee47eab909 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 21 Jul 2023 23:29:16 +0100 Subject: [PATCH 158/172] cd to tugboat root --- scaffold/tugboat/steps/1-init.sh.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index 184750e15..a85dbe9b8 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -72,6 +72,7 @@ curl -L https://github.com/pantheon-systems/terminus/releases/download/3.2.1/ter chmod +x terminus ./terminus self:update sudo ln -s ~/terminus/terminus /usr/local/bin/terminus +cd ${TUGBOAT_ROOT} {% endif %} {% if init.php %} From 600d9e37b4002a533ef69349f3e8fbe6ce445b61 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 11:30:42 +0100 Subject: [PATCH 159/172] Fix sync command --- README.md | 30 ++++++++++++++++++++++++++++++ src/ScaffoldInstallerPlugin.php | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 767759497..bf1af7483 100644 --- a/README.md +++ b/README.md @@ -462,6 +462,19 @@ The following will be autodetected based on your `.ddev/config.yml`: - nodejs version - Redis (Obtained with `ddev get ddev/ddev-redis`) +Additionally, Pantheon Terminus can be added: +```json +{ + "extra": { + "drainpipe": { + "tugboat": { + "terminus": true + } + } + } +} +``` + It is assumed the following tasks exist: - `build` - `sync` @@ -471,6 +484,23 @@ The `build` and `sync` tasks can be overridden with a `build:tugboat` and regenerate the Tugboat scripts if you are adding this task to your `Taskfile.yml` for the first time). +``` + sync: + desc: "Fetches a database from Pantheon and imports it" + cmds: + - task: pantheon:fetch-db + - task: drupal:import-db + sync:tugboat: + desc: "Fetches a database from Pantheon and imports it in Tugboat" + cmds: + - task: pantheon:fetch-db + vars: + DB_DIR: /var/lib/tugboat/files/db + - task: drupal:import-db + vars: + DB_DIR: /var/lib/tugboat/files/db +``` + >>> ๐Ÿ’ก `composer install` should be re-run if any changes are made to the DDEV diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 7d039ece1..78ec8b32f 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -322,7 +322,7 @@ private function installCICommands(): void $tugboatConfig['build_command'] = 'build:tugboat'; } if (isset($taskfile['tasks']['sync:tugboat'])) { - $tugboatConfig['build_command'] = 'sync:tugboat'; + $tugboatConfig['sync_command'] = 'sync:tugboat'; } if (isset($taskfile['tasks']['tugboat:php:init'])) { $tugboatConfig['init']['php'] = true; From e8df32a860b9e787b2fdd441c2800eda006ef3d9 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 11:40:12 +0100 Subject: [PATCH 160/172] Documentation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bf1af7483..e4b32ac01 100644 --- a/README.md +++ b/README.md @@ -457,6 +457,7 @@ Add the following to `composer.json` to add Tugboat configuration: ``` The following will be autodetected based on your `.ddev/config.yml`: +- Web server (nginx or apache) - PHP version - Database type and version - nodejs version From 39b8825772c1a3c9b6e660d6e2f01842be74471d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 12:40:48 +0100 Subject: [PATCH 161/172] Add more default Tugboat settings --- scaffold/tugboat/settings.tugboat.php.twig | 35 +++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/scaffold/tugboat/settings.tugboat.php.twig b/scaffold/tugboat/settings.tugboat.php.twig index a8eade1f6..452a174ae 100644 --- a/scaffold/tugboat/settings.tugboat.php.twig +++ b/scaffold/tugboat/settings.tugboat.php.twig @@ -3,15 +3,30 @@ /** * @file * Tugboat Drupal settings. + * + * This file cannot be edited, but you can add/override Tugboat settings after + * it has been included in the main settings.php file. */ -$databases['default']['default'] = [ - 'database' => 'tugboat', - 'username' => 'tugboat', - 'password' => 'tugboat', - 'prefix' => '', - 'host' => '{{ database_type }}', - 'port' => '3306', - 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', - 'driver' => 'mysql', -]; +if (file_exists(__DIR__ . '/settings.tugboat.php') && getenv('TUGBOAT_PREVIEW_ID')) { + $databases['default']['default'] = [ + 'database' => 'tugboat', + 'username' => 'tugboat', + 'password' => 'tugboat', + 'prefix' => '', + 'host' => '{{ database_type }}', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', + ]; + + $settings['hash_salt'] = hash('sha256', getenv('TUGBOAT_REPO_ID')); + + $settings['trusted_host_patterns'] = [ + '\.tugboatqa\.com$', + ]; + + $config['environment_indicator.indicator']['name'] = 'โ˜‘๏ธ Tugboat'; + $config['environment_indicator.indicator']['bg_color'] = '#07688c'; + $config['environment_indicator.indicator']['fg_color'] = '#ffffff'; +} From 2e3fafda3f44d5f1c882a9f6d08672b48a70736d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 12:42:43 +0100 Subject: [PATCH 162/172] Fix indentation error --- scaffold/tugboat/settings.tugboat.php.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/tugboat/settings.tugboat.php.twig b/scaffold/tugboat/settings.tugboat.php.twig index 452a174ae..ca5c4e04c 100644 --- a/scaffold/tugboat/settings.tugboat.php.twig +++ b/scaffold/tugboat/settings.tugboat.php.twig @@ -23,7 +23,7 @@ if (file_exists(__DIR__ . '/settings.tugboat.php') && getenv('TUGBOAT_PREVIEW_ID $settings['hash_salt'] = hash('sha256', getenv('TUGBOAT_REPO_ID')); $settings['trusted_host_patterns'] = [ - '\.tugboatqa\.com$', + '\.tugboatqa\.com$', ]; $config['environment_indicator.indicator']['name'] = 'โ˜‘๏ธ Tugboat'; From 9e8d0303b8a2c1a4b98374676a57cdfa06a7638b Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 13:43:29 +0100 Subject: [PATCH 163/172] test fixes --- .github/workflows/TestTugboat.yml | 8 +------- .tugboat/config.yml | 3 --- .tugboat/steps/2-update.sh | 1 + scaffold/Taskfile.yml | 3 +-- scaffold/tugboat/steps/1-init.sh.twig | 8 ++------ 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/.github/workflows/TestTugboat.yml b/.github/workflows/TestTugboat.yml index 4b9f88f4d..ed504b74c 100644 --- a/.github/workflows/TestTugboat.yml +++ b/.github/workflows/TestTugboat.yml @@ -28,16 +28,10 @@ jobs: git-email: no-reply@example.com ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - name: Create pantheon.yml - run: | - echo "api_version: 1" >> pantheon.yml - echo "php_version: 8.1" >> pantheon.yml - echo "database:" >> pantheon.yml - echo " version: 10.6" >> pantheon.yml - - name: Setup Project run: | ddev config --auto + ddev config --php-version "8.1" ddev config --nodejs-version "18" ddev config --database=mariadb:10.4 ddev start diff --git a/.tugboat/config.yml b/.tugboat/config.yml index 51e20b2a4..add32b415 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -14,6 +14,3 @@ services: mariadb: image: tugboatqa/mariadb:10.4 - commands: - init: - - sh -c "$(curl --location https://raw.githubusercontent.com/go-task/task/v3.24.0/install-task.sh)" -- -d -b /usr/local/bin diff --git a/.tugboat/steps/2-update.sh b/.tugboat/steps/2-update.sh index 3e1523a3b..b3559ba34 100755 --- a/.tugboat/steps/2-update.sh +++ b/.tugboat/steps/2-update.sh @@ -3,6 +3,7 @@ set -eux echo "Updating..." +composer install ./vendor/bin/task sync #drainpipe-start ./vendor/bin/drush config:export --yes diff --git a/scaffold/Taskfile.yml b/scaffold/Taskfile.yml index 58ec8e05c..a37a3929d 100644 --- a/scaffold/Taskfile.yml +++ b/scaffold/Taskfile.yml @@ -38,8 +38,7 @@ tasks: sync: desc: "Sync a database from production and import it" cmds: - # Replace this with a command to fetch your data - base. + # Replace this with a command to fetch your database. - ./vendor/bin/drush site:install -y - echo "๐Ÿงน Sanitising database" - ./vendor/bin/drush sql:sanitize --yes diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index a85dbe9b8..1e654675d 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -67,12 +67,8 @@ a2enmod headers rewrite {% if pantheon %} # Pantheon -mkdir -p ~/terminus && cd ~/terminus -curl -L https://github.com/pantheon-systems/terminus/releases/download/3.2.1/terminus.phar --output terminus -chmod +x terminus -./terminus self:update -sudo ln -s ~/terminus/terminus /usr/local/bin/terminus -cd ${TUGBOAT_ROOT} +curl --fail -sSL https://github.com/pantheon-systems/terminus/releases/download/$(curl -L --fail --silent "https://api.github.com/repos/pantheon-systems/terminus/releases/latest" | perl -nle'print $& while m{"tag_name": "\K.*?(?=")}g')/terminus.phar --output /usr/local/bin/terminus +chmod 777 /usr/local/bin/terminus {% endif %} {% if init.php %} From da504c46d2ca7dfc064a3d98c3528de2ff59f6e8 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 13:54:09 +0100 Subject: [PATCH 164/172] Fix node setup in test --- .tugboat/steps/1-init.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index d4769368a..948a80378 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -39,8 +39,10 @@ docker-php-ext-install gd apt-get install -y imagemagick # Install node -curl -fsSL https://deb.nodesource.com/setup_18.x | bash - +curl -fsSL https://deb.nodesource.com/setup_current.x | bash - apt-get install -y nodejs +npm install -g n +n 18 # This only works for node > 16, but that version is unsupported now anyway. corepack enable #drainpipe-start From 85221903395705f3b85f8a93ce02a33ad672bf6d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 13:56:37 +0100 Subject: [PATCH 165/172] Remove file --- .tugboat/settings.tugboat.php | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .tugboat/settings.tugboat.php diff --git a/.tugboat/settings.tugboat.php b/.tugboat/settings.tugboat.php deleted file mode 100644 index 9cba8624e..000000000 --- a/.tugboat/settings.tugboat.php +++ /dev/null @@ -1,14 +0,0 @@ - 'tugboat', - 'username' => 'tugboat', - 'password' => 'tugboat', - 'prefix' => '', - 'host' => 'mariadb', - 'port' => '3306', - 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', - 'driver' => 'mysql', - ]; -} From ed765ce49b3a0dd821dd8601c583760f4595e14f Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 14:17:39 +0100 Subject: [PATCH 166/172] Use TUGBOAT_ROOT instead of DOCROOT --- .tugboat/steps/1-init.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index 948a80378..3ec364d72 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -17,8 +17,8 @@ ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" # Create the Drupal private and public files directories if they aren't # already present. -mkdir -p "${DOCROOT}/sites/default/files" -chmod 777 "${DOCROOT}/sites/default/files" +mkdir -p "${TUGBOAT_ROOT}/web/sites/default/files" +chmod 777 "${TUGBOAT_ROOT}/web/sites/default/files" # Install the PHP opcache as it's not included by default and needed for # decent performance. From 1411e0b909870dd942b0dde607f2d50eb426d8fe Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 14:21:28 +0100 Subject: [PATCH 167/172] Use TUGBOAT_ROOT instead of DOCROOT --- scaffold/tugboat/steps/1-init.sh.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scaffold/tugboat/steps/1-init.sh.twig b/scaffold/tugboat/steps/1-init.sh.twig index 1e654675d..4eec6d22a 100644 --- a/scaffold/tugboat/steps/1-init.sh.twig +++ b/scaffold/tugboat/steps/1-init.sh.twig @@ -24,8 +24,8 @@ ln -snf "${TUGBOAT_ROOT}/web" "${DOCROOT}" # Create the Drupal private and public files directories if they aren't # already present. -mkdir -p "${DOCROOT}/sites/default/files" -chmod 777 "${DOCROOT}/sites/default/files" +mkdir -p "${TUGBOAT_ROOT}/web/sites/default/files" +chmod 777 "${TUGBOAT_ROOT}/web/sites/default/files" # Install the PHP opcache as it's not included by default and needed for # decent performance. From 6ca6abecdd0159ead1a5f0477ae41f107dfb1e71 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 14:28:01 +0100 Subject: [PATCH 168/172] remove explicit tugboat settings --- .tugboat/steps/1-init.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index 3ec364d72..19e962f30 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -62,8 +62,6 @@ composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies mv drainpipe/.tugboat . cp web/sites/default/default.settings.php web/sites/default/settings.php -cp .tugboat/settings.tugboat.php web/sites/default/settings.tugboat.php -echo "include __DIR__ . '/settings.tugboat.php';" >> web/sites/default/settings.php #drainpipe-end composer install From 3305f636ab16e2c6181b53100ae9e3ecf8d96e7b Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 14:33:57 +0100 Subject: [PATCH 169/172] Include tugboat settings --- .tugboat/steps/1-init.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index 19e962f30..5f1b20c25 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -62,6 +62,7 @@ composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies mv drainpipe/.tugboat . cp web/sites/default/default.settings.php web/sites/default/settings.php +echo "include __DIR__ . '/settings.tugboat.php';" >> web/sites/default/settings.php #drainpipe-end composer install From 35d64144979d969c9dc273a10cbf80f72e02af19 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 14:40:28 +0100 Subject: [PATCH 170/172] Configure composer.json --- .tugboat/steps/1-init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index 5f1b20c25..dbcd58c3d 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -58,11 +58,11 @@ composer config --no-plugins allow-plugins.composer/installers true composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true composer config --no-plugins allow-plugins.lullabot/drainpipe true composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": true}}' +composer config extra.drainpipe --json '{"tugboat": {}}' composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies mv drainpipe/.tugboat . cp web/sites/default/default.settings.php web/sites/default/settings.php -echo "include __DIR__ . '/settings.tugboat.php';" >> web/sites/default/settings.php #drainpipe-end composer install From 743590aeee9288cd68325f0a06a44029da9bf843 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 14:47:06 +0100 Subject: [PATCH 171/172] . --- .tugboat/steps/1-init.sh | 5 +++++ .tugboat/steps/2-update.sh | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index dbcd58c3d..3c07824f2 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -63,6 +63,11 @@ composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies mv drainpipe/.tugboat . cp web/sites/default/default.settings.php web/sites/default/settings.php +mv .tugboat .tugboat-tmp #drainpipe-end composer install +#drainpipe-start +rm -rf .tugboat +mv .tugboat-tmp .tugboat +#drainpipe-end diff --git a/.tugboat/steps/2-update.sh b/.tugboat/steps/2-update.sh index b3559ba34..6ef6567de 100755 --- a/.tugboat/steps/2-update.sh +++ b/.tugboat/steps/2-update.sh @@ -3,8 +3,13 @@ set -eux echo "Updating..." +#drainpipe-start +mv .tugboat .tugboat-tmp +#drainpipe-end composer install ./vendor/bin/task sync #drainpipe-start ./vendor/bin/drush config:export --yes +rm -rf .tugboat +mv .tugboat-tmp .tugboat #drainpipe-end From ba2539ecb158dee79ff6f3ae2ec2cc58e8618515 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 24 Jul 2023 14:55:02 +0100 Subject: [PATCH 172/172] . --- .tugboat/steps/1-init.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.tugboat/steps/1-init.sh b/.tugboat/steps/1-init.sh index 3c07824f2..2424972f7 100755 --- a/.tugboat/steps/1-init.sh +++ b/.tugboat/steps/1-init.sh @@ -61,13 +61,11 @@ composer config repositories.drainpipe --json '{"type": "path", "url": "drainpip composer config extra.drainpipe --json '{"tugboat": {}}' composer config minimum-stability dev composer require lullabot/drainpipe --with-all-dependencies -mv drainpipe/.tugboat . cp web/sites/default/default.settings.php web/sites/default/settings.php -mv .tugboat .tugboat-tmp #drainpipe-end composer install #drainpipe-start rm -rf .tugboat -mv .tugboat-tmp .tugboat +mv drainpipe/.tugboat .tugboat #drainpipe-end