From 4715833d0131e03d6e7266d60e465d9a2ce18b30 Mon Sep 17 00:00:00 2001 From: hkreuter Date: Fri, 17 Jan 2025 11:41:26 +0100 Subject: [PATCH] OXDEV-7248 Update GHA workflow for shop 8.0 --- .github/oxid-esales/graphql-base.yaml | 125 ++++++++++++----------- .github/oxid-esales/install.sh | 81 +++++++++++++++ .github/workflows/dispatch_module.yaml | 2 +- .github/workflows/schedule_module.yaml | 2 +- .github/workflows/trigger.yaml | 3 +- composer.json | 16 ++- tests/Integration/EnterpriseTestCase.php | 7 +- tests/Integration/TestCase.php | 28 +++-- 8 files changed, 184 insertions(+), 80 deletions(-) create mode 100755 .github/oxid-esales/install.sh diff --git a/.github/oxid-esales/graphql-base.yaml b/.github/oxid-esales/graphql-base.yaml index 9f8fb1c0..14e7861c 100644 --- a/.github/oxid-esales/graphql-base.yaml +++ b/.github/oxid-esales/graphql-base.yaml @@ -3,71 +3,80 @@ # {{ $name := "graphql-base" }}name: {{ $name }} # {{ $repo := "OXID-eSales/graphql-base-module" }}repo: {{ $repo }} +install: + cache: + prepared_shop: false + method: 'script' + script: 'source/.github/oxid-esales/install.sh' + git: + repository: 'OXID-eSales/graphql-base-module' + ref: &ref 'b-8.0.x-GHA-OXDEV-7248' + shop_url: 'https://github.com/OXID-eSales/graphql-base-module.git' + shop_ref: 'b-8.0.x-GHA-OXDEV-7248' + container: + options: '-e ESHOP_BOOTSTRAP_PATH=vendor/oxid-esales/oxideshop-ce/source/bootstrap.php -e THEME_ID=apex' + composer: + root_url: '' + transform: | + { + "config": { + "allow-plugins": { + "infection/extension-installer": true, + "oxid-esales/oxideshop-unified-namespace-generator": true, + "oxid-esales/oxideshop-composer-plugin": true + } + }, + "autoload-dev":{ + "psr-4": { + "OxidEsales\\EshopCommunity\\Tests\\": "./vendor/oxid-esales/oxideshop-ce/tests" + } + } + } + custom_script_container: | + perl -pi -e 'print "SetEnvIf Authorization \"(.*)\" HTTP_AUTHORIZATION=\$1\n\n" if $. == 1' source/.htaccess + vendor/bin/oe-console oe:module:install /var/www + vendor/bin/oe-console oe:database:reset --force + vendor/bin/oe-console oe:theme:activate apex + vendor/bin/oe-console oe:module:activate oe_graphql_base + install_shop_with_modules: - cache: - prepared_shop: false - composer: - transform: | - { - "require": { - "oxid-esales/oxideshop-ce": "{{ .Data.global.composer.dev_ref }}", - "oxid-esales/twig-component": "{{ .Data.global.composer.dev_ref }}", - "oxid-esales/twig-admin-theme": "{{ .Data.global.composer.dev_ref }}", - "oxid-esales/apex-theme": "{{ .Data.global.composer.dev_ref }}", - "oxid-esales/developer-tools": "{{ .Data.global.composer.dev_ref }}", - "{{ $org }}/{{ $name }}": "{{ .Data.global.composer.ref_name }}" - }, - "autoload-dev":{ - "psr-4": { - "OxidEsales\\EshopCommunity\\Tests\\": "./vendor/oxid-esales/oxideshop-ce/tests", - "OxidEsales\\Graphql\\Base\\Tests\\": "./vendor/oxid-esales/graphql-base/tests" - } - }, - "repositories": { - "{{ $org }}/{{ $name }}": { - "type": "git", - "url": "https://github.com/{{ $repo }}.git" - } - } - } - custom_script_container: | - perl -pi -e 'print "SetEnvIf Authorization \"(.*)\" HTTP_AUTHORIZATION=\$1\n\n" if $. == 1' source/.htaccess - vendor/bin/oe-console oe:database:reset --db-host=mysql --db-port=3306 --db-name=example --db-user=root --db-password=root --force - vendor/bin/oe-console oe:module:activate "{{ $ids }}" - vendor/bin/oe-console oe:theme:activate apex + add_services: 'selenium-chrome-debug' + composer: + root_url: '' + transform: '' runscript: &runscript - matrix: - script: | - [ - "graphql_base:tests-unit", - "graphql_base:tests-integration", - "graphql_base:tests-codeception" - ] - graphql_base: - path: 'vendor/{{ $org}}/{{ $name }}' + matrix: + script: | + [ + "graphql_base:tests-unit", + "graphql_base:tests-integration", + "graphql_base:tests-codeception" + ] + graphql_base: + path: '' runslim: - <<: *runscript - matrix: - script: | - [ - "graphql_base:phpcs", - "graphql_base:phpstan", - "graphql_base:phpmd" - ] + <<: *runscript + matrix: + script: | + [ + "graphql_base:phpcs", + "graphql_base:phpstan", + "graphql_base:phpmd" + ] sonarcloud: - matrix: - testplan: '["-"]' - strip_path: '/var/www/vendor/{{ print $org }}/{{ print $name}}/' - project_key: 'OXID-eSales_graphql-base-module' - project_name: '{{ $org}}/{{ $name }}' - parameters: | - -Dsonar.language=php \ - -Dsonar.scm.provider=git \ - -Dsonar.sources=src \ - -Dsonar.tests=tests + matrix: + testplan: '["-"]' + strip_path: '/var/www/vendor/{{ print $org }}/{{ print $name}}/' + project_key: 'OXID-eSales_graphql-base-module' + project_name: '{{ $org}}/{{ $name }}' + parameters: | + -Dsonar.language=php \ + -Dsonar.scm.provider=git \ + -Dsonar.sources=src \ + -Dsonar.tests=tests finish: slack_title: '{{ print $name }} ({{ .Data.global.git.shop_ref }}) by {{ .Github.Actor }}' diff --git a/.github/oxid-esales/install.sh b/.github/oxid-esales/install.sh new file mode 100755 index 00000000..e91d72e1 --- /dev/null +++ b/.github/oxid-esales/install.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# shellcheck disable=SC2154 +# Lower case environment variables are passed from the workflow and used here +# We use a validation loop in init to ensure, they're set +# shellcheck disable=SC2086 +# We want install_container_options to count as multiple arguments +set -e + +function error() { + echo -e "\033[0;31m${1}\033[0m" + exit 1 +} + +function init() { + for VAR in install_container_method install_container_options install_container_name \ + install_config_idebug install_is_enterprise; do + echo -n "Checking, if $VAR is set ..." + if [ -z ${VAR+x} ]; then + error "Variable '${VAR}' not set" + fi + echo "OK, ${VAR}='${!VAR}'" + done + echo -n "Locating oe-console ... " + cd source || exit 1 + if [ -f 'bin/oe-console' ]; then + OE_CONSOLE='bin/oe-console' + else + if [ -f 'vendor/bin/oe-console' ]; then + OE_CONSOLE='vendor/bin/oe-console' + else + error "Can't find oe-console in bin or vendor/bin!" + fi + fi + echo "OK, using '${OE_CONSOLE}'" + if [ -z "${OXID_BUILD_DIRECTORY}" ]; then + echo "OXID_BUILD_DIRECTORY is not set, setting it to /var/www/var/cache/" + export OXID_BUILD_DIRECTORY="/var/www/var/cache/" + else + echo "OXID_BUILD_DIRECTORY is set to '${OXID_BUILD_DIRECTORY}'" + fi + if [ ! -d "${OXID_BUILD_DIRECTORY/\/var\/www/source}" ]; then + echo "Creating '${OXID_BUILD_DIRECTORY}'" + + docker compose "${install_container_method}" -T \ + ${install_container_options} \ + "${install_container_name}" \ + mkdir -p "${OXID_BUILD_DIRECTORY}" + + echo "done with build directory" + fi +} + +init + +cp vendor/oxid-esales/oxideshop-ce/.env.dist .env +cat .env + + +# Run Install Shop +docker compose "${install_container_method}" -T \ + ${install_container_options} \ + "${install_container_name}" \ + ${OE_CONSOLE} oe:database:reset --force + +# Activate iDebug +if [ "${install_config_idebug}" == 'true' ]; then + export OXID_DEBUG_MODE="true" +fi + +# Activate theme +docker compose "${install_container_method}" -T \ + ${install_container_options} \ + "${install_container_name}" \ + ${OE_CONSOLE} oe:theme:activate apex + +# Output PHP error log +if [ -s data/php/logs/error_log.txt ]; then + echo -e "\033[0;35mPHP error log\033[0m" + cat data/php/logs/error_log.txt +fi +exit 0 diff --git a/.github/workflows/dispatch_module.yaml b/.github/workflows/dispatch_module.yaml index f078975e..5c16b36d 100644 --- a/.github/workflows/dispatch_module.yaml +++ b/.github/workflows/dispatch_module.yaml @@ -44,7 +44,7 @@ jobs: ;; esac # shellcheck disable=SC2088 - TESTPLAN="~/defaults/7.3.x.yaml,${LIMIT}~/graphql-base.yaml" + TESTPLAN="~/defaults/8.0.x.yaml,${LIMIT}~/graphql-base.yaml" echo "testplan=${TESTPLAN}" | tee -a "${GITHUB_OUTPUT}" dispatch_stable: diff --git a/.github/workflows/schedule_module.yaml b/.github/workflows/schedule_module.yaml index 19145bab..e38f4870 100644 --- a/.github/workflows/schedule_module.yaml +++ b/.github/workflows/schedule_module.yaml @@ -8,7 +8,7 @@ jobs: call_matrix: uses: OXID-eSales/github-actions/.github/workflows/universal_workflow_light.yaml@v4 with: - testplan: '~/defaults/7.3.x.yaml,~/graphql-base.yaml' + testplan: '~/defaults/8.0.x.yaml,~/graphql-base.yaml' runs_on: '"ubuntu-latest"' defaults: 'v4' plan_folder: '.github/oxid-esales' diff --git a/.github/workflows/trigger.yaml b/.github/workflows/trigger.yaml index 6cb80f05..37704253 100644 --- a/.github/workflows/trigger.yaml +++ b/.github/workflows/trigger.yaml @@ -8,7 +8,7 @@ jobs: call_matrix: uses: OXID-eSales/github-actions/.github/workflows/universal_workflow_light.yaml@v4 with: - testplan: '~/defaults/7.3.x.yaml,~/defaults/php8.2_mysql8.0_only.yaml,~/graphql-base.yaml' + testplan: '~/defaults/8.0.x.yaml,~/defaults/php8.3_mysql8.0_only.yaml,~/graphql-base.yaml' runs_on: '"ubuntu-latest"' defaults: 'v4' plan_folder: '.github/oxid-esales' @@ -20,4 +20,3 @@ jobs: CACHE_SECRET_KEY: ${{ secrets.CACHE_SECRET_KEY }} enterprise_github_token: ${{ secrets.enterprise_github_token }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/composer.json b/composer.json index b5eebb79..a8a28be8 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require-dev": { "phpunit/phpunit": "^10.4", "ext-xdebug": "*", - "oxid-esales/oxideshop-ce": "dev-b-7.3.x", + "oxid-esales/oxideshop-ce": "dev-b-8.0.x", "phpstan/phpstan": "^1.10", "squizlabs/php_codesniffer": "3.*", "phpmd/phpmd": "^2.11", @@ -27,8 +27,18 @@ "codeception/module-phpbrowser": "*", "codeception/module-db": "*", "codeception/codeception": "^5.0", - "oxid-esales/codeception-modules": "dev-b-7.3.x", - "codeception/module-asserts": "^3.0" + "oxid-esales/codeception-modules": "dev-b-8.0.x", + "codeception/module-asserts": "^3.0", + "oxid-esales/oxideshop-ce": "dev-b-8.0.x", + "oxid-esales/twig-component": "dev-b-8.0.x", + "oxid-esales/twig-admin-theme": "dev-b-8.0.x", + "oxid-esales/apex-theme": "dev-b-8.0.x", + "oxid-esales/oxideshop-composer-plugin": "dev-b-8.0.x", + "oxid-esales/oxideshop-db-views-generator": "dev-b-8.0.x", + "oxid-esales/oxideshop-demodata-installer": "dev-b-8.0.x", + "oxid-esales/oxideshop-doctrine-migration-wrapper": "dev-b-8.0.x", + "oxid-esales/oxideshop-unified-namespace-generator": "dev-b-8.0.x", + "oxid-esales/developer-tools": "dev-b-8.0.x" }, "conflict": { "oxid-esales/oxideshop-ce": "<7.2" diff --git a/tests/Integration/EnterpriseTestCase.php b/tests/Integration/EnterpriseTestCase.php index 41043333..3b91a20e 100644 --- a/tests/Integration/EnterpriseTestCase.php +++ b/tests/Integration/EnterpriseTestCase.php @@ -9,15 +9,14 @@ namespace OxidEsales\GraphQL\Base\Tests\Integration; -use OxidEsales\Facts\Facts; +use OxidEsales\EshopCommunity\Internal\Framework\Edition\Edition; +use OxidEsales\EshopCommunity\Internal\Framework\Edition\EditionDirectoriesLocator; abstract class EnterpriseTestCase extends TokenTestCase { public function setUp(): void { - $facts = new Facts(); - - if ($facts->getEdition() !== 'EE') { + if (!(new EditionDirectoriesLocator())->getEditionRootPath(Edition::Enterprise)) { $this->markTestSkipped('Skip EE related tests for CE/PE edition'); return; diff --git a/tests/Integration/TestCase.php b/tests/Integration/TestCase.php index 772ac35a..4388e931 100644 --- a/tests/Integration/TestCase.php +++ b/tests/Integration/TestCase.php @@ -12,7 +12,8 @@ use DateTimeImmutable; use Lcobucci\JWT\UnencryptedToken; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; -use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface; +use OxidEsales\EshopCommunity\Core\Di\ContainerFacade; +use OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionFactoryInterface; use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use OxidEsales\EshopCommunity\Tests\TestContainerFactory; use OxidEsales\Facts\Facts; @@ -46,23 +47,20 @@ public function setUp(): void { parent::setUp(); - $connection = ContainerFactory::getInstance() - ->getContainer() - ->get(QueryBuilderFactoryInterface::class) + ContainerFacade::get(ConnectionFactoryInterface::class) ->create() - ->getConnection(); - - $connection->executeStatement( - file_get_contents( - __DIR__ . '/../Fixtures/dump.sql' - ) - ); + ->executeStatement( + file_get_contents( + __DIR__ . '/../Fixtures/dump.sql' + ) + ); \OxidEsales\Eshop\Core\Registry::getLang()->resetBaseLanguage(); if (static::$container !== null) { return; } + $containerFactory = new TestContainerFactory(); static::$container = $containerFactory->create(); @@ -97,6 +95,14 @@ public function setUp(): void 'oxidesales.graphqlbase.cacheadapter', $cache ); + static::$container->setParameter( + 'oxid_esales.db.replicate', + false + ); + static::$container->setParameter( + 'oxid_esales.db.replicas', + [] + ); static::beforeContainerCompile();