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

Add support for PrestaShop 1.6.1.24 #185

Merged
merged 41 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
fb16f13
add missing dependencies
synicko Jul 31, 2023
6905c5a
Merge branch 'main' into test/1.6.1.24
synicko Aug 28, 2023
ed8514a
fix lint
synicko Aug 29, 2023
a84dd34
try and pass checks
synicko Aug 29, 2023
5573aa1
try and pass checks
synicko Aug 29, 2023
903172a
try and pass checks
synicko Aug 29, 2023
5893fa5
should be better
synicko Aug 29, 2023
c04a841
does it work now ?
synicko Aug 29, 2023
f27aee2
try again
synicko Aug 29, 2023
282e779
should pass checks ?
synicko Aug 30, 2023
9942d18
fix composer.lock
synicko Aug 30, 2023
75eae15
cleaner MakeFile
synicko Aug 30, 2023
798273f
update README
synicko Aug 30, 2023
a34b13d
Improve version checking against PrestaShop
jokesterfr Oct 30, 2023
48120e8
Merge branch 'main' into fix/improve-version-check
jokesterfr Oct 31, 2023
d2954c8
Merge branch 'main' into test/1.6.1.24
jokesterfr Nov 16, 2023
cdd979d
Merge branch 'main' into fix/improve-version-check
jokesterfr Nov 17, 2023
6f3f58d
Add more info
jokesterfr Nov 17, 2023
a070d6a
Packaging enhancement
jokesterfr Nov 17, 2023
cbbd100
Extend support
jokesterfr Nov 21, 2023
135f3d1
Merge branch 'main' into test/1.6.1.24
jokesterfr Nov 22, 2023
f081341
Merge branch 'fix/improve-version-check' into test/1.6.1.24
jokesterfr Nov 22, 2023
5750bb0
Update README.md
jokesterfr Nov 23, 2023
052132b
Merge branch 'main' into test/1.6.1.24
jokesterfr Nov 23, 2023
8434e60
Merge branch 'test/1.6.1.24' of github.com:PrestaShopCorp/ps_eventbus…
jokesterfr Nov 23, 2023
c381e56
Do not call composer on prestashop 1.6.1.24
jokesterfr Nov 23, 2023
a5f638c
Fix sed
jokesterfr Nov 23, 2023
d39d709
Fix bash
jokesterfr Nov 23, 2023
03c26c2
Temporarily disable 1.6 PHPStan checks
jokesterfr Nov 23, 2023
78593c3
Default to 8.1.1
jokesterfr Nov 23, 2023
a0cb6c2
Add contribution note
jokesterfr Nov 23, 2023
fa45a4c
Avoid verbose git clone
jokesterfr Nov 23, 2023
b5ebb7b
Document required extensions
jokesterfr Nov 23, 2023
fb4e7d4
fix: phpstan
fox-john Nov 23, 2023
fa23860
Merge branch 'test/1.6.1.24' of https://github.com/PrestaShopCorp/ps_…
fox-john Nov 23, 2023
c30a167
fix: php-cs-fixer
fox-john Nov 23, 2023
668f077
fix: phpstan return
fox-john Nov 23, 2023
e48451f
fix: phpstan
fox-john Nov 23, 2023
a068af8
fix: phpstan
fox-john Nov 23, 2023
1c9221c
fix: phpstan ...
fox-john Nov 23, 2023
2cb8e63
fix: phpstan for 1.6
fox-john Nov 23, 2023
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
7 changes: 4 additions & 3 deletions .github/workflows/quality-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
presta_version: ["1.7.8.7"]
ps_version: ["1.7.8.10", "8.1.1"]
# @TODO: "1.6.1.24" is temporarily disabled here
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -61,8 +62,8 @@ jobs:
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}
- name: PHPStan PrestaShop 1.7.8.7
run: PS_VERSION="1.7.8.7" make phpstan
- name: PHPStan PrestaShop ${{ matrix.ps_version }}
run: PS_VERSION="${{ matrix.ps_version }}" make phpstan

phpunit:
name: PHP Unit
Expand Down
50 changes: 30 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BUILDPLATFORM ?= linux/amd64
TESTING_DOCKER_IMAGE ?= ps-eventbus-testing:latest
TESTING_DOCKER_BASE_IMAGE ?= phpdockerio/php80-cli
PHP_VERSION ?= 8.2
PS_VERSION ?= 1.7.8.7
PS_VERSION ?= 8.1.1
PS_ROOT_DIR ?= $(shell pwd)/prestashop/prestashop-${PS_VERSION}

# target: default - Calling build by default
Expand Down Expand Up @@ -70,7 +70,7 @@ zip-prod: vendor dist .config.prod.yml
@$(call zip_it,.config.prod.yml,${PACKAGE}.zip)

# target: build - Setup PHP & Node.js locally
build: vendor
build: vendor tools-vendor

composer.phar:
@php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');";
Expand All @@ -80,22 +80,30 @@ composer.phar:
vendor: composer.phar
./composer.phar install --no-dev -o;

vendor/bin/php-cs-fixer: composer.phar
tools-vendor: composer.phar
./composer.phar install --working-dir tools -o;

tools/vendor/bin/php-cs-fixer: composer.phar
./composer.phar install --ignore-platform-reqs
./composer.phar install --working-dir tools --ignore-platform-reqs

vendor/bin/phpunit: composer.phar
tools/vendor/bin/phpunit: composer.phar
./composer.phar install --ignore-platform-reqs
./composer.phar install --working-dir tools --ignore-platform-reqs

vendor/bin/phpstan: composer.phar
tools/vendor/bin/phpstan: composer.phar
./composer.phar install --ignore-platform-reqs
./composer.phar install --working-dir tools --ignore-platform-reqs

prestashop:
@mkdir -p ./prestashop

prestashop/prestashop-${PS_VERSION}: prestashop composer.phar
@if [ ! -d "prestashop/prestashop-${PS_VERSION}" ]; then \
git clone --depth 1 --branch ${PS_VERSION} https://github.com/PrestaShop/PrestaShop.git prestashop/prestashop-${PS_VERSION}; \
./composer.phar -d ./prestashop/prestashop-${PS_VERSION} install; \
git clone --depth 1 --branch ${PS_VERSION} https://github.com/PrestaShop/PrestaShop.git prestashop/prestashop-${PS_VERSION} > /dev/null; \
if [ "${PS_VERSION}" != "1.6.1.24" ]; then \
./composer.phar -d ./prestashop/prestashop-${PS_VERSION} install; \
fi \
fi;

# target: test - Static and unit testing
Expand All @@ -110,33 +118,35 @@ translation-validate:
php tests/translation.test.php

# target: lint - Lint the code and expose errors
lint: vendor/bin/php-cs-fixer
@PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no;
lint: tools/vendor/bin/php-cs-fixer
@PHP_CS_FIXER_IGNORE_ENV=1 tools/vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no;

# target: lint-fix - Lint the code and fix it
lint-fix: vendor/bin/php-cs-fixer
@PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --using-cache=no;
lint-fix: tools/vendor/bin/php-cs-fixer
@PHP_CS_FIXER_IGNORE_ENV=1 tools/vendor/bin/php-cs-fixer fix --using-cache=no;

# target: php-lint - Use php linter to check the code
php-lint:
@git ls-files | grep -E '.*\.(php)' | xargs -n1 php -l -n | (! grep -v "No syntax errors" );
@echo "php $(shell php -r 'echo PHP_VERSION;') lint passed";

# target: phpunit - Run phpunit tests
phpunit: vendor/bin/phpunit
vendor/bin/phpunit --configuration=./tests/phpunit.xml;
phpunit: tools/vendor/bin/phpunit
tools/vendor/bin/phpunit --configuration=./tests/phpunit.xml;

# target: phpunit-coverage - Run phpunit with coverage and allure
phpunit-coverage: vendor/bin/phpunit
php -dxdebug.mode=coverage vendor/bin/phpunit --coverage-html ./coverage-reports/coverage-html --configuration=./tests/phpunit-coverage.xml;
phpunit-coverage: tools/vendor/bin/phpunit
php -dxdebug.mode=coverage tools/vendor/bin/phpunit --coverage-html ./coverage-reports/coverage-html --configuration=./tests/phpunit-coverage.xml;

# target: phpstan - Run phpstan
phpstan: vendor/bin/phpstan prestashop/prestashop-${PS_VERSION}
_PS_ROOT_DIR_=${PS_ROOT_DIR} vendor/bin/phpstan analyse --memory-limit=256M --configuration=./tests/phpstan/phpstan.neon;
phpstan: tools/vendor/bin/phpstan prestashop/prestashop-${PS_VERSION}
sed -i -e 's|%currentWorkingDirectory%/vendor|%currentWorkingDirectory%/tools/vendor|g' ./tools/vendor/prestashop/php-dev-tools/phpstan/ps-module-extension.neon
_PS_ROOT_DIR_=${PS_ROOT_DIR} tools/vendor/bin/phpstan analyse --memory-limit=256M --configuration=./tests/phpstan/phpstan.neon;

# target: phpstan-baseline - Generate a phpstan baseline to ignore all errors
phpstan-baseline: prestashop/prestashop-${PS_VERSION} vendor/bin/phpstan
_PS_ROOT_DIR_=${PS_ROOT_DIR} vendor/bin/phpstan analyse --generate-baseline --memory-limit=256M --configuration=./tests/phpstan/phpstan.neon;
phpstan-baseline: prestashop/prestashop-${PS_VERSION} tools/vendor/bin/phpstan
sed -i -e 's|%currentWorkingDirectory%/vendor|%currentWorkingDirectory%/tools/vendor|g' ./tools/vendor/prestashop/php-dev-tools/phpstan/ps-module-extension.neon
_PS_ROOT_DIR_=${PS_ROOT_DIR} tools/vendor/bin/phpstan analyse --generate-baseline --memory-limit=256M --configuration=./tests/phpstan/phpstan.neon;

# target: docker-test - Static and unit testing in docker
docker-test: docker-lint docker-phpstan docker-phpunit
Expand Down Expand Up @@ -186,7 +196,7 @@ run-docker-actions-177:
all-tests-actions-177:
make rda177
make bps177
docker exec -i prestashop-177 sh -c "cd /var/www/html/modules/ps_eventbus && php vendor/bin/phpunit -c tests/phpunit.xml"
docker exec -i prestashop-177 sh -c "cd /var/www/html/modules/ps_eventbus && php tools/vendor/bin/phpunit -c tests/phpunit.xml"

# Fixme: add "allure-framework/allure-phpunit" in composer.json to solve this.
# Currently failing to resolve devDeps:
Expand Down
46 changes: 41 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

## Compatibility matrix

| PrestaShop platform | PS EventBus |
|---------------------|----------------|
| 8.0 | 2.x - PHP 7.1+ |
| 1.7.0-1.7.8 | 2.x - PHP 7.1+ |
| 1.6.1.x | No |
| PrestaShop platform | PHP | PS EventBus |
| ------------------- | ---- | ----------- |
| 8.0 | 7.1+ | From 2.x |
| 1.7.0-1.7.8 | 7.1+ | From 2.x |
| 1.6.1.24 | 7.1 | From 3.x |

PS Accounts compatibility matrix [can be viewed here](https://github.com/PrestaShopCorp/ps_accounts#compatibility-matrix).

Expand Down Expand Up @@ -39,3 +39,39 @@ make docker-<stuff> # same as above, but within a docker container
```

> Note: you will need [xdebug](https://xdebug.org/) if you want to generate the code-coverage of this project. You may install it with: `pecl install -f xdebug`.

## Healthiness

To check the module healthiness:

```sh
BASE_URL="http://localhost:8000"
curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck" | jq .
{
"prestashop_version": "1.6.1.24",
"ps_eventbus_version": "x.y.z",
"ps_accounts_version": "5.6.2",
"php_version": "7.1.33",
"ps_account": true,
"is_valid_jwt": true,
"ps_eventbus": true,
"env": {
"EVENT_BUS_PROXY_API_URL": "http://reverse-proxy/collector",
"EVENT_BUS_SYNC_API_URL": "http://reverse-proxy/sync-api"
},
"httpCode": 200
}
```

## Contribute

Dev requirements:

- PHP 8.2.12
- PHP Extensions
- [DOM](https://www.php.net/manual/en/book.dom.php)
- [SimpleXML](https://www.php.net/manual/en/book.simplexml.php)
- [gd](https://www.php.net/manual/en/book.image.php)
- [zip](https://www.php.net/manual/en/book.zip.php)

Or an up to dat [Docker engine](https://docs.docker.com/engine/install).
13 changes: 4 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,9 @@
"prestashop/prestashop-accounts-installer": "^1.0.0",
"sentry/sentry": "^1.11.0",
"php-http/message": "<1.15.0",
"psr/http-message": "<1.1"
},
"require-dev": {
"prestashop/php-dev-tools": "^4.3",
"phpunit/phpunit": "^10.1.3",
"phpunit/php-code-coverage": "^10.1.1",
"phpstan/phpstan": "^1.10.15",
"friendsofphp/php-cs-fixer": "^3.16.0",
"phpseclib/phpseclib": "^3.0.19"
"psr/http-message": "<1.1",
"symfony/config": "^3.4",
"symfony/dependency-injection": "^3.4",
"symfony/yaml": "^3.4"
}
}
Loading