Skip to content

Commit

Permalink
Add elasticsearch support to tugboat. (#413)
Browse files Browse the repository at this point in the history
* Add elasticsearch support to tugboat.

---------

Co-authored-by: Andrew Berry <[email protected]>
Co-authored-by: Sally Young <[email protected]>
  • Loading branch information
3 people committed Feb 22, 2024
1 parent 874fe6f commit 4ca15cc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/TestTugboat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ jobs:
git-email: [email protected]
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

# Lock in versions so tests know what to expect.
# Redis tag v1.2.0 == 6-bullseye
# Elasticsearch tag v0.3.2 == 7.17.14
- 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 get ddev/ddev-redis --version v1.2.0
ddev get ddev/ddev-elasticsearch --version v0.3.2
ddev start
ddev composer config extra.drupal-scaffold.gitignore true
ddev composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"]
Expand All @@ -49,13 +54,13 @@ jobs:
# preview - they should be the same.
- name: Test Generated Files
run: |
cmp -b drainpipe/.tugboat/config.yml .tugboat/config.yml
diff -up drainpipe/.tugboat/config.yml .tugboat/config.yml
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
diff -up drainpipe/.tugboat/steps/1-init.sh .tugboat/steps/1-init.sh
diff -up drainpipe/.tugboat/steps/2-update.sh .tugboat/steps/2-update.sh
diff -up drainpipe/.tugboat/steps/3-build.sh .tugboat/steps/3-build.sh
- name: Add a build:tugboat step
run: |
Expand Down
7 changes: 7 additions & 0 deletions .tugboat/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:

depends:
- mariadb
- redis

commands:
init: ./.tugboat/steps/1-init.sh
Expand All @@ -17,3 +18,9 @@ services:

mariadb:
image: tugboatqa/mariadb:10.4

redis:
image: tugboatqa/redis:6-bullseye

elasticsearch:
image: tugboatqa/elasticsearch:7.17.14
5 changes: 5 additions & 0 deletions .tugboat/steps/1-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ docker-php-ext-install gd
# of GD. Lullabot will likely be publishing an ADR recommending it too.
apt-get install -y imagemagick

# Install the PHP redis extension.

yes '' | pecl install -f redis
echo 'extension=redis.so' > /usr/local/etc/php/conf.d/redis.ini

# Install node
apt-get install -y ca-certificates gnupg
mkdir -p /etc/apt/keyrings
Expand Down
5 changes: 5 additions & 0 deletions scaffold/tugboat/config.yml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ services:
- task tugboat:redis:init
{% endif %}
{% endif %}
{% if search_type %}

{{ search_type }}:
image: tugboatqa/{{ search_type }}:{{ search_version }}
{% endif %}
2 changes: 2 additions & 0 deletions scaffold/tugboat/steps/1-init.sh.twig
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ docker-php-ext-install gd
# 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.

apt-get install -y zlib1g-dev
yes '' | pecl install -f memcache
echo 'extension=memcache.so' > /usr/local/etc/php/conf.d/memcache.ini
{% elseif memory_cache_type == "redis" %}

# Install the PHP redis extension.

yes '' | pecl install -f redis
Expand Down
7 changes: 7 additions & 0 deletions src/ScaffoldInstallerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@ private function installCICommands(): void
$tugboatConfig['memory_cache_version'] = array_pop($redisImage);
}

if (file_exists('./.ddev/docker-compose.elasticsearch.yaml')) {
$esConfig = Yaml::parseFile('.ddev/docker-compose.elasticsearch.yaml');
$esImage = explode(':', $esConfig['services']['elasticsearch']['image']);
$tugboatConfig['search_type'] = 'elasticsearch';
$tugboatConfig['search_version'] = array_pop($esImage);
}

if (file_exists('Taskfile.yml')) {
// Get steps out of the Taskfile.
$taskfile = Yaml::parseFile('./Taskfile.yml');
Expand Down

0 comments on commit 4ca15cc

Please sign in to comment.