Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

first e2e commit #444

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .docker/docker-compose.prestashop@prestashop-flashlight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ services:
container_name: phpunit
# image: 'prestashop/prestashop-flashlight:1.7.6.9-7.2'
image: ${PLATFORM_IMAGE}
healthcheck:
test: curl --fail http://localhost:80 || exit 1
interval: 10s
timeout: 10s
retries: 5
user: root
environment:
- PS_DOMAIN=localhost
Expand All @@ -14,7 +19,8 @@ services:
volumes:
- ../:/var/www/html/modules/ps_accounts
depends_on:
- mysql
mysql:
condition: service_healthy

mysql:
image: mariadb:10.8.2
Expand All @@ -39,4 +45,7 @@ services:
- MYSQL_ROOT_PASSWORD=prestashop
- MYSQL_DATABASE=prestashop
- MYSQL_PORT=3306
ports:
- 9906:3306


38 changes: 24 additions & 14 deletions .github/workflows/accounts-qc-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# presta-versions: ["latest", "1.7.6.5", "1.6.1.21"]
presta-versions: ["1.7.7.8-7.1", "1.6.1.24-7.1"]
presta-versions:
- "1.7.7.8-7.1"
- "1.6.1.24-7.1"
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -59,27 +60,36 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: ["1.6.1.24-5.6-fpm-stretch", "1.6.1.24-7.1", "1.7.8.5-7.4", "8.1.5-7.4", "nightly"]
presta-versions:
- "1.6.1.24-5.6-fpm-stretch"
- "1.6.1.24-7.1"
- "1.7.8.5-7.4"
- "8.1.5-7.4"
- "nightly"
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Scoped dependencies
run: make php-scoper

- name: PHPUnit tests
- name: Start container & install module
run: |
make phpunit-${{ matrix.presta-versions }}
make platform-${{ matrix.presta-versions }}

- name: Feature tests
run: |
make phpunit-run-unit

- name: E2e tests
run: |
make phpunit-run-feature

- name: Display logs
if: "!success()"
run: |
make phpunit-display-logs

# alternatively :
# - name: Platform build
# run: |
# make platform-${{ matrix.presta-versions }}
#
# - name: PHPUnit
# run: |
# make phpunit
#
# - name: PHPStan
# run: |
# make phpstan
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/e2e-back-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: account

on:
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:

jobs:
run-test:
name: Run Account back tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1

steps:
- name: Checkout Repository
uses: 'actions/checkout@v4'

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'node'

- name: Cache node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: |
npm ci

- name: Run Dashboard Tests
run: npm run test-all-version
continue-on-error: true

- name: Upload Playwright Test Reports
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-account-back testing
path: playwright-report/
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ install.lock
composer-dev.json
composer-dev.lock
.env
.env.local


### PHPUnit ###
.phpunit.result.cache
Expand Down Expand Up @@ -57,3 +59,25 @@ views/files/*
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# e2e ignore
screenshots
node_modules
*/node_modules
test/reports/*
mochawesome-report
tools/reports/*
playwright-report
test-output
test-results
allure-results
deprecated
.auth
temp
mytun-credentials.json
mytun-config.yml
report-summary
.DS_Store

# e2e-env ignore
downloads/
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ platform-pull:
docker pull ${PLATFORM_IMAGE}

platform-start:
@PLATFORM_IMAGE=${PLATFORM_IMAGE} ${DOCKER_COMPOSE} -f ${PLATFORM_COMPOSE_FILE} up -d
@PLATFORM_IMAGE=${PLATFORM_IMAGE} ${DOCKER_COMPOSE} -f ${PLATFORM_COMPOSE_FILE} up -d --wait
@echo phpunit started

platform-stop:
Expand Down Expand Up @@ -102,7 +102,7 @@ endef

# FIXME: check for PrestaShop & DB coming alive
platform-is-alive:
sleep 10
sleep 0

platform-init: platform-pull platform-restart platform-is-alive platform-module-install platform-fix-permissions
@echo platform container is ready
Expand Down Expand Up @@ -148,6 +148,10 @@ phpunit-run-unit: platform-fix-permissions
phpunit-run-feature: platform-fix-permissions
@docker exec -w ${CONTAINER_INSTALL_DIR}/tests phpunit ./vendor/bin/phpunit --testsuite feature

phpunit-display-logs:
-@docker exec phpunit sh -c "if [ -f ./bin/console ]; then cat var/logs/ps_accounts-$(shell date --iso); fi"
-@docker exec phpunit sh -c "if [ ! -f ./bin/console ]; then cat log/ps_accounts-$(shell date --iso); fi"

phpunit: phpunit-run-unit phpunit-run-feature

REGEX_COMPAT_VOID := "s/\(function \(setUp\|tearDown\)()\)\(: void\)\?/\1/"
Expand Down
4 changes: 3 additions & 1 deletion config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ services:
ps_accounts.logger:
class: PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger
public: true
factory: [ 'PrestaShop\Module\PsAccounts\Factory\PsAccountsLogger', 'create' ]
factory: [ 'PrestaShop\Module\PsAccounts\Log\Logger', 'create' ]
# arguments:
# - '%ps_accounts.log_level%'

PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider:
class: PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider
Expand Down
4 changes: 4 additions & 0 deletions config/config.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ parameters:
# Login page testimonials url
ps_accounts.testimonials_url: 'https://assets.prestashop3.com/dst/accounts/assets/testimonials.json'

# optional log level (defaults to ERROR)
#ps_accounts.log_level: !php/const PrestaShop\Module\PsAccounts\Log\Logger::ERROR
ps_accounts.log_level: ERROR

23 changes: 23 additions & 0 deletions e2e-env/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#########################################################
CI=false
# Infrastructure dependencies
DOCKER_IMAGE_PRESTASHOP=prestashop/prestashop-flashlight
PS_VERSION==8.1.1-8.1-fpm-alpine
#PS_VERSION==8.0.5-8.1-fpm-alpine
#PS_VERSION==1.7.7.8-7.2-fpm-alpine
#PS_VERSION=1.7.8.11-7.2-fpm-alpine
DOCKER_VERSION_MARIADB=lts
HOST_PORT_BIND_PHP_MY_ADMIN=3006
PS_DOMAIN=prestashop.xxxxx-xxxxxx-mytun.prestashop.name
# Modules dependencies
PS_ACCOUNTS_VERSION=v6.3.2
#PS_ACCOUNTS_VERSION=v5.6.2
PS_SHIPPING_VERSION=module-v1.0.5
PS_SHIPPING_TAG=v1.0.5
PS_EVENTBUS_VERSION=v3.0.8
# Authentication
DOWNLOADER_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
## myTun Credentials
ACCOUNT_TAG=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TUNNEL_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TUNNEL_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
10 changes: 10 additions & 0 deletions e2e-env/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
.PHONY: help

docker-build: ## Build 8.0.x docker env
PS_VERSION=${PS_VERSION} PS_DOMAIN=${PS_DOMAIN} PS_ACCOUNTS_VERSION=${PS_ACCOUNTS_VERSION} docker compose up --build --force-recreate -d
.PHONY: docker-build
81 changes: 81 additions & 0 deletions e2e-env/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
services:
mysql:
restart: unless-stopped
image: mariadb:lts
environment:
TZ: Europe/Paris
MYSQL_HOST: mysql
MYSQL_USER: prestashop
MYSQL_PASSWORD: prestashop
MYSQL_ROOT_PASSWORD: prestashop
MYSQL_PORT: 3306
MYSQL_DATABASE: prestashop
healthcheck:
test:
[
"CMD",
"healthcheck.sh",
"--connect",
]
interval: 5s
timeout: 10s
retries: 5
ports:
- "${DB_BIND_PORT}:3306"

prestashop:
restart: unless-stopped
image: prestashop/prestashop-flashlight:${PS_VERSION}
env_file: .env
depends_on:
mysql:
condition: service_healthy
environment:
ADMIN_MAIL: "ervin.klicic@prestashop.com"
ADMIN_PASSWD: "prestashop"
PS_DOMAIN: ${PS_DOMAIN}
SSL_REDIRECT: true
volumes:
- ./init-scripts:/tmp/init-scripts:ro
ports:
- "8000:80"

phpmyadmin:
image: phpmyadmin:latest
depends_on:
mysql:
condition: service_healthy
ports:
- ${HOST_PORT_BIND_PHP_MY_ADMIN:?See e2e-env/.env.dist}:80
environment:
- PMA_HOST=mysql
- PMA_PORT=3306
- PMA_USER=prestashop
- PMA_PASSWORD=prestashop
- MYSQL_ROOT_PASSWORD=prestashop

mytun-config:
restart: 'no'
extends:
file: ./myTun/docker-compose.yml
service: config-generator
environment:
ACCOUNT_TAG: ${ACCOUNT_TAG}
TUNNEL_SECRET: ${TUNNEL_SECRET}
TUNNEL_ID: ${TUNNEL_ID}
PS_DOMAIN: ${PS_DOMAIN}

mytun:
restart: always
image: cloudflare/cloudflared:latest
command: tunnel --config /config.yml run
depends_on:
mytun-config:
condition: service_completed_successfully
volumes:
- ./myTun/config/mytun-config.yml:/config.yml
- ./myTun/config/mytun-credentials.json:/credentials.json

volumes:
modules:
driver: local
15 changes: 15 additions & 0 deletions e2e-env/init-scripts/1-install_ps_acount.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
set -eu
cd "$(dirname $0)" || exit 1

# Download and install the module's zip
GITHUB_REPOSITORY="PrestaShopCorp/ps_accounts"
TARGET_ASSET="ps_accounts_preprod-${PS_ACCOUNTS_VERSION#v}.zip"
TARGET_VERSION=${PS_ACCOUNTS_VERSION}
echo "* [ps_accounts] downloading..."
wget -q -O /tmp/ps_accounts.zip "https://github.com/${GITHUB_REPOSITORY}/releases/download/${TARGET_VERSION}/${TARGET_ASSET}"
echo "* [ps_accounts] unziping..."
unzip -qq /tmp/ps_accounts.zip -d /var/www/html/modules
echo "* [ps_accounts] installing the module..."
cd "$PS_FOLDER"
php -d memory_limit=-1 bin/console prestashop:module --no-interaction install "ps_accounts"
10 changes: 10 additions & 0 deletions e2e-env/myTun/config-generator.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine:latest

# Créer le répertoire de configuration
RUN mkdir -p /config

ADD scripts/generateConfigFiles.sh /

Check notice

Code scanning / SonarCloud

Prefer COPY over ADD for copying local resources Low

Replace this ADD instruction with a COPY instruction. See more on SonarCloud
WORKDIR /

ENTRYPOINT [ "sh" ]
CMD ["/generateConfigFiles.sh"]
8 changes: 8 additions & 0 deletions e2e-env/myTun/config/mytun-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tunnel: "c7cd4e87-4774-4175-accc-9af09cdfb0ee"
credentials-file: /credentials.json
ingress:
- hostname: "1730191128.ervin-klicic-mytun.prestashop.name"
service: http://prestashop:80
originRequest:
httpHostHeader: "1730191128.ervin-klicic-mytun.prestashop.name"
- service: http_status:404
5 changes: 5 additions & 0 deletions e2e-env/myTun/config/mytun-credentials.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"AccountTag": "2b9cd321b1d6b45468e267f416aa9537",
"TunnelSecret": "U2F0LCAyMyBNYXIgMjAyNCAwNToxMjoyOSBHTVQ=",
"TunnelID": "c7cd4e87-4774-4175-accc-9af09cdfb0ee"
}
13 changes: 13 additions & 0 deletions e2e-env/myTun/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
services:
config-generator:
build:
context: .
dockerfile: ./config-generator.Dockerfile
volumes:
- ./config:/config:rw
environment:
ACCOUNT_TAG: ${ACCOUNT_TAG}
TUNNEL_SECRET: ${TUNNEL_SECRET}
TUNNEL_ID: ${TUNNEL_ID}
PS_DOMAIN: ${PS_DOMAIN}
Loading
Loading