Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add elasticsearch support to tugboat. #413

Merged
merged 12 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to find a way to test my changes by generating a more robust config file and testing it against a more complete example. The test runner doesn't seem to be able to locate this file, though, so I'm not sure if I'm doing something wrong or if there's a better way to test my work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KeyboardCowboy the way we're currently testing it is by having the Tugboat file generated match the one we're using to create a Tugboat environment - bit of a hack, but unfortunately we can't generate a tugboat configuration on the fly. If you add elastic search to .tugboat/config.yml then that should be fine. Is there anything we can add to verify that elasticsearch has started correctly and is usable by Drupal?

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 Expand Up @@ -114,4 +119,3 @@ jobs:
run: |
cat .tugboat/steps/1-init.sh
grep -q NODE_MAJOR=16 .tugboat/steps/1-init.sh

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 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 %}
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
Loading