Skip to content

Commit

Permalink
Bump PS Accounts Mock to v7.0.2 (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
jokesterfr authored Aug 14, 2024
1 parent abcedc0 commit 3ad6f0c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 53 deletions.
99 changes: 49 additions & 50 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,14 @@ 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}

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|\(<version><!\[CDATA\[\)[0-9a-z.-]\{1,\}]]></version>|\1${2}]]></version>|" ${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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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|\(<version><!\[CDATA\[\)[0-9a-z.-]\{1,\}]]></version>|\1${2}]]></version>|" ${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
6 changes: 3 additions & 3 deletions e2e-env/init-scripts/install-module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down

0 comments on commit 3ad6f0c

Please sign in to comment.