Skip to content

Commit

Permalink
DES-2 Upgrade to Sylius 1.13 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslavtyc authored Feb 12, 2025
1 parent b9bcac3 commit 184111e
Show file tree
Hide file tree
Showing 55 changed files with 1,085 additions and 359 deletions.
75 changes: 39 additions & 36 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
version: 2.1

workflows:
sylius1.11-php8.0:
jobs:
- build:
name: php-<<matrix.php_version>>-sylius-<< matrix.sylius_version >>-symfony-<< matrix.symfony_version >>
matrix:
parameters:
php_version:
- "8.0"
sylius_version:
- "1.11"
symfony_version:
- "5.4"
sylius1.12-php8.0:
jobs:
- build:
Expand All @@ -21,25 +9,26 @@ workflows:
parameters:
php_version: [ "8.0" ]
sylius_version: [ "1.12" ]
symfony_version: [ "5.4", "6.0" ]
sylius1.11-php8.1+:
symfony_version: [ "6.0" ]
sylius1.12-php8.1+:
jobs:
- build:
name: php-<<matrix.php_version>>-sylius-<< matrix.sylius_version >>-symfony-<< matrix.symfony_version >>
matrix:
parameters:
sylius_version: [ "1.11" ]
symfony_version: [ "5.4" ]
php_version: [ "8.1", "8.2" ]
sylius1.12-php8.1+:
sylius_version: [ "1.12" ]
php_version: [ "8.1", "8.2", "8.3" ]
symfony_version: [ "6.0", "6.1", "6.2", "6.3", "6.4" ]

sylius1.13-php8.1+:
jobs:
- build:
name: php-<<matrix.php_version>>-sylius-<< matrix.sylius_version >>-symfony-<< matrix.symfony_version >>
matrix:
parameters:
sylius_version: [ "1.12" ]
php_version: [ "8.1", "8.2" ]
symfony_version: [ "5.4", "6.0", "6.1", "6.2", "6.3", "6.4" ]
sylius_version: [ "1.13" ]
php_version: [ "8.1", "8.2", "8.3" ]
symfony_version: [ "6.4" ]

jobs:
build:
Expand All @@ -51,9 +40,9 @@ jobs:
php_version:
type: string
docker:
- image: webdevops/php-nginx:<< parameters.php_version >>-alpine
- image: webdevops/php-nginx:<< parameters.php_version >>
environment:
- DATABASE_URL=mysql://root:pass_root@127.0.0.1:3306/3brs_sylius_payment_restriction_plugin_%kernel.environment%?serverVersion=8.0
- DATABASE_URL=mysql://root:pass_root@127.0.0.1:3306/3brs_sylius_payment_fee_plugin_%kernel.environment%?serverVersion=8.0
- image: cimg/mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: pass_root
Expand All @@ -62,9 +51,13 @@ jobs:

steps:
- checkout
- run: apk update
# 'mariadb-connector-c' to avoid ERROR 1045 (28000): Plugin caching_sha2_password could not be loaded: Error loading shared library /usr/lib/mariadb/plugin/caching_sha2_password.so: No such file or directory
- run: apk add yarn mysql-client mariadb-connector-c
# to avoid installing different package "Note, selecting 'cmdtest' instead of 'yarn'"
- run: curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- run: echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
- run: curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
- run: apt-get update
# netcat to get 'nc' command for waiting for database
- run: apt-get install -y nodejs yarn mariadb-client netcat-openbsd
- run: composer self-update

# Sylius & Symfony in current matrix versions
Expand All @@ -73,12 +66,12 @@ jobs:

- run:
name: Wait for database
command: timeout 60s bash -c -- 'while ! nc -z localhost 3306; do sleep 0.1; done' \
&& timeout 30s bash -c -- 'mysql --user=sylius --password=pass --host=localhost --port=3306 -e "exit"'
command: timeout 60s bash -c -- 'while ! nc -z 127.0.0.1 3306; do sleep 0.1; done' \
&& timeout 30s bash -c -- 'mysql --user=sylius --password=pass --host=127.0.0.1 --port=3306 -e "exit"'

# COMPOSER PREFER LOWEST (oldest possible) #
# has to delete vendor for next test with different libraries version to avoid Composer error 'Failed to extract...' if vendor dir cache does not exist
- run: rm -fr vendor composer.lock
- run: rm -fr composer.lock
- run: composer update --no-interaction --prefer-lowest --no-plugins
- run: yarn --cwd tests/Application install
- run: yarn --cwd tests/Application build
Expand All @@ -87,13 +80,16 @@ jobs:
- run: (cd tests/Application && bin/console cache:clear --env=test -vvv)
- run: (cd tests/Application && bin/console cache:warmup --env=test -vvv)
- run:
name: Behat
environment:
APP_SUPPRESS_DEPRECATED_ERRORS: 1
command: APP_ENV=test bin/behat
- run: APP_ENV=test bin/phpstan.sh
name: PHPStan
command: |
if [ "<< parameters.sylius_version >>" != "1.13" ]; then
APP_ENV=test bin/phpstan.sh --configuration phpstan-before-sylius.1.13.dist.neon
else
APP_ENV=test bin/phpstan.sh
fi
- run: APP_ENV=test bin/ecs.sh --clear-cache
- run: APP_ENV=test bin/symfony-lint.sh
- run: APP_ENV=test bin/behat.sh

# COMPOSER PREFER DIST #
- run: composer update --no-interaction --prefer-dist --no-plugins
Expand All @@ -103,7 +99,14 @@ jobs:
- run: (cd tests/Application && bin/console doctrine:schema:update --force --env=test -vvv)
- run: (cd tests/Application && bin/console cache:clear --env=test -vvv)
- run: (cd tests/Application && bin/console cache:warmup --env=test -vvv)
- run: APP_ENV=test bin/behat
- run: APP_ENV=test bin/phpstan.sh
- run:
name: PHPStan
command: |
if [ "<< parameters.sylius_version >>" != "1.13" ]; then
APP_ENV=test bin/phpstan.sh --configuration phpstan-before-sylius.1.13.dist.neon
else
APP_ENV=test bin/phpstan.sh
fi
- run: APP_ENV=test bin/ecs.sh --clear-cache
- run: APP_ENV=test bin/symfony-lint.sh
- run: APP_ENV=test bin/behat.sh
13 changes: 13 additions & 0 deletions .docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ghcr.io/sylius/sylius-nginx:alpine

RUN echo "${WORKING_DIR}"

ENV WORKING_DIR=/srv/sylius/tests/Application

WORKDIR "${WORKING_DIR}"

COPY ./nginx.conf /etc/nginx/conf.d/default.conf

ENV FASTCGI_PASS=php:9000

# To test PHP FastCGI, use `apk add fcgi-dev`, then `cgi-fcgi -bind -connect 127.0.0.1:9000` or `cgi-fcgi -bind -connect php:9000`
62 changes: 20 additions & 42 deletions .docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,50 +1,28 @@
user www-data;
worker_processes auto;
daemon off;
pid /run/nginx.pid;
server {
listen 80;

include /etc/nginx/modules-enabled/*.conf;
server_name sylius_plugin_docker;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

server_tokens off;

client_max_body_size 64m;
sendfile on;
tcp_nodelay on;
tcp_nopush on;

gzip_vary on;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /srv/sylius/tests/Application/public;
index index.php;

server {
listen 80;

server_name sylius_plugin_docker;

root /app/tests/Application/public;
index index.php;

location / {
try_files $uri /index.php$is_args$args;
}
location / {
# try to serve file directly, fallback to index.php
try_files $uri /index.php$is_args$args;
}

location ~ \.php$ {
include fastcgi_params;
location ~ ^/index\.php(/|$) {
fastcgi_pass ${FASTCGI_PASS};
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;

fastcgi_pass unix:/var/run/php-www.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
location ~ \.php$ {
return 404;
}
}
18 changes: 18 additions & 0 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:20-alpine AS node

FROM ghcr.io/sylius/sylius-php:8.3-xdebug-alpine

RUN apk add --no-cache \
bash \
make

COPY --from=node /usr/lib /usr/lib
COPY --from=node /usr/local/share /usr/local/share
COPY --from=node /usr/local/lib /usr/local/lib
COPY --from=node /usr/local/include /usr/local/include
COPY --from=node /usr/local/bin /usr/local/bin
COPY --from=node /opt /opt

CMD [ "php-fpm" ]

ENTRYPOINT [ "docker-php-entrypoint" ]
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,27 @@

/yarn-error.log
/supervisord.log

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

###> symfony/webpack-encore-bundle ###
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###

###> lexik/jwt-authentication-bundle ###
/config/jwt/*.pem
###< lexik/jwt-authentication-bundle ###
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## v2.2.0 (2025-02-12)

#### Details

- Add support for Sylius 1.13
- Drop support for Sylius <= 1.11 and Symfony <= 5.4

## v2.1.0 (2023-01-04)

#### Details
Expand Down
35 changes: 25 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,48 @@ phpstan:
APP_ENV=test bin/phpstan.sh

ecs:
APP_ENV=test bin/ecs.sh
APP_ENV=test bin/ecs.sh --clear-cache

behat-js:
APP_ENV=test APP_SUPPRESS_DEPRECATED_ERRORS=1 bin/behat --colors --strict --no-interaction -vvv -f progress
fix:
APP_ENV=test bin/ecs.sh --fix

install:
composer install --no-interaction --no-scripts
rm -fr tests/Application/public/media/cache && mkdir -p tests/Application/public/media/cache && chmod -R 777 tests/Application/public/media
rm -fr tests/Application/var && mkdir -p tests/Application/var/log && chmod -R 777 tests/Application/var
touch tests/Application/var/log/test.log && chmod 777 tests/Application/var/log/test.log

backend:
APP_ENV=test tests/Application/bin/console sylius:install --no-interaction
APP_ENV=test tests/Application/bin/console doctrine:database:drop --force || true
APP_ENV=test tests/Application/bin/console doctrine:database:create --no-interaction
APP_ENV=test tests/Application/bin/console doctrine:migrations:migrate --no-interaction
APP_ENV=test tests/Application/bin/console doctrine:schema:update --force --complete --no-interaction
APP_ENV=test tests/Application/bin/console doctrine:migration:sync-metadata-storage
APP_ENV=test tests/Application/bin/console sylius:install --no-interaction
APP_ENV=test tests/Application/bin/console sylius:fixtures:load default --no-interaction

frontend:
APP_ENV=test tests/Application/bin/console assets:install
(cd tests/Application && yarn install --pure-lockfile)
(cd tests/Application && GULP_ENV=prod yarn build)

behat:
APP_ENV=test bin/behat --colors --strict --no-interaction -vvv -f progress

lint:
APP_ENV=test bin/symfony-lint.sh

behat:
APP_ENV=test bin/behat.sh

init: install backend frontend

ci: init phpstan ecs behat lint
tests: phpstan ecs lint behat

static: phpstan ecs lint

ci: init static behat

integration: init behat
run:
docker compose up --detach

static: install phpstan ecs lint
php-bash:
@make run
docker compose exec --user 1000:1000 php bash
12 changes: 12 additions & 0 deletions assets/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/

// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.css';

// start the Stimulus application
import './bootstrap';
11 changes: 11 additions & 0 deletions assets/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { startStimulusApp } from '@symfony/stimulus-bridge';

// Registers Stimulus controllers from controllers.json and in the controllers/ directory
export const app = startStimulusApp(require.context(
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
true,
/\.[jt]sx?$/
));

// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);
4 changes: 4 additions & 0 deletions assets/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"controllers": [],
"entrypoints": []
}
16 changes: 16 additions & 0 deletions assets/controllers/hello_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Controller } from '@hotwired/stimulus';

/*
* This is an example Stimulus controller!
*
* Any element with a data-controller="hello" attribute will cause
* this controller to be executed. The name "hello" comes from the filename:
* hello_controller.js -> "hello"
*
* Delete this file or adapt it for your use!
*/
export default class extends Controller {
connect() {
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
}
}
3 changes: 3 additions & 0 deletions assets/styles/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-color: lightgray;
}
Loading

0 comments on commit 184111e

Please sign in to comment.