Skip to content

Commit

Permalink
B 7.0.x fix scripts oxdev 8415 (#975) (#976) (#977)
Browse files Browse the repository at this point in the history
* Add fixed scripts
* Copy codeception output and pin twig
* Always activate apex theme
* Handle OXID_BUILD_DIRECTORY
  • Loading branch information
joernott authored Jun 27, 2024
1 parent 12b60d3 commit 059852a
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 55 deletions.
67 changes: 60 additions & 7 deletions .github/oxid-esales/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ function init() {
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/source/tmp"
export OXID_BUILD_DIRECTORY="/var/www/source/tmp"
else
echo "OXID_BUILD_DIRECTORY is set to '${OXID_BUILD_DIRECTORY}'"
fi
if [ ! -d "${OXID_BUILD_DIRECTORY}" ]; then
echo "Creating '${OXID_BUILD_DIRECTORY}'"
docker compose "${install_container_method}" -T \
${install_container_options} \
"${install_container_name}" \
mkdir -p "${OXID_BUILD_DIRECTORY}"
fi
}

init
Expand All @@ -47,7 +60,49 @@ docker compose "${install_container_method}" -T \
--db-password root \
--shop-url http://localhost.local/ \
--shop-directory /var/www/source \
--compile-directory /var/www/source/tmp
--compile-directory "${OXID_BUILD_DIRECTORY}"

if [ -e vendor/oxid-esales/oxideshop-ce ]; then
# Handle copying of the config
if [ -f source/config.inc.php.dist ] && [ -f source/config.inc.php ]; then
if diff -q source/config.inc.php.dist source/config.inc.php; then
echo "source/config.inc.php has not been modified"
TARGET=source/config.inc.php
else
echo "Config file is source/config.inc.php"
CONFIG_FILE=source/config.inc.php
fi
else
echo "source/config.inc.php does not exist"
TARGET=source/config.inc.php
fi
if [ -f vendor/oxid-esales/oxideshop-ce/source/config.inc.php.dist ] && [ -f vendor/oxid-esales/oxideshop-ce/source/config.inc.php ]; then
if diff -q vendor/oxid-esales/oxideshop-ce/source/config.inc.php.dist vendor/oxid-esales/oxideshop-ce/source/config.inc.php; then
echo "vendor/oxid-esales/oxideshop-ce/source/config.inc.php has not been modified"
if [ -n "${TARGET}" ]; then
echo "ERROR: Neither source/config.inc.php nor vendor/oxid-esales/oxideshop-ce/source/config.inc.php have been updated"
exit 1
fi
TARGET=vendor/oxid-esales/oxideshop-ce/source/config.inc.php
else
if [ -n "${CONFIG_FILE}" ]; then
echo "ERROR: Both source/config.inc.php and vendor/oxid-esales/oxideshop-ce/source/config.inc.php have been updated"
exit 1
fi
echo "Config file is vendor/oxid-esales/oxideshop-ce/source/config.inc.php"
CONFIG_FILE=vendor/oxid-esales/oxideshop-ce/source/config.inc.php
fi
else
if [ -n "${TARGET}" ]; then
echo "ERROR: Neither vendor/oxid-esales/oxideshop-ce/source/config.inc.php nor source/config.inc.php have been updated"
exit 1
fi
TARGET=source/config.inc.php
fi
cp "${CONFIG_FILE}" "${TARGET}"
else
echo "vendor/oxid-esales/oxideshop-ce does not exist, assuming conventional shop install"
fi

# Activate iDebug
if [ "${install_config_idebug}" == 'true' ]; then
Expand All @@ -60,12 +115,10 @@ if [ "${install_config_idebug}" == 'true' ]; then
fi

# Activate theme
if [ "${install_is_enterprise}" == 'true' ]; then
docker compose "${install_container_method}" -T \
${install_container_options} \
"${install_container_name}" \
${OE_CONSOLE} oe:theme:activate apex
fi
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
Expand Down
35 changes: 13 additions & 22 deletions .github/oxid-esales/shop_ce.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# {{ $org := "oxid-esales" }}organisation: {{ $org }}
# {{ $name := "oxideshop-ce" }}name: {{ $name }}
# {{ $repo := "OXID-eSales/oxideshop_ce" }}repo: {{ $repo }}

install:
install: &install
method: script
script: 'source/.github/oxid-esales/install.sh'
cache:
prepared_shop: true
container:
options: '-e SHOP_PATH=vendor/{{ $org}}/{{ $name }}/source'
composer:
root_url: ''
transform: |
{
"preferred-install": {
Expand All @@ -17,16 +16,10 @@ install:
"ddoe/*": "source"
},
"require": {
"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 }}",
"{{ $org }}/{{ $name }}": "{{ .Data.global.composer.ref_name }}"
},
"repositories": {
"{{ $org }}/{{ $name }}": {
"type": "git",
"url": "https://github.com/{{ $repo }}.git"
}
"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 }}",
"twig/twig": "v3.8.0"
}
}
output:
Expand All @@ -38,6 +31,8 @@ install:
source/vendor/oxid-esales/oxideshop-ce/source/config.inc.php
data/php/logs/error_log.txt
install_shop_with_modules: *install

runscript: &runscript
matrix:
script: |
Expand All @@ -48,16 +43,12 @@ runscript: &runscript
"setup:~/shop-setup.sh"
]
shop: &shop
path: 'vendor/{{ $org}}/{{ $name }}'
path: ''
container:
options: '-e XDEBUG_MODE=coverage -e GITHUB_EVENT_NAME={{ .Github.EventName }} -e GITHUB_BASE_REF={{ .Github.BaseRef }} -e GITHUB_REF={{ .Github.Ref }} -e GITHUB_REF_NAME={{ .Github.RefName }}'
options: '-e XDEBUG_MODE=coverage -e GITHUB_EVENT_NAME="{{ .Github.EventName }}" -e GITHUB_BASE_REF="{{ .Github.BaseRef }}" -e GITHUB_REF="{{ .Github.Ref }}" -e GITHUB_REF_NAME="{{ .Github.RefName }}" -e SELENIUM_SERVER_HOST=selenium -e BROWSER_NAME=chrome'
setup:
<<: *shop
load_shop: '{{ .Data.install_shop_with_modules.cache.prepared_shop_prefix }}'
path: 'vendor/{{ $org}}/{{ $name }}'
custom_script_container: |
cd vendor/oxid-esales/oxideshop-ce
composer config -g github-oauth.github.com "${GITHUB_TOKEN}"
composer update --no-interaction

runslim:
<<: *runscript
Expand All @@ -70,5 +61,5 @@ sonarcloud:
strip_path: '/var/www/vendor/{{ print $org }}/{{ print $name}}/'

finish:
slack_title: 'Shop CE ({{ .Data.global.git.shop_ref }}) by {{ .Github.Actor }}'
slack_title: 'Shop CE ({{ .Data.install.git.shop_ref }}) by {{ .Github.Actor }}'
slack_compact: true
97 changes: 97 additions & 0 deletions .github/oxid-esales/shop_ce_compilation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# {{ $org := "oxid-esales" }}organisation: {{ $org }}
# {{ $name := "oxideshop-ce" }}name: {{ $name }}
# {{ $repo := "OXID-eSales/oxideshop_ce" }}repo: {{ $repo }}

install:
method: script
cache:
prepared_shop: true
composer:
transform: |
{
"config": {
"allow-plugins": {
"oxid-esales/oxideshop-composer-plugin": true,
"oxid-esales/oxideshop-unified-namespace-generator": true
}
},
"preferred-install": {
"oxid-esales/*": "source",
"oxid-professional-services/*": "source",
"ddoe/*": "source"
},
"require": {
"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 }}",
"{{ $org }}/{{ $name }}": "{{ .Data.global.composer.ref_name }}"
},
"require-dev": {
"codeception/codeception": "^5.0",
"codeception/module-asserts": "^3.0",
"codeception/module-db": "^3.0",
"codeception/module-filesystem": "^3.0",
"codeception/module-webdriver": "^4.0",
"composer/composer": "^2.0",
"incenteev/composer-parameter-handler": "^v2.1.4",
"mikey179/vfsstream": "~1.6.8",
"oxid-esales/codeception-modules": "dev-b-7.1.x",
"oxid-esales/codeception-page-objects": "dev-b-7.1.x",
"oxid-esales/developer-tools": "dev-b-7.1.x",
"oxid-esales/oxideshop-ide-helper": "dev-b-7.1.x",
"phpspec/prophecy-phpunit": "^v2.0.1",
"phpunit/phpunit": "^10.4",
"squizlabs/php_codesniffer": "^3.5.4"
},
"autoload-dev": {
"psr-4": {
"OxidEsales\\EshopCommunity\\Tests\\": "./vendor/oxid-esales/oxideshop-ce/tests"
}
},
"minimum-stability": "dev",
"repositories": {
"{{ $org }}/{{ $name }}": {
"type": "git",
"url": "https://github.com/{{ $repo }}.git"
}
}
}
output:
files: |
docker-compose.yml
source/composer.json*
source/composer.lock
source/source/config.inc.php
source/vendor/oxid-esales/oxideshop-ce/source/config.inc.php
data/php/logs/error_log.txt
runscript: &runscript
matrix:
script: |
[
"shop:~/unit.sh",
"shop:~/integration.sh",
"shop:~/codeception.sh",
"setup:~/shop-setup.sh"
]
shop: &shop
path: 'vendor/{{ $org}}/{{ $name }}'
container:
options: '-e XDEBUG_MODE=coverage -e GITHUB_EVENT_NAME="{{ .Github.EventName }}" -e GITHUB_BASE_REF="{{ .Github.BaseRef }}" -e GITHUB_REF="{{ .Github.Ref }}" -e GITHUB_REF_NAME="{{ .Github.RefName }}" -e SELENIUM_SERVER_HOST=selenium -e BROWSER_NAME=chrome'
setup:
<<: *shop
load_shop: '{{ .Data.install_shop_with_modules.cache.prepared_shop_prefix }}'

runslim:
<<: *runscript
matrix:
script: '["shop:~/php-cs-report.sh"]'

sonarcloud:
matrix:
testplan: '["-","~/sonarcloud_oxideshop_ce_internal.yaml"]'
strip_path: '/var/www/vendor/{{ print $org }}/{{ print $name}}/'

finish:
slack_title: 'Shop CE ({{ .Data.global.git.shop_ref }}) by {{ .Github.Actor }}'
slack_compact: true
6 changes: 5 additions & 1 deletion tests/scripts/codeception.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ vendor/bin/codecept run acceptance \
| tee tests/Output/codeception_Acceptance.txt
RESULT=$?
echo "Codecept run exited with error code ${RESULT}"
[[ ! -d tests/Output ]] && mkdir tests/Output
if [ -n "$(find tests/Codeception/_output -type f)" ]; then
cp tests/Codeception/_output/* tests/Output
fi
if [ ! -s "tests/Output/codeception_Acceptance.txt" ]; then
echo -e "\033[0;31mLog file is empty! Seems like no tests have been run!\033[0m"
RESULT=1
Expand Down Expand Up @@ -37,7 +41,7 @@ sed -e 's|(.*)\r|$1|' -i failure_pattern.tmp
while read -r LINE ; do
if [ -n "${LINE}" ]; then
if grep -q -E "${LINE}" "tests/Output/codeception_Acceptance.txt"; then
echo -e "\033[0;31m runtest failed matching pattern ${LINE}\033[0m"
echo -e "\033[0;31m codecept ${SUITE} failed matching pattern ${LINE}\033[0m"
grep -E "${LINE}" "tests/Output/codeception_Acceptance.txt"
RESULT=1
else
Expand Down
14 changes: 12 additions & 2 deletions tests/scripts/deprecated.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
#!/bin/bash
set -e
export XDEBUG_MODE=coverage
SUITE="AllTestsUnit"
RUNTEST="vendor/bin/runtests"
if [ ! -f "${RUNTEST}" ]; then
RUNTEST="/var/www/${RUNTEST}"
if [ ! -f "${RUNTEST}" ]; then
echo -e "\033[0;31mCould not find runtests in vendor/bin or /var/www/vendor/bin\033[0m"
exit 1
fi
fi
cp vendor/oxid-esales/testing-library/test_config.yml.dist test_config.yml
XDEBUG_MODE=coverage vendor/bin/runtests \
"${RUNTEST}" \
--coverage-clover=tests/Reports/coverage_deprecated_tests.xml \
AllTestsUnit 2>&1 \
"${SUITE}" 2>&1 \
| tee "tests/Output/deprecated_tests.txt"
RESULT=$?
echo "runtest exited with error code ${RESULT}"
Expand Down
12 changes: 10 additions & 2 deletions tests/scripts/integration.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/bin/bash
set -e
vendor/bin/phpunit \
PHPUNIT="vendor/bin/phpunit"
if [ ! -f "${PHPUNIT}" ]; then
PHPUNIT="/var/www/${PHPUNIT}"
if [ ! -f "${PHPUNIT}" ]; then
echo -e "\033[0;31mCould not find phpunit in vendor/bin or /var/www/vendor/bin\033[0m"
exit 1
fi
fi
"${PHPUNIT}" \
-c phpunit.xml \
--bootstrap tests/bootstrap.php \
--coverage-clover=tests/Reports/coverage_phpunit_integration.xml \
Expand Down Expand Up @@ -39,7 +47,7 @@ while read -r LINE ; do
grep -E "${LINE}" "tests/Output/integration_tests.txt"
RESULT=1
else
echo -e "\033[0;32m runtest passed matching pattern ${LINE}"
echo -e "\033[0;32m integration test passed matching pattern ${LINE}"
fi
fi
done <failure_pattern.tmp
Expand Down
Loading

0 comments on commit 059852a

Please sign in to comment.