Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into test/ci-ps-php-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
davidPrestashop committed Oct 18, 2024
2 parents e15efe4 + b9d16b5 commit e57dbad
Show file tree
Hide file tree
Showing 51 changed files with 3,411 additions and 2,137 deletions.
7 changes: 3 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
end_of_line = lf
indent_size = 2
trim_trailing_whitespace = true
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
Expand Down
2 changes: 1 addition & 1 deletion .github/mktp-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"channel": "stable",
"type_upgrade": "updatemin",
"product_type": "module",
"compatible_from": "1.7.0.0"
"compatible_from": "1.6.1.11"
}
35 changes: 35 additions & 0 deletions .github/workflows/quality-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,38 @@ jobs:
docker compose logs cloudsync-mock prestashop
docker compose down -v
working-directory: e2e-env

e2e-lint:
name: Lint E2E tests
runs-on: ubuntu-latest
timeout-minutes: 30
if: ${{ github.event_name == 'pull_request' }}
steps:
- 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: ${{ env.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 dependencies
run: pnpm install --no-optional --force
working-directory: e2e

- name: Lint test files
run: pnpm lint && pnpm format
working-directory: e2e
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,36 @@ SHELL=/bin/bash -o pipefail
MODULE_NAME = ps_eventbus
VERSION ?= $(shell git describe --tags 2> /dev/null || echo "v0.0.0")
SEM_VERSION ?= $(shell echo ${VERSION} | sed 's/^v//')
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD | sed -e 's/\//_/g')
PACKAGE ?= ${MODULE_NAME}-${VERSION}
PS_VERSION ?= 8.1.7
TESTING_IMAGE ?= prestashop/prestashop-flashlight:${PS_VERSION}
PS_ROOT_DIR ?= $(shell pwd)/prestashop/prestashop-${PS_VERSION}
WORKDIR ?= ./

export PHP_CS_FIXER_IGNORE_ENV = 1
export _PS_ROOT_DIR_ ?= ${PS_ROOT_DIR}
export PATH := ./vendor/bin:./tools/vendor/bin:$(PATH)

# target: default - Calling build by default
# target: (default) - Build the module
default: build

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

# target: help - Get help on this file
.PHONY: help
help:
@egrep "^#" Makefile
@echo -e "##\n# ${MODULE_NAME}:\n# version: ${VERSION}\n# branch: ${BRANCH_NAME}\n##"
@egrep "^# target" Makefile

# target: clean - Clean up the repository
.PHONY: clean
clean:
git -c core.excludesfile=/dev/null clean -X -d -f
git clean -fdX --exclude="!.npmrc" --exclude="!.env*"

# target: zip - Make zip bundles
# target: zip - Make all zip bundles
.PHONY: zip
zip: zip-prod zip-inte zip-e2e

Expand All @@ -48,10 +55,6 @@ zip-prod: vendor tools/vendor dist
zip-unzipped: vendor tools/vendor dist
@$(call no_zip_it,.config.prod.yml)

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

dist:
@mkdir -p ./dist

Expand Down Expand Up @@ -157,12 +160,10 @@ define COMMENT
- allure-framework/allure-phpunit v2.1.0 requires phpunit/phpunit ^9 -> found phpunit/phpunit[9.0.0, ..., 9.6.4] but it conflicts with your root composer.json require (^10.0.14).
allure:
./node_modules/.bin/allure serve build/allure-results/

allure-report:
./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
Expand Down
46 changes: 26 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

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

### Product Images Issue in PHP 8.1

Please note that starting from PHP 8.1, product images may be missing due to a known issue.
This is a recognized problem and is being tracked in the PrestaShop repository.
You can follow the progress and find more details about the resolution [here](https://github.com/PrestaShop/PrestaShop/issues/36836).

## Use

```sh
Expand Down Expand Up @@ -41,7 +47,7 @@ make docker-<stuff> # same as above, but in a docker container
## Healthiness

To check the module healthiness (authentified route):
To check the module healthiness (authenticated route):

```sh
BASE_URL="http://localhost:8000"
Expand All @@ -62,7 +68,7 @@ curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiHealt
}
```

To check the fallback route (unauthentified):
To check the fallback route (unauthenticated):

```sh
BASE_URL="http://localhost:8000"
Expand Down Expand Up @@ -91,24 +97,24 @@ Dev requirements:
- [gd](https://www.php.net/manual/en/book.image.php)
- [zip](https://www.php.net/manual/en/book.zip.php)

Or an up to date [Docker engine](https://docs.docker.com/engine/install).

## List of missing data in database and why is missing

| Object content | Reason | Added in PS version | Link with more info |
|:----------------------------------:|:--------------------:|:-------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| currency.precision | row missing in table | 1.7.6.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/37807f66b40b0cebb365ef952e919be15e9d6b2f#diff-3f41d3529ffdbfd1b994927eb91826a32a0560697025a734cf128a2c8e092a45R124) |
| employee.has_enabled_gravatar | row missing in table | 1.7.8.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/20f1d9fe8a03559dfa9d1f7109de1f70c99f1874#diff-cde6a9d4a58afb13ff068801ee09c0e712c5e90b0cbf5632a0cc965f15cb6802R107) |
| product.additional_delivery_time | row missing in table | 1.7.3.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/10268af8db4163dc2a02edb8da93d02f37f814d8#diff-e94a594ba740485c7a4882b333984d3932a2f99c0d6d0005620745087cce7a10R260) |
| product.delivery_in_stock | row missing in table | 1.7.3.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/10268af8db4163dc2a02edb8da93d02f37f814d8#diff-e94a594ba740485c7a4882b333984d3932a2f99c0d6d0005620745087cce7a10R260) |
| product.delivery_out_stock | row missing in table | 1.7.3.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/10268af8db4163dc2a02edb8da93d02f37f814d8#diff-e94a594ba740485c7a4882b333984d3932a2f99c0d6d0005620745087cce7a10R260) |
| stock.location | row missing in table | 1.7.5.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/4c7d58a905dfb61c7fb2ef4a1f9b4fab2a8d8ecb#diff-e57fb1deeaab9e9079505333394d58f0bf7bb40280b4382aad1278c08c73e2e8R58) |
| store_lang | table missing | 1.7.3.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/7dda2be62d8bd606edc269fa051c36ea68f81682#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2004) |
| wishlist¹ | table missing | n/a | [Prestashop Addons](https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html) |
| taxonomy² | table missing | n/a | [Prestashop Addons](https://addons.prestashop.com/fr/produits-sur-facebook-reseaux-sociaux/50291-prestashop-social-with-facebook-instagram.htmll) |
| stock_available. physical_quantity | row missing in table | 1.7.2.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186) |
| stock_available. reserved_quantity | row missing in table | 1.7.2.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186) |
| languages.locale | row missing in table | 1.7.0.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/481111b8274ed005e1c4a8ce2cf2b3ebbeb9a270#diff-c123d3d30d9c9e012a826a21887fccce6600a2f2a848a58d5910e55f0f8f5093R41) |
Or an up-to-date [Docker engine](https://docs.docker.com/engine/install).

## List of missing data in a database and why is missing

| Object content | Reason | Added in PS version | Link with more info |
|:----------------------------------:|:--------------------:|:-------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| currency.precision | row missing in table | 1.7.6.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/37807f66b40b0cebb365ef952e919be15e9d6b2f#diff-3f41d3529ffdbfd1b994927eb91826a32a0560697025a734cf128a2c8e092a45R124) |
| employee.has_enabled_gravatar | row missing in table | 1.7.8.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/20f1d9fe8a03559dfa9d1f7109de1f70c99f1874#diff-cde6a9d4a58afb13ff068801ee09c0e712c5e90b0cbf5632a0cc965f15cb6802R107) |
| product.additional_delivery_time | row missing in table | 1.7.3.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/10268af8db4163dc2a02edb8da93d02f37f814d8#diff-e94a594ba740485c7a4882b333984d3932a2f99c0d6d0005620745087cce7a10R260) |
| product.delivery_in_stock | row missing in table | 1.7.3.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/10268af8db4163dc2a02edb8da93d02f37f814d8#diff-e94a594ba740485c7a4882b333984d3932a2f99c0d6d0005620745087cce7a10R260) |
| product.delivery_out_stock | row missing in table | 1.7.3.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/10268af8db4163dc2a02edb8da93d02f37f814d8#diff-e94a594ba740485c7a4882b333984d3932a2f99c0d6d0005620745087cce7a10R260) |
| stock.location | row missing in table | 1.7.5.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/4c7d58a905dfb61c7fb2ef4a1f9b4fab2a8d8ecb#diff-e57fb1deeaab9e9079505333394d58f0bf7bb40280b4382aad1278c08c73e2e8R58) |
| store_lang | table missing | 1.7.3.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/7dda2be62d8bd606edc269fa051c36ea68f81682#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2004) |
| wishlist¹ | table missing | n/a | [Prestashop Addons](https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html) |
| taxonomy² | table missing | n/a | [Prestashop Addons](https://addons.prestashop.com/fr/produits-sur-facebook-reseaux-sociaux/50291-prestashop-social-with-facebook-instagram.htmll) |
| stock_available. physical_quantity | row missing in table | 1.7.2.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186) |
| stock_available. reserved_quantity | row missing in table | 1.7.2.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186) |
| languages.locale | row missing in table | 1.7.0.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/481111b8274ed005e1c4a8ce2cf2b3ebbeb9a270#diff-c123d3d30d9c9e012a826a21887fccce6600a2f2a848a58d5910e55f0f8f5093R41) |

¹ Feature enabled only with PsWishlist module</br>
² Feature enabled only with PsFacebook module
2 changes: 0 additions & 2 deletions controllers/front/apiHealthCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ class ps_EventbusApiHealthCheckModuleFrontController extends AbstractApiControll
*/
public function init()
{
/*
try {
parent::init();
} catch (UnauthorizedException $exception) {
$this->isAuthentifiedCall = false;
}
*/
}

/**
Expand Down
28 changes: 22 additions & 6 deletions e2e-env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
## Introduction

Enabling the startup of a complete stack to perform e2e tests on `ps_eventbus`.
stack consists of the following elements:
Stack consists of the following elements:

- A storefront under Flashlight (with a mock of `ps_account` and a local link to `ps_eventbus`);
- A MySQL database;
- PHPMyAdmin;
- A mock of the CloudSync APIs.

For the CloudSync APIs mock, it is a NodeJS application simulating the CloudSync APIs. Requests made by `ps_eventbus` to CloudSync are redirected to the mock using a reverse proxy (nginx).
When a request reaches the mock, it utilizes WebSockets to transmit the said request from `ps_eventbus` to the E2E tests, allowing validation of the information coming out of `ps_eventbus`.
For the CloudSync APIs mock, it is a Node.js application simulating the CloudSync APIs. Requests made by `ps_eventbus` to CloudSync are redirected to the mock using a reverse proxy (nginx).
When a request reaches the mock, it uses WebSockets to transmit the said request from `ps_eventbus` to the E2E tests, allowing validation of the information coming out of `ps_eventbus`.

## Troubleshooting

The end-to-end environment relies on PrestaShop Flashlight, which by default runs scripts and php with the user `www-data`. This user is mapped on the uid/gid _1000_, which might perfectly match your own Linux system user.

However, if for any reason your uid is not 1000, you might disable code mentioned with this comment : `# Notice: you might enable this if your uid is not 1000, or encounter permission issues`. One thing you will loose, is the ability to hot-reload local vendors on your host to the guest docker container. Docker compose down/up will be your friend in that very case.

If you are a MacOS user, mounting a docker won't cause any issue, as the process isolation is greater (and slower).
If you are a macOS user, mounting a docker won't cause any issue, as the process isolation is greater (and slower).

## Start the environment

Expand All @@ -41,12 +41,28 @@ Or in detached mode:
docker compose up -d
```

Or specifically only starting PrestaShop (and its dependencies) with special commands to be sure your containers and volumes will be recreacted/renewed:
Or specifically, only starting PrestaShop (and its dependencies) with special commands to be sure your containers and volumes will be recreacted/renewed:

```shell
docker compose up prestashop --force-recreate --renew-anon-volumes
```

## Testing

Simple!

Is the module healthy?

```sh
curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck&job_id=valid-job-1" | jq .
```

Capture orders:

```sh
curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiOrders&job_id=valid-job-1" | jq .
```

## Make changes to the mock

If you need to make change to the mocks, they can be built and run locally using scripts in `package.json`.
Expand All @@ -58,4 +74,4 @@ docker compose build --no-cache

## Usage

Once the environment is running, simply navigate to the e2e directory and run the e2e tests.
Once the environment is running, navigate to the e2e directory and run the e2e tests.
9 changes: 9 additions & 0 deletions e2e/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
);
32 changes: 21 additions & 11 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,35 @@
"scripts": {
"test:e2e": "jest --config=jest.config.json",
"test:e2e:watch": "jest --config=jest.config.json --watchAll",
"test:e2e:detectOpenHandles": "jest --config=jest.config.json --detectOpenHandles"
"test:e2e:detectOpenHandles": "jest --config=jest.config.json --detectOpenHandles",
"lint": "eslint 'src/**/*.ts'",
"lint:fix": "eslint 'src/**/*.ts' --fix",
"format": "prettier --check ./src",
"format:fix": "prettier --write ./src",
"fix": "pnpm format:fix && pnpm lint:fix"
},
"devDependencies": {
"@eslint/js": "^9.10.0",
"@jest/globals": "^29.7.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.12",
"@types/ramda": "^0.30.0",
"@types/eslint__js": "^8.42.3",
"@types/jest": "^29.5.13",
"@types/node": "^22.5.4",
"@types/ramda": "^0.30.2",
"@types/semver": "^7.5.8",
"@types/ws": "^8.5.10",
"axios": "^1.6.8",
"@types/ws": "^8.5.12",
"axios": "^1.7.7",
"eslint": "^9.10.0",
"jest": "^29.7.0",
"jest-expect-message": "^1.1.3",
"jest-extended": "^4.0.2",
"jest-mock-extended": "^3.0.7",
"ramda": "^0.30.0",
"prettier": "^3.3.3",
"ramda": "^0.30.1",
"rxjs": "^7.8.1",
"ts-jest": "^29.1.2",
"typescript": "^5.4.5",
"ws": "^8.17.1"
"ts-jest": "^29.2.5",
"typescript": "^5.6.2",
"typescript-eslint": "^8.5.0",
"ws": "^8.18.0"
},
"engines": {
"yarn": "please use pnpm",
Expand All @@ -32,6 +42,6 @@
"pnpm": ">=8"
},
"dependencies": {
"semver": "^7.6.2"
"semver": "^7.6.3"
}
}
Loading

0 comments on commit e57dbad

Please sign in to comment.