diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..9a8be03 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,31 @@ +name: Integration tests +on: [push] +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: [8.1] + + steps: + - uses: actions/checkout@v3 + + - name: Cache Composer dependencies + uses: actions/cache@v3 + with: + path: /tmp/composer-cache + key: ${{ runner.os }}-${{ matrix.php-version }} + + - uses: php-actions/composer@v6 + with: + php_version: ${{ matrix.php-version }} + php_extensions: apcu bcmath gd intl pdo_mysql pcntl sodium + args: --ignore-platform-reqs + + - uses: php-actions/composer@v6 + with: + php_version: ${{ matrix.php-version }} + php_extensions: apcu bcmath gd intl pdo_mysql pcntl sodium + command: tests:integration diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml new file mode 100644 index 0000000..3cf9f29 --- /dev/null +++ b/.github/workflows/unit.yml @@ -0,0 +1,30 @@ +name: Unit tests +on: [push] +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: [8.1] + + steps: + - uses: actions/checkout@v3 + + - name: Cache Composer dependencies + uses: actions/cache@v3 + with: + path: /tmp/composer-cache + key: ${{ runner.os }}-${{ matrix.php-version }} + - uses: php-actions/composer@v6 + with: + php_version: ${{ matrix.php-version }} + php_extensions: apcu bcmath gd intl pdo_mysql pcntl sodium + args: --ignore-platform-reqs + + - uses: php-actions/composer@v6 + with: + php_version: ${{ matrix.php-version }} + php_extensions: apcu bcmath gd intl pdo_mysql pcntl sodium + command: tests:unit diff --git a/.gitignore b/.gitignore index a67d42b..791cf89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ -composer.phar +/composer.phar /vendor/ +/.idea/ +/build/*/* +!/build/*/composer.json +/composer.lock +/.phpunit.result.cache # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -# composer.lock diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..64e1bac --- /dev/null +++ b/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +SCRIPT_NAME=$0 +DIRECTORY=$(dirname $SCRIPT_NAME) + +cd $DIRECTORY/build || exit 1 + +build_magento() { + PREV_DIR=$(pwd) + cd $1 || return + composer install --no-dev --prefer-dist --ignore-platform-reqs --no-progress || exit 1 + cd $PREV_DIR || return +} + +for BUILD in $(find ./ -mindepth 1 -maxdepth 1 -type d -exec echo {} \;) +do + build_magento $BUILD & +done + +wait diff --git a/build/2.4.4-p1/composer.json b/build/2.4.4-p1/composer.json new file mode 100644 index 0000000..83cd7ea --- /dev/null +++ b/build/2.4.4-p1/composer.json @@ -0,0 +1,87 @@ +{ + "name": "magento/project-community-edition", + "description": "eCommerce Platform for Growth (Community Edition)", + "type": "project", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "laminas/laminas-dependency-plugin": true, + "magento/*": true + }, + "preferred-install": "dist", + "sort-packages": true + }, + "version": "2.4.4-p1", + "require": { + "magento/product-community-edition": "2.4.4-p1", + "ecomdev/magento2-compiler": "*" + }, + "autoload": { + "exclude-from-classmap": [ + "**/dev/**", + "**/update/**", + "**/Test/**" + ], + "files": [ + "app/etc/NonComposerComponentRegistration.php" + ], + "psr-0": { + "": [ + "app/code/", + "generated/code/" + ] + }, + "psr-4": { + "Magento\\": "app/code/Magento/", + "Magento\\Framework\\": "lib/internal/Magento/Framework/", + "Magento\\Setup\\": "setup/src/Magento/Setup/" + } + }, + "require-dev": { + "allure-framework/allure-phpunit": "~1.5.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", + "friendsofphp/php-cs-fixer": "~3.4.0", + "lusitanian/oauth": "~0.8.10", + "magento/magento-coding-standard": "*", + "magento/magento2-functional-testing-framework": "^3.7", + "pdepend/pdepend": "~2.10.0", + "phpmd/phpmd": "^2.12.0", + "phpstan/phpstan": "^1.6.8", + "phpunit/phpunit": "~9.5.20", + "sebastian/phpcpd": "^6.0.3", + "squizlabs/php_codesniffer": "~3.6.0", + "symfony/finder": "^5.2" + }, + "conflict": { + "gene/bluefoot": "*" + }, + "autoload-dev": { + "psr-4": { + "Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/", + "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/", + "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/", + "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/", + "Magento\\Tools\\": "dev/tools/Magento/Tools/", + "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/" + } + }, + "prefer-stable": true, + "extra": { + "magento-force": "override" + }, + "repositories": [ + { + "type": "composer", + "url": "https://mirror.mage-os.org" + }, + { + "type": "path", + "url": "../../" + } + ], + "minimum-stability": "dev" +} diff --git a/build/2.4.4/composer.json b/build/2.4.4/composer.json new file mode 100644 index 0000000..141579d --- /dev/null +++ b/build/2.4.4/composer.json @@ -0,0 +1,87 @@ +{ + "name": "magento/project-community-edition", + "description": "eCommerce Platform for Growth (Community Edition)", + "type": "project", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "laminas/laminas-dependency-plugin": true, + "magento/*": true + }, + "preferred-install": "dist", + "sort-packages": true + }, + "version": "2.4.4", + "require": { + "magento/product-community-edition": "2.4.4", + "ecomdev/magento2-compiler": "*" + }, + "autoload": { + "exclude-from-classmap": [ + "**/dev/**", + "**/update/**", + "**/Test/**" + ], + "files": [ + "app/etc/NonComposerComponentRegistration.php" + ], + "psr-0": { + "": [ + "app/code/", + "generated/code/" + ] + }, + "psr-4": { + "Magento\\": "app/code/Magento/", + "Magento\\Framework\\": "lib/internal/Magento/Framework/", + "Magento\\Setup\\": "setup/src/Magento/Setup/" + } + }, + "require-dev": { + "allure-framework/allure-phpunit": "~1.5.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", + "friendsofphp/php-cs-fixer": "~3.4.0", + "lusitanian/oauth": "~0.8.10", + "magento/magento-coding-standard": "*", + "magento/magento2-functional-testing-framework": "^3.7", + "pdepend/pdepend": "~2.10.0", + "phpmd/phpmd": "^2.12.0", + "phpstan/phpstan": "^1.6.8", + "phpunit/phpunit": "~9.5.20", + "sebastian/phpcpd": "^6.0.3", + "squizlabs/php_codesniffer": "~3.6.0", + "symfony/finder": "^5.2" + }, + "conflict": { + "gene/bluefoot": "*" + }, + "autoload-dev": { + "psr-4": { + "Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/", + "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/", + "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/", + "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/", + "Magento\\Tools\\": "dev/tools/Magento/Tools/", + "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/" + } + }, + "prefer-stable": true, + "extra": { + "magento-force": "override" + }, + "repositories": [ + { + "type": "composer", + "url": "https://mirror.mage-os.org" + }, + { + "type": "path", + "url": "../../" + } + ], + "minimum-stability": "dev" +} diff --git a/build/2.4.5/composer.json b/build/2.4.5/composer.json new file mode 100644 index 0000000..1a6f5b5 --- /dev/null +++ b/build/2.4.5/composer.json @@ -0,0 +1,87 @@ +{ + "name": "magento/project-community-edition", + "description": "eCommerce Platform for Growth (Community Edition)", + "type": "project", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "laminas/laminas-dependency-plugin": true, + "magento/*": true + }, + "preferred-install": "dist", + "sort-packages": true + }, + "version": "2.4.5", + "require": { + "magento/product-community-edition": "2.4.5", + "ecomdev/magento2-compiler": "*" + }, + "autoload": { + "exclude-from-classmap": [ + "**/dev/**", + "**/update/**", + "**/Test/**" + ], + "files": [ + "app/etc/NonComposerComponentRegistration.php" + ], + "psr-0": { + "": [ + "app/code/", + "generated/code/" + ] + }, + "psr-4": { + "Magento\\": "app/code/Magento/", + "Magento\\Framework\\": "lib/internal/Magento/Framework/", + "Magento\\Setup\\": "setup/src/Magento/Setup/" + } + }, + "require-dev": { + "allure-framework/allure-phpunit": "~1.5.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", + "friendsofphp/php-cs-fixer": "~3.4.0", + "lusitanian/oauth": "~0.8.10", + "magento/magento-coding-standard": "*", + "magento/magento2-functional-testing-framework": "^3.7", + "pdepend/pdepend": "~2.10.0", + "phpmd/phpmd": "^2.12.0", + "phpstan/phpstan": "^1.6.8", + "phpunit/phpunit": "~9.5.20", + "sebastian/phpcpd": "^6.0.3", + "squizlabs/php_codesniffer": "~3.6.0", + "symfony/finder": "^5.2" + }, + "conflict": { + "gene/bluefoot": "*" + }, + "autoload-dev": { + "psr-4": { + "Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/", + "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/", + "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/", + "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/", + "Magento\\Tools\\": "dev/tools/Magento/Tools/", + "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/" + } + }, + "prefer-stable": true, + "extra": { + "magento-force": "override" + }, + "repositories": [ + { + "type": "composer", + "url": "https://mirror.mage-os.org" + }, + { + "type": "path", + "url": "../../" + } + ], + "minimum-stability": "dev" +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..4a56bdf --- /dev/null +++ b/composer.json @@ -0,0 +1,56 @@ +{ + "name": "ecomdev/magento2-compiler", + "description": "Magento 2 Drop-In replacement for setup:di:compile", + "type": "magento2-module", + "license": "MIT", + "autoload": { + "psr-4": { + "EcomDev\\Magento2Compiler\\": "src/" + }, + "files": [ + "src/registration.php", + "src/commands.php" + ] + }, + "autoload-dev": { + "psr-4": { + "EcomDev\\Magento2Compiler\\": "tests/" + }, + "files": [ + "tests/functions.php" + ] + }, + "authors": [ + { + "name": "Ivan Chepurnyi", + "email": "ivan.chepurnyi@ecomdev.org" + } + ], + "require": { + "php": "~8.1", + "magento/framework": "~102.0|~103.0", + "magento/magento2-base": "~2.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~9.5" + }, + "repositories": [ + { + "type": "composer", + "url": "https://mirror.mage-os.org/" + } + ], + "config": { + "allow-plugins": { + "magento/composer-dependency-version-audit-plugin": false, + "magento/magento-composer-installer": false + } + }, + "scripts": { + "tests:unit": "phpunit tests --exclude-group integration", + "tests:integration": [ + "./build.sh", + "phpunit tests --group integration" + ] + } +} diff --git a/src/Console/Command/CompileCommand.php b/src/Console/Command/CompileCommand.php new file mode 100644 index 0000000..f5b1248 --- /dev/null +++ b/src/Console/Command/CompileCommand.php @@ -0,0 +1,27 @@ +setName('setup:di:compile'); + $this->setDescription('DI compilation powered by ecomdev/magento2-compiler.'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln("Compilation is WIP"); + } +} diff --git a/src/Console/CommandList.php b/src/Console/CommandList.php new file mode 100644 index 0000000..aff594c --- /dev/null +++ b/src/Console/CommandList.php @@ -0,0 +1,29 @@ +objectManager = $objectManager; + } + + public function getCommands(): array + { + return [ + $this->objectManager->get(CompileCommand::class) + ]; + } +} diff --git a/src/commands.php b/src/commands.php new file mode 100644 index 0000000..4ee60a5 --- /dev/null +++ b/src/commands.php @@ -0,0 +1,12 @@ +assertJson($output); + + $result = \json_decode($output, true); + + $this->assertStringContainsString("ecomdev/magento2-compiler", $result['description']); + } + + public function installedMagentoVersions(): iterable + { + foreach (buildVersions() as $version) { + yield [$version]; + } + } +} diff --git a/tests/functions.php b/tests/functions.php new file mode 100644 index 0000000..14c28e1 --- /dev/null +++ b/tests/functions.php @@ -0,0 +1,43 @@ +isDot() || !$item->isDir()) { + continue; + } + + if (!file_exists(buildPath($item->getFilename(), 'bin/magento'))) { + continue; + } + + yield $item->getFilename(); + } +}