From 231d5a79959e354b56aa3f8881901acd75e444dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Kr=C3=A4ml?= Date: Fri, 6 Dec 2024 12:08:44 +0100 Subject: [PATCH] NEXT-00000 - Add Github Actions --- .../actions/setup-magento-plugin/action.yml | 48 +++++++++++++++++++ .github/workflows/integration.yml | 44 +++++++++++++++++ .github/workflows/php.yml | 34 +++++++++++++ bin/phpstan-config-generator.php | 5 +- 4 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 .github/actions/setup-magento-plugin/action.yml create mode 100644 .github/workflows/integration.yml create mode 100644 .github/workflows/php.yml diff --git a/.github/actions/setup-magento-plugin/action.yml b/.github/actions/setup-magento-plugin/action.yml new file mode 100644 index 0000000..097f40e --- /dev/null +++ b/.github/actions/setup-magento-plugin/action.yml @@ -0,0 +1,48 @@ +name: Setup SwagMigrationMagento +description: "Setup steps for SwagMigrationMagento" +author: "shopware AG" +branding: + color: "blue" + icon: "download" + +inputs: + php-version: + default: "8.2" + required: false + description: "Which PHP version should be used" + mysql-version: + default: "builtin" + required: false + description: "Which MySQL version should be used" + +runs: + using: composite + steps: + - name: Setup SwagMigrationMagento + uses: shopware/github-actions/setup-extension@main + with: + extensionName: SwagMigrationMagento + install: true + install-admin: true + phpVersion: ${{ inputs.php-version }} + mysqlVersion: ${{ inputs.mysql-version }} + extraRepositories: | + { + "SwagMigrationAssistant": { + "type": "path", + "url": "custom/plugins/SwagMigrationAssistant", + "symlink": true + }, + "${{ github.event.repository.name }}": { + "type": "path", + "url": "custom/plugins/${{ github.event.repository.name }}", + "symlink": true + } + } + dependencies: | + [ + { + "name": "SwagMigrationAssistant", + "repo": "https://github.com/shopware/SwagMigrationAssistant.git" + } + ] diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..3b03410 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,44 @@ +name: Integration +on: + workflow_dispatch: + push: + branches: + - trunk + pull_request: + +jobs: + danger: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker://ghcr.io/shyim/danger-php:latest + with: + args: ci + env: + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_PULL_REQUEST_ID: ${{ github.event.pull_request.number }} + if: ${{ env.ACT != 'true' }} # Don't execute on local runs, this can only fail + + phpunit: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + MYSQL_IMAGE: ["mysql:8.0", "mariadb:10.11"] + PHP_VERSION: ["8.2", "8.3"] + steps: + - name: Checkout SwagMigrationMagento + uses: actions/checkout@v4 + with: + path: custom/plugins/${{ github.event.repository.name }} + - name: Setup SwagMigrationMagento + uses: ./custom/plugins/SwagMigrationMagento/.github/actions/setup-magento-plugin + with: + php-version: ${{ matrix.PHP_VERSION }} + mysql-version: ${{ matrix.MYSQL_IMAGE }} + - name: Run PHPUnit + working-directory: custom/plugins/${{ github.event.repository.name }} + run: | + composer dump-autoload --dev + php -d pcov.enabled=1 -d pcov.directory=${PWD}/src -d pcov.exclude='~(vendor|tests|node_modules)~' ${GITHUB_WORKSPACE}/vendor/bin/phpunit --configuration phpunit.xml.dist diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..559c2b1 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,34 @@ +name: PHP Checks +on: + workflow_dispatch: + push: + branches: + - trunk + pull_request: + paths: + - composer.json + - src/**/*.php + - tests/**/*.php + +jobs: + codestyle_php: + name: Codestyle PHP + runs-on: ubuntu-latest + steps: + - uses: shopware/github-actions/cs-fixer@main + with: + rules: "" + + phpstan: + runs-on: ubuntu-latest + steps: + - name: Checkout SwagMigrationMagento + uses: actions/checkout@v4 + with: + path: custom/plugins/${{ github.event.repository.name }} + - name: Setup SwagMigrationMagento + uses: ./custom/plugins/SwagMigrationMagento/.github/actions/setup-magento-plugin + - name: Run PHPStan + run: | + symfony composer -d custom/plugins/${{ github.event.repository.name }} dump-autoload --dev + symfony composer -d custom/plugins/${{ github.event.repository.name }} run phpstan diff --git a/bin/phpstan-config-generator.php b/bin/phpstan-config-generator.php index cda631d..fe607c3 100755 --- a/bin/phpstan-config-generator.php +++ b/bin/phpstan-config-generator.php @@ -6,9 +6,9 @@ * file that was distributed with this source code. */ +use Shopware\Core\DevOps\StaticAnalyze\StaticAnalyzeKernel; use Shopware\Core\Framework\Adapter\Kernel\KernelFactory; use Shopware\Core\Framework\Plugin\KernelPluginLoader\StaticKernelPluginLoader; -use Shopware\Core\DevOps\StaticAnalyze\StaticAnalyzeKernel; use Swag\MigrationMagento\SwagMigrationMagento; use SwagMigrationAssistant\SwagMigrationAssistant; use Symfony\Component\Dotenv\Dotenv; @@ -21,7 +21,6 @@ (new Dotenv())->usePutEnv()->load($projectRoot . '/.env'); } - $magentoPluginRootPath = dirname(__DIR__); $magentoComposerJson = json_decode((string) file_get_contents($magentoPluginRootPath . '/composer.json'), true); $assistantPluginRootPath = $magentoPluginRootPath . '/../SwagMigrationAssistant'; @@ -77,7 +76,7 @@ [ str_replace($kernel->getProjectDir(), '', $kernel->getCacheDir()), $projectRoot . (is_dir($projectRoot . '/platform') ? '/platform' : ''), - str_replace('\\', '_', get_class($kernel)), + str_replace('\\', '_', $kernel::class), ], $phpStanConfigDist );