From a50f9eed3f8597e0f9c651997c59752de81e05ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9siles?= <1536672+jokesterfr@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:13:17 +0200 Subject: [PATCH 1/7] fix(makefile): minor simplification --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 26c2e186..9055be3f 100644 --- a/Makefile +++ b/Makefile @@ -149,7 +149,7 @@ docker-phpunit-cov: tools/vendor 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) + @$(call in_docker,phpstan,analyse --memory-limit=-1 --configuration=./tests/phpstan/phpstan-docker.neon) define COMMENT Fixme: add "allure-framework/allure-phpunit" in composer.json to solve this. From 613435d4681d41fd6126921058e1ce98d1e15060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9siles?= <1536672+jokesterfr@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:14:00 +0200 Subject: [PATCH 2/7] wait for innodb to be initialized --- e2e-env/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index 32721fdd..d6e4e3d3 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -34,7 +34,7 @@ services: mysql: image: mariadb:${DOCKER_VERSION_MARIADB:?See e2e-env/.env.dist} healthcheck: - test: ["CMD", "healthcheck.sh", "--connect"] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] environment: - MYSQL_HOST=mysql - MYSQL_USER=prestashop From 7aee7547d66a0afe72f2593019af925049774fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9siles?= <1536672+jokesterfr@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:14:42 +0200 Subject: [PATCH 3/7] fix(ga): clarity --- .github/workflows/quality-check.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/quality-check.yml b/.github/workflows/quality-check.yml index db0fcc83..1638b18d 100644 --- a/.github/workflows/quality-check.yml +++ b/.github/workflows/quality-check.yml @@ -1,4 +1,4 @@ -name: Quality Control +name: PRs Quality Check env: NODE_BUILDER_VERSION: "20" @@ -50,13 +50,12 @@ jobs: run: make lint phpstan: - name: PHPStan + name: PHPStan for PrestaShop ${{ matrix.presta-versions }} runs-on: ubuntu-latest timeout-minutes: 15 strategy: matrix: - # @TODO: "1.6.1.24" is temporarily disabled here - ps_version: ["1.6.1.11", "1.7.8.10", "8.1.6"] + ps_version: ["1.6.1.11", "1.7.8.10", "8.1.7"] steps: - name: Checkout uses: actions/checkout@v4 From 4e420cd2ccf3e4f40853004b5a12243f34f371ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9siles?= <1536672+jokesterfr@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:15:20 +0200 Subject: [PATCH 4/7] Add CODEOWNERS --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..730b3aa2 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @PrestaShopCorp/squad-cloud-sync \ No newline at end of file From 2216cec9c32cd3de8526a3d1f18f56ad0c0fb913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9siles?= <1536672+jokesterfr@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:15:33 +0200 Subject: [PATCH 5/7] Lint documentation --- e2e/README.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/e2e/README.md b/e2e/README.md index 7d90455f..dd81530f 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -1,32 +1,33 @@ # e2e testing ps_eventbus -ps_eventbus works by listening to calls and pushing data to the Cloudsync server synchronously. -In order to test the calls made to Cloudsync, tests connect to mock Cloudsync servers using Websocket. +ps_eventbus works by listening to calls and pushing data to the CloudSync server synchronously. +In order to test the calls made to CloudSync, tests connect to mock CloudSync servers using Websocket. ## Running tests -First start e2e environment in ```e2e-env``` (see e2e-env [README.md](../e2e-env/README.md)) then simply run ```pnpm test:e2e```. +First start e2e environment in `e2e-env` (see e2e-env [README.md](../e2e-env/README.md)) then simply run `pnpm test:e2e`. ## Writing tests The `MockProbe` object allows to connect to a mock and check uploaded contents against the query we made. example : -```typescript -import { MockProbe } from './helpers/mock-probe'; -import testConfig from './helpers/test.config'; -import request from 'supertest'; -const controller = 'apiCategories'; +````typescript +import { MockProbe } from "./helpers/mock-probe"; +import testConfig from "./helpers/test.config"; +import request from "supertest"; + +const controller = "apiCategories"; const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5`; -describe('CategoriesController', () => { +describe("CategoriesController", () => { it(`${controller} should upload to collector`, async () => { // arrange const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=1&job_id=${jobId}`; // jobId starting with "valid-job-" will be considered valid by the mock sync-api and will always return 201; // other values will be rejected by the mock - const jobId = 'valid-job-1' + const jobId = "valid-job-1"; // get values sent to the mock as Observable. // only values maching the given parameter will be received, which allows to exclude values sent by other tests. // The obsevable given by ```probe()``` establishes a websocket connection with the mock only on first subscribe, @@ -36,7 +37,7 @@ describe('CategoriesController', () => { // Define a random callId. This param is set into body for define the compat with PHP 5.6, // with header 'Content-Type': 'application/x-www-form-urlencoded' - const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; + const callId = { call_id: Math.random().toString(36).substring(2, 11) }; // act // call ps_eventbus api, which should in turn upload data to the mock. @@ -44,7 +45,7 @@ describe('CategoriesController', () => { axios.post(url, callId, { headers: { Host: testConfig.prestaShopHostHeader, - 'Content-Type': 'application/x-www-form-urlencoded' // for compat PHP 5.6 + "Content-Type": "application/x-www-form-urlencoded", // for compat PHP 5.6 }, }) ); @@ -72,13 +73,13 @@ describe('CategoriesController', () => { }); }); }); -``` +```` ## Using fixtures -Fixtures for prestashop versions should be placed in [src/fixtures](src/fixtures). The correct version is loaded -automatically by ```loadFixture()```. If no fixture matches the version given by prestashop's healthcheck, +Fixtures for prestashop versions should be placed in [src/fixtures](src/fixtures). The correct version is loaded +automatically by `loadFixture()`. If no fixture matches the version given by prestashop's healthcheck, [src/fixtures/latest](src/fixtures/latest) is loaded instead. -```dumpUploadData()``` will write data in [dumps](dumps) using the same format used by ```loadFixture()``` +`dumpUploadData()` will write data in [dumps](dumps) using the same format used by `loadFixture()` to make it easier to make or update fixtures. From a9922038262136b2fe9b898ac971ad9df3b085b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9siles?= <1536672+jokesterfr@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:36:42 +0200 Subject: [PATCH 6/7] Fix mariadb update --- e2e-env/docker-compose.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index d6e4e3d3..0fb53c69 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -35,13 +35,16 @@ services: image: mariadb:${DOCKER_VERSION_MARIADB:?See e2e-env/.env.dist} healthcheck: test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + start_period: 10s + interval: 10s + timeout: 5s + retries: 3 environment: - - MYSQL_HOST=mysql - - MYSQL_USER=prestashop - - MYSQL_PASSWORD=prestashop - - MYSQL_ROOT_PASSWORD=prestashop - - MYSQL_PORT=3306 - - MYSQL_DATABASE=prestashop + - MARIADB_USER=prestashop + - MARIADB_PASSWORD=prestashop + - MARIADB_ROOT_PASSWORD=prestashop + - MARIADB_PORT=3306 + - MARIADB_DATABASE=prestashop ports: - ${HOST_PORT_BIND_MYSQL:?See e2e-env/.env.dist}:3306 networks: @@ -59,7 +62,7 @@ services: - PMA_PORT=3306 - PMA_USER=prestashop - PMA_PASSWORD=prestashop - - MYSQL_ROOT_PASSWORD=prestashop + - MARIADB_ROOT_PASSWORD=prestashop networks: - prestashop From 5840e72654eff857fed406b67a09fba19d8373cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9siles?= <1536672+jokesterfr@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:57:05 +0200 Subject: [PATCH 7/7] Align release e2e testing on PR validation --- .github/workflows/build-release-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-release-publish.yml b/.github/workflows/build-release-publish.yml index 382fd743..6937301a 100644 --- a/.github/workflows/build-release-publish.yml +++ b/.github/workflows/build-release-publish.yml @@ -18,7 +18,7 @@ jobs: if: github.event.release.tag_name != 'staging' strategy: matrix: - ps_version: ["1.7.8.10", "8.1.7"] + ps_version: ["1.6.1.11", "1.7.8.10", "8.1.7"] steps: - name: Checkout the repository uses: actions/checkout@v4