diff --git a/.docker/dev/php.ini b/.docker/dev/php.ini new file mode 100644 index 0000000000..13f0abe509 --- /dev/null +++ b/.docker/dev/php.ini @@ -0,0 +1,5 @@ +[PHP] +memory_limit=512M + +[date] +date.timezone=${PHP_DATE_TIMEZONE} diff --git a/.docker/test/php.ini b/.docker/test/php.ini new file mode 100644 index 0000000000..23b350c649 --- /dev/null +++ b/.docker/test/php.ini @@ -0,0 +1,15 @@ +[PHP] +memory_limit=4096M + +[date] +date.timezone=${PHP_DATE_TIMEZONE} + +[opcache] +opcache.enable=1 +opcache.enable_cli=0 +opcache.memory_consumption=256 +opcache.max_accelerated_files=32531 +opcache.interned_strings_buffer=8 +opcache.validate_timestamps=0 +opcache.save_comments=1 +opcache.fast_shutdown=0 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..e5baff9215 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,55 @@ +name: Docker Based Pipeline + +on: + push: + +jobs: + docker-compose: + name: Excute Tests on Docker Compose + runs-on: ubuntu-latest + env: + COMPOSE_FILE: docker-compose.test.yml + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Run PHPUnit, PHPSpec and Behat tests + run: docker-compose run ci + + docker: + name: Excute Tests on Docker Containers + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Shutdown default MySQL + run: sudo service mysql stop + - + name: Setup MySQL + run: | + docker network create sylius_network + docker run \ + --platform linux/amd64 \ + -e MYSQL_ALLOW_EMPTY_PASSWORD=true \ + -p 3306:3306/tcp \ + --name mysql \ + --net sylius_network \ + -d mysql:5.7 + - + name: Run PHPUnit, PHPSpec and Behat tests + run: | + docker run \ + -v "$(pwd)"/:/app:delegated \ + -v "$(pwd)"/.docker/test/php.ini:/etc/php/8.0/fpm/php.ini:delegated \ + -v "$(pwd)"/.docker/test/php.ini:/etc/php/8.0/cli/php.ini:delegated \ + -e DATABASE_URL="mysql://root@mysql/sylius_test" \ + -e APP_ENV="test" \ + -e PHP_DATE_TIMEZONE="Europe/Warsaw" \ + --net sylius_network \ + --entrypoint="" \ + -p 80:80/tcp \ + -i sylius/standard:1.11-traditional \ + make ci diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..c7dd6f5fd6 --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +init: + composer install --no-interaction --no-scripts + bin/console sylius:install --no-interaction + bin/console sylius:fixtures:load default --no-interaction + yarn install --pure-lockfile + yarn build + +ci: + composer install --no-interaction --no-scripts + bin/console sylius:install --no-interaction + bin/console sylius:fixtures:load default --no-interaction + bin/console cache:warmup + yarn install --pure-lockfile + yarn build + vendor/bin/phpunit + vendor/bin/phpspec run --ansi --no-interaction -f dot + vendor/bin/behat --colors --strict --no-interaction -vvv -f progress --tags="~@javascript&&@cli&&~@todo" # CLI Behat + vendor/bin/behat --colors --strict --no-interaction -vvv -f progress --tags="~@javascript&&~@cli&&~@todo" # NON JS Behat + #vendor/bin/behat --colors --strict --no-interaction -vvv -f progress --tags="@javascript&&~@cli&&~@todo" # JS Behat + +unit: + vendor/bin/phpunit + +spec: + vendor/bin/phpspec run --ansi --no-interaction -f dot + +behat: + vendor/bin/behat --colors --strict --stop-on-failure --no-interaction -vvv -f progress diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 0000000000..97c284bf1f --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,32 @@ +services: + ci: + image: sylius/standard:1.11-traditional + entrypoint: ["make", "ci"] + environment: + APP_ENV: "test" + DATABASE_URL: "mysql://root:mysql@mysql/sylius_test" + PHP_DATE_TIMEZONE: "Europe/Warsaw" + volumes: + - ./:/app:delegated + - ./.docker/test/php.ini:/etc/php/8.0/fpm/php.ini:delegated + - ./.docker/test/php.ini:/etc/php/8.0/cli/php.ini:delegated + ports: + - 80:80 + depends_on: + - mysql + networks: + - sylius + + mysql: + image: mysql:5.7 + platform: linux/amd64 + environment: + - MYSQL_ROOT_PASSWORD=mysql + ports: + - 3306:3306 + networks: + - sylius + +networks: + sylius: + driver: bridge diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..9c6b0252b0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,51 @@ +services: + app: + image: sylius/standard:1.11-traditional + environment: + APP_ENV: "dev" + DATABASE_URL: "mysql://root:mysql@mysql/sylius_%kernel.environment%" +# DATABASE_URL: "pgsql://root:postgres@postgres/sylius_%kernel.environment%" # When using postgres + PHP_DATE_TIMEZONE: "Europe/Warsaw" + MAILER_URL: "smtp://mailhog:1025" + volumes: + - ./:/app:delegated + - ./.docker/dev/php.ini:/etc/php/8.0/fpm/php.ini:delegated + - ./.docker/dev/php.ini:/etc/php/8.0/cli/php.ini:delegated + ports: + - 80:80 + depends_on: + - mysql + networks: + - sylius + + mysql: + image: mysql:5.7 + platform: linux/amd64 + environment: + - MYSQL_ROOT_PASSWORD=mysql + ports: + - 3306:3306 + networks: + - sylius + + # postgres: + # image: postgres:13 + # environment: + # - POSTGRES_USER=root + # - POSTGRES_PASSWORD=postgres + # ports: + # - 5432:5432 + # networks: + # - sylius + + mailhog: + image: mailhog/mailhog + ports: + - 1025:1025 # SMTP + - 8025:8025 # UI + networks: + - sylius + +networks: + sylius: + driver: bridge