Skip to content

Commit

Permalink
Merge pull request #14 from b13/task/v13
Browse files Browse the repository at this point in the history
Add v13 compatibility
  • Loading branch information
ochorocho authored Jan 15, 2025
2 parents b0337ae + fac1e35 commit ff9a301
Show file tree
Hide file tree
Showing 24 changed files with 132 additions and 235 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php: [ '8.1']
TYPO3: [ '12' ]
php: [ '8.2']
TYPO3: [ '12', '13' ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ public
composer.lock
vendor
.php_cs.cache
.php-cs-fixer.cache
/.Build
/Build/testing-docker/.env
68 changes: 26 additions & 42 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/usr/bin/env bash

#
# TYPO3 core test runner based on docker and docker-compose.
# TYPO3 core test runner based on docker and "docker compose".
#

# Function to write a .env file in Build/testing-docker
# This is read by docker-compose and vars defined here are
# This is read by "docker compose" and vars defined here are
# used in Build/testing-docker/docker-compose.yml
setUpDockerComposeDotEnv() {
# Delete possibly existing local .env file if exists
[ -e .env ] && rm .env
# Set up a new .env file for docker-compose
# Set up a new .env file for "docker compose"
{
echo "COMPOSE_PROJECT_NAME=local"
# To prevent access rights of files created by the testing, the docker image later
# runs with the same user that is currently executing the script. docker-compose can't
# runs with the same user that is currently executing the script. "docker compose" can't
# use $UID directly itself since it is a shell variable and not an env variable, so
# we have to set it explicitly here.
echo "HOST_UID=`id -u`"
Expand All @@ -40,7 +40,7 @@ read -r -d '' HELP <<EOF
make test runner. Execute unit test suite and some other details.
Also used by github actions for test execution.
Successfully tested with docker version 18.06.1-ce and docker-compose 1.21.2.
Successfully tested with docker version 18.06.1-ce and "docker compose" 1.21.2.
Usage: $0 [options] [file]
Expand Down Expand Up @@ -69,7 +69,7 @@ Options:
- postgres: use postgres
- sqlite: use sqlite
-p <8.0|8.1>
-p <8.0|8.1|8.2|8.3>
Specifies the PHP minor version to be used
- 8.0 (default): use PHP 8.0
Expand Down Expand Up @@ -114,22 +114,6 @@ Examples:
./Build/Scripts/runTests.sh -p 8.0
EOF

# Test if docker-compose exists, else exit out with error
if ! type "docker-compose" > /dev/null; then
echo "This script relies on docker and docker-compose. Please install" >&2
exit 1
fi

# docker-compose v2 is enabled by docker for mac as experimental feature without
# asking the user. v2 is currently broken. Detect the version and error out.
DOCKER_COMPOSE_VERSION=$(docker-compose version --short)
DOCKER_COMPOSE_MAJOR=$(echo "$DOCKER_COMPOSE_VERSION" | cut -d'.' -f1 | tr -d 'v')
if [ "$DOCKER_COMPOSE_MAJOR" -gt "1" ]; then
echo "docker-compose $DOCKER_COMPOSE_VERSION is currently broken and not supported by runTests.sh."
echo "If you are running Docker Desktop for MacOS/Windows disable 'Use Docker Compose V2 release candidate' (Settings > Experimental Features)"
exit 1
fi

# Go to the directory this script is located, so everything else is relative
# to this dir, no matter from where this script is called.
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
Expand All @@ -149,7 +133,7 @@ fi
# Option defaults
TEST_SUITE="unit"
DBMS="mariadb"
PHP_VERSION="8.0"
PHP_VERSION="8.2"
PHP_XDEBUG_ON=0
PHP_XDEBUG_PORT=9003
EXTRA_TEST_OPTIONS=""
Expand All @@ -173,7 +157,7 @@ while getopts ":s:d:p:e:t:xy:nhuv" OPT; do
;;
p)
PHP_VERSION=${OPTARG}
if ! [[ ${PHP_VERSION} =~ ^(8.0|8.1)$ ]]; then
if ! [[ ${PHP_VERSION} =~ ^(8.0|8.1|8.2|8.3)$ ]]; then
INVALID_OPTIONS+=("${OPTARG}")
fi
;;
Expand Down Expand Up @@ -240,46 +224,46 @@ fi
case ${TEST_SUITE} in
acceptance)
setUpDockerComposeDotEnv
docker-compose run acceptance_backend_mariadb10
docker compose run acceptance_backend_mariadb10
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
cgl)
# Active dry-run for cgl needs not "-n" but specific options
if [ -n "${CGLCHECK_DRY_RUN}" ]; then
CGLCHECK_DRY_RUN="--dry-run --diff"
fi
setUpDockerComposeDotEnv
docker-compose run cgl
docker compose run cgl
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
composerUpdate)
setUpDockerComposeDotEnv
docker-compose run composer_update
docker compose run composer_update
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
composerValidate)
setUpDockerComposeDotEnv
docker-compose run composer_validate
docker compose run composer_validate
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
functional)
setUpDockerComposeDotEnv
case ${DBMS} in
mariadb)
docker-compose run functional_mariadb10
docker compose run functional_mariadb10
SUITE_EXIT_CODE=$?
;;
postgres)
docker-compose run functional_postgres10
docker compose run functional_postgres10
SUITE_EXIT_CODE=$?
;;
sqlite)
mkdir -p ${CORE_ROOT}/.Build/Web/typo3temp/var/tests/functional-sqlite-dbs/
docker-compose run functional_sqlite
docker compose run functional_sqlite
SUITE_EXIT_CODE=$?
;;
*)
Expand All @@ -288,25 +272,25 @@ case ${TEST_SUITE} in
echo "${HELP}" >&2
exit 1
esac
docker-compose down
docker compose down
;;
lint)
setUpDockerComposeDotEnv
docker-compose run lint
docker compose run lint
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
phpstan)
setUpDockerComposeDotEnv
docker-compose run phpstan
docker compose run phpstan
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
unit)
setUpDockerComposeDotEnv
docker-compose run unit
docker compose run unit
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
update)
# pull typo3/core-testing-*:latest versions of those ones that exist locally
Expand Down
1 change: 1 addition & 0 deletions Build/php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

$config = \TYPO3\CodingStandards\CsFixerConfig::create();
$config->getFinder()->in(['Classes', 'Configuration']);
$config->getFinder()->exclude(['var', 'public']);
return $config;
4 changes: 2 additions & 2 deletions Build/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Psr\\\\Http\\\\Message\\\\ServerRequestInterface\\:\\:setControllerExtensionName\\(\\)\\.$#"
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Database\\\\Connection\\:\\:getSchemaManager\\(\\)\\.$#"
count: 1
path: ../Classes/Backend/ToolbarItems/JobStatusToolbarItem.php
path: ../Classes/Domain/Service/DatabaseParameterBuilder.php
21 changes: 1 addition & 20 deletions Build/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '2.3'
services:
chrome:
# Image for Mac M1
Expand Down Expand Up @@ -106,25 +105,7 @@ services:
set -x
fi
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
php -dxdebug.mode=off \
.Build/bin/php-cs-fixer fix \
-v \
${CGLCHECK_DRY_RUN} \
--config=Build/php-cs-fixer.php \
--using-cache=no .
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
PHP_CS_FIXER_ALLOW_XDEBUG=1 \
.Build/bin/php-cs-fixer fix \
-v \
${CGLCHECK_DRY_RUN} \
--config=Build/php-cs-fixer.php \
--using-cache=no .
fi
${CORE_ROOT}/.Build/bin/php-cs-fixer fix --config Build/php-cs-fixer.php
"
composer_update:
Expand Down
10 changes: 5 additions & 5 deletions Classes/Backend/Controller/Ajax/JobController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
Expand Down Expand Up @@ -61,7 +61,7 @@ public function create(ServerRequestInterface $request): Response
'flashMessage' => [
'title' => 'OK',
'message' => LocalizationUtility::translate('LLL:EXT:content_sync/Resources/Private/Language/locallang.xlf:flashMessage.job-created'),
'severity' => FlashMessage::OK,
'severity' => ContextualFeedbackSeverity::OK,
],
'content' => $view->render(),
];
Expand All @@ -70,7 +70,7 @@ public function create(ServerRequestInterface $request): Response
'flashMessage' => [
'title' => 'ERROR',
'message' => LocalizationUtility::translate('LLL:EXT:content_sync/Resources/Private/Language/locallang.xlf:flashMessage.job-not-created'),
'severity' => FlashMessage::ERROR,
'severity' => ContextualFeedbackSeverity::ERROR,
],
];
}
Expand All @@ -93,7 +93,7 @@ public function kill(ServerRequestInterface $request): Response
'flashMessage' => [
'title' => 'OK',
'message' => LocalizationUtility::translate('LLL:EXT:content_sync/Resources/Private/Language/locallang.xlf:flashMessage.job-killed'),
'severity' => FlashMessage::OK,
'severity' => ContextualFeedbackSeverity::OK,
],
'content' => $view->render(),
];
Expand All @@ -102,7 +102,7 @@ public function kill(ServerRequestInterface $request): Response
'flashMessage' => [
'title' => 'ERROR',
'message' => LocalizationUtility::translate('LLL:EXT:content_sync/Resources/Private/Language/locallang.xlf:flashMessage.job-not-killed'),
'severity' => FlashMessage::ERROR,
'severity' => ContextualFeedbackSeverity::ERROR,
],
'content' => $view->render(),
];
Expand Down
8 changes: 1 addition & 7 deletions Classes/Backend/ToolbarItems/JobStatusToolbarItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use B13\ContentSync\Domain\Factory\StatusReportFactory;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
Expand All @@ -27,7 +26,7 @@ class JobStatusToolbarItem implements ToolbarItemInterface
public function __construct(StatusReportFactory $statusReportFactory, PageRenderer $pageRenderer)
{
$this->statusReportFactory = $statusReportFactory;
$pageRenderer->loadRequireJsModule('TYPO3/CMS/ContentSync/ContentSync');
$pageRenderer->loadJavaScriptModule('@b13/content-sync/content-sync.js');
}

public function checkAccess(): bool
Expand Down Expand Up @@ -76,11 +75,6 @@ protected function getFluidTemplateObject(string $filename): StandaloneView
$view->setPartialRootPaths(['EXT:backend/Resources/Private/Partials/ToolbarItems', 'EXT:content_sync/Resources/Private/Partials']);

$templateRootPaths = ['EXT:content_sync/Resources/Private/Templates/ToolbarItems'];
// @todo: remove when v11 was dropped
if ((new Typo3Version())->getMajorVersion() < 12) {
$templateRootPaths = ['EXT:content_sync/Resources/Private/Templates/ToolbarItemsV11'];
$view->getRequest()->setControllerExtensionName('ContentSync');
}

$view->setTemplateRootPaths($templateRootPaths);
$view->setTemplate($filename);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/StatusReportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
$statusReport->getJob()->getConfiguration()->getTargetNode()->getConnection() . ')'
);
switch ($statusReport->getJob()->getStatus()) {
case Job::STATUS_WATING:
case Job::STATUS_WAITING:
$output->writeln(
LocalizationUtility::translate($llPrefix . 'job.created-at') . ': ' .
$statusReport->getJob()->getCreatedTime()->format(LocalizationUtility::translate($llPrefix . 'date-format'))
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

class Job
{
public const STATUS_WATING = 0;
public const STATUS_WAITING = 0;
public const STATUS_RUNNING = 1;
public const STATUS_FINISHED = 2;
public const STATUS_KILLED = 3;
public const STATUS_FAILED = 4;
// can be killed after 10m running
public const KILLABLE_TIMELIMIT = 600;

protected $status = self::STATUS_WATING;
protected int $status = self::STATUS_WAITING;
protected Configuration $configuration;
protected \DateTime $startTime;
protected \DateTime $endTime;
Expand Down Expand Up @@ -126,7 +126,7 @@ public function isKillable(): bool
{
return
$this->status === self::STATUS_RUNNING && $this->getExecutionTime() > self::KILLABLE_TIMELIMIT ||
$this->status === self::STATUS_WATING
$this->status === self::STATUS_WAITING
;
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/StatusReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function isNewJobCreateable(): bool
return $this->configurationIsValid &&
(
$this->job === null ||
!in_array($this->job->getStatus(), [Job::STATUS_WATING, Job::STATUS_RUNNING], true)
!in_array($this->job->getStatus(), [Job::STATUS_WAITING, Job::STATUS_RUNNING], true)
);
}
}
Loading

0 comments on commit ff9a301

Please sign in to comment.