Skip to content

Commit

Permalink
[Search engine] #1204831 Switch to OpenSearch 2
Browse files Browse the repository at this point in the history
- Use openseach container
- Use opensearch php client
- Disable native api-platform elasticsearch bridge (not compatible with es8 or os)
  • Loading branch information
PierreGauthier authored and botisSmile committed Jan 17, 2024
1 parent 7da3fc0 commit a41cb1c
Show file tree
Hide file tree
Showing 18 changed files with 13,173 additions and 145 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/deploy-1.2.x.yml.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<<<<<<< Updated upstream
name: Deploy 1.2.x
=======
name: Deploy 1.1.x
>>>>>>> Stashed changes

on:
schedule:
- cron: '30 4 * * 1-5'
workflow_dispatch:
inputs:
skip_tests:
description: 'Skip tests before delivery ?'
type: boolean
default: false
required: false

jobs:
tests:
name: Tests
if: ${{ inputs.skip_tests == false }}
uses: ./.github/workflows/tests.yml
with:
<<<<<<< Updated upstream
version: 1.2.x
last_published_version: 1.2.0
=======
version: 1.1.x
last_published_version: 1.1.0
>>>>>>> Stashed changes
secrets:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
PACKAGIST_URL: ${{ secrets.PACKAGIST_URL }}

<<<<<<< Updated upstream
deploy-1_2_X:
needs: tests
name: Deploy 1.2.x
=======
deploy-1_1_X:
needs: tests
name: Deploy 1.1.x
>>>>>>> Stashed changes
if: |
always() &&
(needs.tests.result == 'success' || needs.tests.result == 'skipped')
uses: ./.github/workflows/deploy-int.yml
with:
<<<<<<< Updated upstream
version: 1.2.x
last_published_version: 1.2.0
=======
version: 1.1.x
last_published_version: 1.1.0
>>>>>>> Stashed changes
secrets:
AWS_DEPLOY_KEY: ${{ secrets.AWS_DEPLOY_KEY }}
AWS_HOSTNAME: ${{ secrets.AWS_HOSTNAME_STABLE }}
AWS_USER: ${{ secrets.AWS_USER }}
APP_SECRET: ${{ secrets.APP_SECRET }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
PACKAGIST_URL: ${{ secrets.PACKAGIST_URL }}
23 changes: 23 additions & 0 deletions .github/workflows/test-search-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test search engine compatibility

on:
workflow_dispatch:
inputs:
search_engine:
required: false
default: opensearch
type: choice
options:
- opensearch
- elasticsearch7
- elasticsearch8

jobs:
tests:
name: Tests
uses: ./.github/workflows/tests.yml
with:
version: ${{ github.ref_name }}
last_published_version: ${{ github.ref_name }}
search_engine: ${{ inputs.search_engine }}
secrets: inherit
39 changes: 23 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@ on:
version:
description: "Version of Gally's packages (ex: master or 1.0.x)"
type: string
default: 'master'
default: "master"
required: false
last_published_version:
description: "Last release of the current version"
required: false
default: "dev-master"
type: string
use_default_github_ref:
description: 'Use default github ref to checkout Gally ?'
description: "Use default github ref to checkout Gally ?"
type: boolean
default: false
required: false
search_engine:
description: "What search engine do you want to run the tests against ?"
required: false
default: "opensearch"
type: string

secrets:
COMPOSER_AUTH:
required: true
Expand All @@ -34,6 +40,7 @@ jobs:
ref: ${{ inputs.use_default_github_ref == false && inputs.version || '' }}
front_branch: ${{ inputs.version == 'master' && 'main' || inputs.version }}
composer_version: ${{ inputs.version == 'master' && 'dev-master' || (contains(inputs.version, 'x') && format('{0}-dev', inputs.version) || inputs.version) }}
docker_compose_cmd: docker compose -f docker-compose.yml -f docker-compose.ci.yml ${{ inputs.search_engine == 'opensearch' && '' || format('-f docker-compose.{0}.yml', inputs.search_engine) }}

steps:
- name: Checkout
Expand Down Expand Up @@ -66,39 +73,39 @@ jobs:
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
- name: Pull images
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml pull --ignore-pull-failures || true
run: ${{env.docker_compose_cmd}} pull --ignore-pull-failures || true
- name: Start services
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up --build -d --wait
run: ${{env.docker_compose_cmd}} up --build -d --wait
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
- name: Check HTTP reachability
id: http_reachability
run: curl -v -o /dev/null http://localhost
- name: HTTP Failure
if: ${{ failure() && steps.tests.http_reachability == 'failure' }}
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml logs
run: ${{env.docker_compose_cmd}} logs
- name: Check HTTPS reachability
id: https_reachability
run: curl -vk -o /dev/null https://localhost
- name: HTTPS Failure
if: ${{ failure() && steps.tests.https_reachability == 'failure' }}
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml logs
run: ${{env.docker_compose_cmd}} logs
- name: Create test database
run: |
docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -e XDEBUG_MODE=off -T php bin/console -e test doctrine:database:create
docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -e XDEBUG_MODE=off -T php bin/console -e test doctrine:migrations:migrate --no-interaction
${{env.docker_compose_cmd}} exec -e XDEBUG_MODE=off -T php bin/console -e test doctrine:database:create
${{env.docker_compose_cmd}} exec -e XDEBUG_MODE=off -T php bin/console -e test doctrine:migrations:migrate --no-interaction
- name: Doctrine Schema Validator
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -e XDEBUG_MODE=off -T php bin/console doctrine:schema:validate --skip-sync
run: ${{env.docker_compose_cmd}} exec -e XDEBUG_MODE=off -T php bin/console doctrine:schema:validate --skip-sync
- name: Fixtures load
run: |
docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -e XDEBUG_MODE=off -T php bin/console gally:index:clear --no-interaction
docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -e XDEBUG_MODE=off -T php bin/console hautelook:fixtures:load --no-interaction -vv
docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -e XDEBUG_MODE=off -T php bin/console doctrine:fixtures:load --append --no-interaction
${{env.docker_compose_cmd}} exec -e XDEBUG_MODE=off -T php bin/console gally:index:clear --no-interaction
${{env.docker_compose_cmd}} exec -e XDEBUG_MODE=off -T php bin/console hautelook:fixtures:load --no-interaction -vv
${{env.docker_compose_cmd}} exec -e XDEBUG_MODE=off -T php bin/console doctrine:fixtures:load --append --no-interaction
- name: Coverage
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -e XDEBUG_MODE=coverage -T php bin/phpunit --coverage-clover=coverage/coverage.xml vendor/gally
run: ${{env.docker_compose_cmd}} exec -e XDEBUG_MODE=coverage -T php bin/phpunit --coverage-clover=coverage/coverage.xml vendor/gally

- name: Cleanup coverage file
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -T php sed -i 's:<file name="/srv/:<file name="/:' coverage/coverage.xml
run: ${{env.docker_compose_cmd}} exec -T php sed -i 's:<file name="/srv/:<file name="/:' coverage/coverage.xml

- if: ${{ github.event_name == 'pull_request' }}
name: Download artifact
Expand Down Expand Up @@ -139,7 +146,7 @@ jobs:
path: api/coverage/coverage.xml

- name: Jest
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -T pwa yarn test:ci
run: ${{env.docker_compose_cmd}} exec -T pwa yarn test:ci

- name: Frontend Coverage Report
uses: 5monkeys/cobertura-action@v12
Expand All @@ -153,4 +160,4 @@ jobs:

- name: "[End] Job failed, gathering logs"
if: ${{ failure() }}
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml logs
run: ${{env.docker_compose_cmd}} logs
4 changes: 2 additions & 2 deletions api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###

# Manual Elasticsearch Configuration, we might remove redundancy in the future
ELASTICSEARCH_HOST=elasticsearch
ELASTICSEARCH_HOST=search
ELASTICSEARCH_PORT=9200
ELASTICSEARCH_SCHEME=http
ELASTICSEARCH_URL=http://elasticsearch:9200/
ELASTICSEARCH_URL=http://search:9200/

# Varnish URL for purging HTTP cache
VARNISH_URL=varnish
Expand Down
20 changes: 18 additions & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG PHP_VERSION=8.1
ARG CADDY_VERSION=2.6.4
ARG ELASTIC_VERSION=7.16.3
ARG OPENSEARCH2_VERSION=2.11.0
ARG ELASTIC7_VERSION=7.16.3
ARG ELASTIC8_VERSION=8.10.4
# ARG XDEBUG_VERSION=3.1.2

# "php" stage
Expand Down Expand Up @@ -169,7 +171,21 @@ COPY --from=gally_caddy_builder /usr/bin/caddy /usr/bin/caddy
COPY --from=gally_php /srv/api/public public/
COPY docker/caddy/Caddyfile /etc/caddy/Caddyfile

FROM docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION} AS gally_elasticsearch
FROM opensearchproject/opensearch:${OPENSEARCH2_VERSION} AS gally_opensearch2

WORKDIR /usr/share/opensearch

RUN bin/opensearch-plugin install analysis-phonetic
RUN bin/opensearch-plugin install analysis-icu

FROM docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC7_VERSION} AS gally_elasticsearch7

WORKDIR /usr/share/elasticsearch

RUN bin/elasticsearch-plugin install analysis-phonetic
RUN bin/elasticsearch-plugin install analysis-icu

FROM docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC8_VERSION} AS gally_elasticsearch8

WORKDIR /usr/share/elasticsearch

Expand Down
8 changes: 8 additions & 0 deletions api/auth.json.bkp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"http-basic": {
"packagist.smile.fr": {
"username": "elasticsuitepremium",
"password": "S?7aQ$wsRWw:2;2g"
}
}
}
2 changes: 1 addition & 1 deletion api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.7",
"elasticsearch/elasticsearch": "^7.0",
"gally/gally-standard": "dev-master",
"guzzlehttp/guzzle": "^7.0",
"hautelook/alice-bundle": "^2.10",
"lexik/jwt-authentication-bundle": "^2.14",
"nelmio/cors-bundle": "^2.1",
"opensearch-project/opensearch-php": "^2.1",
"phpdocumentor/reflection-docblock": "^5.2",
"stof/doctrine-extensions-bundle": "^1.7",
"symfony/asset": "6.0.*",
Expand Down
Loading

0 comments on commit a41cb1c

Please sign in to comment.