From d120d4f6d0246fb6d2f9ee342f3cc4269bc65059 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 06:33:36 +0000 Subject: [PATCH 01/20] dev: initial add of warden setup environment actions Co-authored-by: Vladyslav Podorozhnyi --- warden/setup-environment/action.yml | 275 ++++++++++++++++++++++++++++ 1 file changed, 275 insertions(+) create mode 100644 warden/setup-environment/action.yml diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml new file mode 100644 index 0000000..cdedf44 --- /dev/null +++ b/warden/setup-environment/action.yml @@ -0,0 +1,275 @@ +name: "Setup Mage-OS in Warden" +author: "Vladyslav Podorozhnyi" +description: "A Github Action that pull and set-up Magen-OS in warden env." + +inputs: + warden_version: + required: true + default: "0.14.1" + description: "The version of warden to use." + + php_version: + required: true + default: "8.1" + description: "PHP version used in warden container." + + composer_version: + required: true + default: "2.3.0" + description: "The version of composer to use." + + database: + required: true + default: "mariadb:10.6" + description: "The distribution : version of the database to use." + + search: + required: true + default: "elasticsearch:7.15.1" + description: "The search engine to use." + + varnish: + required: true + default: "varnish:7.1" + description: "Varnish version to use." + + rabbitmq: + required: true + default: "rabbitmq:3.9" + description: "Rabbit MQ version to use." + + redis: + required: true + default: "redis:7.0" + description: "Redis version to use." + + run_composer_install: + required: true + default: "0" + description: "Whether to run composer install or not." + + run_setup_install: + required: true + default: "0" + description: "Whether to run setup:install or not." + + run_setup_upgrade: + required: true + default: "0" + description: "Whether to run setup:upgrade or not." + + run_reindex: + required: true + default: "0" + description: "Whether to run indexer:reindex or not." + + run_production_deploy_mode: + required: true + default: "0" + description: "Whether to run deploy:mode:set production or not." + + run_magento_config_preset: + required: true + default: "0" + description: "Whether to run magento config preset or not." + + run_admin_user_creation: + required: true + default: "0" + description: "Whether to run admin user creation or not." + + base_directory: + required: true + default: "./" + description: "Base directory for the Mage-OS codebase." + +runs: + using: composite + steps: + - name: Checkout Den Repo + uses: actions/checkout@v3 + with: + repository: wardenenv/warden + path: warden + ref: refs/tags/${{ inputs.warden_version }} + + - name: Init / Configure Warden + working-directory: ${{ inputs.base_directory }} + shell: bash + env: + PHP_VERSION: ${{ inputs.php_version }} + COMPOSER_VERSION: ${{ inputs.composer_version }} + DATABASE: ${{ inputs.database }} + SEARCH: ${{ inputs.search }} + VARNISH: ${{ inputs.varnish }} + RABBITMQ: ${{ inputs.rabbitmq }} + REDIS: ${{ inputs.redis }} + run: | + # Splitting database input to distribution and version + DB_DISTRIBUTION=${DATABASE%%:*} + DB_DISTRIBUTION_VERSION=${DATABASE##*:} + echo "DB_DISTRIBUTION: ${DB_DISTRIBUTION}" + + if [[ $SEARCH == elasticsearch* ]]; then + WARDEN_ELASTICSEARCH=1 + WARDEN_OPENSEARCH=0 + ELASTICSEARCH_VERSION=${SEARCH##*:} + OPENSEARCH_VERSION="" + else + WARDEN_ELASTICSEARCH=0 + WARDEN_OPENSEARCH=1 + ELASTICSEARCH_VERSION="" + OPENSEARCH_VERSION=${SEARCH##*:} + fi + echo "ELASTICSEARCH_VERSION: ${ELASTICSEARCH_VERSION}" + echo "OPENSEARCH_VERSION: ${OPENSEARCH_VERSION}" +# bash build_scripts/generate_warden_env.sh "$PHP_VERSION" "$COMPOSER_VERSION" "$DATABASE" "$SEARCH" "$VARNISH" "$RABBITMQ" "$REDIS" > .env +# echo "DEBUG .env\n" && cat .env + + - name: Warden svc up && Warden env up + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} svc up + ${DEN} env up + + - name: Change Directory Permissions + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm sudo chmod -R 777 . + + - name: Wait for environment to be ready + working-directory: ${{ inputs.base_directory }} + shell: bash + env: + SEARCH: ${{ inputs.search }} + run: | + sleep 60 +# export DEN="$(dirname $(pwd))/warden/bin/warden" +# case "${SEARCH}" in +# elasticsearch:*) +# SEARCH_HOST="elasticsearch" +# ;; +# *) +# SEARCH_HOST="opensearch" +# ;; +# esac + +# # TODO +# # curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st) + + + - name: composer install run + working-directory: ${{ inputs.base_directory }} + shell: bash + env: + RUN_INSTALL: ${{ inputs.run_composer_install }} + run: | + if [ $RUN_INSTALL == "1" ]; then + export DEN="$(dirname $(pwd))/warden/bin/warden" + wget https://getcomposer.org/download/${{ inputs.composer_version }}/composer.phar -O composer.phar 1>/dev/null 2>&1 && chmod +x composer.phar + ${DEN} env exec -T php-fpm ls -la | grep composer + ${DEN} env exec -T php-fpm php composer.phar -v + ${DEN} env exec -T php-fpm php composer.phar install --no-interaction --no-progress + else + echo "Skipping composer install" + fi + + - name: Install Magento + working-directory: ${{ inputs.base_directory }} + shell: bash + env: + SEARCH: ${{ inputs.search }} + REDIS: ${{ inputs.redis }} + RABBITMQ: ${{ inputs.rabbitmq }} + VARNISH: ${{ inputs.varnish }} + RUN_SETUP_INSTALL: ${{ inputs.run_setup_install }} + DEN: /home/runner/work/mageos-magento2/mageos-magento2/warden/bin/warden + run: | + if [ $RUN_SETUP_INSTALL == "1" ]; then + bash build_scripts/run_setup_install.sh "$SEARCH" "$REDIS" "$VARNISH" "$RABBITMQ" "$DEN" + else + echo "Skipping setup:install" + fi + + - name: Create Admin User + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + if [ ${{ inputs.run_admin_user_creation }} == "1" ]; then + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm php bin/magento admin:user:create \ + --admin-user=admin \ + --admin-password=abcABC123 \ + --admin-email=user-email-dummy@mage-os-awesome.com \ + --admin-firstname=Admin \ + --admin-lastname=User + else + echo "Skipping admin user creation" + fi + + - name: Set All Magento Configs + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + if [ ${{ inputs.run_magento_config_preset }} == "1" ]; then + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm bin/magento config:set --lock-env web/secure/use_in_adminhtml 1 + ${DEN} env exec -T php-fpm bin/magento config:set --lock-env web/secure/use_in_frontend 1 + ${DEN} env exec -T php-fpm bin/magento config:set --lock-env web/secure/use_in_frontend 1 + ${DEN} env exec -T php-fpm bin/magento config:set cms/wysiwyg/enabled disabled + ${DEN} env exec -T php-fpm bin/magento config:set admin/security/admin_account_sharing 1 + ${DEN} env exec -T php-fpm bin/magento config:set admin/security/use_form_key 0 + ${DEN} env exec -T php-fpm bin/magento config:set web/seo/use_rewrites 1 + else + echo "Skipping magento config preset" + fi + + - name: Run Magento Setup Upgrade + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + if [ ${{ inputs.run_setup_upgrade }} == "1" ]; then + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm bin/magento cache:flush + ${DEN} env exec -T php-fpm bin/magento setup:upgrade + ${DEN} env exec -T php-fpm bin/magento setup:db:status + else + echo "Skipping setup:upgrade" + fi + + - name: Set to production mode + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + if [ ${{ inputs.run_production_deploy_mode }} == "1" ]; then + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm bin/magento deploy:mode:set production + else + echo "Skipping deploy:mode:set production" + fi + + - name: Run Magento Re-indexation + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + if [ ${{ inputs.run_reindex }} == "1" ]; then + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm bin/magento indexer:reindex + else + echo "Skipping indexer:reindex" + fi + + - name: Run PHP BIN/MAGENTO + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + if [ ${{ inputs.run_setup_install }} == "1" ]; then + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm php bin/magento + else + echo "Skipping php bin/magento test command" + fi From 6bcaa9bdea09138128cba9b044b6e1674a722883 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 06:47:22 +0000 Subject: [PATCH 02/20] dev: work on action --- warden/setup-environment/action.yml | 79 +++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index cdedf44..be1054f 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -108,8 +108,8 @@ runs: # Splitting database input to distribution and version DB_DISTRIBUTION=${DATABASE%%:*} DB_DISTRIBUTION_VERSION=${DATABASE##*:} - echo "DB_DISTRIBUTION: ${DB_DISTRIBUTION}" + # Splitting search input and setting corresponding flags and versions if [[ $SEARCH == elasticsearch* ]]; then WARDEN_ELASTICSEARCH=1 WARDEN_OPENSEARCH=0 @@ -121,8 +121,81 @@ runs: ELASTICSEARCH_VERSION="" OPENSEARCH_VERSION=${SEARCH##*:} fi - echo "ELASTICSEARCH_VERSION: ${ELASTICSEARCH_VERSION}" - echo "OPENSEARCH_VERSION: ${OPENSEARCH_VERSION}" + + # Setting version variables based on the usage flags + RABBITMQ_VERSION="" + if [[ $RABBITMQ != null ]]; then + RABBITMQ_VERSION=${RABBITMQ##*:} + RABBITMQ=1 + else + RABBITMQ=0 + fi + + REDIS_VERSION="" + if [[ $REDIS != null ]]; then + REDIS_VERSION=${REDIS##*:} + REDIS=1 + else + REDIS=0 + fi + + VARNISH_VERSION="" + if [[ $VARNISH != null ]]; then + VARNISH_VERSION=${VARNISH##*:} + VARNISH=1 + else + VARNISH=0 + fi + + # Creating .env file by substituting variables directly in the template + cat << EOF > .env + WARDEN_ENV_NAME=mageos + WARDEN_ENV_TYPE=magento2 + WARDEN_WEB_ROOT=/ + + TRAEFIK_DOMAIN=mageos.test + TRAEFIK_SUBDOMAIN=app + + WARDEN_DB=1 + WARDEN_ELASTICSEARCH=${WARDEN_ELASTICSEARCH} + WARDEN_OPENSEARCH=${WARDEN_OPENSEARCH} + WARDEN_ELASTICHQ=0 + WARDEN_VARNISH=${VARNISH} + WARDEN_RABBITMQ=${RABBITMQ} + WARDEN_REDIS=${REDIS} + + ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} + OPENSEARCH_VERSION=${OPENSEARCH_VERSION} + DB_DISTRIBUTION=${DB_DISTRIBUTION} + DB_DISTRIBUTION_VERSION=${DB_DISTRIBUTION_VERSION} + NODE_VERSION=12 + COMPOSER_VERSION=${COMPOSER_VERSION} + PHP_VERSION=${PHP_VERSION} + PHP_XDEBUG_3=1 + RABBITMQ_VERSION=${RABBITMQ_VERSION} + REDIS_VERSION=${REDIS_VERSION} + VARNISH_VERSION=${VARNISH_VERSION} + + WARDEN_SYNC_IGNORE= + + WARDEN_ALLURE=0 + WARDEN_SELENIUM=0 + WARDEN_SELENIUM_DEBUG=0 + WARDEN_BLACKFIRE=0 + WARDEN_SPLIT_SALES=0 + WARDEN_SPLIT_CHECKOUT=0 + WARDEN_TEST_DB=1 + WARDEN_MAGEPACK=0 + + BLACKFIRE_CLIENT_ID= + BLACKFIRE_CLIENT_TOKEN= + BLACKFIRE_SERVER_ID= + BLACKFIRE_SERVER_TOKEN= + EOF + + echo ".env created" + cat .env + # bash build_scripts/generate_warden_env.sh "$PHP_VERSION" "$COMPOSER_VERSION" "$DATABASE" "$SEARCH" "$VARNISH" "$RABBITMQ" "$REDIS" > .env # echo "DEBUG .env\n" && cat .env From fd91ed3677e275b0ed8707aac40bcd89e369aa8b Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 06:54:06 +0000 Subject: [PATCH 03/20] dev: work on action --- warden/setup-environment/action.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index be1054f..df6e321 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -196,9 +196,6 @@ runs: echo ".env created" cat .env -# bash build_scripts/generate_warden_env.sh "$PHP_VERSION" "$COMPOSER_VERSION" "$DATABASE" "$SEARCH" "$VARNISH" "$RABBITMQ" "$REDIS" > .env -# echo "DEBUG .env\n" && cat .env - - name: Warden svc up && Warden env up working-directory: ${{ inputs.base_directory }} shell: bash @@ -220,7 +217,24 @@ runs: env: SEARCH: ${{ inputs.search }} run: | - sleep 60 + echo "===================================================" + docker ps -a + sleep 10 + echo "===================================================" + docker ps -a + sleep 10 + echo "===================================================" + docker ps -a + sleep 10 + echo "===================================================" + docker ps -a + sleep 10 + echo "===================================================" + docker ps -a + sleep 10 + echo "===================================================" + docker ps -a + sleep 10 # export DEN="$(dirname $(pwd))/warden/bin/warden" # case "${SEARCH}" in # elasticsearch:*) From 62a4308154be9bf6068cd83220ece025558ff034 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 07:01:51 +0000 Subject: [PATCH 04/20] dev: work on action --- warden/setup-environment/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index df6e321..38429ca 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -235,6 +235,7 @@ runs: echo "===================================================" docker ps -a sleep 10 + curl --write-out %{http_code} --silent --output /dev/null http://mageos-elasticsearch-1:9200/_cat/health?h=st) # export DEN="$(dirname $(pwd))/warden/bin/warden" # case "${SEARCH}" in # elasticsearch:*) @@ -246,7 +247,7 @@ runs: # esac # # TODO -# # curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st) +# - name: composer install run From 952c43771c697ea0ebababb006a8522d1a02e38f Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 07:06:24 +0000 Subject: [PATCH 05/20] dev: work on action --- warden/setup-environment/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index 38429ca..0d45e0a 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -235,7 +235,7 @@ runs: echo "===================================================" docker ps -a sleep 10 - curl --write-out %{http_code} --silent --output /dev/null http://mageos-elasticsearch-1:9200/_cat/health?h=st) + curl --write-out %{http_code} --silent --output /dev/null http://mageos-elasticsearch-1:9200/_cat/health?h=st # export DEN="$(dirname $(pwd))/warden/bin/warden" # case "${SEARCH}" in # elasticsearch:*) From 800e2a1288c8aa4086d74f68728c9590fc94923d Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 07:12:19 +0000 Subject: [PATCH 06/20] dev: work on action --- warden/setup-environment/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index 0d45e0a..4c85dc7 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -235,7 +235,12 @@ runs: echo "===================================================" docker ps -a sleep 10 + + echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + curl http://mageos-elasticsearch-1:9200/_cat/health?h=st || true + echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" curl --write-out %{http_code} --silent --output /dev/null http://mageos-elasticsearch-1:9200/_cat/health?h=st + echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" # export DEN="$(dirname $(pwd))/warden/bin/warden" # case "${SEARCH}" in # elasticsearch:*) From a91d08567a8e64da67c61de465f3b0308a7f19ea Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 07:37:45 +0000 Subject: [PATCH 07/20] dev: work on action --- warden/setup-environment/action.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index 4c85dc7..5d9d64c 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -237,9 +237,12 @@ runs: sleep 10 echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - curl http://mageos-elasticsearch-1:9200/_cat/health?h=st || true + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm bash -c "curl http://elasticsearch:9200/_cat/health?h=st" + echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - curl --write-out %{http_code} --silent --output /dev/null http://mageos-elasticsearch-1:9200/_cat/health?h=st + + # curl --write-out %{http_code} --silent --output /dev/null http://mageos-elasticsearch-1:9200/_cat/health?h=st echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" # export DEN="$(dirname $(pwd))/warden/bin/warden" # case "${SEARCH}" in From 45a92e5b81f508c88b422d9c6fbd1e11cb2246b2 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 07:49:59 +0000 Subject: [PATCH 08/20] dev: work on action --- warden/setup-environment/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index 5d9d64c..a7f8e34 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -238,7 +238,7 @@ runs: echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm bash -c "curl http://elasticsearch:9200/_cat/health?h=st" + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" From e58a777bddb500fa77fd8722df810fb5b76c0bc5 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 07:56:55 +0000 Subject: [PATCH 09/20] dev: work on action --- warden/setup-environment/action.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index a7f8e34..89882e6 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -217,27 +217,32 @@ runs: env: SEARCH: ${{ inputs.search }} run: | + export DEN="$(dirname $(pwd))/warden/bin/warden" echo "===================================================" docker ps -a + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" sleep 10 echo "===================================================" docker ps -a + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" sleep 10 echo "===================================================" docker ps -a + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" sleep 10 echo "===================================================" docker ps -a + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" sleep 10 echo "===================================================" docker ps -a + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" sleep 10 echo "===================================================" docker ps -a - sleep 10 + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - export DEN="$(dirname $(pwd))/warden/bin/warden" ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" From 8027ccfb40e9adcfaa4ebe0f2cd5320fa4a993b1 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 08:00:19 +0000 Subject: [PATCH 10/20] dev: work on action --- warden/setup-environment/action.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index 89882e6..24f7658 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -220,30 +220,30 @@ runs: export DEN="$(dirname $(pwd))/warden/bin/warden" echo "===================================================" docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" sleep 10 echo "===================================================" docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" sleep 10 echo "===================================================" docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" sleep 10 echo "===================================================" docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" sleep 10 echo "===================================================" docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" sleep 10 echo "===================================================" docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st" + ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" From 748532bb101e7f61ddc4db75568de73dd59f280d Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 08:28:49 +0000 Subject: [PATCH 11/20] dev: work on action --- warden/setup-environment/action.yml | 47 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index 24f7658..a84ef71 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -218,46 +218,43 @@ runs: SEARCH: ${{ inputs.search }} run: | export DEN="$(dirname $(pwd))/warden/bin/warden" + case "${SEARCH}" in + elasticsearch:*) + SEARCH_HOST="elasticsearch" + ;; + *) + SEARCH_HOST="opensearch" + ;; + esac + echo "search host: ${SEARCH_HOST}" echo "===================================================" - docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + echo "search status: ${SEARCH_STATUS}" sleep 10 echo "===================================================" - docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + echo "search status: ${SEARCH_STATUS}" sleep 10 echo "===================================================" - docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + echo "search status: ${SEARCH_STATUS}" sleep 10 echo "===================================================" - docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + echo "search status: ${SEARCH_STATUS}" sleep 10 echo "===================================================" - docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + echo "search status: ${SEARCH_STATUS}" sleep 10 echo "===================================================" - docker ps -a - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" - - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - ${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0" - - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + echo "search status: ${SEARCH_STATUS}" # curl --write-out %{http_code} --silent --output /dev/null http://mageos-elasticsearch-1:9200/_cat/health?h=st echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" # export DEN="$(dirname $(pwd))/warden/bin/warden" -# case "${SEARCH}" in -# elasticsearch:*) -# SEARCH_HOST="elasticsearch" -# ;; -# *) -# SEARCH_HOST="opensearch" -# ;; -# esac + # # TODO # From e3a0b778b7eae5aea467e974ca837af12733e882 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 08:49:44 +0000 Subject: [PATCH 12/20] dev: work on action --- warden/setup-environment/action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index a84ef71..3c33d46 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -228,27 +228,27 @@ runs: esac echo "search host: ${SEARCH_HOST}" echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") echo "search status: ${SEARCH_STATUS}" sleep 10 echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") echo "search status: ${SEARCH_STATUS}" sleep 10 echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") echo "search status: ${SEARCH_STATUS}" sleep 10 echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") echo "search status: ${SEARCH_STATUS}" sleep 10 echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") echo "search status: ${SEARCH_STATUS}" sleep 10 echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st; exit 0") + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") echo "search status: ${SEARCH_STATUS}" # curl --write-out %{http_code} --silent --output /dev/null http://mageos-elasticsearch-1:9200/_cat/health?h=st From 483ee7ce1fd8c74d620c8de6afad4d4005a21fe6 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 09:21:20 +0000 Subject: [PATCH 13/20] dev: work on action --- warden/setup-environment/action.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index 3c33d46..36bc3be 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -226,7 +226,18 @@ runs: SEARCH_HOST="opensearch" ;; esac - echo "search host: ${SEARCH_HOST}" + HEALTHY=1 + for ((i=1; i<=24; i++)); do + SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") + echo "search status: ${SEARCH_STATUS}" + if [ ${SEARCH_STATUS} -eq "200" ]; then + HEALTHY=0 + break + fi + sleep 5 + done + echo "HEALTHY: ${HEALTHY}" + exit ${HEALTHY} echo "===================================================" SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") echo "search status: ${SEARCH_STATUS}" From 822a6e2cb4c19bb874c81de04f099d9045f1b9a7 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 10:13:52 +0000 Subject: [PATCH 14/20] dev: work on action --- warden/integration-tests/action.yml | 190 ++++++++++++++++++++++++++++ warden/setup-environment/action.yml | 34 +---- 2 files changed, 191 insertions(+), 33 deletions(-) create mode 100644 warden/integration-tests/action.yml diff --git a/warden/integration-tests/action.yml b/warden/integration-tests/action.yml new file mode 100644 index 0000000..17cc8fc --- /dev/null +++ b/warden/integration-tests/action.yml @@ -0,0 +1,190 @@ +name: "Integration Tests Mage-OS in Warden" +author: "Vladyslav Podorozhnyi" +description: "A Github Action that run Integration Tests of Mage-OS in warden." + +## TODO: use inputs as list of tests to be executed + +inputs: + search: + required: true + default: "elasticsearch:7.15.1" + description: "The search engine to use." + + rabbitmq: + required: true + default: "rabbitmq:3.9" + description: "Rabbit MQ version to use." + + redis: + required: true + default: "redis:7.0" + description: "Redis version to use." + + run_memory_test: + required: true + default: "0" + description: "Run Memory Test." + + run_magento_integration_tests: + required: true + default: "1" + description: "Run Magento Integration Tests." + + run_magento_integration_tests_real_suite: + required: true + default: "1" + description: "Run Magento Integration Tests Real Suite." + + base_directory: + required: true + default: "./" + description: "Base directory for the Mage-OS codebase." + +runs: + using: composite + steps: + + - name: Prepare config for Integration tests + working-directory: ${{ inputs.base_directory }} + shell: bash + env: + SEARCH: ${{ inputs.search }} + RABBITMQ: ${{ inputs.rabbitmq }} + REDIS: ${{ inputs.redis }} + run: | + CONFIG_FILE=dev/tests/integration/etc/install-config-mysql.php + + SEARCH_ENGINE_TYPE=${SEARCH%%:*} + SEARCH_ENGINE_VERSION=${SEARCH##:*} + + case "$SEARCH" in + elasticsearch:*) + SEARCH_HOST="elasticsearch" + ;;& + elasticsearch:5*) + SEARCH_ENGINE="elasticsearch5" + SEARCH_PARAMS="'search-engine' => '$SEARCH_ENGINE', 'elasticsearch-host' => '$SEARCH_HOST', 'elasticsearch-port' => 9200," + ;; + elasticsearch:6*) + SEARCH_ENGINE="elasticsearch6" + SEARCH_PARAMS="'search-engine' => '$SEARCH_ENGINE', 'elasticsearch-host' => '$SEARCH_HOST', 'elasticsearch-port' => 9200," + ;; + elasticsearch:7* | elasticsearch:8*) + SEARCH_ENGINE="elasticsearch7" + SEARCH_PARAMS="'search-engine' => '$SEARCH_ENGINE', 'elasticsearch-host' => '$SEARCH_HOST', 'elasticsearch-port' => 9200," + ;; + opensearch:*) + SEARCH_ENGINE="opensearch" + SEARCH_HOST="opensearch" + SEARCH_PARAMS="'search-engine' => '$SEARCH_ENGINE', 'opensearch-host' => '$SEARCH_HOST', 'opensearch-port' => 9200, 'opensearch-index-prefix' => 'magento2', 'opensearch-enable-auth' => 0, 'opensearch-timeout' => 15," + ;; + *) + SEARCH_ENGINE="elasticsearch7" + SEARCH_HOST="UKNOWN" + SEARCH_PARAMS="'search-engine' => '$SEARCH_ENGINE', 'elasticsearch-host' => '$SEARCH_HOST', 'elasticsearch-port' => 9200," + ;; + esac + + cat << EOL > ${CONFIG_FILE} + 'tmp-mysql', + 'db-user' => 'root', + 'db-password' => 'magento', + 'db-name' => 'magento_integration_tests', + 'backend-frontname' => 'backend', + $SEARCH_PARAMS + 'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, + 'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD, + 'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL, + 'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME, + 'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME, + EOL + + if [[ -n $RABBITMQ ]]; then + cat << EOL >> ${CONFIG_FILE} + 'amqp-host' => 'rabbitmq', + 'amqp-port' => '5672', + 'amqp-user' => 'guest', + 'amqp-password' => 'guest', + EOL + fi + + if [[ -n $REDIS ]]; then + cat << EOL >> ${CONFIG_FILE} + 'session-save' => 'redis', + 'session-save-redis-host' => 'redis', + 'session-save-redis-port' => 6379, + 'session-save-redis-db' => 2, + 'session-save-redis-max-concurrency' => 20, + 'cache-backend' => 'redis', + 'cache-backend-redis-server' => 'redis', + 'cache-backend-redis-db' => 0, + 'cache-backend-redis-port' => 6379, + 'page-cache' => 'redis', + 'page-cache-redis-server' => 'redis', + 'page-cache-redis-db' => 1, + 'page-cache-redis-port' => 6379, + EOL + fi + + cat << EOL >> ${CONFIG_FILE} + ]; + EOL + + echo "configuration" + cat ${CONFIG_FILE} + + +# bash build_scripts/build_integration_tests_config.sh "$SEARCH" "$RABBITMQ" "$REDIS" > dev/tests/integration/etc/install-config-mysql.php +# echo "Debug integration tests config:" +# cat dev/tests/integration/etc/install-config-mysql.php + + - name: Run Memory Test + if: ${{ inputs.run_memory_test == 1 }} + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm /bin/bash -c "cd ./dev/tests/integration + echo -e '\033[32mRun Memory Tests\033[0m' + php ../../../vendor/bin/phpunit + --configuration phpunit.xml.dist + --coverage-clover=coverage.xml + --log-junit=test-results.xml + --coverage-html=coverage + --testsuite 'Memory Usage Tests' + --filter 'AdminAnalytics' + " + + - name: Run Magento Integration Tests + if: ${{ inputs.run_magento_integration_tests == 1 }} + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm /bin/bash -c "cd ./dev/tests/integration + echo -e '\033[32mRun Magento Integration Tests\033[0m' + php ../../../vendor/bin/phpunit + --configuration phpunit.xml.dist + --coverage-clover=coverage.xml + --log-junit=test-results.xml + --coverage-html=coverage + --testsuite 'Magento Integration Tests' + " + + - name: Run Magento Integration Tests Real Suite + if: ${{ inputs.run_magento_integration_tests_real_suite == 1 }} + working-directory: ${{ inputs.base_directory }} + shell: bash + run: | + export DEN="$(dirname $(pwd))/warden/bin/warden" + ${DEN} env exec -T php-fpm /bin/bash -c "cd ./dev/tests/integration + echo -e '\033[32mRun Magento Integration Tests Real Suite\033[0m' + php ../../../vendor/bin/phpunit + --configuration phpunit.xml.dist + --coverage-clover=coverage.xml + --log-junit=test-results.xml + --coverage-html=coverage + --testsuite 'Magento Integration Tests Real Suite' + " diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index 36bc3be..d7f90d2 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -238,39 +238,7 @@ runs: done echo "HEALTHY: ${HEALTHY}" exit ${HEALTHY} - echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") - echo "search status: ${SEARCH_STATUS}" - sleep 10 - echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") - echo "search status: ${SEARCH_STATUS}" - sleep 10 - echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") - echo "search status: ${SEARCH_STATUS}" - sleep 10 - echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") - echo "search status: ${SEARCH_STATUS}" - sleep 10 - echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") - echo "search status: ${SEARCH_STATUS}" - sleep 10 - echo "===================================================" - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") - echo "search status: ${SEARCH_STATUS}" - - # curl --write-out %{http_code} --silent --output /dev/null http://mageos-elasticsearch-1:9200/_cat/health?h=st - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" -# export DEN="$(dirname $(pwd))/warden/bin/warden" - - -# # TODO -# - - + - name: composer install run working-directory: ${{ inputs.base_directory }} shell: bash From eb79849a072029031181e88f9194cd1838c94bdb Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Oct 2023 10:45:25 +0000 Subject: [PATCH 15/20] dev: work on action --- warden/integration-tests/action.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/warden/integration-tests/action.yml b/warden/integration-tests/action.yml index 17cc8fc..258711e 100644 --- a/warden/integration-tests/action.yml +++ b/warden/integration-tests/action.yml @@ -2,8 +2,6 @@ name: "Integration Tests Mage-OS in Warden" author: "Vladyslav Podorozhnyi" description: "A Github Action that run Integration Tests of Mage-OS in warden." -## TODO: use inputs as list of tests to be executed - inputs: search: required: true @@ -135,11 +133,6 @@ runs: echo "configuration" cat ${CONFIG_FILE} - -# bash build_scripts/build_integration_tests_config.sh "$SEARCH" "$RABBITMQ" "$REDIS" > dev/tests/integration/etc/install-config-mysql.php -# echo "Debug integration tests config:" -# cat dev/tests/integration/etc/install-config-mysql.php - - name: Run Memory Test if: ${{ inputs.run_memory_test == 1 }} working-directory: ${{ inputs.base_directory }} From b65059225cff87895619255e72666f8b91047351 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 24 Oct 2023 14:45:39 +0100 Subject: [PATCH 16/20] refact: requests from PR --- warden/integration-tests/action.yml | 15 ++-- warden/setup-environment/action.yml | 124 +++++++++++++++++++--------- 2 files changed, 92 insertions(+), 47 deletions(-) diff --git a/warden/integration-tests/action.yml b/warden/integration-tests/action.yml index 258711e..147aa13 100644 --- a/warden/integration-tests/action.yml +++ b/warden/integration-tests/action.yml @@ -10,7 +10,7 @@ inputs: rabbitmq: required: true - default: "rabbitmq:3.9" + default: "rabbitmq:3.11" description: "Rabbit MQ version to use." redis: @@ -138,8 +138,8 @@ runs: working-directory: ${{ inputs.base_directory }} shell: bash run: | - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm /bin/bash -c "cd ./dev/tests/integration + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm /bin/bash -c "cd ./dev/tests/integration echo -e '\033[32mRun Memory Tests\033[0m' php ../../../vendor/bin/phpunit --configuration phpunit.xml.dist @@ -147,7 +147,6 @@ runs: --log-junit=test-results.xml --coverage-html=coverage --testsuite 'Memory Usage Tests' - --filter 'AdminAnalytics' " - name: Run Magento Integration Tests @@ -155,8 +154,8 @@ runs: working-directory: ${{ inputs.base_directory }} shell: bash run: | - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm /bin/bash -c "cd ./dev/tests/integration + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm /bin/bash -c "cd ./dev/tests/integration echo -e '\033[32mRun Magento Integration Tests\033[0m' php ../../../vendor/bin/phpunit --configuration phpunit.xml.dist @@ -171,8 +170,8 @@ runs: working-directory: ${{ inputs.base_directory }} shell: bash run: | - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm /bin/bash -c "cd ./dev/tests/integration + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm /bin/bash -c "cd ./dev/tests/integration echo -e '\033[32mRun Magento Integration Tests Real Suite\033[0m' php ../../../vendor/bin/phpunit --configuration phpunit.xml.dist diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index d7f90d2..6d7f9ff 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -10,12 +10,12 @@ inputs: php_version: required: true - default: "8.1" + default: "8.2" description: "PHP version used in warden container." composer_version: required: true - default: "2.3.0" + default: "2.2.22" description: "The version of composer to use." database: @@ -30,12 +30,12 @@ inputs: varnish: required: true - default: "varnish:7.1" + default: "varnish:7.3" description: "Varnish version to use." rabbitmq: required: true - default: "rabbitmq:3.9" + default: "rabbitmq:3.11" description: "Rabbit MQ version to use." redis: @@ -86,8 +86,8 @@ inputs: runs: using: composite steps: - - name: Checkout Den Repo - uses: actions/checkout@v3 + - name: Checkout Warden Repo + uses: actions/checkout@v4 with: repository: wardenenv/warden path: warden @@ -200,16 +200,16 @@ runs: working-directory: ${{ inputs.base_directory }} shell: bash run: | - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} svc up - ${DEN} env up + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} svc up + ${WARDEN} env up - name: Change Directory Permissions working-directory: ${{ inputs.base_directory }} shell: bash run: | - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm sudo chmod -R 777 . + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm sudo chmod -R 777 . - name: Wait for environment to be ready working-directory: ${{ inputs.base_directory }} @@ -217,7 +217,7 @@ runs: env: SEARCH: ${{ inputs.search }} run: | - export DEN="$(dirname $(pwd))/warden/bin/warden" + export WARDEN="$(dirname $(pwd))/warden/bin/warden" case "${SEARCH}" in elasticsearch:*) SEARCH_HOST="elasticsearch" @@ -228,7 +228,7 @@ runs: esac HEALTHY=1 for ((i=1; i<=24; i++)); do - SEARCH_STATUS=$(${DEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") + SEARCH_STATUS=$(${WARDEN} env exec -T php-fpm bash -c "curl --write-out %{http_code} --silent --output /dev/null http://${SEARCH_HOST}:9200/_cat/health?h=st; exit 0") echo "search status: ${SEARCH_STATUS}" if [ ${SEARCH_STATUS} -eq "200" ]; then HEALTHY=0 @@ -246,11 +246,11 @@ runs: RUN_INSTALL: ${{ inputs.run_composer_install }} run: | if [ $RUN_INSTALL == "1" ]; then - export DEN="$(dirname $(pwd))/warden/bin/warden" + export WARDEN="$(dirname $(pwd))/warden/bin/warden" wget https://getcomposer.org/download/${{ inputs.composer_version }}/composer.phar -O composer.phar 1>/dev/null 2>&1 && chmod +x composer.phar - ${DEN} env exec -T php-fpm ls -la | grep composer - ${DEN} env exec -T php-fpm php composer.phar -v - ${DEN} env exec -T php-fpm php composer.phar install --no-interaction --no-progress + ${WARDEN} env exec -T php-fpm ls -la | grep composer + ${WARDEN} env exec -T php-fpm php composer.phar -v + ${WARDEN} env exec -T php-fpm php composer.phar install --no-interaction --no-progress else echo "Skipping composer install" fi @@ -264,10 +264,57 @@ runs: RABBITMQ: ${{ inputs.rabbitmq }} VARNISH: ${{ inputs.varnish }} RUN_SETUP_INSTALL: ${{ inputs.run_setup_install }} - DEN: /home/runner/work/mageos-magento2/mageos-magento2/warden/bin/warden run: | if [ $RUN_SETUP_INSTALL == "1" ]; then - bash build_scripts/run_setup_install.sh "$SEARCH" "$REDIS" "$VARNISH" "$RABBITMQ" "$DEN" + SEARCH_ENGINE_VERSION=${SEARCH##*:} + case "$SEARCH" in + elasticsearch:*) + SEARCH_HOST="elasticsearch" + ;;& + elasticsearch:5*) + SEARCH_TYPE="elasticsearch5" + ;; + elasticsearch:6*) + SEARCH_TYPE="elasticsearch6" + ;; + elasticsearch:7* | elasticsearch:8*) + SEARCH_TYPE="elasticsearch7" + ;; + opensearch:*) + SEARCH_TYPE="opensearch" + SEARCH_HOST="opensearch" + ;; + *) + # Default values + SEARCH_TYPE="elasticsearch7" + SEARCH_HOST="elasticsearch" + ;; + esac + + declare -a PARAMETERS + PARAMETERS+=(--backend-frontname=admin --db-host=db --db-name=magento --db-user=magento --db-password=magento) + + if [[ -n $REDIS ]]; then + PARAMETERS+=(--session-save=redis --session-save-redis-host=redis --session-save-redis-port=6379 --session-save-redis-db=2 --cache-backend=redis --cache-backend-redis-server=redis --cache-backend-redis-db=0 --cache-backend-redis-port=6379 --page-cache=redis --page-cache-redis-server=redis --page-cache-redis-db=1 --page-cache-redis-port=6379) + fi + + if [[ -n $VARNISH ]]; then + PARAMETERS+=(--http-cache-hosts=varnish:80) + fi + + if [[ -n $RABBITMQ ]]; then + PARAMETERS+=(--amqp-host=rabbitmq --amqp-port=5672 --amqp-user=guest --amqp-password=guest) + fi + + if [[ $SEARCH_TYPE == "opensearch" ]]; then + PARAMETERS+=(--opensearch-host=$SEARCH_HOST --opensearch-port=9200 --opensearch-index-prefix=magento2 --opensearch-enable-auth=0 --opensearch-timeout=15) + else + PARAMETERS+=(--search-engine=$SEARCH_TYPE --elasticsearch-host=$SEARCH_HOST --elasticsearch-port=9200 --elasticsearch-enable-auth=0 --elasticsearch-index-prefix=magento2) + fi + + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm bin/magento setup:install "${PARAMETERS[@]}" + else echo "Skipping setup:install" fi @@ -277,8 +324,8 @@ runs: shell: bash run: | if [ ${{ inputs.run_admin_user_creation }} == "1" ]; then - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm php bin/magento admin:user:create \ + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm php bin/magento admin:user:create \ --admin-user=admin \ --admin-password=abcABC123 \ --admin-email=user-email-dummy@mage-os-awesome.com \ @@ -293,14 +340,14 @@ runs: shell: bash run: | if [ ${{ inputs.run_magento_config_preset }} == "1" ]; then - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm bin/magento config:set --lock-env web/secure/use_in_adminhtml 1 - ${DEN} env exec -T php-fpm bin/magento config:set --lock-env web/secure/use_in_frontend 1 - ${DEN} env exec -T php-fpm bin/magento config:set --lock-env web/secure/use_in_frontend 1 - ${DEN} env exec -T php-fpm bin/magento config:set cms/wysiwyg/enabled disabled - ${DEN} env exec -T php-fpm bin/magento config:set admin/security/admin_account_sharing 1 - ${DEN} env exec -T php-fpm bin/magento config:set admin/security/use_form_key 0 - ${DEN} env exec -T php-fpm bin/magento config:set web/seo/use_rewrites 1 + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm bin/magento config:set --lock-env web/secure/use_in_adminhtml 1 + ${WARDEN} env exec -T php-fpm bin/magento config:set --lock-env web/secure/use_in_frontend 1 + ${WARDEN} env exec -T php-fpm bin/magento config:set --lock-env web/secure/use_in_frontend 1 + ${WARDEN} env exec -T php-fpm bin/magento config:set cms/wysiwyg/enabled disabled + ${WARDEN} env exec -T php-fpm bin/magento config:set admin/security/admin_account_sharing 1 + ${WARDEN} env exec -T php-fpm bin/magento config:set admin/security/use_form_key 0 + ${WARDEN} env exec -T php-fpm bin/magento config:set web/seo/use_rewrites 1 else echo "Skipping magento config preset" fi @@ -310,10 +357,9 @@ runs: shell: bash run: | if [ ${{ inputs.run_setup_upgrade }} == "1" ]; then - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm bin/magento cache:flush - ${DEN} env exec -T php-fpm bin/magento setup:upgrade - ${DEN} env exec -T php-fpm bin/magento setup:db:status + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm bin/magento setup:upgrade + ${WARDEN} env exec -T php-fpm bin/magento setup:db:status else echo "Skipping setup:upgrade" fi @@ -323,8 +369,8 @@ runs: shell: bash run: | if [ ${{ inputs.run_production_deploy_mode }} == "1" ]; then - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm bin/magento deploy:mode:set production + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm bin/magento deploy:mode:set production else echo "Skipping deploy:mode:set production" fi @@ -334,8 +380,8 @@ runs: shell: bash run: | if [ ${{ inputs.run_reindex }} == "1" ]; then - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm bin/magento indexer:reindex + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm bin/magento indexer:reindex else echo "Skipping indexer:reindex" fi @@ -345,8 +391,8 @@ runs: shell: bash run: | if [ ${{ inputs.run_setup_install }} == "1" ]; then - export DEN="$(dirname $(pwd))/warden/bin/warden" - ${DEN} env exec -T php-fpm php bin/magento + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm php bin/magento else echo "Skipping php bin/magento test command" fi From c78cab7241bc52541b0665951142d4b01efb9087 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 30 Oct 2023 16:31:50 +0000 Subject: [PATCH 17/20] change: defaulting to opensearch --- warden/integration-tests/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/warden/integration-tests/action.yml b/warden/integration-tests/action.yml index 147aa13..af55479 100644 --- a/warden/integration-tests/action.yml +++ b/warden/integration-tests/action.yml @@ -5,7 +5,7 @@ description: "A Github Action that run Integration Tests of Mage-OS in warden." inputs: search: required: true - default: "elasticsearch:7.15.1" + default: "opensearch:2.5" description: "The search engine to use." rabbitmq: From 93ff9135540ef9927861eb342967f8b7c67b5e33 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 30 Oct 2023 16:38:57 +0000 Subject: [PATCH 18/20] Apply suggestions from code review Co-authored-by: Simon Sprankel --- warden/integration-tests/action.yml | 4 ++-- warden/setup-environment/action.yml | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/warden/integration-tests/action.yml b/warden/integration-tests/action.yml index af55479..5673d57 100644 --- a/warden/integration-tests/action.yml +++ b/warden/integration-tests/action.yml @@ -1,6 +1,6 @@ name: "Integration Tests Mage-OS in Warden" -author: "Vladyslav Podorozhnyi" -description: "A Github Action that run Integration Tests of Mage-OS in warden." +author: "Mage-OS" +description: "A Github Action that run Integration Tests of Mage-OS in Warden." inputs: search: diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index 6d7f9ff..e0a7b44 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -1,22 +1,22 @@ name: "Setup Mage-OS in Warden" -author: "Vladyslav Podorozhnyi" -description: "A Github Action that pull and set-up Magen-OS in warden env." +author: "Mage-OS" +description: "A Github Action that pull and set-up Mage-OS in Warden env." inputs: warden_version: required: true default: "0.14.1" - description: "The version of warden to use." + description: "The version of Warden to use." php_version: required: true default: "8.2" - description: "PHP version used in warden container." + description: "PHP version used in Warden container." composer_version: required: true default: "2.2.22" - description: "The version of composer to use." + description: "The version of Composer to use." database: required: true From e7cdca1774d3c3e69c9e0c299335c84515c2fbae Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 30 Oct 2023 16:41:08 +0000 Subject: [PATCH 19/20] dev: code review suggestion --- warden/setup-environment/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index e0a7b44..36d6d83 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -25,7 +25,7 @@ inputs: search: required: true - default: "elasticsearch:7.15.1" + default: "opensearch:2.5" description: "The search engine to use." varnish: From 258cda966c62d861329729e6e10d19c062e3dce1 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 30 Oct 2023 16:42:32 +0000 Subject: [PATCH 20/20] Update warden/setup-environment/action.yml Co-authored-by: Simon Sprankel --- warden/setup-environment/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index 36d6d83..712de6d 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -248,7 +248,6 @@ runs: if [ $RUN_INSTALL == "1" ]; then export WARDEN="$(dirname $(pwd))/warden/bin/warden" wget https://getcomposer.org/download/${{ inputs.composer_version }}/composer.phar -O composer.phar 1>/dev/null 2>&1 && chmod +x composer.phar - ${WARDEN} env exec -T php-fpm ls -la | grep composer ${WARDEN} env exec -T php-fpm php composer.phar -v ${WARDEN} env exec -T php-fpm php composer.phar install --no-interaction --no-progress else