diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 408e2f2..d50fd21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: ['8.3'] + php: ['8.4'] steps: - name: Checkout Code diff --git a/.gitignore b/.gitignore index b7c0b54..f523218 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /.editorconfig /.php-cs-fixer.cache -/.phpunit.result.cache +/.phpunit.cache /composer.lock /vendor /vendor-bin/*/composer.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index d2a2c98..006a839 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +4.1.1 +===== + +* (improvement) Don't store build info in cache. +* (improvement) Bump dependencies. +* (improvement) Require PHP 8.4+ + + 4.1.0 ===== diff --git a/composer.json b/composer.json index cd69eff..57ebdd9 100644 --- a/composer.json +++ b/composer.json @@ -11,31 +11,31 @@ ], "homepage": "https://github.com/21TORR/hosting-bundle", "require": { - "php": ">= 8.3", + "php": ">= 8.4", "ext-ctype": "*", "ext-intl": "*", "ext-json": "*", "ext-mbstring": "*", - "21torr/bundle-helpers": "^2.2", - "21torr/cli": "^1.2.3", + "21torr/bundle-helpers": "^2.3.1", + "21torr/cli": "^1.2.4", "psr/log": "^3.0", - "symfony/cache": "^7.1", - "symfony/cache-contracts": "^3.5", - "symfony/clock": "^7.1", - "symfony/config": "^7.1", - "symfony/console": "^7.1", - "symfony/dependency-injection": "^7.1", - "symfony/event-dispatcher-contracts": "^3.5", - "symfony/filesystem": "^7.1", - "symfony/framework-bundle": "^7.1", - "symfony/process": "^7.1" + "symfony/cache": "^7.4 || ^8.0", + "symfony/cache-contracts": "^3.6", + "symfony/clock": "^7.4 || ^8.0", + "symfony/config": "^7.4 || ^8.0", + "symfony/console": "^7.4 || ^8.0", + "symfony/dependency-injection": "^7.4 || ^8.0", + "symfony/event-dispatcher-contracts": "^3.6", + "symfony/filesystem": "^7.4 || ^8.0", + "symfony/framework-bundle": "^7.4 || ^8.0", + "symfony/process": "^7.4 || ^8.0" }, "require-dev": { - "21torr/janus": "^1.4", - "bamarni/composer-bin-plugin": "^1.8", - "doctrine/orm": "^3.0", - "roave/security-advisories": "dev-latest", - "symfony/phpunit-bridge": "^7.1" + "21torr/janus": "^2.0.2", + "bamarni/composer-bin-plugin": "^1.8.2", + "doctrine/orm": "^3.6", + "phpunit/phpunit": "^12.5", + "roave/security-advisories": "dev-latest" }, "replace": { "symfony/polyfill-ctype": "*", @@ -54,7 +54,8 @@ "symfony/polyfill-php80": "*", "symfony/polyfill-php81": "*", "symfony/polyfill-php82": "*", - "symfony/polyfill-php83": "*" + "symfony/polyfill-php83": "*", + "symfony/polyfill-php84": "*" }, "suggest": { "doctrine/orm": "For automatic integration of health checks" @@ -71,6 +72,7 @@ }, "config": { "allow-plugins": { + "21torr/janus": true, "bamarni/composer-bin-plugin": true }, "sort-packages": true @@ -88,15 +90,15 @@ "scripts": { "fix-lint": [ "@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --ansi", - "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi" + "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --allow-unsupported-php-version=yes --no-interaction --ansi" ], "lint": [ "@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --dry-run --ansi", - "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi" + "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --allow-unsupported-php-version=yes --no-interaction --ansi" ], "test": [ - "simple-phpunit", + "phpunit", "vendor-bin/phpstan/vendor/bin/phpstan analyze -c phpstan.neon . --ansi -v" ] } -} +} \ No newline at end of file diff --git a/phpstan.neon b/phpstan.neon index 7b95bf7..fd17d4b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,5 +2,18 @@ includes: - vendor/21torr/janus/phpstan/lib.neon parameters: - bootstrapFiles: - - vendor/bin/.phpunit/phpunit/vendor/autoload.php + +# If you use simple-phpunit, you need to uncomment the following line. +# Always make sure to first run simple-phpunit and then PHPStan. +# bootstrapFiles: +# - vendor/bin/.phpunit/phpunit/vendor/autoload.php + +# These are temporarily copied here, as normally they should be in the lib.neon of janus. +# However, due to a bug in PHPStan, this currently doesn't work (https://github.com/phpstan/phpstan/issues/12844) + excludePaths: + analyse: + - vendor + analyseAndScan: + - node_modules (?) + - var (?) + - vendor-bin diff --git a/phpunit.xml b/phpunit.xml index d9842ec..63270d1 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,25 +1,21 @@ - - - - - - - - - - - tests - tests/fixtures - - - - - - + + + + + + + + + + tests + tests/fixtures + + diff --git a/src/BuildInfo/BuildInfoStorage.php b/src/BuildInfo/BuildInfoStorage.php index a8c5912..9d55877 100644 --- a/src/BuildInfo/BuildInfoStorage.php +++ b/src/BuildInfo/BuildInfoStorage.php @@ -3,21 +3,19 @@ namespace Torr\Hosting\BuildInfo; use Symfony\Component\Filesystem\Filesystem; -use Symfony\Contracts\Cache\CacheInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Torr\Hosting\Event\CollectBuildInfoEvent; use Torr\Hosting\Exception\InvalidBuildInfoException; final class BuildInfoStorage { - private const CACHE_KEY = "hosting.build-info"; + private ?BuildInfo $cache = null; /** */ public function __construct ( private readonly EventDispatcherInterface $dispatcher, private readonly Filesystem $filesystem, - private readonly CacheInterface $cache, private readonly string $filePath, ) {} @@ -25,10 +23,7 @@ public function __construct ( */ public function getBuildInfo () : BuildInfo { - return $this->cache->get( - self::CACHE_KEY, - $this->loadBuildInfo(...), - ); + return $this->cache ??= $this->loadBuildInfo(); } /** @@ -60,6 +55,7 @@ private function loadBuildInfo () : BuildInfo // sort info before passing it to build info uksort($data, "strnatcasecmp"); + /** @var array $data */ return new BuildInfo($data); } catch (\JsonException $exception) @@ -78,7 +74,7 @@ public function refresh () : void { // remove existing file $this->filesystem->remove($this->filePath); - $this->cache->delete(self::CACHE_KEY); + $this->cache = null; // refetch build info $event = new CollectBuildInfoEvent(); diff --git a/src/Deployment/Task/ResetBuildInfoTask.php b/src/Deployment/Task/ResetBuildInfoTask.php index 0ea5ab1..076e115 100644 --- a/src/Deployment/Task/ResetBuildInfoTask.php +++ b/src/Deployment/Task/ResetBuildInfoTask.php @@ -7,7 +7,7 @@ use Torr\Hosting\Deployment\TaskCli; /** - * Refreshes the build info. Should run as first task. + * Refreshes the build info. Should run as the first task. */ final readonly class ResetBuildInfoTask implements BuildHookInterface { @@ -29,6 +29,6 @@ public function getLabel () : string public function runPostBuild (TaskCli $io) : void { $this->buildInfo->refresh(); - $io->done("Build info reset"); + $io->done("build info stored"); } } diff --git a/src/Deployment/TaskCli.php b/src/Deployment/TaskCli.php index 33ffdc1..75d0ea0 100644 --- a/src/Deployment/TaskCli.php +++ b/src/Deployment/TaskCli.php @@ -6,14 +6,4 @@ final class TaskCli extends TorrStyle { - /** - * - */ - public function done (string $message) : void - { - $this->write(\sprintf( - "✓ %s", - $message, - )); - } } diff --git a/src/Listener/ValidateAppListener.php b/src/Listener/ValidateAppListener.php index bf7852f..43f60de 100644 --- a/src/Listener/ValidateAppListener.php +++ b/src/Listener/ValidateAppListener.php @@ -20,8 +20,7 @@ public function __construct ( public function onValidateApp (ValidateAppEvent $event) : void { // Technically this can't happen, as we can't set anything besides the - // correct type as tier. However we want to force parsing of the hosting tier, - // so that we catch invalid tiers. + // correct type as tier. However, we want to force parsing of the hosting tier so that we catch invalid tier values. // @phpstan-ignore-next-line instanceof.alwaysTrue (this is a dummy check, please read above for the explanation) if (!$this->environment->getTier() instanceof HostingTier) { diff --git a/tests/BuildInfo/BuildInfoTest.php b/tests/BuildInfo/BuildInfoTest.php index 8554782..d170066 100644 --- a/tests/BuildInfo/BuildInfoTest.php +++ b/tests/BuildInfo/BuildInfoTest.php @@ -2,6 +2,7 @@ namespace Tests\Torr\Hosting\BuildInfo; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Clock\MockClock; use Symfony\Component\EventDispatcher\EventDispatcher; @@ -31,8 +32,8 @@ public static function provideBuildInfoGitIntegration () : iterable } /** - * @dataProvider provideBuildInfoGitIntegration */ + #[DataProvider("provideBuildInfoGitIntegration")] public function testBuildInfoGitIntegration (?array $data, array $expected) : void { $versionFetcher = $this->createMock(GitVersionFetcher::class); diff --git a/tests/Hosting/HostingEnvironmentTest.php b/tests/Hosting/HostingEnvironmentTest.php index 2cf692c..d7be673 100644 --- a/tests/Hosting/HostingEnvironmentTest.php +++ b/tests/Hosting/HostingEnvironmentTest.php @@ -2,6 +2,7 @@ namespace Tests\Torr\Hosting\Hosting; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Torr\Hosting\Hosting\HostingEnvironment; use Torr\Hosting\Tier\HostingTier; @@ -45,8 +46,8 @@ public static function provideHostingTiers () : iterable } /** - * @dataProvider provideHostingTiers */ + #[DataProvider("provideHostingTiers")] public function testHostingTiers (string|HostingTier $value, HostingTier $expected) : void { $environment = new HostingEnvironment($value, false, "installation"); diff --git a/vendor-bin/c-norm/composer.json b/vendor-bin/c-norm/composer.json index 29d96fe..43031c1 100644 --- a/vendor-bin/c-norm/composer.json +++ b/vendor-bin/c-norm/composer.json @@ -1,6 +1,6 @@ { "require-dev": { - "ergebnis/composer-normalize": "^2.42", + "ergebnis/composer-normalize": "^2.47", "roave/security-advisories": "dev-latest" }, "config": { diff --git a/vendor-bin/cs-fixer/composer.json b/vendor-bin/cs-fixer/composer.json index ceadfce..42e20ab 100644 --- a/vendor-bin/cs-fixer/composer.json +++ b/vendor-bin/cs-fixer/composer.json @@ -1,6 +1,6 @@ { "require-dev": { - "21torr/php-cs-fixer": "^1.1.1", + "21torr/php-cs-fixer": "^1.1.5", "roave/security-advisories": "dev-latest" } } diff --git a/vendor-bin/phpstan/composer.json b/vendor-bin/phpstan/composer.json index cf165ff..4eb9387 100644 --- a/vendor-bin/phpstan/composer.json +++ b/vendor-bin/phpstan/composer.json @@ -3,14 +3,14 @@ "php": "^8.3" }, "require-dev": { - "phpstan/extension-installer": "^1.3.1", - "phpstan/phpstan": "^1.11", - "phpstan/phpstan-deprecation-rules": "^1.2", - "phpstan/phpstan-doctrine": "^1.4", - "phpstan/phpstan-phpunit": "^1.4", - "phpstan/phpstan-symfony": "^1.4", + "phpstan/extension-installer": "^1.4.2", + "phpstan/phpstan": "^2.1.11", + "phpstan/phpstan-deprecation-rules": "^2.0.1", + "phpstan/phpstan-doctrine": "^2.0.2", + "phpstan/phpstan-phpunit": "^2.0.6", + "phpstan/phpstan-symfony": "^2.0.4", "roave/security-advisories": "dev-latest", - "staabm/phpstan-todo-by": "^0.1.25" + "staabm/phpstan-todo-by": "^0.2" }, "config": { "sort-packages": true,