Skip to content

Commit

Permalink
chore(ci): fix PHPStan and e2e-env errors (#280)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Renard <[email protected]>
Co-authored-by: John.R <[email protected]>
  • Loading branch information
3 people authored May 23, 2024
1 parent ee6cdd0 commit e295b3e
Show file tree
Hide file tree
Showing 13 changed files with 4,487 additions and 3,693 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/quality-check.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Quality Control

env:
DOCKER_COMPOSE_VERSION: v2.23.3
DOCKER_COMPOSE_VERSION: v2.27.0

on:
pull_request:
Expand Down Expand Up @@ -58,8 +58,8 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
ps_version: ["1.7.8.10", "8.1.1"]
# @TODO: "1.6.1.24" is temporarily disabled here
ps_version: ["1.7.8.10", "8.1.6"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
strategy:
matrix:
ps_version: [ "1.7.8.10", "8.1.1", "latest" ]
ps_version: ["1.7.8.10", "8.1.6", "nightly"]
steps:
- name: Checkout the repository
uses: actions/checkout@v4
Expand All @@ -107,7 +107,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
cache: "pnpm"
cache-dependency-path: e2e/pnpm-lock.yaml

- name: Cache vendor folder
Expand All @@ -126,7 +126,7 @@ jobs:
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
- name: Install dependencies and setup e2e
run: pnpm install --no-optional
run: pnpm install --no-optional --force
working-directory: e2e

- name: Setup e2e-env with Prestashop ${{ matrix.ps_version }}
Expand All @@ -141,3 +141,10 @@ jobs:
- name: Run e2e:tests with Prestashop ${{ matrix.ps_version }}
run: pnpm test:e2e
working-directory: e2e

- name: More logs on failure
if: failure()
run: |
docker compose logs cloudsync-mock
docker compose down -v
working-directory: e2e-env
24 changes: 5 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ VERSION ?= $(shell git describe --tags 2> /dev/null || echo "v0.0.0")
SEM_VERSION ?= $(shell echo ${VERSION} | sed 's/^v//')
PACKAGE ?= ${MODULE_NAME}-${VERSION}
PHP_VERSION ?= 8.1
PS_VERSION ?= 8.1.3
PS_VERSION ?= 8.1.5
TESTING_IMAGE ?= prestashop/prestashop-flashlight:${PS_VERSION}
PS_ROOT_DIR ?= $(shell pwd)/prestashop/prestashop-${PS_VERSION}

Expand All @@ -31,13 +31,6 @@ define create_module
echo ${TMP_DIR}
endef

define in_docker
docker run \
--env _PS_ROOT_DIR_=/var/www/html \
--workdir /var/www/html/modules/${MODULE_NAME} \
--volume $(shell pwd):/var/www/html/modules/${MODULE_NAME}:rw \
--entrypoint $1 ${TESTING_IMAGE} $2
endef

define zip_it
TMP_DIR=$(call create_module,$1)
Expand All @@ -55,7 +48,6 @@ endef

define in_docker
docker run \
--env _PS_ROOT_DIR_=/var/www/html \
--workdir /var/www/html/modules/${MODULE_NAME} \
--volume $(shell pwd):/var/www/html/modules/${MODULE_NAME}:rw \
--entrypoint $1 ${TESTING_IMAGE} $2
Expand Down Expand Up @@ -115,7 +107,6 @@ vendor: composer.phar

tools/vendor: composer.phar vendor
./composer.phar install --working-dir tools -o;
sed -i -e 's|%currentWorkingDirectory%/vendor|%currentWorkingDirectory%/tools/vendor|g' ./tools/vendor/prestashop/php-dev-tools/phpstan/ps-module-extension.neon

prestashop:
@mkdir -p ./prestashop
Expand Down Expand Up @@ -192,15 +183,10 @@ docker-phpunit-cov: tools/vendor

# target: phpstan (or docker-phpstan) - Run phpstan
.PHONY: phpstan docker-phpstan
phpstan: tools/vendor prestashop/prestashop-${PS_VERSION}
phpstan analyse --memory-limit=256M --configuration=./tests/phpstan/phpstan.neon;
docker-phpstan: tools/vendor
@$(call in_docker,make,phpstan)

# target: phpstan-baseline - Generate a phpstan baseline to ignore all errors
.PHONY: phpstan-baseline
phpstan-baseline: prestashop/prestashop-${PS_VERSION} phpstan
phpstan analyse --generate-baseline --memory-limit=256M --configuration=./tests/phpstan/phpstan.neon;
phpstan: tools/vendor ${PS_ROOT_DIR}
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
Expand Down
3 changes: 2 additions & 1 deletion e2e-env/cloudsync-mock/.swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"decorators": false,
"dynamicImport": false
}
}
},
"minify": false
}
7 changes: 5 additions & 2 deletions e2e-env/cloudsync-mock/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ RUN npm install -g pnpm

WORKDIR /home/node
ADD . /home/node
RUN pnpm install
RUN pnpm run build

# Avoid "failed to compile" error from ARM deps shipped in pnpm-lock.yaml
RUN rm pnpm-lock.yaml \
&& pnpm install \
&& pnpm run build

ENTRYPOINT [ "pnpm" ]
CMD [ "start" ]
22 changes: 11 additions & 11 deletions e2e-env/cloudsync-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cloudsync-mock",
"version": "0.0.0",
"main": "dist/app.js",
"main": "dist/src/app.js",
"type": "module",
"private": true,
"engines": {
Expand All @@ -11,7 +11,7 @@
"pnpm": ">=8"
},
"scripts": {
"start": "node dist/app.js",
"start": "node dist/src/app.js",
"start:dev": "nodemon",
"build": "npx swc ./src -d ./dist && pnpm fix-esm-js-ext",
"fix-esm-js-ext": "find ./dist -type f -name '*.js' -exec sed -i -E 's/import (.+) from (\\x22|\\x27)\\.\\/([^.]+)(\\.ts|\\.js)?(\\x22|\\x27)/import \\1 from \"\\.\\/\\3.js\"/g' {} \\;",
Expand All @@ -24,18 +24,18 @@
"express": "^4.19.2"
},
"devDependencies": {
"@swc/cli": "^0.1.63",
"@swc/core": "^1.3.100",
"@swc/cli": "^0.3.12",
"@swc/core": "^1.5.6",
"@types/express": "^4.17.21",
"@types/node": "^20.10.4",
"@types/node": "^20.12.12",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"eslint": "^8.55.0",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"eslint": "^9.2.0",
"eslint-plugin-import": "^2.29.1",
"nodemon": "^3.0.2",
"rimraf": "^5.0.5",
"typescript": "^5.3.3",
"ws": "^8.16.0",
"nodemon": "^3.1.0",
"rimraf": "^5.0.7",
"typescript": "^5.4.5",
"ws": "^8.17.0",
"@types/multer": "^1.4.11",
"multer": "^1.4.5-lts.1"
}
Expand Down
Loading

0 comments on commit e295b3e

Please sign in to comment.