From 9f4d2fffc45ff899b420abfd290b8e0408e53640 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Tue, 30 Nov 2021 21:10:37 +0100 Subject: [PATCH 01/28] [TASK] Initial changes for typo3 v10 & v11 support --- .gitignore | 1 + .../Configuration/ExtensionConfiguration.php | 79 ++++-------- Classes/Enumeration/GitCommandEnumeration.php | 17 +-- .../ProjectVersionModeEnumeration.php | 9 +- .../ProjectVersionEventListener.php} | 30 +++-- Classes/Facade/CommandUtilityFacade.php | 1 + Classes/Facade/LocalizationUtilityFacade.php | 1 + .../Facade/SystemEnvironmentBuilderFacade.php | 39 ------ Classes/Service/ProjectVersion.php | 12 +- Classes/Service/ProjectVersionService.php | 115 +++++++----------- Configuration/Services.yaml | 14 +++ .../ToolbarItems/ProjectVersionSlotTest.php | 6 +- .../Service/ProjectVersionServiceTest.php | 3 +- Tests/Unit/Service/ProjectVersionTest.php | 3 +- composer.json | 23 ++-- ext_emconf.php | 4 +- ext_localconf.php | 18 +-- 17 files changed, 147 insertions(+), 228 deletions(-) rename Classes/{Backend/ToolbarItems/ProjectVersionSlot.php => EventListener/ProjectVersionEventListener.php} (60%) delete mode 100644 Classes/Facade/SystemEnvironmentBuilderFacade.php create mode 100644 Configuration/Services.yaml diff --git a/.gitignore b/.gitignore index 752bd8e..0cf621c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.ddev /.Build/ /.idea/ /composer.lock diff --git a/Classes/Configuration/ExtensionConfiguration.php b/Classes/Configuration/ExtensionConfiguration.php index be11951..28bb870 100644 --- a/Classes/Configuration/ExtensionConfiguration.php +++ b/Classes/Configuration/ExtensionConfiguration.php @@ -1,4 +1,5 @@ getVersionFilePath()); } - /** - * @return string - */ - public static function getVersionFilePath(): string + public function getVersionFilePath(): string { - return self::$versionFilePath; + return $this->versionFilePath; } - /** - * @return string - */ - public static function getMode(): string + public function getMode(): string { - return self::$mode; + return $this->mode; } - /** - * @return string - */ - public static function getGitFormat(): string + public function getGitFormat(): string { - return self::$gitFormat; + return $this->gitFormat; } - /** - * @return string - */ - public static function getStaticVersion(): string + public function getStaticVersion(): string { - return self::$staticVersion; + return $this->staticVersion; } public function __construct() { - self::$configuration = $this->getExtensionConfigurationFromGlobals(); + $this->configuration = $this->getExtensionConfigurationFromGlobals(); - self::$versionFilePath = $this->resolveVersionFilePath(); - self::$mode = self::$configuration['mode']; - self::$gitFormat = self::$configuration['gitFormat']; - self::$staticVersion = self::$configuration['staticVersion']; + $this->versionFilePath = $this->resolveVersionFilePath(); + $this->mode = $this->configuration['mode'] ?? ProjectVersionModeEnumeration::FILE; + $this->gitFormat = $this->configuration['gitFormat'] ?? ''; + $this->staticVersion = $this->configuration['staticVersion'] ?? ''; } - /** - * @return array - */ private function getExtensionConfigurationFromGlobals(): array { - $configuration = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['project_version']; - - if (is_string($configuration)) { - $configuration = @unserialize($configuration); - } - - return $configuration ?? []; + return $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['project_version'] ?? []; } - /** - * @return string - */ private function resolveVersionFilePath(): string { - $pathFromConfiguration = self::$configuration['versionFilePath'] ?? ''; + $pathFromConfiguration = $this->configuration['versionFilePath'] ?? ''; if (empty($pathFromConfiguration) || $this->isDirectory($pathFromConfiguration)) { - $pathFromConfiguration .= 'VERSION'; + $pathFromConfiguration .= self::DEFAULT_VERSION_FILE; } return $pathFromConfiguration; } - /** - * @param string $pathFromConfiguration - * @return bool - */ private function isDirectory(string $pathFromConfiguration): bool { - return StringUtility::endsWith($pathFromConfiguration, '/') === true; + return StringUtility::endsWith($pathFromConfiguration, '/'); } } diff --git a/Classes/Enumeration/GitCommandEnumeration.php b/Classes/Enumeration/GitCommandEnumeration.php index a39dd1e..75f8b86 100644 --- a/Classes/Enumeration/GitCommandEnumeration.php +++ b/Classes/Enumeration/GitCommandEnumeration.php @@ -1,4 +1,5 @@ projectVersionService = $projectVersionService; + } + + public function __invoke(SystemInformationToolbarCollectorEvent $event) { - $projectVersion = GeneralUtility::makeInstance(ObjectManager::class) - ->get(ProjectVersionService::class) - ->getProjectVersion(); + $projectVersion = $this->projectVersionService->getProjectVersion(); $version = $projectVersion->getVersion(); @@ -43,7 +41,7 @@ public function getProjectVersion(SystemInformationToolbarItem $pObj) $version = GeneralUtility::makeInstance(LocalizationUtilityFacade::class)->translate($version); } - $pObj->addSystemInformation( + $event->getToolbarItem()->addSystemInformation( $projectVersion->getTitle(), $version, $projectVersion->getIconIdentifier() diff --git a/Classes/Facade/CommandUtilityFacade.php b/Classes/Facade/CommandUtilityFacade.php index c293bf0..d5a2c43 100644 --- a/Classes/Facade/CommandUtilityFacade.php +++ b/Classes/Facade/CommandUtilityFacade.php @@ -1,4 +1,5 @@ title = $title; } @@ -66,7 +68,7 @@ public function getVersion(): string /** * @param string $version */ - public function setVersion(string $version) + public function setVersion(string $version): void { $this->version = $version; } @@ -82,7 +84,7 @@ public function getIconIdentifier(): string /** * @param string $iconIdentifier */ - public function setIconIdentifier(string $iconIdentifier) + public function setIconIdentifier(string $iconIdentifier): void { $this->iconIdentifier = $iconIdentifier; } diff --git a/Classes/Service/ProjectVersionService.php b/Classes/Service/ProjectVersionService.php index aff0541..2baf19e 100644 --- a/Classes/Service/ProjectVersionService.php +++ b/Classes/Service/ProjectVersionService.php @@ -1,4 +1,5 @@ commandUtilityFacade = $commandUtilityFacade; + $this->extensionConfiguration = $extensionConfiguration; + } /** * @api @@ -44,7 +57,7 @@ public function getProjectVersion(): ProjectVersion { $projectVersion = GeneralUtility::makeInstance(ProjectVersion::class); - switch (ExtensionConfiguration::getMode()) { + switch ($this->extensionConfiguration->getMode()) { case ProjectVersionModeEnumeration::STATIC_VERSION: $this->setStaticVersion($projectVersion); break; @@ -67,20 +80,14 @@ public function getProjectVersion(): ProjectVersion return $projectVersion; } - /** - * @param $revision - * @param $tag - * @param $branch - * @return string - */ - private function formatVersionBasedOnConfiguration($revision, $tag, $branch): string + private function formatVersion($revision, $tag, $branch): string { - switch (ExtensionConfiguration::getGitFormat()) { + switch ($this->extensionConfiguration->getGitFormat()) { case GitCommandEnumeration::FORMAT_REVISION: $format = $revision; break; case GitCommandEnumeration::FORMAT_REVISION_TAG: - $format = \sprintf('[%s] %s', $revision, $tag); + $format = sprintf('[%s] %s', $revision, $tag); break; case GitCommandEnumeration::FORMAT_BRANCH: $format = $branch; @@ -90,102 +97,66 @@ private function formatVersionBasedOnConfiguration($revision, $tag, $branch): st break; case GitCommandEnumeration::FORMAT_REVISION_BRANCH: default: - $format = \sprintf('[%s] %s', $revision, $branch); + $format = sprintf('[%s] %s', $revision, $branch); } return $format; } - /** - * SystemEnvironmentBuilderFacade injector. - * - * @param \KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade $systemEnvironmentBuilderFacade - */ - public function injectSystemEnvironmentBuilderFacade(SystemEnvironmentBuilderFacade $systemEnvironmentBuilderFacade) - { - $this->systemEnvironmentBuilderFacade = $systemEnvironmentBuilderFacade; - } - - /** - * CommandUtilityFacade injector. - * - * @param \KamiYang\ProjectVersion\Facade\CommandUtilityFacade $commandUtilityFacade - */ - public function injectCommandUtilityFacade(CommandUtilityFacade $commandUtilityFacade) - { - $this->commandUtilityFacade = $commandUtilityFacade; - } - - /** - * @return bool - */ - protected function isGitAvailable(): bool + private function isGitAvailable(): bool { - return $this->systemEnvironmentBuilderFacade->isFunctionDisabled('exec') === false && + return $this->isExecEnabled() && // check if git exists $this->commandUtilityFacade->exec('git --version', $_, $returnCode) && $returnCode === 0; } - /** - * @param \KamiYang\ProjectVersion\Service\ProjectVersion $projectVersion - */ - private function setStaticVersion(ProjectVersion $projectVersion) + private function setStaticVersion(ProjectVersion $projectVersion): void { - $projectVersion->setVersion(ExtensionConfiguration::getStaticVersion()); + $projectVersion->setVersion($this->extensionConfiguration->getStaticVersion()); } - /** - * Resolve version by common VERSION-file. - * - * @param \KamiYang\ProjectVersion\Service\ProjectVersion $projectVersion - */ - private function setVersionFromFile(ProjectVersion $projectVersion) + private function setVersionFromFile(ProjectVersion $projectVersion): void { - $versionFilePath = ExtensionConfiguration::getAbsVersionFilePath(); - if (\file_exists($versionFilePath)) { - $versionFileContent = \file_get_contents($versionFilePath); + $versionFilePath = $this->extensionConfiguration->getAbsVersionFilePath(); + if (file_exists($versionFilePath)) { + $versionFileContent = file_get_contents($versionFilePath); $projectVersion->setVersion($versionFileContent); } } - /** - * @param \KamiYang\ProjectVersion\Service\ProjectVersion $projectVersion - */ - private function setVersionFromGit(ProjectVersion $projectVersion) + private function setVersionFromGit(ProjectVersion $projectVersion): void { - if ($this->isGitAvailable() === false) { + if (!$this->isGitAvailable()) { return; } $version = $this->getVersionByFormat(); if (!empty($version)) { - /* - * The icon identifier for "git" changed between TYPO3 v8 and v9. - * For TYPO3 v8 it's "sysinfo-git" and for v9 it's "information-git" - */ - $gitIconIdentifier = (float)TYPO3_version < 9 ? 'sysinfo-git' : 'information-git'; + $gitIconIdentifier = 'information-git'; $projectVersion->setVersion($version); $projectVersion->setIconIdentifier($gitIconIdentifier); } } - /** - * @return string - */ private function getVersionByFormat(): string { - $branch = \trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_BRANCH)); - $revision = \trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_REVISION)); - $tag = \trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_TAG)); + $branch = trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_BRANCH)); + $revision = trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_REVISION)); + $tag = trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_TAG)); $format = ''; if ($branch || $revision || $tag) { - $format = $this->formatVersionBasedOnConfiguration($revision, $tag, $branch); + $format = $this->formatVersion($revision, $tag, $branch); } return $format; } + + private function isExecEnabled(): bool + { + return in_array('exec', GeneralUtility::trimExplode(',', ini_get('disable_functions'))); + } } diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 0000000..0068b13 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,14 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + KamiYang\ProjectVersion\: + resource: '../Classes/*' + + KamiYang\ProjectVersion\EventListener\ProjectVersionEventListener: + tags: + - name: event.listener + identifier: 'kamiyang-project-version' + event: TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent diff --git a/Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php b/Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php index 36b8b88..c1cc9e8 100644 --- a/Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php +++ b/Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php @@ -1,4 +1,5 @@ subject = new ProjectVersionSlot(); } - protected function tearDown() + protected function tearDown(): void { GeneralUtility::purgeInstances(); @@ -47,7 +48,6 @@ protected function tearDown() } /** - * @test */ public function getProjectVersionShouldAddProjectVersionAsSystemInformation() { diff --git a/Tests/Unit/Service/ProjectVersionServiceTest.php b/Tests/Unit/Service/ProjectVersionServiceTest.php index f2bab82..7b413e9 100644 --- a/Tests/Unit/Service/ProjectVersionServiceTest.php +++ b/Tests/Unit/Service/ProjectVersionServiceTest.php @@ -1,4 +1,5 @@ subject->injectSystemEnvironmentBuilderFacade($this->systemEnvironmentBuilderFacadeProphecy->reveal()); } - protected function tearDown() + protected function tearDown(): void { GeneralUtility::purgeInstances(); diff --git a/Tests/Unit/Service/ProjectVersionTest.php b/Tests/Unit/Service/ProjectVersionTest.php index 241d78b..ce22359 100644 --- a/Tests/Unit/Service/ProjectVersionTest.php +++ b/Tests/Unit/Service/ProjectVersionTest.php @@ -1,4 +1,5 @@ subject = new ProjectVersion(); } diff --git a/composer.json b/composer.json index 6a61698..d8699c9 100644 --- a/composer.json +++ b/composer.json @@ -22,14 +22,15 @@ "kamiyang/project_version": "self.version" }, "require": { - "typo3/cms-backend": "9.5.*", - "typo3/cms-extbase": "9.5.*", - "typo3/cms-extensionmanager": "9.5.*" + "typo3/cms-backend": "^10.4", + "typo3/cms-extbase": "^10.4", + "typo3/cms-extensionmanager": "^10.4", + "nimut/testing-framework": "^6" }, "require-dev": { - "nimut/testing-framework": "~4.1.1", - "phpunit/phpunit": "~6.5", - "satooshi/php-coveralls": "^2.0" + "satooshi/php-coveralls": "^2.0", + "michielroos/typo3scan": "^1.7", + "squizlabs/php_codesniffer": "^3.6" }, "autoload": { "psr-4": { @@ -42,9 +43,9 @@ } }, "scripts": { - "create-dummy-version-file": "echo \"9.0.42\" > .Build/web/VERSION", - "create-extension-directory": "mkdir -p .Build/web/typo3conf/ext", - "link-package": "ln -snvf ../../../../. .Build/web/typo3conf/ext/project_version", + "create-dummy-version-file": "echo \"9.0.42\" > .Build/public/VERSION", + "create-extension-directory": "mkdir -p .Build/public/typo3conf/ext", + "link-package": "ln -snvf ../../../../. .Build/public/typo3conf/ext/project_version", "post-update-cmd": [ "@create-extension-directory", "@link-package", @@ -55,7 +56,7 @@ "vendor-dir": ".Build/vendor", "bin-dir": ".Build/bin", "platform": { - "php": "7.2" + "php": "7.4" } }, "extra": { @@ -63,7 +64,7 @@ "extension-key": "project_version", "cms-package-dir": "{$vendor-dir}/typo3/cms", "app-dir": ".Build", - "web-dir": ".Build/web" + "web-dir": ".Build/public" } } } diff --git a/ext_emconf.php b/ext_emconf.php index a62fee9..b8af38b 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -2,7 +2,7 @@ $EM_CONF[$_EXTKEY] = [ 'title' => 'Project Version', - 'description' => 'Displays current project version based on \'VERSION\' file or GIT revision.', + 'description' => 'Displays current project version based on a \'VERSION\' file or GIT revision.', 'category' => 'misc', 'state' => 'stable', 'uploadfolder' => 0, @@ -14,7 +14,7 @@ 'constraints' => [ 'depends' => [ 'php' => '7.0', - 'typo3' => '9.5.0-9.5.99' + 'typo3' => '10.4.0-11.5.99' ], 'conflicts' => [ ], diff --git a/ext_localconf.php b/ext_localconf.php index e63f285..2f5dd89 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,8 +1,9 @@ 'EXT:project_version/Resources/Public/Icons/ToolbarItem.svg' ] ); - - // Add project version to SystemInformation - $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( - \TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class - ); - $signalSlotDispatcher->connect( - \TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::class, - 'getSystemInformation', - \KamiYang\ProjectVersion\Backend\ToolbarItems\ProjectVersionSlot::class, - 'getProjectVersion' - ); } -}, 'project_version'); +})(); From c20ab69bdf7417439ca2fa953850459dae03ad42 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Tue, 30 Nov 2021 22:12:45 +0100 Subject: [PATCH 02/28] [TASK] Drop LocalizationUtilityFacade and fix check for if git is available --- .../ProjectVersionEventListener.php | 16 ++++-- Classes/Facade/LocalizationUtilityFacade.php | 50 ------------------- Classes/Service/ProjectVersionService.php | 2 +- 3 files changed, 13 insertions(+), 55 deletions(-) delete mode 100644 Classes/Facade/LocalizationUtilityFacade.php diff --git a/Classes/EventListener/ProjectVersionEventListener.php b/Classes/EventListener/ProjectVersionEventListener.php index f559a8b..c48b430 100644 --- a/Classes/EventListener/ProjectVersionEventListener.php +++ b/Classes/EventListener/ProjectVersionEventListener.php @@ -16,19 +16,27 @@ * LICENSE file that was distributed with this source code. */ -use KamiYang\ProjectVersion\Facade\LocalizationUtilityFacade; use KamiYang\ProjectVersion\Service\ProjectVersionService; use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent; -use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\StringUtility; final class ProjectVersionEventListener { + /** + * @var \KamiYang\ProjectVersion\Service\ProjectVersionService + */ private $projectVersionService; - public function __construct(ProjectVersionService $projectVersionService) + /** + * @var \TYPO3\CMS\Core\Localization\LanguageService + */ + private $languageService; + + public function __construct(ProjectVersionService $projectVersionService, LanguageService $languageService) { $this->projectVersionService = $projectVersionService; + $this->languageService = $languageService; } public function __invoke(SystemInformationToolbarCollectorEvent $event) @@ -38,7 +46,7 @@ public function __invoke(SystemInformationToolbarCollectorEvent $event) $version = $projectVersion->getVersion(); if (StringUtility::beginsWith($version, 'LLL:')) { - $version = GeneralUtility::makeInstance(LocalizationUtilityFacade::class)->translate($version); + $version = $this->languageService->sL($version); } $event->getToolbarItem()->addSystemInformation( diff --git a/Classes/Facade/LocalizationUtilityFacade.php b/Classes/Facade/LocalizationUtilityFacade.php deleted file mode 100644 index 21be2f1..0000000 --- a/Classes/Facade/LocalizationUtilityFacade.php +++ /dev/null @@ -1,50 +0,0 @@ - Date: Tue, 30 Nov 2021 22:30:16 +0100 Subject: [PATCH 03/28] [TASK] Fix ProjectVersionTest --- Tests/Unit/Service/ProjectVersionTest.php | 32 ++++++++++++++--------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Tests/Unit/Service/ProjectVersionTest.php b/Tests/Unit/Service/ProjectVersionTest.php index ce22359..eeac9c3 100644 --- a/Tests/Unit/Service/ProjectVersionTest.php +++ b/Tests/Unit/Service/ProjectVersionTest.php @@ -37,7 +37,7 @@ protected function setUp(): void /** * @test */ - public function getTitleShouldReturnInitialValue() + public function getTitleShouldReturnInitialValue(): void { static::assertSame( 'LLL:EXT:project_version/Resources/Private/Language/Backend.xlf:toolbarItems.sysinfo.project-version', @@ -48,43 +48,48 @@ public function getTitleShouldReturnInitialValue() /** * @test */ - public function setTitleShouldSetPropertyTitle() + public function setTitleShouldSetPropertyTitle(): void { $newValue = 'Project Version is awesome!'; $this->subject->setTitle($newValue); - static::assertAttributeSame($newValue, 'title', $this->subject); + static::assertSame( + $newValue, + $this->subject->getTitle() + ); } /** * @test */ - public function initialVersionValueShouldBeLLLString() + public function initialVersionValueShouldBeLLLString(): void { - static::assertAttributeSame( + static::assertSame( 'LLL:EXT:project_version/Resources/Private/Language/Backend.xlf:toolbarItems.sysinfo.project-version.unknown', - 'version', - $this->subject + $this->subject->getVersion() ); } /** * @test */ - public function setVersionShouldSetPropertyVersion() + public function setVersionShouldSetPropertyVersion(): void { $newValue = 'Project Version is awesome!'; $this->subject->setVersion($newValue); - static::assertAttributeSame($newValue, 'version', $this->subject); + static::assertSame( + $newValue, + $this->subject->getVersion() + ); } /** * @test */ - public function getIconIdentifierShouldReturnInitialValue() + public function getIconIdentifierShouldReturnInitialValue(): void { static::assertSame('information-project-version', $this->subject->getIconIdentifier()); } @@ -92,12 +97,15 @@ public function getIconIdentifierShouldReturnInitialValue() /** * @test */ - public function setIconIdentifierShouldSetPropertyIconIdentifier() + public function setIconIdentifierShouldSetPropertyIconIdentifier(): void { $newValue = 'Project Version is awesome!'; $this->subject->setIconIdentifier($newValue); - static::assertAttributeSame($newValue, 'iconIdentifier', $this->subject); + static::assertSame( + $newValue, + $this->subject->getIconIdentifier() + ); } } From 90836bee47f16cada6000766b2678bdd869fc261 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Wed, 1 Dec 2021 00:04:35 +0100 Subject: [PATCH 04/28] [TASK] Fix most tests --- Classes/Service/ProjectVersion.php | 4 +- .../Service/ProjectVersionServiceTest.php | 329 +++++++++--------- 2 files changed, 163 insertions(+), 170 deletions(-) diff --git a/Classes/Service/ProjectVersion.php b/Classes/Service/ProjectVersion.php index 369fe85..8484806 100644 --- a/Classes/Service/ProjectVersion.php +++ b/Classes/Service/ProjectVersion.php @@ -18,6 +18,8 @@ use TYPO3\CMS\Core\SingletonInterface; +use function trim; + /** * Class ProjectVersion */ @@ -70,7 +72,7 @@ public function getVersion(): string */ public function setVersion(string $version): void { - $this->version = $version; + $this->version = trim($version); } /** diff --git a/Tests/Unit/Service/ProjectVersionServiceTest.php b/Tests/Unit/Service/ProjectVersionServiceTest.php index 7b413e9..780cba3 100644 --- a/Tests/Unit/Service/ProjectVersionServiceTest.php +++ b/Tests/Unit/Service/ProjectVersionServiceTest.php @@ -16,17 +16,22 @@ * LICENSE file that was distributed with this source code. */ +use Generator; use KamiYang\ProjectVersion\Configuration\ExtensionConfiguration; use KamiYang\ProjectVersion\Enumeration\GitCommandEnumeration; use KamiYang\ProjectVersion\Enumeration\ProjectVersionModeEnumeration; use KamiYang\ProjectVersion\Facade\CommandUtilityFacade; -use KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade; use KamiYang\ProjectVersion\Service\ProjectVersion; use KamiYang\ProjectVersion\Service\ProjectVersionService; use Nimut\TestingFramework\TestCase\UnitTestCase; use Prophecy\Argument; use TYPO3\CMS\Core\Utility\GeneralUtility; +use function array_replace; +use function ini_get; +use function ini_set; +use function var_dump; + /** * Class ProjectVersionServiceTest */ @@ -37,18 +42,13 @@ class ProjectVersionServiceTest extends UnitTestCase */ private $subject; - private $extensionConfiguration = [ + private $defaultExtensionConfiguration = [ 'gitFormat' => GitCommandEnumeration::FORMAT_REVISION_BRANCH, 'mode' => ProjectVersionModeEnumeration::FILE, 'staticVersion' => '', 'versionFilePath' => 'VERSION' ]; - /** - * @var \KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade|\Prophecy\Prophecy\ObjectProphecy - */ - private $systemEnvironmentBuilderFacadeProphecy; - /** * @var \KamiYang\ProjectVersion\Facade\CommandUtilityFacade */ @@ -57,15 +57,18 @@ class ProjectVersionServiceTest extends UnitTestCase /** * @test */ - public function getProjectVersionShouldNotSetProjectVersionIfVersionFileIsNotFound() + public function getProjectVersionShouldNotSetProjectVersionIfVersionFileIsNotFound(): void { - $this->extensionConfiguration['versionFilePath'] = '/some/not/existing/path'; - $this->setUpExtensionConfiguration(); + $this->setUpExtensionConfiguration([ + 'versionFilePath' => '/some/not/existing/path' + ]); $projectVersionProphecy = $this->prophesize(ProjectVersion::class); GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersionProphecy->reveal()); - - $this->subject->getProjectVersion(); + new ProjectVersionService( + $this->commandUtilityFacadeProphecy->reveal(), + new ExtensionConfiguration() + ); $projectVersionProphecy->setVersion(Argument::any()) ->shouldNotHaveBeenCalled(); @@ -76,56 +79,56 @@ public function getProjectVersionShouldNotSetProjectVersionIfVersionFileIsNotFou * @param string $versionFilePath * @dataProvider versionFilePathDataProvider */ - public function getProjectVersionShouldSetVersionFromVersionFileIfFileExists(string $versionFilePath) + public function getProjectVersionShouldSetVersionFromVersionFileIfFileExists(string $versionFilePath): void { - $this->extensionConfiguration['versionFilePath'] = $versionFilePath; - $this->setUpExtensionConfiguration(); + $this->setUpExtensionConfiguration(['versionFilePath' => $versionFilePath]); - $projectVersionProphecy = $this->prophesize(ProjectVersion::class); - GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersionProphecy->reveal()); - - $this->subject->getProjectVersion(); + $subject = new ProjectVersionService( + $this->commandUtilityFacadeProphecy->reveal(), + new ExtensionConfiguration() + ); - $projectVersionProphecy->setVersion(Argument::containingString('1.0.1')) - ->shouldHaveBeenCalledTimes(1); + self::assertEquals( + '1.0.1', + $subject->getProjectVersion()->getVersion() + ); } - /** - * @return array - */ - public function versionFilePathDataProvider(): array + public function versionFilePathDataProvider(): Generator { - return [ - 'version file with EXT shortcut' => [ - 'EXT:project_version/Tests/Fixture/VERSION' - ], - 'directory with EXT shortcut' => [ - 'EXT:project_version/Tests/Fixture/' - ], - 'Version file with EXT shortcut and different filename' => [ - 'EXT:project_version/Tests/Fixture/VersionFileWithDifferentName' - ] + yield 'version file with EXT shortcut' => [ + 'EXT:project_version/Tests/Fixture/VERSION' + ]; + yield 'directory with EXT shortcut' => [ + 'EXT:project_version/Tests/Fixture/' + ]; + yield 'Version file with EXT shortcut and different filename' => [ + 'EXT:project_version/Tests/Fixture/VersionFileWithDifferentName' ]; } /** * @test */ - public function getProjectVersionShouldNotSetVersionFromGitIfCommandExecIsNotAvailable() + public function getProjectVersionShouldNotSetVersionFromGitIfCommandExecIsNotAvailable(): void { - $this->extensionConfiguration['mode'] = ProjectVersionModeEnumeration::GIT; - $this->setUpExtensionConfiguration(); + $this->setUpExtensionConfiguration(['mode' => ProjectVersionModeEnumeration::GIT]); $projectVersionProphecy = $this->prophesize(ProjectVersion::class); GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersionProphecy->reveal()); - $this->systemEnvironmentBuilderFacadeProphecy->isFunctionDisabled('exec') - ->willReturn(true); + $originalDisbableFunctions = ini_get('disable_functions'); + ini_set('disable_functions', 'exec'); - $this->subject->getProjectVersion(); + new ProjectVersionService( + $this->commandUtilityFacadeProphecy->reveal(), + new ExtensionConfiguration() + ); $projectVersionProphecy->setVersion(Argument::any()) ->shouldNotHaveBeenCalled(); + + ini_set('disable_functions', $originalDisbableFunctions); } /** @@ -145,30 +148,28 @@ public function getProjectVersionShouldReturnSpecifiedVersionBasedOnConfiguredGi string $revision, string $tag, string $expected - ) { - // Arrange - $this->extensionConfiguration['mode'] = ProjectVersionModeEnumeration::GIT; - $this->extensionConfiguration['gitFormat'] = $format; - $this->setUpExtensionConfiguration(); - - $projectVersionProphecy = $this->prophesize(ProjectVersion::class); - GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersionProphecy->reveal()); - + ): void { + $this->setUpExtensionConfiguration([ + 'mode' => ProjectVersionModeEnumeration::GIT, + 'gitFormat' => $format + ]); + $this->commandUtilityFacadeProphecy->exec('git --version', Argument::cetera()) + ->will(function (&$arguments) { + $arguments[2] = 0; + }); $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_BRANCH)->willReturn($branch); $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_REVISION)->willReturn($revision); $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_TAG)->willReturn($tag); - /** @var \KamiYang\ProjectVersion\Service\ProjectVersionService|\PHPUnit\Framework\MockObject\MockObject $subject */ - $subject = $this->createPartialMock(ProjectVersionService::class, ['isGitAvailable']); - $subject->method('isGitAvailable')->willReturn(true); - $subject->injectCommandUtilityFacade($this->commandUtilityFacadeProphecy->reveal()); - $subject->injectSystemEnvironmentBuilderFacade($this->systemEnvironmentBuilderFacadeProphecy->reveal()); - - // Act - $actual = $subject->getProjectVersion(); + $subject = new ProjectVersionService( + $this->commandUtilityFacadeProphecy->reveal(), + new ExtensionConfiguration() + ); - // Assert - $projectVersionProphecy->setVersion($expected)->shouldHaveBeenCalled(); + static::assertSame( + $expected, + $subject->getProjectVersion()->getVersion() + ); $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_BRANCH)->shouldHaveBeenCalledTimes(1); $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_REVISION)->shouldHaveBeenCalledTimes(1); @@ -178,108 +179,102 @@ public function getProjectVersionShouldReturnSpecifiedVersionBasedOnConfiguredGi /** * @test */ - public function getProjectVersionShouldTryToFetchVersionFromFileIfResolvingUsingGitErrored() + public function getProjectVersionShouldTryToFetchVersionFromFileIfResolvingUsingGitErrored(): void { //Arrange - $this->extensionConfiguration['versionFilePath'] = 'EXT:project_version/Tests/Fixture/VERSION'; - $this->extensionConfiguration['mode'] = ProjectVersionModeEnumeration::GIT_FILE_FALLBACK; - $this->extensionConfiguration['gitFormat'] = GitCommandEnumeration::FORMAT_REVISION_BRANCH; - $this->setUpExtensionConfiguration(); + $versionFilePath = 'EXT:project_version/Tests/Fixture/VERSION'; + $this->setUpExtensionConfiguration([ + 'versionFilePath' => $versionFilePath, + 'mode' => ProjectVersionModeEnumeration::GIT_FILE_FALLBACK, + 'gitFormat' => GitCommandEnumeration::FORMAT_REVISION_BRANCH + ]); $branch = ''; $revision = ''; $tag = ''; - $absoluteVersionFilename = GeneralUtility::getFileAbsFileName($this->extensionConfiguration['versionFilePath']); - $expected = \file_get_contents($absoluteVersionFilename); - - $projectVersion = new ProjectVersion(); - GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersion); + $absoluteVersionFilename = GeneralUtility::getFileAbsFileName($versionFilePath); + $expected = trim(file_get_contents($absoluteVersionFilename)); $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_BRANCH)->willReturn($branch); $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_REVISION)->willReturn($revision); $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_TAG)->willReturn($tag); + $this->commandUtilityFacadeProphecy->exec('git --version', $_, $returnCode)->willReturn(0); - /** @var \KamiYang\ProjectVersion\Service\ProjectVersionService $subject */ - $subject = $this->createPartialMock(ProjectVersionService::class, ['isGitAvailable']); - $subject->method('isGitAvailable')->willReturn(true); - $subject->injectCommandUtilityFacade($this->commandUtilityFacadeProphecy->reveal()); - $subject->injectSystemEnvironmentBuilderFacade($this->systemEnvironmentBuilderFacadeProphecy->reveal()); - - // Act - $subject->getProjectVersion(); - - // Assert - static::assertSame($expected, $projectVersion->getVersion()); + $subject = new ProjectVersionService( + $this->commandUtilityFacadeProphecy->reveal(), + new ExtensionConfiguration() + ); + static::assertSame($expected, $subject->getProjectVersion()->getVersion()); } /** * @return array */ - public function gitFormatDataProvider(): array + public function gitFormatDataProvider(): Generator { $branch = 'master'; $revision = 'abcdefg'; $tag = '9.0.42-rc.2'; - return [ - 'default git format' => [ - 'format' => GitCommandEnumeration::FORMAT_REVISION_BRANCH, - 'branch' => $branch, - 'revision' => $revision, - 'tag' => $tag, - 'expected' => "[{$revision}] {$branch}" - ], - 'git format: revision' => [ - 'format' => GitCommandEnumeration::FORMAT_REVISION, - 'branch' => $branch, - 'revision' => $revision, - 'tag' => $tag, - 'expected' => "{$revision}" - ], - 'git format: [revision] branch' => [ - 'format' => GitCommandEnumeration::FORMAT_REVISION_BRANCH, - 'branch' => $branch, - 'revision' => $revision, - 'tag' => $tag, - 'expected' => "[{$revision}] {$branch}" - ], - 'git format: [revision] tag' => [ - 'format' => GitCommandEnumeration::FORMAT_REVISION_TAG, - 'branch' => $branch, - 'revision' => $revision, - 'tag' => $tag, - 'expected' => "[{$revision}] {$tag}" - ], - 'git format: branch' => [ - 'format' => GitCommandEnumeration::FORMAT_BRANCH, - 'branch' => $branch, - 'revision' => $revision, - 'tag' => $tag, - 'expected' => "{$branch}" - ], - 'git format: tag' => [ - 'format' => GitCommandEnumeration::FORMAT_TAG, - 'branch' => $branch, - 'revision' => $revision, - 'tag' => $tag, - 'expected' => "{$tag}" - ], + yield 'default git format' => [ + 'format' => GitCommandEnumeration::FORMAT_REVISION_BRANCH, + 'branch' => $branch, + 'revision' => $revision, + 'tag' => $tag, + 'expected' => "[{$revision}] {$branch}" + ]; + yield 'git format: revision' => [ + 'format' => GitCommandEnumeration::FORMAT_REVISION, + 'branch' => $branch, + 'revision' => $revision, + 'tag' => $tag, + 'expected' => "{$revision}" + ]; + yield 'git format: [revision] branch' => [ + 'format' => GitCommandEnumeration::FORMAT_REVISION_BRANCH, + 'branch' => $branch, + 'revision' => $revision, + 'tag' => $tag, + 'expected' => "[{$revision}] {$branch}" + ]; + yield 'git format: [revision] tag' => [ + 'format' => GitCommandEnumeration::FORMAT_REVISION_TAG, + 'branch' => $branch, + 'revision' => $revision, + 'tag' => $tag, + 'expected' => "[{$revision}] {$tag}" + ]; + yield 'git format: branch' => [ + 'format' => GitCommandEnumeration::FORMAT_BRANCH, + 'branch' => $branch, + 'revision' => $revision, + 'tag' => $tag, + 'expected' => "{$branch}" + ]; + yield 'git format: tag' => [ + 'format' => GitCommandEnumeration::FORMAT_TAG, + 'branch' => $branch, + 'revision' => $revision, + 'tag' => $tag, + 'expected' => "{$tag}" ]; } /** * @test */ - public function getProjectVersionShouldAlwaysSetStaticVersionIfSelected() + public function getProjectVersionShouldAlwaysSetStaticVersionIfSelected(): void { - $this->extensionConfiguration['mode'] = ProjectVersionModeEnumeration::STATIC_VERSION; - $this->setUpExtensionConfiguration(); + $this->setUpExtensionConfiguration(['mode' => ProjectVersionModeEnumeration::STATIC_VERSION]); - $projectVersionProphecy = $this->prophesize(ProjectVersion::class); - GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersionProphecy->reveal()); + $subject = new ProjectVersionService( + $this->commandUtilityFacadeProphecy->reveal(), + new ExtensionConfiguration() + ); - $this->subject->getProjectVersion(); - - $projectVersionProphecy->setVersion('')->shouldHaveBeenCalledTimes(1); + static::assertSame( + '', + $subject->getProjectVersion()->getVersion() + ); } /** @@ -287,46 +282,41 @@ public function getProjectVersionShouldAlwaysSetStaticVersionIfSelected() * @param string $staticVersion * @dataProvider staticVersionDataProvider */ - public function getProjectVersionShouldSetStaticVersionFromExtensionConfigurationIfSelected(string $staticVersion) - { - $this->extensionConfiguration['mode'] = ProjectVersionModeEnumeration::STATIC_VERSION; - $this->extensionConfiguration['staticVersion'] = $staticVersion; - $this->setUpExtensionConfiguration(); - - $projectVersionProphecy = $this->prophesize(ProjectVersion::class); - GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersionProphecy->reveal()); - - $this->subject->getProjectVersion(); - - $projectVersionProphecy->setVersion($staticVersion)->shouldHaveBeenCalledTimes(1); + public function getProjectVersionShouldSetStaticVersionFromExtensionConfigurationIfSelected( + string $staticVersion + ): void { + $this->setUpExtensionConfiguration([ + 'mode' => ProjectVersionModeEnumeration::STATIC_VERSION, + 'staticVersion' => $staticVersion + ]); + + $subject = new ProjectVersionService( + $this->commandUtilityFacadeProphecy->reveal(), + new ExtensionConfiguration() + ); + + self::assertSame( + $staticVersion, + $subject->getProjectVersion()->getVersion() + ); } - public function staticVersionDataProvider(): array + public function staticVersionDataProvider(): Generator { - return [ - 'empty static version (default value)' => [ - 'staticVersion' => '' - ], - 'some value' => [ - 'staticVersion' => 'some value' - ], - 'some extreme long value' => [ - 'staticVersion' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos hic ipsa labore molestiae nesciunt quo repellendus similique tenetur vitae voluptatem! Dicta dolor minus nostrum ratione voluptas? Ad animi iste sunt!' - ] + yield 'empty static version (default value)' => [ + 'staticVersion' => '' + ]; + yield 'some value' => [ + 'staticVersion' => 'some value' + ]; + yield 'some extreme long value' => [ + 'staticVersion' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos hic ipsa labore molestiae nesciunt quo repellendus similique tenetur vitae voluptatem! Dicta dolor minus nostrum ratione voluptas? Ad animi iste sunt!' ]; } - protected function setUp() + protected function setUp(): void { - $this->systemEnvironmentBuilderFacadeProphecy = $this->prophesize(SystemEnvironmentBuilderFacade::class); - $this->systemEnvironmentBuilderFacadeProphecy->isFunctionDisabled('exec') - ->willReturn(false); - $this->commandUtilityFacadeProphecy = $this->prophesize(CommandUtilityFacade::class); - - $this->subject = new ProjectVersionService(); - $this->subject->injectCommandUtilityFacade($this->commandUtilityFacadeProphecy->reveal()); - $this->subject->injectSystemEnvironmentBuilderFacade($this->systemEnvironmentBuilderFacadeProphecy->reveal()); } protected function tearDown(): void @@ -336,10 +326,11 @@ protected function tearDown(): void parent::tearDown(); } - protected function setUpExtensionConfiguration() + protected function setUpExtensionConfiguration(array $extConfig): void { - $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['project_version'] = serialize($this->extensionConfiguration); - - GeneralUtility::makeInstance(ExtensionConfiguration::class); + $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['project_version'] = array_replace( + $this->defaultExtensionConfiguration, + $extConfig + ); } } From 709802be37255b7dd5b9236073629dbd6cbeacf5 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 12:55:31 +0200 Subject: [PATCH 05/28] [#17] Update copyright comments of php-files --- Classes/Configuration/ExtensionConfiguration.php | 4 ++-- Classes/Enumeration/GitCommandEnumeration.php | 4 ++-- .../Enumeration/ProjectVersionModeEnumeration.php | 4 ++-- .../EventListener/ProjectVersionEventListener.php | 4 ++-- Classes/Facade/CommandUtilityFacade.php | 4 ++-- Classes/Service/ProjectVersion.php | 4 ++-- Classes/Service/ProjectVersionService.php | 8 ++++---- .../Backend/ToolbarItems/ProjectVersionSlotTest.php | 4 ++-- Tests/Unit/Service/ProjectVersionServiceTest.php | 4 ++-- Tests/Unit/Service/ProjectVersionTest.php | 4 ++-- ext_emconf.php | 12 ++++++++++++ ext_localconf.php | 12 ++++++++++++ 12 files changed, 46 insertions(+), 22 deletions(-) diff --git a/Classes/Configuration/ExtensionConfiguration.php b/Classes/Configuration/ExtensionConfiguration.php index 28bb870..1f3acd5 100644 --- a/Classes/Configuration/ExtensionConfiguration.php +++ b/Classes/Configuration/ExtensionConfiguration.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace KamiYang\ProjectVersion\Configuration; - /* * This file is part of the ProjectVersion project. * @@ -16,6 +14,8 @@ * LICENSE file that was distributed with this source code. */ +namespace KamiYang\ProjectVersion\Configuration; + use KamiYang\ProjectVersion\Enumeration\ProjectVersionModeEnumeration; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; diff --git a/Classes/Enumeration/GitCommandEnumeration.php b/Classes/Enumeration/GitCommandEnumeration.php index 75f8b86..ebe101a 100644 --- a/Classes/Enumeration/GitCommandEnumeration.php +++ b/Classes/Enumeration/GitCommandEnumeration.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace KamiYang\ProjectVersion\Enumeration; - /* * This file is part of the ProjectVersion project. * @@ -16,6 +14,8 @@ * LICENSE file that was distributed with this source code. */ +namespace KamiYang\ProjectVersion\Enumeration; + /** * Class GitCommandEnumeration */ diff --git a/Classes/Enumeration/ProjectVersionModeEnumeration.php b/Classes/Enumeration/ProjectVersionModeEnumeration.php index 8f63a20..44f121e 100644 --- a/Classes/Enumeration/ProjectVersionModeEnumeration.php +++ b/Classes/Enumeration/ProjectVersionModeEnumeration.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace KamiYang\ProjectVersion\Enumeration; - /* * This file is part of the ProjectVersion project. * @@ -16,6 +14,8 @@ * LICENSE file that was distributed with this source code. */ +namespace KamiYang\ProjectVersion\Enumeration; + /** * Class ProjectVersionModeEnumeration */ diff --git a/Classes/EventListener/ProjectVersionEventListener.php b/Classes/EventListener/ProjectVersionEventListener.php index c48b430..cdb6e54 100644 --- a/Classes/EventListener/ProjectVersionEventListener.php +++ b/Classes/EventListener/ProjectVersionEventListener.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace KamiYang\ProjectVersion\EventListener; - /* * This file is part of the ProjectVersion project. * @@ -16,6 +14,8 @@ * LICENSE file that was distributed with this source code. */ +namespace KamiYang\ProjectVersion\EventListener; + use KamiYang\ProjectVersion\Service\ProjectVersionService; use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent; use TYPO3\CMS\Core\Localization\LanguageService; diff --git a/Classes/Facade/CommandUtilityFacade.php b/Classes/Facade/CommandUtilityFacade.php index d5a2c43..af172f4 100644 --- a/Classes/Facade/CommandUtilityFacade.php +++ b/Classes/Facade/CommandUtilityFacade.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace KamiYang\ProjectVersion\Facade; - /* * This file is part of the ProjectVersion project. * @@ -16,6 +14,8 @@ * LICENSE file that was distributed with this source code. */ +namespace KamiYang\ProjectVersion\Facade; + use TYPO3\CMS\Core\Utility\CommandUtility; /** diff --git a/Classes/Service/ProjectVersion.php b/Classes/Service/ProjectVersion.php index 8484806..08527b1 100644 --- a/Classes/Service/ProjectVersion.php +++ b/Classes/Service/ProjectVersion.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace KamiYang\ProjectVersion\Service; - /* * This file is part of the ProjectVersion project. * @@ -16,6 +14,8 @@ * LICENSE file that was distributed with this source code. */ +namespace KamiYang\ProjectVersion\Service; + use TYPO3\CMS\Core\SingletonInterface; use function trim; diff --git a/Classes/Service/ProjectVersionService.php b/Classes/Service/ProjectVersionService.php index 2b860e4..79f3a9b 100644 --- a/Classes/Service/ProjectVersionService.php +++ b/Classes/Service/ProjectVersionService.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace KamiYang\ProjectVersion\Service; - /* * This file is part of the ProjectVersion project. * @@ -16,6 +14,8 @@ * LICENSE file that was distributed with this source code. */ +namespace KamiYang\ProjectVersion\Service; + use KamiYang\ProjectVersion\Configuration\ExtensionConfiguration; use KamiYang\ProjectVersion\Enumeration\GitCommandEnumeration; use KamiYang\ProjectVersion\Enumeration\ProjectVersionModeEnumeration; @@ -38,11 +38,11 @@ class ProjectVersionService implements SingletonInterface /** * @var \KamiYang\ProjectVersion\Facade\CommandUtilityFacade */ - protected $commandUtilityFacade; + protected CommandUtilityFacade $commandUtilityFacade; /** * @var \KamiYang\ProjectVersion\Configuration\ExtensionConfiguration */ - private $extensionConfiguration; + private ExtensionConfiguration $extensionConfiguration; public function __construct(CommandUtilityFacade $commandUtilityFacade, ExtensionConfiguration $extensionConfiguration) { diff --git a/Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php b/Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php index c1cc9e8..1574952 100644 --- a/Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php +++ b/Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace KamiYang\ProjectVersion\Tests\Unit\Backend\ToolbarItems; - /* * This file is part of the ProjectVersion project. * @@ -16,6 +14,8 @@ * LICENSE file that was distributed with this source code. */ +namespace KamiYang\ProjectVersion\Tests\Unit\Backend\ToolbarItems; + use KamiYang\ProjectVersion\Backend\ToolbarItems\ProjectVersionSlot; use KamiYang\ProjectVersion\Facade\LocalizationUtilityFacade; use KamiYang\ProjectVersion\Service\ProjectVersion; diff --git a/Tests/Unit/Service/ProjectVersionServiceTest.php b/Tests/Unit/Service/ProjectVersionServiceTest.php index 780cba3..4b5c168 100644 --- a/Tests/Unit/Service/ProjectVersionServiceTest.php +++ b/Tests/Unit/Service/ProjectVersionServiceTest.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace KamiYang\ProjectVersion\Tests\Unit\Service; - /* * This file is part of the ProjectVersion project. * @@ -16,6 +14,8 @@ * LICENSE file that was distributed with this source code. */ +namespace KamiYang\ProjectVersion\Tests\Unit\Service; + use Generator; use KamiYang\ProjectVersion\Configuration\ExtensionConfiguration; use KamiYang\ProjectVersion\Enumeration\GitCommandEnumeration; diff --git a/Tests/Unit/Service/ProjectVersionTest.php b/Tests/Unit/Service/ProjectVersionTest.php index eeac9c3..9ececb9 100644 --- a/Tests/Unit/Service/ProjectVersionTest.php +++ b/Tests/Unit/Service/ProjectVersionTest.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace KamiYang\ProjectVersion\Tests\Unit\Service; - /* * This file is part of the ProjectVersion project. * @@ -16,6 +14,8 @@ * LICENSE file that was distributed with this source code. */ +namespace KamiYang\ProjectVersion\Tests\Unit\Service; + use KamiYang\ProjectVersion\Service\ProjectVersion; use Nimut\TestingFramework\TestCase\UnitTestCase; diff --git a/ext_emconf.php b/ext_emconf.php index b8af38b..5c5ad7a 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -1,5 +1,17 @@ 'Project Version', 'description' => 'Displays current project version based on a \'VERSION\' file or GIT revision.', diff --git a/ext_localconf.php b/ext_localconf.php index 2f5dd89..12e020b 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,5 +1,17 @@ Date: Mon, 6 Jun 2022 13:06:27 +0200 Subject: [PATCH 06/28] [#17] Make classes php7.2 compatible --- Classes/Service/ProjectVersionService.php | 4 +- README.md | 111 ++++++++++------------ ext_emconf.php | 2 +- 3 files changed, 51 insertions(+), 66 deletions(-) diff --git a/Classes/Service/ProjectVersionService.php b/Classes/Service/ProjectVersionService.php index 79f3a9b..e68340c 100644 --- a/Classes/Service/ProjectVersionService.php +++ b/Classes/Service/ProjectVersionService.php @@ -38,11 +38,11 @@ class ProjectVersionService implements SingletonInterface /** * @var \KamiYang\ProjectVersion\Facade\CommandUtilityFacade */ - protected CommandUtilityFacade $commandUtilityFacade; + protected $commandUtilityFacade; /** * @var \KamiYang\ProjectVersion\Configuration\ExtensionConfiguration */ - private ExtensionConfiguration $extensionConfiguration; + private $extensionConfiguration; public function __construct(CommandUtilityFacade $commandUtilityFacade, ExtensionConfiguration $extensionConfiguration) { diff --git a/README.md b/README.md index 1d6d3cd..89b8ccc 100644 --- a/README.md +++ b/README.md @@ -6,55 +6,67 @@ [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/KamiYang/project_version/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/KamiYang/project_version/?branch=master) ## What is project version? -Project version is a TYPO3 extension that adds an entry to the TYPO3 system information in the toolbar. This entry is based either on the common 'VERSION' file or on the local GIT revision. -## How do I install it? +Project version is a TYPO3 extension that adds an entry to the TYPO3 system information in the toolbar. This entry is +based either on the common 'VERSION' file or on the local GIT revision. + +## How do I install it? + First make sure you match the requirements: -| Requirement | Version | -| --- | --- | -| TYPO3 | \>=8.7 <9.6 | -| php | \>= 7.0 | +| Requirement | Version | +|-------------|---------------| +| TYPO3 | \>=10.4 <11.5 | +| php | \>= 7.2 | ### Composer -Simply require the extension from packagist: + +Simply require the extension from packagist: `composer require kamiyang/ext-projectversion` Or if you prefer typo3-ter: `composer require typo3-ter/projectversion` -### TER -No composer available? No problem! You also can find this extension at TYPO3's Extension Repository (TER). -You can straight download it from inside your TYPO3 as long, as your TYPO3 is not in composer mode. - ## How do I use it? + ### "VERSION"-file -Now, this is the easiest part. Create a file called `VERSION` (case sensitive) in your TYPO3 frontend docroot with the project version. This can be done like this: -`$ echo 1.0.0-rc.3 > /var/www/html/VERSION` + +Now, this is the easiest part. Create a file called `VERSION` (case sensitive) in your TYPO3 frontend docroot with the +project version. This can be done like this: +`echo 1.0.0-rc.3 > /var/www/html/VERSION` + +Thats it. In the typo3 backend the version "1.0.0-rc.3" will now be shown. ### Custom Path + You can use your own filename and path. Note that this path still has to be accessible from your web docroot. -The configuration can be done in the ExtensionConfiguration. It is also possible to change the directory of the 'VERSION'-file. Only provide a directory path (with trailing slash '/') and it will automatically search for an file called 'VERSION'. +The configuration can be done in the ExtensionConfiguration. It is also possible to change the directory of the ' +VERSION'-file. Only provide a directory path (with trailing slash '/') and it will automatically search for an file +called 'VERSION'. Examples: We assume that the web document root (`PATH_site`) is `/var/www/html`. -| Configured Path | Absolute filename | -| --- | --- | -| (empty - default) | /var/www/html/VERSION | -| MyVersion | /var/www/html/MyVersion | -| typo3conf/ | /var/www/html/typo3conf/VERSION | -| ./My/Custom/Version/File/In/Some/Nested/File/Structure | /var/www/html/./My/Custom/Version/File/In/Some/Nested/File/Structure| +| Configured Path | Absolute filename | +|--------------------------------------------------------|----------------------------------------------------------------------| +| (empty - default) | /var/www/html/VERSION | +| MyVersion | /var/www/html/MyVersion | +| typo3conf/ | /var/www/html/typo3conf/VERSION | +| ./My/Custom/Version/File/In/Some/Nested/File/Structure | /var/www/html/./My/Custom/Version/File/In/Some/Nested/File/Structure | ### GIT + Since release 0.3.0 git is supported. This must be manually activated. In order to use git, make sure it's available! -Common case is that the local development environment is based on docker images. Many docker images do not have git out of the box available. -To activate it, simply move via your preferred web browser into the TYPO3 backend. For TYPO3 v8.7 - go to "Extensions > Project Version" and configure the extension. -The configuration screen will look like this on default: +Common case is that the local development environment is based on docker images. Many docker images do not have git out +of the box available. +To activate it, simply move via your preferred web browser into the TYPO3 backend. For TYPO3 v8.7 - go to "Extensions > +Project Version" and configure the extension. +The configuration screen will look like this on default: ![default extension configuration](Documentation/Images/DefaultConfig.png) -This has changed a bit in TYPO3 v9. To configure the extension go to "Settings > Configure extensions" and filter for "project version". +This has changed a bit in TYPO3 v9. To configure the extension go to "Settings > Configure extensions" and filter for " +project version". The new configuration screen will look like this: ![new default extension configuration screen](Documentation/Images/DefaultConfigTYPO3v9.png) @@ -63,45 +75,18 @@ The new configuration screen will look like this: ##### basic.mode -| Configuration | Description | -| --- | --- | -| VERSION File (default)| Fetches the current project version based on the path configured in `basic.versionFilePath` | -| GIT | Uses GIT if available to resolve the project version in the format configured in `basic.gitFormat` | -| GIT (VERSION file as fallback) | Will use GIT as preferred resolving method. If not available will fallback to VERSION file. | - +| Configuration | Description | +|--------------------------------|----------------------------------------------------------------------------------------------------| +| VERSION File (default) | Fetches the current project version based on the path configured in `basic.versionFilePath` | +| GIT | Uses GIT if available to resolve the project version in the format configured in `basic.gitFormat` | +| GIT (VERSION file as fallback) | Will use GIT as preferred resolving method. If not available will fallback to VERSION file. | ##### basic.gitFormat -| Configuration | Description | Example | -| --- | --- | --- | -| Revision | Will only fetch the revision as project version | ![git revision example ](Documentation/Images/BasicGitFormatRevision.png) | -| \[revision] Branch (default) | Will fetch the current revision and branch | ![git revision and branch example ](Documentation/Images/BasicGitFormatRevisionAndBranch.png) | -| \[revision] Tag | Will fetch the current revision and tag | ![git revision and tag example ](Documentation/Images/BasicGitFormatRevisionAndTag.png) | -| Branch | Will only fetch the current branch | ![git branch example ](Documentation/Images/BasicGitFormatRevisionBranch.png) | -| Tag | Will only fetch the current tag | ![git tag example ](Documentation/Images/BasicGitFormatRevisionTag.png) | - -## Roadmap to v1.0.0 - - - [x] Static VERSION file support - - [x] Add ability to configure "VERSION"-file path - - [x] GIT revision support - - [x] GIT tag/branch based on revision support - - [x] Add documentation of this extensions features - - [x] Upload extension to packagist.org - - [x] Upload extension to TER - - [x] Support TYPO3 v9.4 - - [x] Support TYPO3 v9 LTS - - [x] Achieve overall test coverage above 95% - - [x] Configure [TravisCI](https://travis-ci.org/KamiYang/project_version) - - [x] Configure [StyleCI](https://github.styleci.io/repos/134700322) - - [x] Configure [Coveralls](https://coveralls.io/github/KamiYang/project_version) - - [x] Static VERSION value via extension configuration - -### Milestone for v0.6.0 - - Ability to "hardcode" static project version via the TYPO3 backend - -## Note -The TYPO3 v8 version of this extension will not be maintained after release 1.0.0! But this should be no problem because TYPO3 v8 only gets bugfixes. -This means, version 1.0.0 should stay compatible with all further TYPO3 v8 releases! - -After releasing version 1.0.0, which will be around the release of the first TYPO3 v9 LTS version, EXT:project_version will be refactored to php7.2 and will integrate TYPO3 v9 features. +| Configuration | Description | Example | +|------------------------------|-------------------------------------------------|-----------------------------------------------------------------------------------------------| +| Revision | Will only fetch the revision as project version | ![git revision example ](Documentation/Images/BasicGitFormatRevision.png) | +| \[revision] Branch (default) | Will fetch the current revision and branch | ![git revision and branch example ](Documentation/Images/BasicGitFormatRevisionAndBranch.png) | +| \[revision] Tag | Will fetch the current revision and tag | ![git revision and tag example ](Documentation/Images/BasicGitFormatRevisionAndTag.png) | +| Branch | Will only fetch the current branch | ![git branch example ](Documentation/Images/BasicGitFormatRevisionBranch.png) | +| Tag | Will only fetch the current tag | ![git tag example ](Documentation/Images/BasicGitFormatRevisionTag.png) | diff --git a/ext_emconf.php b/ext_emconf.php index 5c5ad7a..5385da8 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -25,7 +25,7 @@ 'version' => '2.0.0-dev', 'constraints' => [ 'depends' => [ - 'php' => '7.0', + 'php' => '7.4', 'typo3' => '10.4.0-11.5.99' ], 'conflicts' => [ From 7d23fc4e8ab96f5b5bcd1fe126e43a1f364c890f Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 19:09:25 +0200 Subject: [PATCH 07/28] [#17] Fix tests --- .../ProjectVersionEventListener.php | 2 - Classes/Service/ProjectVersionService.php | 4 +- .../ProjectVersionEventListenerTest.php} | 62 +++++++++---------- .../Service/ProjectVersionServiceTest.php | 18 +++--- composer.json | 2 +- phpunit.xml | 6 +- 6 files changed, 46 insertions(+), 48 deletions(-) rename Tests/Unit/{Backend/ToolbarItems/ProjectVersionSlotTest.php => EventListener/ProjectVersionEventListenerTest.php} (56%) diff --git a/Classes/EventListener/ProjectVersionEventListener.php b/Classes/EventListener/ProjectVersionEventListener.php index cdb6e54..a4d1c52 100644 --- a/Classes/EventListener/ProjectVersionEventListener.php +++ b/Classes/EventListener/ProjectVersionEventListener.php @@ -42,9 +42,7 @@ public function __construct(ProjectVersionService $projectVersionService, Langua public function __invoke(SystemInformationToolbarCollectorEvent $event) { $projectVersion = $this->projectVersionService->getProjectVersion(); - $version = $projectVersion->getVersion(); - if (StringUtility::beginsWith($version, 'LLL:')) { $version = $this->languageService->sL($version); } diff --git a/Classes/Service/ProjectVersionService.php b/Classes/Service/ProjectVersionService.php index e68340c..1d4984f 100644 --- a/Classes/Service/ProjectVersionService.php +++ b/Classes/Service/ProjectVersionService.php @@ -42,7 +42,7 @@ class ProjectVersionService implements SingletonInterface /** * @var \KamiYang\ProjectVersion\Configuration\ExtensionConfiguration */ - private $extensionConfiguration; + protected $extensionConfiguration; public function __construct(CommandUtilityFacade $commandUtilityFacade, ExtensionConfiguration $extensionConfiguration) { @@ -103,7 +103,7 @@ private function formatVersion($revision, $tag, $branch): string return $format; } - private function isGitAvailable(): bool + protected function isGitAvailable(): bool { return $this->isExecEnabled() && // check if git exists diff --git a/Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php b/Tests/Unit/EventListener/ProjectVersionEventListenerTest.php similarity index 56% rename from Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php rename to Tests/Unit/EventListener/ProjectVersionEventListenerTest.php index 1574952..8ac3ea1 100644 --- a/Tests/Unit/Backend/ToolbarItems/ProjectVersionSlotTest.php +++ b/Tests/Unit/EventListener/ProjectVersionEventListenerTest.php @@ -14,30 +14,31 @@ * LICENSE file that was distributed with this source code. */ -namespace KamiYang\ProjectVersion\Tests\Unit\Backend\ToolbarItems; +namespace KamiYang\ProjectVersion\Tests\Unit\EventListener; -use KamiYang\ProjectVersion\Backend\ToolbarItems\ProjectVersionSlot; -use KamiYang\ProjectVersion\Facade\LocalizationUtilityFacade; +use KamiYang\ProjectVersion\EventListener\ProjectVersionEventListener; use KamiYang\ProjectVersion\Service\ProjectVersion; use KamiYang\ProjectVersion\Service\ProjectVersionService; use Nimut\TestingFramework\TestCase\UnitTestCase; +use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent; use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; /** * Class ProjectVersionSlotTest */ -class ProjectVersionSlotTest extends UnitTestCase +class ProjectVersionEventListenerTest extends UnitTestCase { /** - * @var \KamiYang\ProjectVersion\Backend\ToolbarItems\ProjectVersionSlot + * @var \TYPO3\CMS\Core\Localization\LanguageService|\Prophecy\Prophecy\ObjectProphecy */ - private $subject; + private $languageServiceProphecy; protected function setUp(): void { - $this->subject = new ProjectVersionSlot(); + $this->languageServiceProphecy = $this->prophesize(LanguageService::class); } protected function tearDown(): void @@ -48,8 +49,9 @@ protected function tearDown(): void } /** + * @test */ - public function getProjectVersionShouldAddProjectVersionAsSystemInformation() + public function getProjectVersionShouldAddProjectVersionAsSystemInformation(): void { $version = '9000-rc.69'; $title = 'Project Version'; @@ -60,17 +62,9 @@ public function getProjectVersionShouldAddProjectVersionAsSystemInformation() $projectVersion->setTitle($title); $systemInformationToolbarItemProphecy = $this->prophesize(SystemInformationToolbarItem::class); - - $projectVersionServiceProphecy = $this->prophesize(ProjectVersionService::class); - $projectVersionServiceProphecy->getProjectVersion()->willReturn($projectVersion); - - $objectManagerProphecy = $this->prophesize(ObjectManager::class); - $objectManagerProphecy->get(ProjectVersionService::class)->willReturn($projectVersionServiceProphecy->reveal()); - - GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal()); - GeneralUtility::setSingletonInstance(ProjectVersionService::class, $projectVersionServiceProphecy->reveal()); - - $this->subject->getProjectVersion($systemInformationToolbarItemProphecy->reveal()); + $event = new SystemInformationToolbarCollectorEvent($systemInformationToolbarItemProphecy->reveal()); + $subject = $this->getSubject($projectVersion); + $subject($event); $systemInformationToolbarItemProphecy->addSystemInformation($title, $version, $iconIdentifier) ->shouldHaveBeenCalledTimes(1); @@ -79,28 +73,19 @@ public function getProjectVersionShouldAddProjectVersionAsSystemInformation() /** * @test */ - public function getProjectVersionShouldResolveCurrentVersionAndLocalizeItIfNecessary() + public function getProjectVersionShouldResolveCurrentVersionAndLocalizeItIfNecessary(): void { $initialVersionValue = 'LLL:EXT:project_version/Resources/Private/Language/Backend.xlf:toolbarItems.sysinfo.project-version.unknown'; $projectVersion = new ProjectVersion(); $projectVersion->setVersion($initialVersionValue); $expectedVersion = 'Unknown project version'; - $projectVersionServiceProphecy = $this->prophesize(ProjectVersionService::class); - $projectVersionServiceProphecy->getProjectVersion()->willReturn($projectVersion); - - $objectManagerProphecy = $this->prophesize(ObjectManager::class); - $objectManagerProphecy->get(ProjectVersionService::class)->willReturn($projectVersionServiceProphecy->reveal()); - - $localizationUtilityFacadeProphecy = $this->prophesize(LocalizationUtilityFacade::class); - $localizationUtilityFacadeProphecy->translate($initialVersionValue)->willReturn($expectedVersion); - - GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal()); - GeneralUtility::setSingletonInstance(ProjectVersionService::class, $projectVersionServiceProphecy->reveal()); - GeneralUtility::addInstance(LocalizationUtilityFacade::class, $localizationUtilityFacadeProphecy->reveal()); + $this->languageServiceProphecy->sL($initialVersionValue)->willReturn($expectedVersion); $systemInformationToolbarItemProphecy = $this->prophesize(SystemInformationToolbarItem::class); - $actual = $this->subject->getProjectVersion($systemInformationToolbarItemProphecy->reveal()); + $event = new SystemInformationToolbarCollectorEvent($systemInformationToolbarItemProphecy->reveal()); + $subject = $this->getSubject($projectVersion); + $subject($event); $systemInformationToolbarItemProphecy->addSystemInformation( $projectVersion->getTitle(), @@ -109,4 +94,15 @@ public function getProjectVersionShouldResolveCurrentVersionAndLocalizeItIfNeces ) ->shouldHaveBeenCalledTimes(1); } + + private function getSubject(ProjectVersion $projectVersion): ProjectVersionEventListener + { + $projectVersionServiceProphecy = $this->prophesize(ProjectVersionService::class); + $projectVersionServiceProphecy->getProjectVersion()->willReturn($projectVersion); + + return new ProjectVersionEventListener( + $projectVersionServiceProphecy->reveal(), + $this->languageServiceProphecy->reveal() + ); + } } diff --git a/Tests/Unit/Service/ProjectVersionServiceTest.php b/Tests/Unit/Service/ProjectVersionServiceTest.php index 4b5c168..d4beaff 100644 --- a/Tests/Unit/Service/ProjectVersionServiceTest.php +++ b/Tests/Unit/Service/ProjectVersionServiceTest.php @@ -30,7 +30,6 @@ use function array_replace; use function ini_get; use function ini_set; -use function var_dump; /** * Class ProjectVersionServiceTest @@ -153,7 +152,8 @@ public function getProjectVersionShouldReturnSpecifiedVersionBasedOnConfiguredGi 'mode' => ProjectVersionModeEnumeration::GIT, 'gitFormat' => $format ]); - $this->commandUtilityFacadeProphecy->exec('git --version', Argument::cetera()) + $returnValue = 0; + $this->commandUtilityFacadeProphecy->exec('git --version', $_, $returnValue) ->will(function (&$arguments) { $arguments[2] = 0; }); @@ -161,10 +161,14 @@ public function getProjectVersionShouldReturnSpecifiedVersionBasedOnConfiguredGi $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_REVISION)->willReturn($revision); $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_TAG)->willReturn($tag); - $subject = new ProjectVersionService( - $this->commandUtilityFacadeProphecy->reveal(), - new ExtensionConfiguration() - ); + $subject = $this->createPartialMock(ProjectVersionService::class, ['isGitAvailable']); + $dependency = new ExtensionConfiguration(); + $this->inject($subject, 'extensionConfiguration', $dependency); + $this->inject($subject, 'commandUtilityFacade', $this->commandUtilityFacadeProphecy->reveal()); + $subject + ->expects(self::once()) + ->method('isGitAvailable') + ->willReturn(true); static::assertSame( $expected, @@ -207,7 +211,7 @@ public function getProjectVersionShouldTryToFetchVersionFromFileIfResolvingUsing } /** - * @return array + * @return Generator */ public function gitFormatDataProvider(): Generator { diff --git a/composer.json b/composer.json index d8699c9..3d27163 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,7 @@ "vendor-dir": ".Build/vendor", "bin-dir": ".Build/bin", "platform": { - "php": "7.4" + "php": "7.2" } }, "extra": { diff --git a/phpunit.xml b/phpunit.xml index 1a2fc8f..018d1e3 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,11 +1,11 @@ @@ -22,6 +22,6 @@ - + From cdca72ba7a9839d3fa0fbfbff4b61b969ed2e89f Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 19:32:04 +0200 Subject: [PATCH 08/28] [#17] Cleanup --- .../Configuration/ExtensionConfiguration.php | 4 +- .../ProjectVersionEventListener.php | 4 +- Classes/Service/ProjectVersionService.php | 27 ++++++------ Resources/Private/Language/Backend.xlf | 4 +- .../ProjectVersionEventListenerTest.php | 1 - .../Service/ProjectVersionServiceTest.php | 43 +++++++------------ Tests/Unit/Service/ProjectVersionTest.php | 2 +- 7 files changed, 36 insertions(+), 49 deletions(-) diff --git a/Classes/Configuration/ExtensionConfiguration.php b/Classes/Configuration/ExtensionConfiguration.php index 1f3acd5..cb3cccb 100644 --- a/Classes/Configuration/ExtensionConfiguration.php +++ b/Classes/Configuration/ExtensionConfiguration.php @@ -46,7 +46,7 @@ final class ExtensionConfiguration implements SingletonInterface * Indicator for the fetching method. * * @var string - * @see \KamiYang\ProjectVersion\Enumeration\ProjectVersionModeEnumeration + * @see ProjectVersionModeEnumeration */ private $mode; @@ -93,7 +93,6 @@ public function getStaticVersion(): string public function __construct() { $this->configuration = $this->getExtensionConfigurationFromGlobals(); - $this->versionFilePath = $this->resolveVersionFilePath(); $this->mode = $this->configuration['mode'] ?? ProjectVersionModeEnumeration::FILE; $this->gitFormat = $this->configuration['gitFormat'] ?? ''; @@ -108,7 +107,6 @@ private function getExtensionConfigurationFromGlobals(): array private function resolveVersionFilePath(): string { $pathFromConfiguration = $this->configuration['versionFilePath'] ?? ''; - if (empty($pathFromConfiguration) || $this->isDirectory($pathFromConfiguration)) { $pathFromConfiguration .= self::DEFAULT_VERSION_FILE; } diff --git a/Classes/EventListener/ProjectVersionEventListener.php b/Classes/EventListener/ProjectVersionEventListener.php index a4d1c52..96b3ad9 100644 --- a/Classes/EventListener/ProjectVersionEventListener.php +++ b/Classes/EventListener/ProjectVersionEventListener.php @@ -24,12 +24,12 @@ final class ProjectVersionEventListener { /** - * @var \KamiYang\ProjectVersion\Service\ProjectVersionService + * @var ProjectVersionService */ private $projectVersionService; /** - * @var \TYPO3\CMS\Core\Localization\LanguageService + * @var LanguageService */ private $languageService; diff --git a/Classes/Service/ProjectVersionService.php b/Classes/Service/ProjectVersionService.php index 1d4984f..5ee973d 100644 --- a/Classes/Service/ProjectVersionService.php +++ b/Classes/Service/ProjectVersionService.php @@ -36,11 +36,11 @@ class ProjectVersionService implements SingletonInterface { /** - * @var \KamiYang\ProjectVersion\Facade\CommandUtilityFacade + * @var CommandUtilityFacade */ protected $commandUtilityFacade; /** - * @var \KamiYang\ProjectVersion\Configuration\ExtensionConfiguration + * @var ExtensionConfiguration */ protected $extensionConfiguration; @@ -56,7 +56,6 @@ public function __construct(CommandUtilityFacade $commandUtilityFacade, Extensio public function getProjectVersion(): ProjectVersion { $projectVersion = GeneralUtility::makeInstance(ProjectVersion::class); - switch ($this->extensionConfiguration->getMode()) { case ProjectVersionModeEnumeration::STATIC_VERSION: $this->setStaticVersion($projectVersion); @@ -66,7 +65,6 @@ public function getProjectVersion(): ProjectVersion break; case ProjectVersionModeEnumeration::GIT_FILE_FALLBACK: $this->setVersionFromGit($projectVersion); - if ($projectVersion->getVersion() === ProjectVersion::UNKNOWN_VERSION) { //if version is still unknown, try to resolve version by file $this->setVersionFromFile($projectVersion); @@ -80,6 +78,18 @@ public function getProjectVersion(): ProjectVersion return $projectVersion; } + /** + * @internal protected so we can mock it in unit tests. + * @return bool + */ + protected function isGitAvailable(): bool + { + return $this->isExecEnabled() && + // check if git exists + $this->commandUtilityFacade->exec('git --version', $_, $returnCode) && + $returnCode === 0; + } + private function formatVersion($revision, $tag, $branch): string { switch ($this->extensionConfiguration->getGitFormat()) { @@ -103,14 +113,6 @@ private function formatVersion($revision, $tag, $branch): string return $format; } - protected function isGitAvailable(): bool - { - return $this->isExecEnabled() && - // check if git exists - $this->commandUtilityFacade->exec('git --version', $_, $returnCode) && - $returnCode === 0; - } - private function setStaticVersion(ProjectVersion $projectVersion): void { $projectVersion->setVersion($this->extensionConfiguration->getStaticVersion()); @@ -132,7 +134,6 @@ private function setVersionFromGit(ProjectVersion $projectVersion): void } $version = $this->getVersionByFormat(); - if (!empty($version)) { $gitIconIdentifier = 'information-git'; diff --git a/Resources/Private/Language/Backend.xlf b/Resources/Private/Language/Backend.xlf index 9581d1c..04a596f 100644 --- a/Resources/Private/Language/Backend.xlf +++ b/Resources/Private/Language/Backend.xlf @@ -1,6 +1,6 @@ - - +
diff --git a/Tests/Unit/EventListener/ProjectVersionEventListenerTest.php b/Tests/Unit/EventListener/ProjectVersionEventListenerTest.php index 8ac3ea1..1d2c69c 100644 --- a/Tests/Unit/EventListener/ProjectVersionEventListenerTest.php +++ b/Tests/Unit/EventListener/ProjectVersionEventListenerTest.php @@ -24,7 +24,6 @@ use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; /** * Class ProjectVersionSlotTest diff --git a/Tests/Unit/Service/ProjectVersionServiceTest.php b/Tests/Unit/Service/ProjectVersionServiceTest.php index d4beaff..a91cd02 100644 --- a/Tests/Unit/Service/ProjectVersionServiceTest.php +++ b/Tests/Unit/Service/ProjectVersionServiceTest.php @@ -64,10 +64,7 @@ public function getProjectVersionShouldNotSetProjectVersionIfVersionFileIsNotFou $projectVersionProphecy = $this->prophesize(ProjectVersion::class); GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersionProphecy->reveal()); - new ProjectVersionService( - $this->commandUtilityFacadeProphecy->reveal(), - new ExtensionConfiguration() - ); + $_ = $this->getSubject(); $projectVersionProphecy->setVersion(Argument::any()) ->shouldNotHaveBeenCalled(); @@ -82,10 +79,7 @@ public function getProjectVersionShouldSetVersionFromVersionFileIfFileExists(str { $this->setUpExtensionConfiguration(['versionFilePath' => $versionFilePath]); - $subject = new ProjectVersionService( - $this->commandUtilityFacadeProphecy->reveal(), - new ExtensionConfiguration() - ); + $subject = $this->getSubject(); self::assertEquals( '1.0.1', @@ -119,10 +113,7 @@ public function getProjectVersionShouldNotSetVersionFromGitIfCommandExecIsNotAva $originalDisbableFunctions = ini_get('disable_functions'); ini_set('disable_functions', 'exec'); - new ProjectVersionService( - $this->commandUtilityFacadeProphecy->reveal(), - new ExtensionConfiguration() - ); + $_ = $this->getSubject(); $projectVersionProphecy->setVersion(Argument::any()) ->shouldNotHaveBeenCalled(); @@ -162,8 +153,7 @@ public function getProjectVersionShouldReturnSpecifiedVersionBasedOnConfiguredGi $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_TAG)->willReturn($tag); $subject = $this->createPartialMock(ProjectVersionService::class, ['isGitAvailable']); - $dependency = new ExtensionConfiguration(); - $this->inject($subject, 'extensionConfiguration', $dependency); + $this->inject($subject, 'extensionConfiguration', new ExtensionConfiguration()); $this->inject($subject, 'commandUtilityFacade', $this->commandUtilityFacadeProphecy->reveal()); $subject ->expects(self::once()) @@ -185,7 +175,6 @@ public function getProjectVersionShouldReturnSpecifiedVersionBasedOnConfiguredGi */ public function getProjectVersionShouldTryToFetchVersionFromFileIfResolvingUsingGitErrored(): void { - //Arrange $versionFilePath = 'EXT:project_version/Tests/Fixture/VERSION'; $this->setUpExtensionConfiguration([ 'versionFilePath' => $versionFilePath, @@ -203,10 +192,8 @@ public function getProjectVersionShouldTryToFetchVersionFromFileIfResolvingUsing $this->commandUtilityFacadeProphecy->exec(GitCommandEnumeration::CMD_TAG)->willReturn($tag); $this->commandUtilityFacadeProphecy->exec('git --version', $_, $returnCode)->willReturn(0); - $subject = new ProjectVersionService( - $this->commandUtilityFacadeProphecy->reveal(), - new ExtensionConfiguration() - ); + $subject = $this->getSubject(); + static::assertSame($expected, $subject->getProjectVersion()->getVersion()); } @@ -270,10 +257,7 @@ public function getProjectVersionShouldAlwaysSetStaticVersionIfSelected(): void { $this->setUpExtensionConfiguration(['mode' => ProjectVersionModeEnumeration::STATIC_VERSION]); - $subject = new ProjectVersionService( - $this->commandUtilityFacadeProphecy->reveal(), - new ExtensionConfiguration() - ); + $subject = $this->getSubject(); static::assertSame( '', @@ -294,10 +278,7 @@ public function getProjectVersionShouldSetStaticVersionFromExtensionConfiguratio 'staticVersion' => $staticVersion ]); - $subject = new ProjectVersionService( - $this->commandUtilityFacadeProphecy->reveal(), - new ExtensionConfiguration() - ); + $subject = $this->getSubject(); self::assertSame( $staticVersion, @@ -337,4 +318,12 @@ protected function setUpExtensionConfiguration(array $extConfig): void $extConfig ); } + + private function getSubject(): ProjectVersionService + { + return new ProjectVersionService( + $this->commandUtilityFacadeProphecy->reveal(), + new ExtensionConfiguration() + ); + } } diff --git a/Tests/Unit/Service/ProjectVersionTest.php b/Tests/Unit/Service/ProjectVersionTest.php index 9ececb9..1e96e41 100644 --- a/Tests/Unit/Service/ProjectVersionTest.php +++ b/Tests/Unit/Service/ProjectVersionTest.php @@ -25,7 +25,7 @@ class ProjectVersionTest extends UnitTestCase { /** - * @var \KamiYang\ProjectVersion\Service\ProjectVersion + * @var ProjectVersion */ private $subject; From 81a1b1890862ff92cf22bebf5f08462d99d60e2f Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 19:42:03 +0200 Subject: [PATCH 09/28] [#17] Raise typo3 versions in .travis.yaml --- .travis.yml | 66 ++++++++++++++++++++++++++++----------------------- composer.json | 6 ++--- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index d361cb9..38c01c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,10 @@ # .travis.yml language: php - sudo: false - php: - 7.2 - matrix: fast_finish: true - addons: apt: packages: @@ -16,12 +12,10 @@ addons: cache: directories: - $HOME/.composer/cache - install: - composer require typo3/cms-backend:${TYPO3_VERSION} typo3/cms-core:${TYPO3_VERSION} typo3/cms-extbase:${TYPO3_VERSION} typo3/cms-extensionmanager:${TYPO3_VERSION} typo3/cms-filelist:${TYPO3_VERSION} typo3/cms-fluid:${TYPO3_VERSION} typo3/cms-frontend:${TYPO3_VERSION} typo3/cms-install:${TYPO3_VERSION} typo3/cms-recordlist:${TYPO3_VERSION} typo3/cms-lowlevel:${TYPO3_VERSION} typo3/cms-about:${TYPO3_VERSION} typo3/cms-belog:${TYPO3_VERSION} typo3/cms-beuser:${TYPO3_VERSION} typo3/cms-felogin:${TYPO3_VERSION} typo3/cms-fluid-styled-content:${TYPO3_VERSION} typo3/cms-form:${TYPO3_VERSION} typo3/cms-impexp:${TYPO3_VERSION} typo3/cms-info:${TYPO3_VERSION} typo3/cms-rte-ckeditor:${TYPO3_VERSION} typo3/cms-setup:${TYPO3_VERSION} typo3/cms-seo:${TYPO3_VERSION} typo3/cms-sys-note:${TYPO3_VERSION} typo3/cms-t3editor:${TYPO3_VERSION} typo3/cms-tstemplate:${TYPO3_VERSION} typo3/cms-viewpage:${TYPO3_VERSION} typo3/cms-adminpanel:${TYPO3_VERSION} typo3/cms-redirects:${TYPO3_VERSION} typo3/cms-workspaces:${TYPO3_VERSION} typo3/cms-reports:${TYPO3_VERSION} typo3/cms-scheduler:${TYPO3_VERSION} typo3/cms-recycler:${TYPO3_VERSION} typo3/cms-opendocs:${TYPO3_VERSION} typo3/cms-linkvalidator:${TYPO3_VERSION} - - git checkout composer.json - - export TYPO3_PATH_WEB="$PWD/.Build/web" + - export TYPO3_PATH_WEB="$PWD/.Build/public" script: - > @@ -46,30 +40,42 @@ jobs: allow_failures: - env: TYPO3_VERSION=dev-master include: - - stage: test - php: 7.2 - env: TYPO3_VERSION=9.5.0 - - stage: test - php: 7.2 - env: TYPO3_VERSION=9.5.1 - - stage: test - php: 7.2 - env: TYPO3_VERSION=9.5.2 - - stage: test - php: 7.2 - env: TYPO3_VERSION=9.5.3 - - stage: test - php: 7.2 - env: TYPO3_VERSION=9.5.4 - - stage: test - php: 7.2 - env: TYPO3_VERSION=9.5.5 - - stage: test - php: 7.2 - env: TYPO3_VERSION=9.5.6 - - stage: test + - &test + stage: test php: 7.2 - env: TYPO3_VERSION=9.5.7 + env: TYPO3_VERSION=10.5.20 + - *test + env: TYPO3_VERSION=10.5.21 + - *test + env: TYPO3_VERSION=10.5.22 + - *test + env: TYPO3_VERSION=10.5.23 + - *test + env: TYPO3_VERSION=10.5.24 + - *test + env: TYPO3_VERSION=10.5.25 + - *test + env: TYPO3_VERSION=10.5.26 + - *test + env: TYPO3_VERSION=10.5.27 + - *test + env: TYPO3_VERSION=10.5.28 + - *test + env: TYPO3_VERSION=11.3.3 + - *test + env: TYPO3_VERSION=11.3.4 + - *test + env: TYPO3_VERSION=11.3.5 + - *test + env: TYPO3_VERSION=11.3.6 + - *test + env: TYPO3_VERSION=11.3.7 + - *test + env: TYPO3_VERSION=11.3.8 + - *test + env: TYPO3_VERSION=11.3.9 + - *test + env: TYPO3_VERSION=11.3.10 - stage: test php: 7.2 env: TYPO3_VERSION=dev-master diff --git a/composer.json b/composer.json index 3d27163..75bb701 100644 --- a/composer.json +++ b/composer.json @@ -24,13 +24,13 @@ "require": { "typo3/cms-backend": "^10.4", "typo3/cms-extbase": "^10.4", - "typo3/cms-extensionmanager": "^10.4", - "nimut/testing-framework": "^6" + "typo3/cms-extensionmanager": "^10.4" }, "require-dev": { "satooshi/php-coveralls": "^2.0", "michielroos/typo3scan": "^1.7", - "squizlabs/php_codesniffer": "^3.6" + "squizlabs/php_codesniffer": "^3.6", + "nimut/testing-framework": "^6" }, "autoload": { "psr-4": { From 6dd73bffedbc4016aab848865ea2670c713c931f Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 19:45:38 +0200 Subject: [PATCH 10/28] [#17] Fix version numbers in .travis.yml --- .travis.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38c01c8..e2b0854 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,21 +61,27 @@ jobs: - *test env: TYPO3_VERSION=10.5.28 - *test - env: TYPO3_VERSION=11.3.3 + env: TYPO3_VERSION=11.5.0 - *test - env: TYPO3_VERSION=11.3.4 + env: TYPO3_VERSION=11.5.1 - *test - env: TYPO3_VERSION=11.3.5 + env: TYPO3_VERSION=11.5.2 - *test - env: TYPO3_VERSION=11.3.6 + env: TYPO3_VERSION=11.5.3 - *test - env: TYPO3_VERSION=11.3.7 + env: TYPO3_VERSION=11.5.4 - *test - env: TYPO3_VERSION=11.3.8 + env: TYPO3_VERSION=11.5.5 - *test - env: TYPO3_VERSION=11.3.9 + env: TYPO3_VERSION=11.5.6 - *test - env: TYPO3_VERSION=11.3.10 + env: TYPO3_VERSION=11.5.7 + - *test + env: TYPO3_VERSION=11.5.8 + - *test + env: TYPO3_VERSION=11.5.9 + - *test + env: TYPO3_VERSION=11.5.10 - stage: test php: 7.2 env: TYPO3_VERSION=dev-master From 215e86f8d926799677d1debd8194ac476893922a Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 19:53:56 +0200 Subject: [PATCH 11/28] [#17] Ignore root .ddev folder from git --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0cf621c..0fcd87d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.ddev +/.ddev /.Build/ /.idea/ /composer.lock From 0ad0b5b7e1831a57adc8d1fca90668f19feff79a Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 20:24:10 +0200 Subject: [PATCH 12/28] [#17] Introduce GHA --- .github/workflows/ci.yml | 100 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8030745 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,100 @@ +name: Unit tests + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + ci: + runs-on: ubuntu-18.04 + strategy: + matrix: + typo3_version: + - 10.5.20 + - 10.5.21 +# - 10.5.22 +# - 10.5.23 +# - 10.5.24 +# - 10.5.25 +# - 10.5.26 +# - 10.5.27 +# - 10.5.28 +# - 11.5.0 +# - 11.5.1 +# - 11.5.2 +# - 11.5.3 +# - 11.5.4 +# - 11.5.5 +# - 11.5.6 +# - 11.5.7 +# - 11.5.8 +# - 11.5.9 +# - 11.5.10 +# - dev-master + + steps: + - uses: actions/checkout@v3 + + - name: Set up PHP Version + uses: shivammathur/setup-php@v2 + with: + php-version: 7.2 + tools: composer:v1 + + # Directory permissions for .composer are wrong, so we remove the complete directory + # https://github.com/actions/virtual-environments/issues/824 +# - name: Delete .composer directory +# run: sudo rm -rf ~/.composer + - name: Validate composer.json + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: .Build/vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}-${{ matrix.typo3_version }} + restore-keys: | + ${{ runner.os }}-php-${{ matrix.typo3_version }}- + + - name: Install dependencies for TYPO3 version "${{ matrix.typo3_version }}" + run: | + composer require + typo3/cms-backend:${{ matrix.typo3_version }} + typo3/cms-core:${{ matrix.typo3_version }} + typo3/cms-extbase:${{ matrix.typo3_version }} + typo3/cms-extensionmanager:${{ matrix.typo3_version }} + typo3/cms-filelist:${{ matrix.typo3_version }} + typo3/cms-fluid:${{ matrix.typo3_version }} + typo3/cms-frontend:${{ matrix.typo3_version }} + typo3/cms-install:${{ matrix.typo3_version }} + typo3/cms-recordlist:${{ matrix.typo3_version }} + typo3/cms-lowlevel:${{ matrix.typo3_version }} + typo3/cms-about:${{ matrix.typo3_version }} + typo3/cms-belog:${{ matrix.typo3_version }} + typo3/cms-beuser:${{ matrix.typo3_version }} + typo3/cms-felogin:${{ matrix.typo3_version }} + typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} + typo3/cms-form:${{ matrix.typo3_version }} + typo3/cms-impexp:${{ matrix.typo3_version }} + typo3/cms-info:${{ matrix.typo3_version }} + typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} + typo3/cms-setup:${{ matrix.typo3_version }} + typo3/cms-seo:${{ matrix.typo3_version }} + typo3/cms-sys-note:${{ matrix.typo3_version }} + typo3/cms-t3editor:${{ matrix.typo3_version }} + typo3/cms-tstemplate:${{ matrix.typo3_version }} + typo3/cms-viewpage:${{ matrix.typo3_version }} + typo3/cms-adminpanel:${{ matrix.typo3_version }} + typo3/cms-redirects:${{ matrix.typo3_version }} + typo3/cms-workspaces:${{ matrix.typo3_version }} + typo3/cms-reports:${{ matrix.typo3_version }} + typo3/cms-scheduler:${{ matrix.typo3_version }} + typo3/cms-recycler:${{ matrix.typo3_version }} + typo3/cms-opendocs:${{ matrix.typo3_version }} + typo3/cms-linkvalidator:${{ matrix.typo3_version }} + + - name: Unit tests + run: .Build/bin/phpunit --colors -c phpunit.xml From 98bb0159ced443dc8f1e9314da1e9eeed58cf6d0 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 20:28:54 +0200 Subject: [PATCH 13/28] [#17] Fix typo3 versions --- .github/workflows/ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8030745..e8d4055 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,15 +12,15 @@ jobs: strategy: matrix: typo3_version: - - 10.5.20 - - 10.5.21 -# - 10.5.22 -# - 10.5.23 -# - 10.5.24 -# - 10.5.25 -# - 10.5.26 -# - 10.5.27 -# - 10.5.28 + - 10.4.20 + - 10.4.21 +# - 10.4.22 +# - 10.4.23 +# - 10.4.24 +# - 10.4.25 +# - 10.4.26 +# - 10.4.27 +# - 10.4.28 # - 11.5.0 # - 11.5.1 # - 11.5.2 @@ -60,7 +60,7 @@ jobs: ${{ runner.os }}-php-${{ matrix.typo3_version }}- - name: Install dependencies for TYPO3 version "${{ matrix.typo3_version }}" - run: | + run: >- composer require typo3/cms-backend:${{ matrix.typo3_version }} typo3/cms-core:${{ matrix.typo3_version }} From 02b87b285917d72dc0e388b49bfd92442deb74c4 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 20:36:14 +0200 Subject: [PATCH 14/28] [#17] Dont preserve newlines --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8d4055..42937ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: ${{ runner.os }}-php-${{ matrix.typo3_version }}- - name: Install dependencies for TYPO3 version "${{ matrix.typo3_version }}" - run: >- + run: |- composer require typo3/cms-backend:${{ matrix.typo3_version }} typo3/cms-core:${{ matrix.typo3_version }} From fb102093574aa3b9d951dfe24c9568080dfc3554 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 20:40:23 +0200 Subject: [PATCH 15/28] [#17] Dont use multiline string --- .github/workflows/ci.yml | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42937ca..2554f45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: matrix: typo3_version: - 10.4.20 - - 10.4.21 +# - 10.4.21 # - 10.4.22 # - 10.4.23 # - 10.4.24 @@ -60,41 +60,7 @@ jobs: ${{ runner.os }}-php-${{ matrix.typo3_version }}- - name: Install dependencies for TYPO3 version "${{ matrix.typo3_version }}" - run: |- - composer require - typo3/cms-backend:${{ matrix.typo3_version }} - typo3/cms-core:${{ matrix.typo3_version }} - typo3/cms-extbase:${{ matrix.typo3_version }} - typo3/cms-extensionmanager:${{ matrix.typo3_version }} - typo3/cms-filelist:${{ matrix.typo3_version }} - typo3/cms-fluid:${{ matrix.typo3_version }} - typo3/cms-frontend:${{ matrix.typo3_version }} - typo3/cms-install:${{ matrix.typo3_version }} - typo3/cms-recordlist:${{ matrix.typo3_version }} - typo3/cms-lowlevel:${{ matrix.typo3_version }} - typo3/cms-about:${{ matrix.typo3_version }} - typo3/cms-belog:${{ matrix.typo3_version }} - typo3/cms-beuser:${{ matrix.typo3_version }} - typo3/cms-felogin:${{ matrix.typo3_version }} - typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} - typo3/cms-form:${{ matrix.typo3_version }} - typo3/cms-impexp:${{ matrix.typo3_version }} - typo3/cms-info:${{ matrix.typo3_version }} - typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} - typo3/cms-setup:${{ matrix.typo3_version }} - typo3/cms-seo:${{ matrix.typo3_version }} - typo3/cms-sys-note:${{ matrix.typo3_version }} - typo3/cms-t3editor:${{ matrix.typo3_version }} - typo3/cms-tstemplate:${{ matrix.typo3_version }} - typo3/cms-viewpage:${{ matrix.typo3_version }} - typo3/cms-adminpanel:${{ matrix.typo3_version }} - typo3/cms-redirects:${{ matrix.typo3_version }} - typo3/cms-workspaces:${{ matrix.typo3_version }} - typo3/cms-reports:${{ matrix.typo3_version }} - typo3/cms-scheduler:${{ matrix.typo3_version }} - typo3/cms-recycler:${{ matrix.typo3_version }} - typo3/cms-opendocs:${{ matrix.typo3_version }} - typo3/cms-linkvalidator:${{ matrix.typo3_version }} + run: composer require typo3/cms-backend:${{ matrix.typo3_version }} typo3/cms-core:${{ matrix.typo3_version }} typo3/cms-extbase:${{ matrix.typo3_version }} typo3/cms-extensionmanager:${{ matrix.typo3_version }} typo3/cms-filelist:${{ matrix.typo3_version }} typo3/cms-fluid:${{ matrix.typo3_version }} typo3/cms-frontend:${{ matrix.typo3_version }} typo3/cms-install:${{ matrix.typo3_version }} typo3/cms-recordlist:${{ matrix.typo3_version }} typo3/cms-lowlevel:${{ matrix.typo3_version }} typo3/cms-about:${{ matrix.typo3_version }} typo3/cms-belog:${{ matrix.typo3_version }} typo3/cms-beuser:${{ matrix.typo3_version }} typo3/cms-felogin:${{ matrix.typo3_version }} typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} typo3/cms-form:${{ matrix.typo3_version }} typo3/cms-impexp:${{ matrix.typo3_version }} typo3/cms-info:${{ matrix.typo3_version }} typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} typo3/cms-setup:${{ matrix.typo3_version }} typo3/cms-seo:${{ matrix.typo3_version }} typo3/cms-sys-note:${{ matrix.typo3_version }} typo3/cms-t3editor:${{ matrix.typo3_version }} typo3/cms-tstemplate:${{ matrix.typo3_version }} typo3/cms-viewpage:${{ matrix.typo3_version }} typo3/cms-adminpanel:${{ matrix.typo3_version }} typo3/cms-redirects:${{ matrix.typo3_version }} typo3/cms-workspaces:${{ matrix.typo3_version }} typo3/cms-reports:${{ matrix.typo3_version }} typo3/cms-scheduler:${{ matrix.typo3_version }} typo3/cms-recycler:${{ matrix.typo3_version }} typo3/cms-opendocs:${{ matrix.typo3_version }} typo3/cms-linkvalidator:${{ matrix.typo3_version }} - name: Unit tests run: .Build/bin/phpunit --colors -c phpunit.xml From f76d4f559b3f8d3ec3118dcff1c762132c988bba Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 20:45:03 +0200 Subject: [PATCH 16/28] [#17] Run tests on two versions --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2554f45..4b5ed0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: matrix: typo3_version: - 10.4.20 -# - 10.4.21 + - 10.4.21 # - 10.4.22 # - 10.4.23 # - 10.4.24 @@ -60,7 +60,41 @@ jobs: ${{ runner.os }}-php-${{ matrix.typo3_version }}- - name: Install dependencies for TYPO3 version "${{ matrix.typo3_version }}" - run: composer require typo3/cms-backend:${{ matrix.typo3_version }} typo3/cms-core:${{ matrix.typo3_version }} typo3/cms-extbase:${{ matrix.typo3_version }} typo3/cms-extensionmanager:${{ matrix.typo3_version }} typo3/cms-filelist:${{ matrix.typo3_version }} typo3/cms-fluid:${{ matrix.typo3_version }} typo3/cms-frontend:${{ matrix.typo3_version }} typo3/cms-install:${{ matrix.typo3_version }} typo3/cms-recordlist:${{ matrix.typo3_version }} typo3/cms-lowlevel:${{ matrix.typo3_version }} typo3/cms-about:${{ matrix.typo3_version }} typo3/cms-belog:${{ matrix.typo3_version }} typo3/cms-beuser:${{ matrix.typo3_version }} typo3/cms-felogin:${{ matrix.typo3_version }} typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} typo3/cms-form:${{ matrix.typo3_version }} typo3/cms-impexp:${{ matrix.typo3_version }} typo3/cms-info:${{ matrix.typo3_version }} typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} typo3/cms-setup:${{ matrix.typo3_version }} typo3/cms-seo:${{ matrix.typo3_version }} typo3/cms-sys-note:${{ matrix.typo3_version }} typo3/cms-t3editor:${{ matrix.typo3_version }} typo3/cms-tstemplate:${{ matrix.typo3_version }} typo3/cms-viewpage:${{ matrix.typo3_version }} typo3/cms-adminpanel:${{ matrix.typo3_version }} typo3/cms-redirects:${{ matrix.typo3_version }} typo3/cms-workspaces:${{ matrix.typo3_version }} typo3/cms-reports:${{ matrix.typo3_version }} typo3/cms-scheduler:${{ matrix.typo3_version }} typo3/cms-recycler:${{ matrix.typo3_version }} typo3/cms-opendocs:${{ matrix.typo3_version }} typo3/cms-linkvalidator:${{ matrix.typo3_version }} + run: > + composer require + typo3/cms-backend:${{ matrix.typo3_version }} + typo3/cms-core:${{ matrix.typo3_version }} + typo3/cms-extbase:${{ matrix.typo3_version }} + typo3/cms-extensionmanager:${{ matrix.typo3_version }} + typo3/cms-filelist:${{ matrix.typo3_version }} + typo3/cms-fluid:${{ matrix.typo3_version }} + typo3/cms-frontend:${{ matrix.typo3_version }} + typo3/cms-install:${{ matrix.typo3_version }} + typo3/cms-recordlist:${{ matrix.typo3_version }} + typo3/cms-lowlevel:${{ matrix.typo3_version }} + typo3/cms-about:${{ matrix.typo3_version }} + typo3/cms-belog:${{ matrix.typo3_version }} + typo3/cms-beuser:${{ matrix.typo3_version }} + typo3/cms-felogin:${{ matrix.typo3_version }} + typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} + typo3/cms-form:${{ matrix.typo3_version }} + typo3/cms-impexp:${{ matrix.typo3_version }} + typo3/cms-info:${{ matrix.typo3_version }} + typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} + typo3/cms-setup:${{ matrix.typo3_version }} + typo3/cms-seo:${{ matrix.typo3_version }} + typo3/cms-sys-note:${{ matrix.typo3_version }} + typo3/cms-t3editor:${{ matrix.typo3_version }} + typo3/cms-tstemplate:${{ matrix.typo3_version }} + typo3/cms-viewpage:${{ matrix.typo3_version }} + typo3/cms-adminpanel:${{ matrix.typo3_version }} + typo3/cms-redirects:${{ matrix.typo3_version }} + typo3/cms-workspaces:${{ matrix.typo3_version }} + typo3/cms-reports:${{ matrix.typo3_version }} + typo3/cms-scheduler:${{ matrix.typo3_version }} + typo3/cms-recycler:${{ matrix.typo3_version }} + typo3/cms-opendocs:${{ matrix.typo3_version }} + typo3/cms-linkvalidator:${{ matrix.typo3_version }} - name: Unit tests run: .Build/bin/phpunit --colors -c phpunit.xml From f7eb74bcfb9bccbc615c32c91fc5197d99e0269b Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 20:46:43 +0200 Subject: [PATCH 17/28] [#17] Dont use multiline string --- .github/workflows/ci.yml | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b5ed0a..90d2502 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,41 +60,7 @@ jobs: ${{ runner.os }}-php-${{ matrix.typo3_version }}- - name: Install dependencies for TYPO3 version "${{ matrix.typo3_version }}" - run: > - composer require - typo3/cms-backend:${{ matrix.typo3_version }} - typo3/cms-core:${{ matrix.typo3_version }} - typo3/cms-extbase:${{ matrix.typo3_version }} - typo3/cms-extensionmanager:${{ matrix.typo3_version }} - typo3/cms-filelist:${{ matrix.typo3_version }} - typo3/cms-fluid:${{ matrix.typo3_version }} - typo3/cms-frontend:${{ matrix.typo3_version }} - typo3/cms-install:${{ matrix.typo3_version }} - typo3/cms-recordlist:${{ matrix.typo3_version }} - typo3/cms-lowlevel:${{ matrix.typo3_version }} - typo3/cms-about:${{ matrix.typo3_version }} - typo3/cms-belog:${{ matrix.typo3_version }} - typo3/cms-beuser:${{ matrix.typo3_version }} - typo3/cms-felogin:${{ matrix.typo3_version }} - typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} - typo3/cms-form:${{ matrix.typo3_version }} - typo3/cms-impexp:${{ matrix.typo3_version }} - typo3/cms-info:${{ matrix.typo3_version }} - typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} - typo3/cms-setup:${{ matrix.typo3_version }} - typo3/cms-seo:${{ matrix.typo3_version }} - typo3/cms-sys-note:${{ matrix.typo3_version }} - typo3/cms-t3editor:${{ matrix.typo3_version }} - typo3/cms-tstemplate:${{ matrix.typo3_version }} - typo3/cms-viewpage:${{ matrix.typo3_version }} - typo3/cms-adminpanel:${{ matrix.typo3_version }} - typo3/cms-redirects:${{ matrix.typo3_version }} - typo3/cms-workspaces:${{ matrix.typo3_version }} - typo3/cms-reports:${{ matrix.typo3_version }} - typo3/cms-scheduler:${{ matrix.typo3_version }} - typo3/cms-recycler:${{ matrix.typo3_version }} - typo3/cms-opendocs:${{ matrix.typo3_version }} - typo3/cms-linkvalidator:${{ matrix.typo3_version }} + run: composer require typo3/cms-backend:${{ matrix.typo3_version }} typo3/cms-core:${{ matrix.typo3_version }} typo3/cms-extbase:${{ matrix.typo3_version }} typo3/cms-extensionmanager:${{ matrix.typo3_version }} typo3/cms-filelist:${{ matrix.typo3_version }} typo3/cms-fluid:${{ matrix.typo3_version }} typo3/cms-frontend:${{ matrix.typo3_version }} typo3/cms-install:${{ matrix.typo3_version }} typo3/cms-recordlist:${{ matrix.typo3_version }} typo3/cms-lowlevel:${{ matrix.typo3_version }} typo3/cms-about:${{ matrix.typo3_version }} typo3/cms-belog:${{ matrix.typo3_version }} typo3/cms-beuser:${{ matrix.typo3_version }} typo3/cms-felogin:${{ matrix.typo3_version }} typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} typo3/cms-form:${{ matrix.typo3_version }} typo3/cms-impexp:${{ matrix.typo3_version }} typo3/cms-info:${{ matrix.typo3_version }} typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} typo3/cms-setup:${{ matrix.typo3_version }} typo3/cms-seo:${{ matrix.typo3_version }} typo3/cms-sys-note:${{ matrix.typo3_version }} typo3/cms-t3editor:${{ matrix.typo3_version }} typo3/cms-tstemplate:${{ matrix.typo3_version }} typo3/cms-viewpage:${{ matrix.typo3_version }} typo3/cms-adminpanel:${{ matrix.typo3_version }} typo3/cms-redirects:${{ matrix.typo3_version }} typo3/cms-workspaces:${{ matrix.typo3_version }} typo3/cms-reports:${{ matrix.typo3_version }} typo3/cms-scheduler:${{ matrix.typo3_version }} typo3/cms-recycler:${{ matrix.typo3_version }} typo3/cms-opendocs:${{ matrix.typo3_version }} typo3/cms-linkvalidator:${{ matrix.typo3_version }} - name: Unit tests run: .Build/bin/phpunit --colors -c phpunit.xml From 58cd080a32b23ab903b4c50e5448f7d7634d14d7 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 20:47:21 +0200 Subject: [PATCH 18/28] [#17] Dont use multiline string --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90d2502..f32e70b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,10 +43,6 @@ jobs: php-version: 7.2 tools: composer:v1 - # Directory permissions for .composer are wrong, so we remove the complete directory - # https://github.com/actions/virtual-environments/issues/824 -# - name: Delete .composer directory -# run: sudo rm -rf ~/.composer - name: Validate composer.json run: composer validate --strict From b49b9074e93be87c9ca44867abb789e8ad265f3e Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 20:55:16 +0200 Subject: [PATCH 19/28] [#17] Run actions for all supported typo3 versions --- .github/workflows/ci.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f32e70b..1f41d2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,24 +14,24 @@ jobs: typo3_version: - 10.4.20 - 10.4.21 -# - 10.4.22 -# - 10.4.23 -# - 10.4.24 -# - 10.4.25 -# - 10.4.26 -# - 10.4.27 -# - 10.4.28 -# - 11.5.0 -# - 11.5.1 -# - 11.5.2 -# - 11.5.3 -# - 11.5.4 -# - 11.5.5 -# - 11.5.6 -# - 11.5.7 -# - 11.5.8 -# - 11.5.9 -# - 11.5.10 + - 10.4.22 + - 10.4.23 + - 10.4.24 + - 10.4.25 + - 10.4.26 + - 10.4.27 + - 10.4.28 + - 11.5.0 + - 11.5.1 + - 11.5.2 + - 11.5.3 + - 11.5.4 + - 11.5.5 + - 11.5.6 + - 11.5.7 + - 11.5.8 + - 11.5.9 + - 11.5.10 # - dev-master steps: From 5c155a9c06cbade162443fca65bc964eaa5872d1 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 21:02:13 +0200 Subject: [PATCH 20/28] [#17] Don't run tests for typo3 v11 --- .github/workflows/ci.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f41d2a..54aa4f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,17 +21,17 @@ jobs: - 10.4.26 - 10.4.27 - 10.4.28 - - 11.5.0 - - 11.5.1 - - 11.5.2 - - 11.5.3 - - 11.5.4 - - 11.5.5 - - 11.5.6 - - 11.5.7 - - 11.5.8 - - 11.5.9 - - 11.5.10 +# - 11.5.0 +# - 11.5.1 +# - 11.5.2 +# - 11.5.3 +# - 11.5.4 +# - 11.5.5 +# - 11.5.6 +# - 11.5.7 +# - 11.5.8 +# - 11.5.9 +# - 11.5.10 # - dev-master steps: @@ -52,8 +52,7 @@ jobs: with: path: .Build/vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}-${{ matrix.typo3_version }} - restore-keys: | - ${{ runner.os }}-php-${{ matrix.typo3_version }}- + restore-keys: ${{ runner.os }}-php-${{ matrix.typo3_version }}- - name: Install dependencies for TYPO3 version "${{ matrix.typo3_version }}" run: composer require typo3/cms-backend:${{ matrix.typo3_version }} typo3/cms-core:${{ matrix.typo3_version }} typo3/cms-extbase:${{ matrix.typo3_version }} typo3/cms-extensionmanager:${{ matrix.typo3_version }} typo3/cms-filelist:${{ matrix.typo3_version }} typo3/cms-fluid:${{ matrix.typo3_version }} typo3/cms-frontend:${{ matrix.typo3_version }} typo3/cms-install:${{ matrix.typo3_version }} typo3/cms-recordlist:${{ matrix.typo3_version }} typo3/cms-lowlevel:${{ matrix.typo3_version }} typo3/cms-about:${{ matrix.typo3_version }} typo3/cms-belog:${{ matrix.typo3_version }} typo3/cms-beuser:${{ matrix.typo3_version }} typo3/cms-felogin:${{ matrix.typo3_version }} typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} typo3/cms-form:${{ matrix.typo3_version }} typo3/cms-impexp:${{ matrix.typo3_version }} typo3/cms-info:${{ matrix.typo3_version }} typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} typo3/cms-setup:${{ matrix.typo3_version }} typo3/cms-seo:${{ matrix.typo3_version }} typo3/cms-sys-note:${{ matrix.typo3_version }} typo3/cms-t3editor:${{ matrix.typo3_version }} typo3/cms-tstemplate:${{ matrix.typo3_version }} typo3/cms-viewpage:${{ matrix.typo3_version }} typo3/cms-adminpanel:${{ matrix.typo3_version }} typo3/cms-redirects:${{ matrix.typo3_version }} typo3/cms-workspaces:${{ matrix.typo3_version }} typo3/cms-reports:${{ matrix.typo3_version }} typo3/cms-scheduler:${{ matrix.typo3_version }} typo3/cms-recycler:${{ matrix.typo3_version }} typo3/cms-opendocs:${{ matrix.typo3_version }} typo3/cms-linkvalidator:${{ matrix.typo3_version }} From 943302885093ba0ec901fb09bbfdca1d2727705d Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 21:04:30 +0200 Subject: [PATCH 21/28] [#17] Remove unnecessary lines --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54aa4f0..56841f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,16 +36,13 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up PHP Version uses: shivammathur/setup-php@v2 with: php-version: 7.2 tools: composer:v1 - - name: Validate composer.json run: composer validate --strict - - name: Cache Composer packages id: composer-cache uses: actions/cache@v3 @@ -53,9 +50,7 @@ jobs: path: .Build/vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}-${{ matrix.typo3_version }} restore-keys: ${{ runner.os }}-php-${{ matrix.typo3_version }}- - - name: Install dependencies for TYPO3 version "${{ matrix.typo3_version }}" run: composer require typo3/cms-backend:${{ matrix.typo3_version }} typo3/cms-core:${{ matrix.typo3_version }} typo3/cms-extbase:${{ matrix.typo3_version }} typo3/cms-extensionmanager:${{ matrix.typo3_version }} typo3/cms-filelist:${{ matrix.typo3_version }} typo3/cms-fluid:${{ matrix.typo3_version }} typo3/cms-frontend:${{ matrix.typo3_version }} typo3/cms-install:${{ matrix.typo3_version }} typo3/cms-recordlist:${{ matrix.typo3_version }} typo3/cms-lowlevel:${{ matrix.typo3_version }} typo3/cms-about:${{ matrix.typo3_version }} typo3/cms-belog:${{ matrix.typo3_version }} typo3/cms-beuser:${{ matrix.typo3_version }} typo3/cms-felogin:${{ matrix.typo3_version }} typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} typo3/cms-form:${{ matrix.typo3_version }} typo3/cms-impexp:${{ matrix.typo3_version }} typo3/cms-info:${{ matrix.typo3_version }} typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} typo3/cms-setup:${{ matrix.typo3_version }} typo3/cms-seo:${{ matrix.typo3_version }} typo3/cms-sys-note:${{ matrix.typo3_version }} typo3/cms-t3editor:${{ matrix.typo3_version }} typo3/cms-tstemplate:${{ matrix.typo3_version }} typo3/cms-viewpage:${{ matrix.typo3_version }} typo3/cms-adminpanel:${{ matrix.typo3_version }} typo3/cms-redirects:${{ matrix.typo3_version }} typo3/cms-workspaces:${{ matrix.typo3_version }} typo3/cms-reports:${{ matrix.typo3_version }} typo3/cms-scheduler:${{ matrix.typo3_version }} typo3/cms-recycler:${{ matrix.typo3_version }} typo3/cms-opendocs:${{ matrix.typo3_version }} typo3/cms-linkvalidator:${{ matrix.typo3_version }} - - name: Unit tests run: .Build/bin/phpunit --colors -c phpunit.xml From 555191811b98e4151a096edb1fb1c5f1fb4c23eb Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 21:45:42 +0200 Subject: [PATCH 22/28] [#17] Optimize CI --- .github/workflows/ci.yml | 45 +++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56841f5..0c855ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,11 +4,22 @@ on: push: branches: [ "master" ] pull_request: - branches: [ "master" ] jobs: + setup: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v3 + - name: Set up PHP Version + uses: shivammathur/setup-php@v2 + with: + php-version: 7.2 + tools: composer:v1 + - name: Validate composer.json + run: composer validate --strict ci: runs-on: ubuntu-18.04 + needs: [ setup ] strategy: matrix: typo3_version: @@ -21,28 +32,20 @@ jobs: - 10.4.26 - 10.4.27 - 10.4.28 -# - 11.5.0 -# - 11.5.1 -# - 11.5.2 -# - 11.5.3 -# - 11.5.4 -# - 11.5.5 -# - 11.5.6 -# - 11.5.7 -# - 11.5.8 -# - 11.5.9 -# - 11.5.10 -# - dev-master + # - 11.5.0 + # - 11.5.1 + # - 11.5.2 + # - 11.5.3 + # - 11.5.4 + # - 11.5.5 + # - 11.5.6 + # - 11.5.7 + # - 11.5.8 + # - 11.5.9 + # - 11.5.10 + # - dev-master steps: - - uses: actions/checkout@v3 - - name: Set up PHP Version - uses: shivammathur/setup-php@v2 - with: - php-version: 7.2 - tools: composer:v1 - - name: Validate composer.json - run: composer validate --strict - name: Cache Composer packages id: composer-cache uses: actions/cache@v3 From bfbb1f6b5b56dcf98927a27efac2d83289c3661e Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 21:47:35 +0200 Subject: [PATCH 23/28] [#17] Fix "needs" --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c855ce..d4c0eea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: pull_request: jobs: - setup: + build: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v3 @@ -17,9 +17,9 @@ jobs: tools: composer:v1 - name: Validate composer.json run: composer validate --strict - ci: + test: runs-on: ubuntu-18.04 - needs: [ setup ] + needs: build strategy: matrix: typo3_version: From a457df2cf38a0d85b7d9ffad0d492fdf4d923505 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 22:07:43 +0200 Subject: [PATCH 24/28] [#17] Try to add composer cache --- .github/workflows/ci.yml | 42 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4c0eea..dc52b33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,18 +6,8 @@ on: pull_request: jobs: - build: - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v3 - - name: Set up PHP Version - uses: shivammathur/setup-php@v2 - with: - php-version: 7.2 - tools: composer:v1 - - name: Validate composer.json - run: composer validate --strict test: + name: 'Run unit tests on TYPO3 version: '${{ matrix.typo3_version }} runs-on: ubuntu-18.04 needs: build strategy: @@ -46,14 +36,34 @@ jobs: # - dev-master steps: - - name: Cache Composer packages + - uses: actions/checkout@v3 + + - name: Set up PHP Version + uses: shivammathur/setup-php@v2 + with: + php-version: 7.2 + tools: composer:v1 + + - name: Validate composer.json + run: composer validate --strict + + - name: Setup problem matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Get composer cache directory id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies uses: actions/cache@v3 with: - path: .Build/vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}-${{ matrix.typo3_version }} - restore-keys: ${{ runner.os }}-php-${{ matrix.typo3_version }}- + path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.typo3_version }} + restore-keys: ${{ runner.os }}-composer- + - name: Install dependencies for TYPO3 version "${{ matrix.typo3_version }}" run: composer require typo3/cms-backend:${{ matrix.typo3_version }} typo3/cms-core:${{ matrix.typo3_version }} typo3/cms-extbase:${{ matrix.typo3_version }} typo3/cms-extensionmanager:${{ matrix.typo3_version }} typo3/cms-filelist:${{ matrix.typo3_version }} typo3/cms-fluid:${{ matrix.typo3_version }} typo3/cms-frontend:${{ matrix.typo3_version }} typo3/cms-install:${{ matrix.typo3_version }} typo3/cms-recordlist:${{ matrix.typo3_version }} typo3/cms-lowlevel:${{ matrix.typo3_version }} typo3/cms-about:${{ matrix.typo3_version }} typo3/cms-belog:${{ matrix.typo3_version }} typo3/cms-beuser:${{ matrix.typo3_version }} typo3/cms-felogin:${{ matrix.typo3_version }} typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} typo3/cms-form:${{ matrix.typo3_version }} typo3/cms-impexp:${{ matrix.typo3_version }} typo3/cms-info:${{ matrix.typo3_version }} typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} typo3/cms-setup:${{ matrix.typo3_version }} typo3/cms-seo:${{ matrix.typo3_version }} typo3/cms-sys-note:${{ matrix.typo3_version }} typo3/cms-t3editor:${{ matrix.typo3_version }} typo3/cms-tstemplate:${{ matrix.typo3_version }} typo3/cms-viewpage:${{ matrix.typo3_version }} typo3/cms-adminpanel:${{ matrix.typo3_version }} typo3/cms-redirects:${{ matrix.typo3_version }} typo3/cms-workspaces:${{ matrix.typo3_version }} typo3/cms-reports:${{ matrix.typo3_version }} typo3/cms-scheduler:${{ matrix.typo3_version }} typo3/cms-recycler:${{ matrix.typo3_version }} typo3/cms-opendocs:${{ matrix.typo3_version }} typo3/cms-linkvalidator:${{ matrix.typo3_version }} + - name: Unit tests - run: .Build/bin/phpunit --colors -c phpunit.xml + run: .Build/bin/phpunit --colors -c phpunit.xml --coverage-text From 3dff1b9f9f6bfcf4ad0be68bd9d1fdf2cde15d53 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 22:08:38 +0200 Subject: [PATCH 25/28] [#17] Remove name from workflow stage --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc52b33..589faab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ on: jobs: test: - name: 'Run unit tests on TYPO3 version: '${{ matrix.typo3_version }} runs-on: ubuntu-18.04 needs: build strategy: From c17dd50c833da08ee2e757ef1a0bfd3a3fef34b5 Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 22:09:22 +0200 Subject: [PATCH 26/28] [#17] Remove not existing stage build --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 589faab..49054c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,8 @@ on: jobs: test: + name: 'Run unit tests on TYPO3 version: '${{ matrix.typo3_version }} runs-on: ubuntu-18.04 - needs: build strategy: matrix: typo3_version: From 8ea9a1e9e923669da7a8badfaec904b139a99d7c Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 22:10:08 +0200 Subject: [PATCH 27/28] [#17] Remove stuff --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49054c3..7186919 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ on: jobs: test: - name: 'Run unit tests on TYPO3 version: '${{ matrix.typo3_version }} runs-on: ubuntu-18.04 strategy: matrix: From 88db0367066cfb68480bd32b1b2a448e6ead1c0a Mon Sep 17 00:00:00 2001 From: Jan Stockfisch Date: Mon, 6 Jun 2022 22:13:43 +0200 Subject: [PATCH 28/28] [#17] Set coverage: xdebug --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7186919..ea9fe6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,11 +36,12 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up PHP Version + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: 7.2 tools: composer:v1 + coverage: xdebug - name: Validate composer.json run: composer validate --strict