From 3ad6f0cb1cc54551d5d96059dd3ce8d543ae21d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9siles?=
<1536672+jokesterfr@users.noreply.github.com>
Date: Wed, 14 Aug 2024 12:38:37 +0200
Subject: [PATCH] Bump PS Accounts Mock to v7.0.2 (#342)
---
Makefile | 99 +++++++++++++-------------
e2e-env/init-scripts/install-module.sh | 6 +-
2 files changed, 52 insertions(+), 53 deletions(-)
diff --git a/Makefile b/Makefile
index b61e5f4c..26c2e186 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ MODULE_NAME = ps_eventbus
VERSION ?= $(shell git describe --tags 2> /dev/null || echo "v0.0.0")
SEM_VERSION ?= $(shell echo ${VERSION} | sed 's/^v//')
PACKAGE ?= ${MODULE_NAME}-${VERSION}
-PS_VERSION ?= 8.1.5
+PS_VERSION ?= 8.1.7
TESTING_IMAGE ?= prestashop/prestashop-flashlight:${PS_VERSION}
PS_ROOT_DIR ?= $(shell pwd)/prestashop/prestashop-${PS_VERSION}
@@ -11,48 +11,6 @@ export PHP_CS_FIXER_IGNORE_ENV = 1
export _PS_ROOT_DIR_ ?= ${PS_ROOT_DIR}
export PATH := ./vendor/bin:./tools/vendor/bin:$(PATH)
-define replace_version
- sed -i.bak -e "s/\(VERSION = \).*/\1\'${2}\';/" ${1}/${MODULE_NAME}.php
- sed -i.bak -e "s/\($this->version = \).*/\1\'${2}\';/" ${1}/${MODULE_NAME}.php
- sed -i.bak -e "s|\(|\1${2}]]>|" ${1}/config.xml
- rm -f ${1}/${MODULE_NAME}.php.bak ${1}/config.xml.bak
-endef
-
-define create_module
- $(eval TMP_DIR := $(shell mktemp -d))
- mkdir -p ${TMP_DIR}/${MODULE_NAME};
- cp -r $(shell cat .zip-contents) ${TMP_DIR}/${MODULE_NAME};
- $(call replace_version,${TMP_DIR}/${MODULE_NAME},${SEM_VERSION})
- ./tools/vendor/bin/autoindex prestashop:add:index ${TMP_DIR}
- cp $1 ${TMP_DIR}/${MODULE_NAME}/config/parameters.yml
- cd ${TMP_DIR}/${MODULE_NAME} && composer dump-autoload
-
- echo ${TMP_DIR}
-endef
-
-
-define zip_it
- TMP_DIR=$(call create_module,$1)
- cd ${TMP_DIR} && zip -9 -r $2 ./${MODULE_NAME};
- mv ${TMP_DIR}/$2 ./dist;
- rm -rf ${TMP_DIR:-/dev/null};
-endef
-
-define no_zip_it
- rm -rf ./dist/${MODULE_NAME}
- TMP_DIR=$(call create_module,$1)
- mv ${TMP_DIR}/${MODULE_NAME} ./dist;
- rm -rf ${TMP_DIR:-/dev/null};
-endef
-
-define in_docker
- docker run \
- --rm \
- --workdir /var/www/html/modules/${MODULE_NAME} \
- --volume $(shell pwd):/var/www/html/modules/${MODULE_NAME}:rw \
- --entrypoint $1 ${TESTING_IMAGE} $2
-endef
-
# target: default - Calling build by default
default: build
@@ -62,7 +20,7 @@ help:
@egrep "^#" Makefile
# target: clean - Clean up the repository
-.PHONY: clean
+.PHONY: clean
clean:
git -c core.excludesfile=/dev/null clean -X -d -f
@@ -123,6 +81,10 @@ prestashop/prestashop-${PS_VERSION}: prestashop composer.phar
.PHONY: test
test: composer-validate lint php-lint phpstan phpunit translation-validate
+# target: docker-test - Static and unit testing in docker
+.PHONY: docker-test
+docker-test: docker-lint docker-phpstan docker-phpunit
+
# target: composer-validate (or docker-composer-validate) - Validates composer.json and composer.lock
.PHONY: composer-validate
composer-validate: vendor
@@ -141,7 +103,8 @@ lint: php-cs-fixer php-lint
docker-lint: docker-php-cs-fixer docker-php-lint
# target: lint-fix (or docker-lint-fix) - Automatically fix the linting errors
-.PHONY: lint-fix docker-lint-fix
+.PHONY: lint-fix docker-lint-fix fix
+fix: lint-fix
lint-fix: php-cs-fixer-fix
docker-lint-fix: docker-php-cs-fixer-fix
@@ -183,15 +146,11 @@ docker-phpunit-cov: tools/vendor
# target: phpstan (or docker-phpstan) - Run phpstan
.PHONY: phpstan docker-phpstan
-phpstan: tools/vendor ${PS_ROOT_DIR}
+phpstan: tools/vendor prestashop/prestashop-${PS_VERSION}
phpstan analyse --memory-limit=-1 --configuration=./tests/phpstan/phpstan-local.neon;
docker-phpstan:
@$(call in_docker,/usr/bin/phpstan,analyse --memory-limit=-1 --configuration=./tests/phpstan/phpstan-docker.neon)
-# target: docker-test - Static and unit testing in docker
-.PHONY: docker-test
-docker-test: docker-lint docker-phpstan docker-phpunit
-
define COMMENT
Fixme: add "allure-framework/allure-phpunit" in composer.json to solve this.
Currently failing to resolve devDeps:
@@ -203,3 +162,43 @@ define COMMENT
./node_modules/.bin/allure generate build/allure-results/
endef
+
+define replace_version
+ echo "Setting up version: ${VERSION}..."
+ sed -i.bak -e "s/\(VERSION = \).*/\1\'${2}\';/" ${1}/${MODULE_NAME}.php
+ sed -i.bak -e "s/\($this->version = \).*/\1\'${2}\';/" ${1}/${MODULE_NAME}.php
+ sed -i.bak -e "s|\(|\1${2}]]>|" ${1}/config.xml
+ rm -f ${1}/${MODULE_NAME}.php.bak ${1}/config.xml.bak
+endef
+
+define create_module
+ $(eval TMP_DIR := $(shell mktemp -d))
+ mkdir -p ${TMP_DIR}/${MODULE_NAME};
+ cp -r $(shell cat .zip-contents) ${TMP_DIR}/${MODULE_NAME};
+ $(call replace_version,${TMP_DIR}/${MODULE_NAME},${SEM_VERSION})
+ ./tools/vendor/bin/autoindex prestashop:add:index ${TMP_DIR}
+ cp $1 ${TMP_DIR}/${MODULE_NAME}/config/parameters.yml
+ cd ${TMP_DIR}/${MODULE_NAME} && composer dump-autoload
+endef
+
+define zip_it
+ TMP_DIR=$(call create_module,$1)
+ cd ${TMP_DIR} && zip -9 -r $2 ./${MODULE_NAME};
+ mv ${TMP_DIR}/$2 ./dist;
+ rm -rf ${TMP_DIR};
+endef
+
+define no_zip_it
+ rm -rf ./dist/${MODULE_NAME}
+ TMP_DIR=$(call create_module,$1)
+ mv ${TMP_DIR}/${MODULE_NAME} ./dist;
+ rm -rf ${TMP_DIR:-/dev/null};
+endef
+
+define in_docker
+ docker run \
+ --rm \
+ --workdir /var/www/html/modules/${MODULE_NAME} \
+ --volume $(shell pwd):/var/www/html/modules/${MODULE_NAME}:rw \
+ --entrypoint $1 ${TESTING_IMAGE} $2
+endef
diff --git a/e2e-env/init-scripts/install-module.sh b/e2e-env/init-scripts/install-module.sh
index 30272c97..9282983c 100755
--- a/e2e-env/init-scripts/install-module.sh
+++ b/e2e-env/init-scripts/install-module.sh
@@ -18,9 +18,9 @@ run_user() {
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"
+ PS_ACCOUNTS_MOCK_VERSION="v7.0.2"
+ echo "* [ps_accounts_mock] downloading..."
+ 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..."
run_user unzip -qq /tmp/ps_accounts.zip -d /var/www/html/modules
echo "* [ps_accounts_mock] installing the module..."