Skip to content

Commit

Permalink
OXDEV-7248 Update GHA workflow for shop 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hkreuter committed Jan 22, 2025
1 parent 6070ba2 commit 4715833
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 80 deletions.
125 changes: 67 additions & 58 deletions .github/oxid-esales/graphql-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
81 changes: 81 additions & 0 deletions .github/oxid-esales/install.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/dispatch_module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schedule_module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/trigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }}
16 changes: 13 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions tests/Integration/EnterpriseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 17 additions & 11 deletions tests/Integration/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 4715833

Please sign in to comment.