From 2cd25355761f3e6d0fb58d4b65478d97277c42bb Mon Sep 17 00:00:00 2001 From: dparis Date: Wed, 29 May 2024 09:08:00 +0200 Subject: [PATCH 01/11] github workflow e2e matrix: prestashop version & php version --- .github/workflows/quality-check.yml | 38 +++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/.github/workflows/quality-check.yml b/.github/workflows/quality-check.yml index 79003213..360bd1dc 100644 --- a/.github/workflows/quality-check.yml +++ b/.github/workflows/quality-check.yml @@ -5,7 +5,7 @@ env: on: pull_request: - types: [opened, reopened, synchronize] + types: [ opened, reopened, synchronize ] push: branches: - "main" @@ -17,7 +17,7 @@ jobs: timeout-minutes: 15 strategy: matrix: - php_version: ["7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2"] + php_version: [ "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2" ] steps: - name: Checkout uses: actions/checkout@v4 @@ -59,7 +59,7 @@ jobs: strategy: matrix: # @TODO: "1.6.1.24" is temporarily disabled here - ps_version: ["1.7.8.10", "8.1.4"] + ps_version: [ "1.7.8.10", "8.1.4" ] steps: - name: Checkout uses: actions/checkout@v4 @@ -86,14 +86,36 @@ jobs: - name: PHP unit run: make phpunit + setup-matrix: + name: Create campaign matrix + runs-on: ubuntu-latest + steps: + - name: Create Matrix + id: matrixSetup + shell: bash + run: | + declare -a ps_version=() + + if [[ "${{ github.event_name }}" == "schedule" ]]; then + ps_version=({ps:8.1.4, php:8.1}, {ps:8.0.5, php:8.1}, {ps:1.7.8.11, php:7.4}, {ps:1.7.7.8, php:7.3}, {ps:1.7.6.9, php:7.2}, {ps:1.7.5.2, php:7.2}, {ps1.7.4.4:, php:7.1}, {ps:1.7.3.4, php:7.1}, {ps:1.7.2.5, php:7.1}, {ps:1.7.1.2, php:7.1}, {ps:1.6.1.24, php:7.1}) + else + ps_version=({ps:8.1.4, php:8.1}, {ps:1.7.8.11, php:7.4}, {ps:nightly, php:8.1}) + fi; + + echo "matrix=$(jq -n --argjson ps_version "$(printf '%s\n' "${ps_version[@]}" | jq -R '.' | jq -s .)" '{ps_version: ps_version' | jq -c .)" >> $GITHUB_OUTPUT + outputs: + matrix: ${{ steps.matrixSetup.outputs.matrix }} + e2e-tests: name: E2E Tests runs-on: ubuntu-latest timeout-minutes: 30 - if: ${{ github.event_name == 'pull_request' }} + needs: setup-matrix strategy: + fail-fast: false + max-parallel: 1 matrix: - ps_version: ["1.7.8.10", "8.1.4", "nightly"] + ps_version: ${{ fromJson(needs.setup-matrix.outputs.matrix).ps_version }} steps: - name: Checkout the repository uses: actions/checkout@v4 @@ -129,16 +151,16 @@ jobs: run: pnpm install --no-optional --force working-directory: e2e - - name: Setup e2e-env with Prestashop ${{ matrix.ps_version }} + - name: Setup e2e-env with Prestashop ${{ matrix.ps_version.ps }}:${{ matrix.ps_version.php }} run: | cp .env.dist .env docker compose build docker compose up --detach --wait env: - DOCKER_IMAGE_PRESTASHOP: prestashop/prestashop-flashlight:${{matrix.ps_version}} + DOCKER_IMAGE_PRESTASHOP: prestashop/prestashop-flashlight:${{matrix.ps_version.ps}} working-directory: e2e-env - - name: Run e2e:tests with Prestashop ${{ matrix.ps_version }} + - name: Run e2e:tests with Prestashop ${{ matrix.ps_version.ps }}:${{ matrix.ps_version.php }} run: pnpm test:e2e working-directory: e2e From 2ca519ec6fc010f2d3d0a2c8a45ddbc23dddf876 Mon Sep 17 00:00:00 2001 From: dparis Date: Tue, 18 Jun 2024 14:01:42 +0200 Subject: [PATCH 02/11] docker mariadb lts/healthcheck install module --- .github/actions/e2e/action.yml | 105 ++++++++++++++++++ .github/workflows/e2e.yml | 81 ++++++++++++++ e2e-env/.env.dist | 7 ++ e2e-env/docker-compose.yml | 13 ++- e2e-env/init-scripts/1-install_ps_eventbus.sh | 16 +++ e2e-env/init-scripts/2-install_ps_accounts.sh | 12 ++ e2e-env/init-scripts/install-module.sh | 56 ---------- 7 files changed, 230 insertions(+), 60 deletions(-) create mode 100644 .github/actions/e2e/action.yml create mode 100644 .github/workflows/e2e.yml create mode 100755 e2e-env/init-scripts/1-install_ps_eventbus.sh create mode 100755 e2e-env/init-scripts/2-install_ps_accounts.sh delete mode 100755 e2e-env/init-scripts/install-module.sh diff --git a/.github/actions/e2e/action.yml b/.github/actions/e2e/action.yml new file mode 100644 index 00000000..2fbf4ebf --- /dev/null +++ b/.github/actions/e2e/action.yml @@ -0,0 +1,105 @@ +--- +name: 'e2e tests' +description: '' +inputs: + services: + description: list of services + type: string + required: false + image-tag: + description: Tag for docker image (pr-xxx) + type: string + required: false + githhub-event-name: + description: PR, workflow dispatch, or schedule + ps-version: + description: Prestashop version + required: true + php-version: + description: Php version + required: true + docker-compose-version: + description: Docker compose version + required: false + default: v2.24.4 + pnpm-version: + description: pnpm version + required: false + default: 9 + npm-token-prestashopcorp: + description: npm PrestashopCorp token + required: true + +runs: + using: composite + steps: + - name: 'Install docker compose' + shell: bash + run: | + DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} + mkdir -p $DOCKER_CONFIG/cli-plugins + rm -f $DOCKER_CONFIG/cli-plugins/docker-compose + curl -SL https://github.com/docker/compose/releases/download/${{ inputs.docker-compose-version }}/docker-compose-linux-x86_64 \ + -o $DOCKER_CONFIG/cli-plugins/docker-compose + chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose + + - name: 'Get general node version' + id: node_version + shell: bash + run: echo "VERSION=$(jq -r '.engines.node' package.json)" >> $GITHUB_OUTPUT + + - uses: actions/setup-node@v4 + with: + node-version: ${{ steps.node_version.outputs.VERSION }} + + - name: Install dependencies and setup e2e-env + shell: bash + run: | + npm install -g pnpm@${{ inputs.pnpm-version }} + pnpm install --no-optional + cp ./e2e-env/.env.dist ./e2e-env/.env + cat ./e2e-env/.env + env: + NPM_TOKEN_PRESTASHOPCORP: ${{ inputs.npm-token-prestashopcorp }} + + - name: PS${{ inputs.ps-version }} & PHP${{matrix.php_version}} setup env + shell: bash + run: | + cp .env.dist .env + docker compose build + docker compose up --detach --wait + env: + DOCKER_IMAGE_PRESTASHOP: prestashop/prestashop-flashlight:${{matrix.ps_version}}-${{matrix.php_version}} + working-directory: e2e-env + + - name: PS${{ inputs.ps-version }} docker instances + shell: bash + run: | + ./e2e-env.sh run --capture + while ! nc -z localhost 8000; do sleep 1; done; + working-directory: e2e-env + + - name: PS${{ inputs.ps-version }} & PHP${{ inputs.php-version }} run tests & stop e2e-env + shell: bash + run: | + pnpm test:e2e + working-directory: e2e + + - name: More logs on failure + if: failure() + shell: bash + run: | + echo "========= Shop healthcheck ==============" + curl -s -L 'http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck' | jq . + docker logs prestashop + echo "========= Failed at startup containers ==========" + docker container ps --filter "status=created" --format "{{.Names}}" + echo "========= Failed at startup containers logs ==========" + docker container ps --filter "status=created" --format "{{.Names}}" | xargs docker compose logs + echo "========= Unhealthy containers ==========" + docker container ps --filter "health=unhealthy" --format "{{.Names}}" + echo "========= Unhealthy containers logs ==========" + docker container ps --filter "health=unhealthy" --format "{{.Names}}" | xargs docker compose logs + echo "========= Shutting down env ==========" + ./e2e-env.sh stop + working-directory: e2e-env diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 00000000..2e074c83 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,81 @@ +--- +name: E2E + +on: + schedule: + - cron: '1 0 * * *' + workflow_dispatch: + +env: + DOCKER_COMPOSE_VERSION: v2.24.4 + PNPM_VERSION: 9 + +jobs: + # E2E tests are enable, only for: + # - Scheduled every day at 01:00 am (production) + e2e-eventbus-tests: + name: E2E Eventbus Tests + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: 'read' + id-token: 'write' + strategy: + fail-fast: false + matrix: + campaign: [ + { ps: 8.1.6, php: 8.1 }, + { ps: 8.0.5, php: 8.1 }, + { ps: 1.7.8.11, php: 7.4 }, + { ps: 1.7.7.8, php: 7.3 }, + { ps: 1.7.6.9, php: 7.2 }, + { ps: 1.7.5.2, php: 7.2 }, + { ps: 1.7.4.4, php: 7.1 }, + { ps: 1.7.3.4, php: 7.1 } + ] + if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Auth Docker GCP + uses: ./.github/actions/auth-docker-gcp + with: + workload-identity-provider: ${{ secrets.WI_PROVIDER_INTEGRATION }} + service-account: ${{ secrets.WI_SA_INTEGRATION }} + + - name: e2e tests + uses: ./.github/actions/e2e + with: + github-event-name: ${{ github.event_name }} + ps-version: ${{ matrix.campaign.ps }} + php-version: ${{ matrix.campaign.php }} + docker-compose-version: ${{ env.DOCKER_COMPOSE_VERSION }} + pnpm-version: ${{ env.PNPM_VERSION }} + npm-token-prestashopcorp: ${{ secrets.NPM_TOKEN_PRESTASHOPCORP }} + + - name: Slack notification on failures + if: github.event_name == 'schedule' && failure() + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_COLOR: EC1111 + SLACK_TITLE: E2E Eventbus module tests + SLACK_MESSAGE: The latest E2E Eventbus module tests failed :( + SLACK_FOOTER: 'Review the last github actions here: https://github.com/PrestaShopCorp/ps_eventbus/actions/workflows/e2e.yml' + SLACK_USERNAME: QABot + SLACK_CHANNEL: squad-cloudsync-dev + SLACK_ICON: https://avatars.githubusercontent.com/u/56089550?s=48&v=4 + + - name: Slack notification on success + if: github.event_name == 'schedule' && success() + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_COLOR: 0CAD34 + SLACK_TITLE: E2E Capture tests + SLACK_MESSAGE: ✓ The latest E2E Eventbus module tests just passed! + SLACK_FOOTER: '' + SLACK_USERNAME: QABot + SLACK_CHANNEL: cloudsync-alerting + SLACK_ICON: https://avatars.githubusercontent.com/u/56089550?s=48&v=4 diff --git a/e2e-env/.env.dist b/e2e-env/.env.dist index b99b0ede..116f0bfe 100644 --- a/e2e-env/.env.dist +++ b/e2e-env/.env.dist @@ -4,6 +4,10 @@ COMPOSE_PROJECT_NAME=ps_eventbus DOCKER_IMAGE_PRESTASHOP=prestashop/prestashop-flashlight:latest DOCKER_VERSION_MARIADB=lts +# e2e test dataset : default uses dataset from prestashop flashlight docker image, uses dataset from dataset +# folder otherwise +TEST_DATASET=default + # Infrastructure port binding on the host HOST_PORT_BIND_PRESTASHOP=8000 HOST_PORT_BIND_MYSQL=3306 @@ -14,3 +18,6 @@ SYNC_API_PORT=3232 COLLECTOR_API_PORT=3333 LIVE_SYNC_API_PORT=3434 WS_PORT=8080 + +PS_EVENTBUS_VERSION=v3.0.12 +PS_ACCOUNTS_MOCK_VERSION=v1.0.4 diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index e8128be5..2dfcb98d 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -1,6 +1,7 @@ services: prestashop: image: ${DOCKER_IMAGE_PRESTASHOP:?See e2e-env/.env.dist} + container_name: prestashop depends_on: mysql: condition: service_healthy @@ -32,8 +33,9 @@ services: mysql: image: mariadb:${DOCKER_VERSION_MARIADB:?See e2e-env/.env.dist} + container_name: mysql healthcheck: - test: ["CMD", "healthcheck.sh", "--connect"] + test: [ "CMD", "healthcheck.sh", "--connect" ] environment: - MYSQL_HOST=mysql - MYSQL_USER=prestashop @@ -48,6 +50,7 @@ services: phpmyadmin: image: phpmyadmin:latest + container_name: phpmyadmin depends_on: mysql: condition: service_healthy @@ -66,10 +69,11 @@ services: build: context: ./cloudsync-mock dockerfile: Dockerfile + container_name: cloudsync-mock environment: - RUN_IN_DOCKER=1 healthcheck: - test: ["CMD", "curl", "-sI", "http://localhost:8080"] + test: [ "CMD", "curl", "-sI", "http://localhost:8080" ] volumes: - ./cloudsync-mock/src:/home/node/src:ro ports: @@ -82,11 +86,12 @@ services: reverse-proxy: image: nginx:stable-alpine + container_name: reverse-proxy healthcheck: - test: ["CMD", "curl", "-sI", "http://localhost:80/nginx_status"] + test: [ "CMD", "curl", "-sI", "http://localhost:80/nginx_status" ] volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro,cached - command: [nginx-debug, "-g", "daemon off;"] + command: [ nginx-debug, "-g", "daemon off;" ] networks: - prestashop ports: diff --git a/e2e-env/init-scripts/1-install_ps_eventbus.sh b/e2e-env/init-scripts/1-install_ps_eventbus.sh new file mode 100755 index 00000000..e90cd166 --- /dev/null +++ b/e2e-env/init-scripts/1-install_ps_eventbus.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -eu +cd "$(dirname $0)" || exit 1 + +# Download and install the module's zip +echo "* [ps_eventbus] downloading..." +wget -q -O /tmp/ps_eventbus.zip "https://github.com/PrestaShopCorp/ps_eventbus/releases/download/${PS_EVENTBUS_VERSION}/ps_eventbus-${PS_EVENTBUS_VERSION}.zip" +echo "* [ps_eventbus] unziping..." +unzip -qq /tmp/ps_eventbus.zip -d /var/www/html/modules +echo "* [ps_eventbus] installing the module..." +cd "$PS_FOLDER" +php -d memory_limit=-1 bin/console prestashop:module --no-interaction install "ps_eventbus" + +# Override the default parameters with the E2E settings +wget -O "/var/www/html/modules/ps_eventbus/config/parameters.yml" \ + "https://raw.githubusercontent.com/PrestaShopCorp/ps_eventbus/main/config/parameters.yml" diff --git a/e2e-env/init-scripts/2-install_ps_accounts.sh b/e2e-env/init-scripts/2-install_ps_accounts.sh new file mode 100755 index 00000000..2a30b8a0 --- /dev/null +++ b/e2e-env/init-scripts/2-install_ps_accounts.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -eu +cd "$(dirname $0)" || exit 1 + +echo "* [ps_accounts_mock] downloading..." +echo "https://github.com/PrestaShopCorp/ps_accounts_mock/releases/download/${PS_ACCOUNTS_MOCK_VERSION}/ps_accounts_mock-${PS_ACCOUNTS_MOCK_VERSION:1}.zip" +wget -q -O /tmp/ps_accounts.zip "https://github.com/PrestaShopCorp/ps_accounts_mock/releases/download/${PS_ACCOUNTS_MOCK_VERSION}/ps_accounts_mock-${PS_ACCOUNTS_MOCK_VERSION:1}.zip" +echo "* [ps_accounts_mock] unziping..." +unzip -qq /tmp/ps_accounts.zip -d /var/www/html/modules +echo "* [ps_accounts_mock] installing the module..." +cd "$PS_FOLDER" +php -d memory_limit=-1 bin/console prestashop:module --no-interaction install "ps_accounts" diff --git a/e2e-env/init-scripts/install-module.sh b/e2e-env/init-scripts/install-module.sh deleted file mode 100755 index 30272c97..00000000 --- a/e2e-env/init-scripts/install-module.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# -# This is an init-script for prestashop-flashlight. -# -# Storing a folder in /var/www/html/modules is not enough to register the module -# into PrestaShop, hence why we have to call the console install CLI. -# -set -eu - -error() { - printf "\e[1;31m%s\e[0m\n" "${1:-Unknown error}" - exit "${2:-1}" -} - -run_user() { - sudo -g www-data -u www-data -- "$@" -} - -ps_accounts_mock_install() { - echo "* [ps_accounts_mock] downloading..." - PS_ACCOUNTS_MOCK_VERSION="v1.0.4" - wget -q -O /tmp/ps_accounts.zip \ - "https://github.com/PrestaShopCorp/ps_accounts_mock/releases/download/${PS_ACCOUNTS_MOCK_VERSION}/ps_accounts.zip" - echo "* [ps_accounts_mock] unziping..." - run_user unzip -qq /tmp/ps_accounts.zip -d /var/www/html/modules - echo "* [ps_accounts_mock] installing the module..." - cd "$PS_FOLDER" - run_user php -d memory_limit=-1 bin/console prestashop:module --no-interaction install "ps_accounts" -} - -ps_eventbus_install() { - # Some explanations are required here: - # - # If you look closer to the ./docker-compose.yml prestashop service, you will - # see multiple mounts on the same files: - # - ..:/var/www/html/modules/ps_eventbus:rw => mount all the sources - # - /var/www/html/modules/ps_eventbus/vendor => void the specific vendor dir, makint it empty - # - /var/www/html/modules/ps_eventbus/tools/vendor => void the specific vendor dev dir, making it empty - # - # That said, we now want our container to have RW access on these directories, - # and to install the required composer dependencies for the module to work. - # - # Other scenarios could be imagined, but this is the best way to avoid writes on a mounted volume, - # which would not work on a Linux environment (binding a volume), as opposed to a Windows or Mac one (NFS mount). - chown www-data:www-data ./modules/ps_eventbus/vendor - chown www-data:www-data ./modules/ps_eventbus/tools/vendor - run_user composer install -n -d ./modules/ps_eventbus - - echo "* [ps_eventbus] installing the module..." - cd "$PS_FOLDER" - run_user php -d memory_limit=-1 bin/console prestashop:module --no-interaction install "ps_eventbus" -} - -ps_accounts_mock_install -ps_eventbus_install - From 3394a1f2e0973e173dbe8b2cd457b669ea79c76f Mon Sep 17 00:00:00 2001 From: dparis Date: Thu, 20 Jun 2024 16:49:00 +0200 Subject: [PATCH 03/11] github workflow e2e matrix: prestashop & php versions --- .github/actions/e2e/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/e2e/action.yml b/.github/actions/e2e/action.yml index 2fbf4ebf..d30839f4 100644 --- a/.github/actions/e2e/action.yml +++ b/.github/actions/e2e/action.yml @@ -62,14 +62,14 @@ runs: env: NPM_TOKEN_PRESTASHOPCORP: ${{ inputs.npm-token-prestashopcorp }} - - name: PS${{ inputs.ps-version }} & PHP${{matrix.php_version}} setup env + - name: PS${{ inputs.ps-version }} & PHP${{inputs.php_version}} setup env shell: bash run: | cp .env.dist .env docker compose build docker compose up --detach --wait env: - DOCKER_IMAGE_PRESTASHOP: prestashop/prestashop-flashlight:${{matrix.ps_version}}-${{matrix.php_version}} + DOCKER_IMAGE_PRESTASHOP: prestashop/prestashop-flashlight:${{inputs.ps_version}}-${{inputs.php_version}} working-directory: e2e-env - name: PS${{ inputs.ps-version }} docker instances From a52b37ad720de5910157705a96a01712a410fe44 Mon Sep 17 00:00:00 2001 From: dparis Date: Wed, 26 Jun 2024 17:54:18 +0200 Subject: [PATCH 04/11] actions/workflows e2e matrix: prestashop & php versions --- .github/actions/e2e/action.yml | 102 +++++++++++++-------------------- .github/workflows/e2e.yml | 67 +++++++++++----------- 2 files changed, 74 insertions(+), 95 deletions(-) diff --git a/.github/actions/e2e/action.yml b/.github/actions/e2e/action.yml index d30839f4..313e1a11 100644 --- a/.github/actions/e2e/action.yml +++ b/.github/actions/e2e/action.yml @@ -2,38 +2,44 @@ name: 'e2e tests' description: '' inputs: - services: - description: list of services - type: string - required: false - image-tag: - description: Tag for docker image (pr-xxx) - type: string - required: false - githhub-event-name: - description: PR, workflow dispatch, or schedule ps-version: description: Prestashop version required: true php-version: description: Php version required: true + node-builder-version: + description: Node builder version + required: true docker-compose-version: description: Docker compose version - required: false - default: v2.24.4 - pnpm-version: - description: pnpm version - required: false - default: 9 - npm-token-prestashopcorp: - description: npm PrestashopCorp token - required: true + required: trur runs: using: composite steps: - - name: 'Install docker compose' + - name: Checkout the repository + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + + - uses: pnpm/action-setup@v3 + with: + version: latest + + - uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-builder-version }} + cache: "pnpm" + cache-dependency-path: e2e/pnpm-lock.yaml + + - name: Cache vendor folder + uses: actions/cache@v3 + with: + path: vendor + key: php-${{ hashFiles('composer.lock') }} + + - name: Install docker compose shell: bash run: | DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} @@ -43,63 +49,35 @@ runs: -o $DOCKER_CONFIG/cli-plugins/docker-compose chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose - - name: 'Get general node version' - id: node_version + - name: Install dependencies and setup e2e shell: bash - run: echo "VERSION=$(jq -r '.engines.node' package.json)" >> $GITHUB_OUTPUT - - - uses: actions/setup-node@v4 - with: - node-version: ${{ steps.node_version.outputs.VERSION }} - - - name: Install dependencies and setup e2e-env - shell: bash - run: | - npm install -g pnpm@${{ inputs.pnpm-version }} - pnpm install --no-optional - cp ./e2e-env/.env.dist ./e2e-env/.env - cat ./e2e-env/.env - env: - NPM_TOKEN_PRESTASHOPCORP: ${{ inputs.npm-token-prestashopcorp }} + run: pnpm install --no-optional --force + working-directory: e2e - - name: PS${{ inputs.ps-version }} & PHP${{inputs.php_version}} setup env + - name: Setup e2e-env with Prestashop ${{ inputs.ps-version }} & Php ${{ inputs.php-version }} shell: bash run: | + FLASHLIGHT_BASE_IMAGE="prestashop/prestashop-flashlight" + if [[ "${{ inputs.ps-version }}" != "latest" ]]; then + sed -i 's+${FLASHLIGHT_BASE_IMAGE}:latest/${FLASHLIGHT_BASE_IMAGE}:${PS_VERSION}/g' .env.dist + fi; cp .env.dist .env docker compose build docker compose up --detach --wait - env: - DOCKER_IMAGE_PRESTASHOP: prestashop/prestashop-flashlight:${{inputs.ps_version}}-${{inputs.php_version}} - working-directory: e2e-env - - - name: PS${{ inputs.ps-version }} docker instances - shell: bash - run: | - ./e2e-env.sh run --capture - while ! nc -z localhost 8000; do sleep 1; done; working-directory: e2e-env - - name: PS${{ inputs.ps-version }} & PHP${{ inputs.php-version }} run tests & stop e2e-env + - name: Run e2e:tests with Prestashop ${{ inputs.ps-version }} & Php ${{ inputs.php-version }} shell: bash - run: | - pnpm test:e2e + run: pnpm test:e2e working-directory: e2e - name: More logs on failure - if: failure() shell: bash + if: failure() run: | echo "========= Shop healthcheck ==============" curl -s -L 'http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck' | jq . - docker logs prestashop - echo "========= Failed at startup containers ==========" - docker container ps --filter "status=created" --format "{{.Names}}" - echo "========= Failed at startup containers logs ==========" - docker container ps --filter "status=created" --format "{{.Names}}" | xargs docker compose logs - echo "========= Unhealthy containers ==========" - docker container ps --filter "health=unhealthy" --format "{{.Names}}" - echo "========= Unhealthy containers logs ==========" - docker container ps --filter "health=unhealthy" --format "{{.Names}}" | xargs docker compose logs - echo "========= Shutting down env ==========" - ./e2e-env.sh stop + echo "========= Containers logs ==========" + docker compose logs cloudsync-mock prestashop + docker compose down -v working-directory: e2e-env diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 2e074c83..78ea34fc 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,43 +1,46 @@ ---- -name: E2E +name: E2e on: schedule: - cron: '1 0 * * *' - workflow_dispatch: env: - DOCKER_COMPOSE_VERSION: v2.24.4 - PNPM_VERSION: 9 + DOCKER_COMPOSE_VERSION: v2.27.0 + NODE_BUILDER_VERSION: "20" jobs: - # E2E tests are enable, only for: - # - Scheduled every day at 01:00 am (production) - e2e-eventbus-tests: - name: E2E Eventbus Tests + e2e-tests: + name: E2E Tests runs-on: ubuntu-latest timeout-minutes: 30 - permissions: - contents: 'read' - id-token: 'write' strategy: fail-fast: false matrix: - campaign: [ - { ps: 8.1.6, php: 8.1 }, - { ps: 8.0.5, php: 8.1 }, - { ps: 1.7.8.11, php: 7.4 }, - { ps: 1.7.7.8, php: 7.3 }, - { ps: 1.7.6.9, php: 7.2 }, - { ps: 1.7.5.2, php: 7.2 }, - { ps: 1.7.4.4, php: 7.1 }, - { ps: 1.7.3.4, php: 7.1 } - ] - if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} + include: + - ps-version: 8.1.6 + php-version: 8.2 + - ps-version: 8.0.5 + php-version: 8.2 + - ps-version: 1.7.8.11 + php-version: 7.4 + - ps-version: 1.7.7.8 + php-version: 7.3 + - ps-version: 1.7.6.9 + php-version: 7.2 + - ps-version: 1.7.5.2 + php-version: 7.2 + - ps-version: 1.7.4.4 + php-version: 7.1 + - ps-version: 1.7.3.4 + php-version: 7.1 steps: - name: Checkout the repository uses: actions/checkout@v4 + - uses: pnpm/action-setup@v3 + with: + version: latest + - name: Auth Docker GCP uses: ./.github/actions/auth-docker-gcp with: @@ -47,12 +50,10 @@ jobs: - name: e2e tests uses: ./.github/actions/e2e with: - github-event-name: ${{ github.event_name }} - ps-version: ${{ matrix.campaign.ps }} - php-version: ${{ matrix.campaign.php }} + ps-version: ${{ matrix.ps-version }} + php-version: ${{ matrix.php-version }} docker-compose-version: ${{ env.DOCKER_COMPOSE_VERSION }} - pnpm-version: ${{ env.PNPM_VERSION }} - npm-token-prestashopcorp: ${{ secrets.NPM_TOKEN_PRESTASHOPCORP }} + node-builder-version: ${{ env.NODE_BUILDER_VERSION }} - name: Slack notification on failures if: github.event_name == 'schedule' && failure() @@ -60,9 +61,9 @@ jobs: env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} SLACK_COLOR: EC1111 - SLACK_TITLE: E2E Eventbus module tests - SLACK_MESSAGE: The latest E2E Eventbus module tests failed :( - SLACK_FOOTER: 'Review the last github actions here: https://github.com/PrestaShopCorp/ps_eventbus/actions/workflows/e2e.yml' + SLACK_TITLE: E2E Capture tests PS${{ matrix.ps-version }} & Php${{ matrix.php-version }} + SLACK_MESSAGE: The latest E2E Capture tests failed :( + SLACK_FOOTER: 'Review the last github actions here: https://github.com/PrestaShopCorp/cloudsync/actions/workflows/e2e.yml' SLACK_USERNAME: QABot SLACK_CHANNEL: squad-cloudsync-dev SLACK_ICON: https://avatars.githubusercontent.com/u/56089550?s=48&v=4 @@ -73,8 +74,8 @@ jobs: env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} SLACK_COLOR: 0CAD34 - SLACK_TITLE: E2E Capture tests - SLACK_MESSAGE: ✓ The latest E2E Eventbus module tests just passed! + SLACK_TITLE: E2E Capture tests PS${{ matrix.ps-version }} & Php${{ matrix.php-version }} + SLACK_MESSAGE: ✓ The latest E2E Capture tests just passed! SLACK_FOOTER: '' SLACK_USERNAME: QABot SLACK_CHANNEL: cloudsync-alerting From ba3b52ebb3635c834fea12193434394fa50aff98 Mon Sep 17 00:00:00 2001 From: dparis Date: Fri, 5 Jul 2024 15:00:09 +0200 Subject: [PATCH 05/11] actions/workflows e2e matrix: prestashop & php versions --- e2e-env/init-scripts/2-install_ps_accounts.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-env/init-scripts/2-install_ps_accounts.sh b/e2e-env/init-scripts/2-install_ps_accounts.sh index 2a30b8a0..2b1180f6 100755 --- a/e2e-env/init-scripts/2-install_ps_accounts.sh +++ b/e2e-env/init-scripts/2-install_ps_accounts.sh @@ -3,8 +3,8 @@ set -eu cd "$(dirname $0)" || exit 1 echo "* [ps_accounts_mock] downloading..." -echo "https://github.com/PrestaShopCorp/ps_accounts_mock/releases/download/${PS_ACCOUNTS_MOCK_VERSION}/ps_accounts_mock-${PS_ACCOUNTS_MOCK_VERSION:1}.zip" -wget -q -O /tmp/ps_accounts.zip "https://github.com/PrestaShopCorp/ps_accounts_mock/releases/download/${PS_ACCOUNTS_MOCK_VERSION}/ps_accounts_mock-${PS_ACCOUNTS_MOCK_VERSION:1}.zip" +echo "https://github.com/PrestaShopCorp/ps_accounts_mock/releases/download/${PS_ACCOUNTS_MOCK_VERSION}/ps_accounts_mock-${PS_ACCOUNTS_MOCK_VERSION}.zip" +wget -q -O /tmp/ps_accounts.zip "https://github.com/PrestaShopCorp/ps_accounts_mock/releases/download/${PS_ACCOUNTS_MOCK_VERSION}/ps_accounts_mock-${PS_ACCOUNTS_MOCK_VERSION}.zip" echo "* [ps_accounts_mock] unziping..." unzip -qq /tmp/ps_accounts.zip -d /var/www/html/modules echo "* [ps_accounts_mock] installing the module..." From a3aa085ba7aa35b9f824e9e4dbefe9527a1df888 Mon Sep 17 00:00:00 2001 From: dparis Date: Fri, 19 Jul 2024 15:14:31 +0200 Subject: [PATCH 06/11] matrix --- .github/actions/e2e/action.yml | 2 +- .github/workflows/e2e.yml | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/actions/e2e/action.yml b/.github/actions/e2e/action.yml index 313e1a11..c6bf6e2b 100644 --- a/.github/actions/e2e/action.yml +++ b/.github/actions/e2e/action.yml @@ -59,7 +59,7 @@ runs: run: | FLASHLIGHT_BASE_IMAGE="prestashop/prestashop-flashlight" if [[ "${{ inputs.ps-version }}" != "latest" ]]; then - sed -i 's+${FLASHLIGHT_BASE_IMAGE}:latest/${FLASHLIGHT_BASE_IMAGE}:${PS_VERSION}/g' .env.dist + sed -i 's+${FLASHLIGHT_BASE_IMAGE}:latest/${FLASHLIGHT_BASE_IMAGE}:${{inputs.ps-version}}-${{inputs.php-version}}/g' .env.dist fi; cp .env.dist .env docker compose build diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 78ea34fc..ad0a6c12 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -33,6 +33,16 @@ jobs: php-version: 7.1 - ps-version: 1.7.3.4 php-version: 7.1 + - ps-version: 1.7.2.5 + php-version: 7.1 + - ps-version: 1.7.1.2 + php-version: 7.1 + - ps-version: 1.7.0.6 + php-version: 7.1 + - ps-version: 1.6.1.24 + php-version: 7.1 + - ps-version: 1.7.3.4 + php-version: 7.1 steps: - name: Checkout the repository uses: actions/checkout@v4 From 83b22d49967c6eae30af9cc35f993e47b2ee32ae Mon Sep 17 00:00:00 2001 From: dparis Date: Fri, 19 Jul 2024 15:17:39 +0200 Subject: [PATCH 07/11] oups --- .github/actions/e2e/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/e2e/action.yml b/.github/actions/e2e/action.yml index c6bf6e2b..c17776d5 100644 --- a/.github/actions/e2e/action.yml +++ b/.github/actions/e2e/action.yml @@ -13,7 +13,7 @@ inputs: required: true docker-compose-version: description: Docker compose version - required: trur + required: true runs: using: composite From 618b81a23f273957afbe87d9aa9690b943c271ce Mon Sep 17 00:00:00 2001 From: dparis Date: Fri, 19 Jul 2024 15:31:09 +0200 Subject: [PATCH 08/11] e2e PR & workflow_dispatch --- .github/actions/e2e/action.yml | 1 + .github/workflows/e2e-pr.yml | 112 +++++++++++++++++++++++++++++++++ .github/workflows/e2e.yml | 9 +-- 3 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/e2e-pr.yml diff --git a/.github/actions/e2e/action.yml b/.github/actions/e2e/action.yml index c17776d5..0fa83b59 100644 --- a/.github/actions/e2e/action.yml +++ b/.github/actions/e2e/action.yml @@ -1,5 +1,6 @@ --- name: 'e2e tests' + description: '' inputs: ps-version: diff --git a/.github/workflows/e2e-pr.yml b/.github/workflows/e2e-pr.yml new file mode 100644 index 00000000..6d457ddc --- /dev/null +++ b/.github/workflows/e2e-pr.yml @@ -0,0 +1,112 @@ +name: E2e + +on: + workflow_call: + inputs: + ps-version: + description: 'Prestashop version (if latest no Php version needed).' + type: string + required: false + default: latest + php-version: + description: 'Php version' + type: string + required: false + default: 8.1 + workflow_dispatch: + inputs: + ps-version: + description: 'Prestashop version (if latest no Php version needed) \n + Compatibility: \n + ps8.x.x with php 8.1, 8.0, 7.4, 7.3, 7.2, 7.1 \n + ps1.7.8.x with 7.4, 7.3, 7.2, 7.1 \n + ps1.7.7.x with 7.3, 7.2, 7.1 \n + ps1.7.5.x & ps1.7.6.x with php 7.2, 7.1, 7.0 \n + ps1.7.0.x to ps1.7.4.x with php 7.1, 7.0 + ps1.6.1.x with php 7.1, 7.0, 5.6' + default: 'latest' + type: choice + options: + - latest + - 8.1.7 + - 8.0.5 + - 1.7.8.11 + - 1.7.7.8 + - 1.7.6.9 + - 1.7.5.2 + - 1.7.4.4 + - 1.7.3.4 + - 1.7.2.5 + - 1.7.1.2 + - 1.7.0.6 + - 1.6.1.24 + php-version: + description: 'Php version' + default: '8.1' + type: choice + options: + - 8.1 + - 8.0 + - 7.4 + - 7.3 + - 7.2 + - 7.1 + - 7.0 + - 5.6 + +env: + DOCKER_COMPOSE_VERSION: v2.27.0 + NODE_BUILDER_VERSION: "20" + +jobs: + e2e-tests: + name: E2E Tests + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v3 + with: + version: latest + + - name: Auth Docker GCP + uses: ./.github/actions/auth-docker-gcp + with: + workload-identity-provider: ${{ secrets.WI_PROVIDER_INTEGRATION }} + service-account: ${{ secrets.WI_SA_INTEGRATION }} + + - name: e2e tests + uses: ./.github/actions/e2e + with: + ps-version: ${{ inputs.ps-version }} + php-version: ${{ inputs.php-version }} + docker-compose-version: ${{ env.DOCKER_COMPOSE_VERSION }} + node-builder-version: ${{ env.NODE_BUILDER_VERSION }} + + - name: Slack notification on failures + if: github.event_name == 'schedule' && failure() + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_COLOR: EC1111 + SLACK_TITLE: E2E Capture tests PS$${{ inputs.ps-version }} & Php${{ inputs.php-version }} + SLACK_MESSAGE: The latest E2E Capture tests failed :( + SLACK_FOOTER: 'Review the last github actions here: https://github.com/PrestaShopCorp/cloudsync/actions/workflows/e2e.yml' + SLACK_USERNAME: QABot + SLACK_CHANNEL: squad-cloudsync-qa + SLACK_ICON: https://avatars.githubusercontent.com/u/56089550?s=48&v=4 + + - name: Slack notification on success + if: github.event_name == 'schedule' && success() + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_COLOR: 0CAD34 + SLACK_TITLE: E2E Capture tests PS${{ matrix.ps-version }} & Php${{ matrix.php-version }} + SLACK_MESSAGE: ✓ The latest E2E Capture tests just passed! + SLACK_FOOTER: '' + SLACK_USERNAME: QABot + SLACK_CHANNEL: squad-cloudsync-qa + SLACK_ICON: https://avatars.githubusercontent.com/u/56089550?s=48&v=4 diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index ad0a6c12..b56f873e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,9 +1,5 @@ name: E2e -on: - schedule: - - cron: '1 0 * * *' - env: DOCKER_COMPOSE_VERSION: v2.27.0 NODE_BUILDER_VERSION: "20" @@ -17,7 +13,7 @@ jobs: fail-fast: false matrix: include: - - ps-version: 8.1.6 + - ps-version: 8.1.7 php-version: 8.2 - ps-version: 8.0.5 php-version: 8.2 @@ -41,8 +37,7 @@ jobs: php-version: 7.1 - ps-version: 1.6.1.24 php-version: 7.1 - - ps-version: 1.7.3.4 - php-version: 7.1 + steps: - name: Checkout the repository uses: actions/checkout@v4 From 3f864f29fbc040ff0e4d8917a598dc7c4dae5f7c Mon Sep 17 00:00:00 2001 From: dparis Date: Fri, 19 Jul 2024 15:33:07 +0200 Subject: [PATCH 09/11] pS1.6.x php versions compatibility --- .github/workflows/e2e-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-pr.yml b/.github/workflows/e2e-pr.yml index 6d457ddc..3e164fa4 100644 --- a/.github/workflows/e2e-pr.yml +++ b/.github/workflows/e2e-pr.yml @@ -23,7 +23,7 @@ on: ps1.7.7.x with 7.3, 7.2, 7.1 \n ps1.7.5.x & ps1.7.6.x with php 7.2, 7.1, 7.0 \n ps1.7.0.x to ps1.7.4.x with php 7.1, 7.0 - ps1.6.1.x with php 7.1, 7.0, 5.6' + ps1.6.1.x with php 7.1, 7.0, 5.6, 5.5, 5.4, 5.3, 5.2' default: 'latest' type: choice options: From c5d9211900260adbe17cfc1c034e7d2d6dafec8c Mon Sep 17 00:00:00 2001 From: dparis Date: Fri, 19 Jul 2024 15:33:40 +0200 Subject: [PATCH 10/11] pS1.6.x php versions compatibility --- .github/workflows/e2e-pr.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/e2e-pr.yml b/.github/workflows/e2e-pr.yml index 3e164fa4..ef41de05 100644 --- a/.github/workflows/e2e-pr.yml +++ b/.github/workflows/e2e-pr.yml @@ -53,6 +53,10 @@ on: - 7.1 - 7.0 - 5.6 + - 5.5 + - 5.4 + - 5.3 + - 5.2 env: DOCKER_COMPOSE_VERSION: v2.27.0 From 522606649d5dd9fcba0c9b381826c29ed6676de9 Mon Sep 17 00:00:00 2001 From: dparis Date: Fri, 19 Jul 2024 15:43:06 +0200 Subject: [PATCH 11/11] slack --- .github/workflows/e2e-pr.yml | 2 +- .github/workflows/e2e.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-pr.yml b/.github/workflows/e2e-pr.yml index ef41de05..b9adf6d9 100644 --- a/.github/workflows/e2e-pr.yml +++ b/.github/workflows/e2e-pr.yml @@ -1,4 +1,4 @@ -name: E2e +name: E2e PR on: workflow_call: diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b56f873e..d6d6b649 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -70,7 +70,7 @@ jobs: SLACK_MESSAGE: The latest E2E Capture tests failed :( SLACK_FOOTER: 'Review the last github actions here: https://github.com/PrestaShopCorp/cloudsync/actions/workflows/e2e.yml' SLACK_USERNAME: QABot - SLACK_CHANNEL: squad-cloudsync-dev + SLACK_CHANNEL: squad-cloudsync-qa SLACK_ICON: https://avatars.githubusercontent.com/u/56089550?s=48&v=4 - name: Slack notification on success @@ -83,5 +83,5 @@ jobs: SLACK_MESSAGE: ✓ The latest E2E Capture tests just passed! SLACK_FOOTER: '' SLACK_USERNAME: QABot - SLACK_CHANNEL: cloudsync-alerting + SLACK_CHANNEL: squad-cloudsync-qa SLACK_ICON: https://avatars.githubusercontent.com/u/56089550?s=48&v=4