From d744e8895290505788e6952e72d80e8f3eeb72cf Mon Sep 17 00:00:00 2001 From: Nicolas PHILIPPE Date: Thu, 2 Nov 2023 07:31:26 +0100 Subject: [PATCH] chore: remove Makefile --- .env | 7 + .github/workflows/ci.yml | 258 ++++++------------ .gitignore | 1 - Makefile | 176 ------------ composer.json | 20 ++ config/cli-config.php | 29 -- docker-compose.yaml | 50 +--- docker/Dockerfile | 62 ----- docker/build.sh | 56 ---- docker/mongo-init.js | 13 - docker/xdebug.ini | 12 - ...doctrine.xml.dist => phpunit.dama.xml.dist | 0 tests/bootstrap.php | 3 + 13 files changed, 119 insertions(+), 568 deletions(-) create mode 100644 .env delete mode 100644 Makefile delete mode 100644 config/cli-config.php delete mode 100644 docker/Dockerfile delete mode 100755 docker/build.sh delete mode 100644 docker/mongo-init.js delete mode 100644 docker/xdebug.ini rename phpunit-dama-doctrine.xml.dist => phpunit.dama.xml.dist (100%) diff --git a/.env b/.env new file mode 100644 index 00000000..ca40d4ef --- /dev/null +++ b/.env @@ -0,0 +1,7 @@ +#DATABASE_URL="mysql://root:1234@127.0.0.1:3307/foundry_test?serverVersion=5.7.42" +DATABASE_URL="postgresql://zenstruck:zenstruck@127.0.0.1:5433/zenstruck_foundry?serverVersion=15" +MONGO_URL="mongodb://127.0.0.1:27018/dbName?compressors=disabled&gssapiServiceName=mongodb" +DATABASE_RESET_MODE=schema +USE_ORM=1 +USE_ODM=1 +USE_FOUNDRY_BUNDLE=1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 556d1101..5d3315e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,76 +8,60 @@ on: jobs: tests: - name: PHP ${{ matrix.php }}, SF ${{ matrix.symfony }} - ${{ matrix.deps }} ${{ matrix.use-orm == '1' && (matrix.orm-db == 'postgres' && '- ORM (postgres)' || '- ORM (mysql)') || '' }} ${{ matrix.use-odm == '1' && '- ODM' || '' }} ${{ matrix.use-dama == '1' && '- DAMA' || '' }} + name: P:${{ matrix.php }}, S:${{ matrix.symfony }}, D:${{ matrix.database }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }} runs-on: ubuntu-latest strategy: - fail-fast: false matrix: - php: [8.0, 8.1, 8.2] - symfony: [5.4.*, 6.2.*, 6.3.*] - deps: [highest] - use-orm: [1] - use-odm: [1] - use-dama: [1] - orm-db: [postgres] - exclude: - - {use-orm: 0, use-odm: 0} # tested directly in a test case - - {use-orm: 0, use-dama: 1} # cannot happen - # conflicts - - {php: 8.0, symfony: 6.2.*} - - {php: 8.0, symfony: 6.3.*} + php: [ 8.1, 8.2 ] + deps: [ highest ] + symfony: [ 6.3.*, 6.4.* ] + database: [ mysql, mongo ] include: - - {php: 8.0, symfony: 5.4.*, use-orm: 1, use-odm: 0, use-dama: 0, deps: lowest, orm-db: postgres} - - {php: 8.0, symfony: 5.4.*, use-orm: 1, use-odm: 1, use-dama: 0, deps: lowest, orm-db: postgres} - - {php: 8.0, symfony: 5.4.*, use-orm: 0, use-odm: 1, use-dama: 0, deps: lowest, orm-db: postgres} - - {php: 8.2, symfony: 6.3.*, use-orm: 1, use-odm: 0, use-dama: 0, deps: highest, orm-db: postgres} - - {php: 8.2, symfony: 6.3.*, use-orm: 1, use-odm: 1, use-dama: 0, deps: highest, orm-db: postgres} - - {php: 8.2, symfony: 6.3.*, use-orm: 1, use-odm: 0, use-dama: 1, deps: highest, orm-db: postgres} - - {php: 8.2, symfony: 6.3.*, use-orm: 0, use-odm: 1, use-dama: 0, deps: highest, orm-db: postgres} - - {php: 8.2, symfony: 6.3.*, use-orm: 1, use-odm: 0, use-dama: 1, deps: highest, orm-db: mysql} - - {php: 8.2, symfony: 6.3.*, use-orm: 1, use-odm: 0, use-dama: 0, deps: highest, orm-db: mysql} - + - php: 8.1 + deps: lowest + symfony: '*' + database: mysql|mongo + - php: 8.2 + deps: highest + symfony: '*' + database: none + - php: 8.2 + deps: highest + symfony: '*' + database: mysql|mongo + - php: 8.2 + deps: highest + symfony: '*' + database: pgsql|mongo + env: + DATABASE_URL: ${{ contains(matrix.database, 'mysql') && 'mysql://root:root@localhost:3306/foundry?serverVersion=5.7.42' || contains(matrix.database, 'pgsql') && 'postgresql://root:root@localhost:5432/foundry?serverVersion=15' || '' }} + MONGO_URL: ${{ contains(matrix.database, 'mongo') && 'mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb' || '' }} services: - mysql: - image: mysql:5.7.42 - env: - MYSQL_ROOT_PASSWORD: 1234 - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - postgres: - image: postgres:15 + image: ${{ contains(matrix.database, 'pgsql') && 'postgres:15' || '' }} env: - POSTGRES_USER: postgres - POSTGRES_DB: zenstruck_foundry_${{ matrix.use-dama }}_${{ matrix.orm-db }} - POSTGRES_PASSWORD: 1234 - options: --health-cmd pg_isready --health-interval=10s --health-timeout=5s --health-retries=5 + POSTGRES_USER: root + POSTGRES_PASSWORD: root + POSTGRES_DB: foundry ports: - 5432:5432 - + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 mongo: - image: mongo:4 + image: ${{ contains(matrix.database, 'mongo') && 'mongo:4' || '' }} ports: - 27017:27017 - - env: - MYSQL_URL: mysql://root:1234@127.0.0.1:3306/zenstruck_foundry?serverVersion=5.7.42 - PGSQL_URL: postgresql://postgres:1234@127.0.0.1:5432/zenstruck_foundry_${{ matrix.use-dama }}_${{ matrix.orm-db }}?charset=utf8&serverVersion=15 - MONGO_URL: mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb - steps: - name: Checkout code uses: actions/checkout@v3 - - name: Verify MySQL version - run: mysql --host 127.0.0.1 -uroot -p1234 -e "STATUS" - - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: pgsql, sqlite, mongodb coverage: none tools: flex @@ -89,51 +73,65 @@ jobs: env: SYMFONY_REQUIRE: ${{ matrix.symfony }} - - name: 'Test' - run: | - if [ "${{ matrix.use-dama }}" == "1" ]; then - CONFIGURATION="--configuration phpunit-dama-doctrine.xml.dist" - fi + - name: Set up MySQL + if: contains(matrix.database, 'mysql') + run: sudo /etc/init.d/mysql start + + - name: Test + run: vendor/bin/phpunit + shell: bash + + - name: Test with "migrate" + if: contains(matrix.database, 'sql') + run: vendor/bin/phpunit + shell: bash + env: + DATABASE_RESET_MODE: migrate + + - name: Test with "dama" + if: contains(matrix.database, 'sql') + run: vendor/bin/phpunit -c phpunit.dama.xml.dist + shell: bash - vendor/bin/simple-phpunit ${CONFIGURATION} + - name: Test with "dama" and "migrate" + if: contains(matrix.database, 'sql') + run: vendor/bin/phpunit -c phpunit.dama.xml.dist + shell: bash env: - USE_ORM: ${{ matrix.use-orm }} - USE_ODM: ${{ matrix.use-odm }} - USE_FOUNDRY_BUNDLE: 1 - DATABASE_URL: ${{ matrix.orm-db == 'postgres' && env.PGSQL_URL || env.MYSQL_URL }} + DATABASE_RESET_MODE: migrate code-coverage: name: Code Coverage runs-on: ubuntu-latest + env: + DATABASE_URL: postgresql://root:root@localhost:5432/foundry?serverVersion=15 + MONGO_URL: mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb services: - mysql: - image: mysql:5.7 - env: - MYSQL_ROOT_PASSWORD: 1234 - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 mongo: image: mongo:4 ports: - 27017:27017 - - env: - DATABASE_URL: mysql://root:1234@127.0.0.1:3306/zenstruck_foundry?serverVersion=5.7 - MONGO_URL: mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb - + postgres: + image: postgres:15 + env: + POSTGRES_USER: root + POSTGRES_PASSWORD: root + POSTGRES_DB: foundry + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 steps: - name: Checkout code uses: actions/checkout@v3 - - name: Verify MySQL version - run: mysql --host 127.0.0.1 -uroot -p1234 -e "STATUS" - - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.0 - extensions: pgsql, sqlite + php-version: 8.2 coverage: xdebug ini-values: xdebug.mode=coverage @@ -141,114 +139,21 @@ jobs: uses: ramsey/composer-install@v2 with: composer-options: --prefer-dist - dependency-versions: "highest" - - name: 'Coverage' - run: vendor/bin/simple-phpunit -v --configuration phpunit-dama-doctrine.xml.dist --coverage-text --coverage-clover=foundry.clover - env: - USE_ORM: 1 - USE_ODM: 1 - USE_FOUNDRY_BUNDLE: 1 + - name: Test with coverage + run: vendor/bin/phpunit --coverage-text --coverage-clover coverage.xml + shell: bash - name: Publish coverage report to Codecov uses: codecov/codecov-action@v3 with: - file: ./*.clover + file: ./coverage.xml composer-validate: uses: zenstruck/.github/.github/workflows/php-composer-validate.yml@main - build-docs: - name: Build Documentation - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.0 - coverage: none - - - name: Install dependencies - uses: ramsey/composer-install@v2 - with: - composer-options: --prefer-dist - - - name: Build docs - run: bin/build-docs - - static-analysis: - name: Static Analysis - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.0 - coverage: none - - - name: Install dependencies - uses: ramsey/composer-install@v2 - with: - composer-options: --prefer-dist - - - name: Install PHPStan - run: composer bin phpstan install - - - name: Run static analysis - run: bin/tools/phpstan/vendor/phpstan/phpstan/phpstan analyse - - - name: Install Psalm - run: composer bin psalm install - - - name: Run Psalm on factories generated with maker - run: bin/tools/psalm/vendor/vimeo/psalm/psalm - - test-docker-stack: - name: CI with docker stack - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php: ['8.0', '8.1', '8.2'] - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Run test suite with docker - run: | - echo "PHP_VERSION=${{ matrix.php }}" > .env - make validate - - push_docker_images: - name: Push docker images after CI complete on main branch - needs: [tests, composer-validate, build-docs, static-analysis, test-docker-stack] - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/1.x' }} - strategy: - fail-fast: false - matrix: - php: ['8.0', '8.1', '8.2'] - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Login to ghcr.io - uses: docker/login-action@v2 - with: - registry: ghcr.io/zenstruck - username: token - password: ${{ secrets.PACKAGE_PUSH_TOKEN }} - - - name: Build and push images - run: ./docker/build.sh push ${{ matrix.php }} - env: - GITHUB_TOKEN: ${{ secrets.PACKAGE_PUSH_TOKEN }} + sca: + uses: zenstruck/.github/.github/workflows/php-stan.yml@main fixcs: name: Run php-cs-fixer @@ -271,4 +176,3 @@ jobs: with: key: ${{ secrets.GPG_PRIVATE_KEY }} token: ${{ secrets.COMPOSER_TOKEN }} - phpcsconfig: false diff --git a/.gitignore b/.gitignore index 9060a923..3a30ce60 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,4 @@ /tests/Fixtures/tmp /var/ /docs/output/ -/.env /docker/.makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index 5bad441a..00000000 --- a/Makefile +++ /dev/null @@ -1,176 +0,0 @@ -.DEFAULT_GOAL := help - -SHELL=/bin/bash - -# DB variables -PGSQL_URL="postgresql://zenstruck:zenstruck@postgres:5432/zenstruck_foundry?serverVersion=15" -MONGO_URL="mongodb://mongo:mongo@mongo:27017/mongo?compressors=disabled&gssapiServiceName=mongodb&authSource=mongo" - -# Default test context variables -USE_FOUNDRY_BUNDLE=1 -USE_ORM=1 -USE_ODM=1 -USE_DAMA_DOCTRINE_TEST_BUNDLE=1 -SYMFONY_REQUIRE=5.4.* -PHP_VERSION=8.0 -PREFER_LOWEST=false - -# Override test context variables with `.env` file -ifneq (,$(wildcard .env)) - include .env - export $(shell sed 's/=.*//' .env) -endif - -ifeq (${PREFER_LOWEST},1) - COMPOSER_UPDATE_OPTIONS=--prefer-dist --prefer-lowest -else - COMPOSER_UPDATE_OPTIONS=--prefer-dist -endif - -DOCKER_PHP_CONTAINER_FLAG := docker/.makefile/.docker-containers-${PHP_VERSION} -PHPSTAN_BIN := bin/tools/phpstan/vendor/phpstan/phpstan/phpstan -PSALM_BIN := bin/tools/psalm/vendor/vimeo/psalm/psalm - -ifeq ($(USE_DAMA_DOCTRINE_TEST_BUNDLE),1) - PHPUNIT_CONFIG_FILE='phpunit-dama-doctrine.xml.dist' -else - PHPUNIT_CONFIG_FILE='phpunit.xml.dist' -endif - -# Define docker executable -ifeq ($(shell docker --help | grep "compose"),) - DOCKER_COMPOSE := COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -else - DOCKER_COMPOSE := COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -endif - -# Create special context for CI -INTERACTIVE:=$(shell [ -t 0 ] && echo 1) -ifdef INTERACTIVE - DC_EXEC=$(DOCKER_COMPOSE) exec -e USE_FOUNDRY_BUNDLE=${USE_FOUNDRY_BUNDLE} -e DATABASE_URL=${PGSQL_URL} -e MONGO_URL=${MONGO_URL} -else - # CI needs to be ran in no-tty mode - DC_EXEC=$(DOCKER_COMPOSE) exec -e USE_FOUNDRY_BUNDLE=${USE_FOUNDRY_BUNDLE} -e DATABASE_URL=${PGSQL_URL} -e MONGO_URL=${MONGO_URL} -T -endif - -PHP=php${PHP_VERSION} -DOCKER_PHP=${DC_EXEC} ${PHP} -DOCKER_PHP_WITHOUT_XDEBUG=${DOCKER_PHP} php -d 'xdebug.mode=off' - -ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) -$(eval $(RUN_ARGS):;@:) - -.PHONY: help -help: - @fgrep -h "###" $(MAKEFILE_LIST) | fgrep -v fgrep | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' - -.PHONY: validate -validate: sca psalm test database-validate-mapping ### Run sca, full test suite and validate migrations - -.PHONY: test -test: vendor ### Run PHPUnit tests suite - @$(MAKE) --no-print-directory docker-start-if-not-running - @${DC_EXEC} -e USE_ORM=${USE_ORM} -e USE_ODM=${USE_ODM} ${PHP} vendor/bin/simple-phpunit --configuration ${PHPUNIT_CONFIG_FILE} $(ARGS) - -.PHONY: sca -sca: phpstan ### Run static analysis - -.PHONY: phpstan -phpstan: $(PHPSTAN_BIN) - @$(MAKE) --no-print-directory docker-start-if-not-running - @${DOCKER_PHP_WITHOUT_XDEBUG} $(PHPSTAN_BIN) analyse - -$(PHPSTAN_BIN): vendor bin/tools/phpstan/composer.json bin/tools/phpstan/composer.lock - @$(MAKE) --no-print-directory docker-start-if-not-running - @${DOCKER_PHP_WITHOUT_XDEBUG} /usr/bin/composer bin phpstan install - @touch -c $@ bin/tools/phpstan/composer.json bin/tools/phpstan/composer.lock - -# Psalm is only used to validate factories generated thanks to make:factory command. -.PHONY: psalm -psalm: $(PSALM_BIN) - @$(MAKE) --no-print-directory docker-start-if-not-running - @${DOCKER_PHP_WITHOUT_XDEBUG} $(PSALM_BIN) - -$(PSALM_BIN): vendor bin/tools/psalm/composer.json bin/tools/psalm/composer.lock - @$(MAKE) --no-print-directory docker-start-if-not-running - @${DOCKER_PHP_WITHOUT_XDEBUG} /usr/bin/composer bin psalm install - @touch -c $@ bin/tools/psalm/composer.json bin/tools/psalm/composer.lock - -.PHONY: docs -docs: vendor ### Generate documentation to docs/output - @$(MAKE) --no-print-directory docker-start-if-not-running - @${DOCKER_PHP} ./bin/build-docs - -.PHONY: database-generate-migration -database-generate-migration: database-drop-schema ### Generate new migration based on mapping in Zenstruck\Foundry\Tests\Fixtures\Entity - @${DOCKER_PHP} vendor/bin/doctrine-migrations migrations:migrate --no-interaction --allow-no-migration # first, let's load into db existing migrations - @${DOCKER_PHP} vendor/bin/doctrine-migrations migrations:diff --no-interaction - @${DOCKER_PHP} vendor/bin/doctrine-migrations migrations:migrate --no-interaction # load the new migration - @${DOCKER_PHP} bin/doctrine orm:validate-schema - -.PHONY: database-validate-mapping -database-validate-mapping: database-drop-schema ### Validate mapping in Zenstruck\Foundry\Tests\Fixtures\Entity - @${DOCKER_PHP} vendor/bin/doctrine-migrations migrations:migrate --no-interaction --allow-no-migration - @${DOCKER_PHP} bin/doctrine orm:validate-schema - -.PHONY: database-drop-schema -database-drop-schema: vendor ### Drop database schema - @$(MAKE) --no-print-directory docker-start-if-not-running - @${DOCKER_PHP} bin/doctrine orm:schema-tool:drop --force - @${DOCKER_PHP} vendor/bin/doctrine-migrations migrations:sync-metadata-storage # prevents the next command to fail if migrations table does not exist - @${DOCKER_PHP} bin/doctrine dbal:run-sql "TRUNCATE doctrine_migration_versions" --quiet - -.PHONY: composer -composer: ### Run composer command - @$(MAKE) --no-print-directory docker-start-if-not-running - @${DOCKER_PHP_WITHOUT_XDEBUG} /usr/bin/composer $(ARGS) - -vendor: $(DOCKER_PHP_CONTAINER_FLAG) composer.json $(wildcard composer.lock) $(wildcard .env) - @$(MAKE) --no-print-directory docker-start-if-not-running - @${DC_EXEC} -e SYMFONY_REQUIRE=${SYMFONY_REQUIRE} ${PHP} php -d 'xdebug.mode=off' /usr/bin/composer update ${COMPOSER_UPDATE_OPTIONS} - @touch -c $@ composer.json .env composer.lock - -.PHONY: docker-start-if-not-running -docker-start-if-not-running: - @if [ -f "$(DOCKER_PHP_CONTAINER_FLAG)" ] ; then \ - if $(DOCKER_COMPOSE) ps -a | grep "${PHP}" | grep -q -v 'Up '; then \ - $(MAKE) --no-print-directory docker-start; \ - fi; \ - fi - -.PHONY: docker-build -docker-build: ### Build and start containers - @rm -f $(DOCKER_PHP_CONTAINER_FLAG) - @$(MAKE) --no-print-directory $(DOCKER_PHP_CONTAINER_FLAG) - -.PHONY: docker-start -docker-start: ### Start containers - @echo -e "\nStarting containers. This could take up to one minute.\n" - @$(DOCKER_COMPOSE) up --detach --no-build --remove-orphans postgres mongo "${PHP}"; - -.PHONY: docker-stop -docker-stop: ### Stop containers - @rm $(DOCKER_PHP_CONTAINER_FLAG) - @$(DOCKER_COMPOSE) stop - -.PHONY: docker-purge -docker-purge: docker-stop ### Purge containers - @$(DOCKER_COMPOSE) down --volumes - -$(DOCKER_PHP_CONTAINER_FLAG): - @./docker/build.sh load "${PHP_VERSION}" - @$(MAKE) --no-print-directory docker-start - @echo "" - @$(DOCKER_COMPOSE) ps - @echo "" - @${DOCKER_PHP} php -v - @echo "" - @mkdir -p docker/.makefile/ - @touch $@ - -.PHONY: clear -clear: ### Start from a fresh install (use it for troubleshooting) - rm -rf composer.lock vendor/ bin/tools/*/vendor/ docker/.makefile - -%: # black hole to prevent extra args warning - @: diff --git a/composer.json b/composer.json index d3604ff5..0d8ce7a8 100644 --- a/composer.json +++ b/composer.json @@ -30,6 +30,7 @@ "doctrine/mongodb-odm-bundle": "^4.4.0", "doctrine/orm": "^2.9", "matthiasnoback/symfony-dependency-injection-test": "^4.1", + "symfony/dotenv": "^6.3", "symfony/framework-bundle": "^5.4|^6.0|^7.0", "symfony/maker-bundle": "^1.49", "symfony/phpunit-bridge": "^5.4|^6.0|^7.0", @@ -65,6 +66,25 @@ "forward-command": false } }, + "scripts": { + "test": [ + "@test-schema-no-dama", + "@test-migrate-no-dama", + "@test-schema-dama", + "@test-migrate-dama" + ], + "test-schema-no-dama": "DATABASE_RESET_MODE=schema USE_ORM=1 vendor/bin/simple-phpunit", + "test-migrate-no-dama": "DATABASE_RESET_MODE=migrate USE_ORM=1 vendor/bin/simple-phpunit", + "test-schema-dama": "DATABASE_RESET_MODE=schema USE_ORM=1 vendor/bin/simple-phpunit -c phpunit.dama.xml.dist", + "test-migrate-dama": "DATABASE_RESET_MODE=migrate USE_ORM=1 vendor/bin/simple-phpunit -c phpunit.dama.xml.dist" + }, + "scripts-descriptions": { + "test": "Run all test permutations", + "test-schema-no-dama": "Test with schema reset (no dama/doctrine-test-bundle)", + "test-migrate-no-dama": "Test with migrations reset (no dama/doctrine-test-bundle)", + "test-schema-dama": "Test with schema reset and dama/doctrine-test-bundle", + "test-migrate-dama": "Test with migrations reset and dama/doctrine-test-bundle" + }, "minimum-stability": "dev", "prefer-stable": true } diff --git a/config/cli-config.php b/config/cli-config.php deleted file mode 100644 index 1b2b22f8..00000000 --- a/config/cli-config.php +++ /dev/null @@ -1,29 +0,0 @@ -= 80100) { - $entities[] = '/app/tests/Fixtures/PHP81'; -} -$ORMconfig = ORMSetup::createAttributeMetadataConfiguration($entities, true); -$entityManager = EntityManager::create(['memory' => true, 'url' => getenv('DATABASE_URL')], $ORMconfig); - -return DependencyFactory::fromEntityManager( - new ConfigurationArray([ - 'table_storage' => [ - 'table_name' => 'doctrine_migration_versions', - ], - - 'migrations_paths' => [ - 'Zenstruck\Foundry\Tests\Fixtures\Migrations' => './tests/Fixtures/Migrations', - ], - ]), - new ExistingEntityManager($entityManager) -); diff --git a/docker-compose.yaml b/docker-compose.yaml index e2d2b1f7..2c2c3642 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,41 +1,21 @@ version: '3.9' services: - php8.0: &php - container_name: foundry_php8.0 - image: ghcr.io/zenstruck/foundry/php:8.0 - depends_on: - postgres: - condition: service_healthy - mongo: - condition: service_healthy - volumes: - - .:/app - working_dir: /app + mysql: + image: mysql:5.7 + ports: + - 3307:3306 environment: - PHP_IDE_CONFIG: "serverName=FOUNDRY" - - php8.1: - <<: *php - container_name: foundry_php8.1 - image: ghcr.io/zenstruck/foundry/php:8.1 - - php8.2: - <<: *php - container_name: foundry_php8.2 - image: ghcr.io/zenstruck/foundry/php:8.2 + MYSQL_ROOT_PASSWORD: 1234 postgres: - container_name: foundry_postgres image: postgres:15 environment: POSTGRES_DB: zenstruck_foundry POSTGRES_PASSWORD: zenstruck POSTGRES_USER: zenstruck - volumes: - - db-data:/var/lib/postgresql/data:rw ports: - - ${PGSQL_PORT:-5432}:5432 + - 5433:5432 healthcheck: test: 'pg_isready -d zenstruck_foundry' timeout: 120s @@ -43,24 +23,10 @@ services: interval: 2s mongo: - container_name: foundry_mongo - image: mongo:4.4 - tmpfs: - - /data - environment: - - MONGO_INITDB_ROOT_USERNAME=admin - - MONGO_INITDB_ROOT_PASSWORD=admin - - MONGO_INITDB_DATABASE=mongo - - MONGO_NON_ROOT_USERNAME=mongo - - MONGO_NON_ROOT_PASSWORD=mongo + image: mongo:4 ports: - - ${MONGO_PORT:-27017}:27017 - volumes: - - ./docker/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro + - 27018:27017 healthcheck: test: echo 'db.runCommand("ping").ok' | mongo mongo:27017/test --quiet timeout: 10s retries: 10 - -volumes: - db-data: diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 17384486..00000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,62 +0,0 @@ -ARG PHP_VERSION - -FROM php:${PHP_VERSION}-cli-bullseye - -COPY --from=composer:2.4 /usr/bin/composer /usr/bin/composer - -RUN set -eux ; \ - apt-get update ; \ - apt-get install --no-install-recommends -y \ - $PHPIZE_DEPS \ - git \ - curl \ - zip \ - unzip \ - libicu-dev \ - git \ - curl \ - unzip \ - procps \ - dialog \ - apt-utils \ - libpq-dev \ - libcurl4-openssl-dev \ - pkg-config \ - libssl-dev \ - ; \ - docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql; \ - docker-php-ext-install pdo pdo_mysql pdo_pgsql pgsql; \ - pecl install -f mongodb-1.15; \ - pecl install xdebug ; \ - docker-php-ext-enable mongodb xdebug ; \ - pecl clear-cache ; \ - apt-get remove -y $PHPIZE_DEPS zlib1g-dev libcurl4-openssl-dev pkg-config libssl-dev ; \ - rm -rf /var/lib/apt/lists/* ; \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false - -LABEL org.opencontainers.image.source="https://github.com/zenstruck/foundry" - -# We want these last commands to be at the bottom of the file because they depend on the host -# And we want to benefit of the cache layering as much as possible - -COPY docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini - -# Set user rights -ARG USER=docker - -# this may be overridden to match host's machine user -ARG UID=1001 -ARG XDEBUG_HOST="172.17.0.1" - -RUN addgroup --system --gid ${UID} ${USER} ; \ - adduser --system --home /home/${USER} --disabled-password --uid ${UID} --ingroup ${USER} ${USER} ; \ - mkdir -p /app/var ; \ - chown -R ${USER}:${USER} /app ; \ - sed -i "s/%xdebug_host%/${XDEBUG_HOST}/g" /usr/local/etc/php/conf.d/xdebug.ini - -USER ${USER} - -RUN composer global require --no-progress --no-scripts --no-plugins symfony/flex ; \ - composer global config --no-plugins allow-plugins.symfony/flex true - -CMD tail -f /dev/null diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index ef1ff7d6..00000000 --- a/docker/build.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -# Build PHP image with buildx -# usage: ./docker/build.sh [load|push] [8.0|8.1|8.2] - -set -e - -build() { - ACTION=${1} - PHP_VERSION=${2} - - DOCKER_IMAGE_TAG="ghcr.io/zenstruck/foundry/php:${PHP_VERSION}" - - # From inside the containers, docker host ip is different in linux and macos - UNAME=$(uname -s) - if [ "${UNAME}" = "Linux" ]; then - XDEBUG_HOST="172.17.0.1" - elif [ "${UNAME}" = "Darwin" ]; then - XDEBUG_HOST="host.docker.internal" - fi - - docker pull ${DOCKER_IMAGE_TAG} || true - - DOCKER_BUILDKIT=1 docker buildx build \ - --tag "${DOCKER_IMAGE_TAG}" \ - --cache-from "${DOCKER_IMAGE_TAG}" \ - --build-arg BUILDKIT_INLINE_CACHE=1 \ - --build-arg UID="$(id -u)" \ - --build-arg PHP_VERSION="${PHP_VERSION}" \ - --build-arg XDEBUG_HOST="${XDEBUG_HOST}" \ - --file docker/Dockerfile \ - "--${ACTION}" \ - . -} - -main() { - ACTION="${1:-load}" - PHP_VERSION="${2:-8.0}" - - if [ "${ACTION}" != 'push' ] && [ "${ACTION}" != 'load' ]; then - echo "Error: action \"${1}\" invalid. Allowed actions are push|load" - exit 1; - fi - - if [ "${PHP_VERSION}" != '8.0' ] && [ "${PHP_VERSION}" != '8.1' ] && [ "${PHP_VERSION}" != '8.2' ]; then - echo "Error: given php version \"${2}\" invalid. Only 8.0, 8.1 and 8.2 are accepted." - exit 1; - fi - - # ensure default builder is used, it is needed to benefit from cache layering - docker buildx use default - - build "${ACTION}" "${PHP_VERSION}" -} - -main "$@" diff --git a/docker/mongo-init.js b/docker/mongo-init.js deleted file mode 100644 index d2c2ecbe..00000000 --- a/docker/mongo-init.js +++ /dev/null @@ -1,13 +0,0 @@ -db.createUser( - { - user: "mongo", - pwd: "mongo", - roles: [ - { - role: "readWrite", - db: "mongo" - } - ] - } -); - diff --git a/docker/xdebug.ini b/docker/xdebug.ini deleted file mode 100644 index d969fde6..00000000 --- a/docker/xdebug.ini +++ /dev/null @@ -1,12 +0,0 @@ -memory_limit=1024M - -[xdebug] -xdebug.mode=debug -xdebug.start_with_request=yes -xdebug.client_host=%xdebug_host% -xdebug.client_port=9003 -xdebug.idekey=xdebug_foundry - -# prevents a warning to be displayed in CLI -# when phpstorm does not listen incoming connexions -xdebug.log_level=0 diff --git a/phpunit-dama-doctrine.xml.dist b/phpunit.dama.xml.dist similarity index 100% rename from phpunit-dama-doctrine.xml.dist rename to phpunit.dama.xml.dist diff --git a/tests/bootstrap.php b/tests/bootstrap.php index aac0fe40..ed82f07b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -9,8 +9,11 @@ * file that was distributed with this source code. */ +use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\Filesystem\Filesystem; require \dirname(__DIR__).'/vendor/autoload.php'; (new Filesystem())->remove(__DIR__.'/../var'); + +(new Dotenv())->usePutenv()->loadEnv(__DIR__.'/../.env');