Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
php: ['8.3']
php: ['8.4']

steps:
- name: Checkout Code
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/.editorconfig
/.php-cs-fixer.cache
/.phpunit.result.cache
/.phpunit.cache
/composer.lock
/vendor
/vendor-bin/*/composer.lock
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
=====

Expand Down
48 changes: 25 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand All @@ -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"
Expand All @@ -71,6 +72,7 @@
},
"config": {
"allow-plugins": {
"21torr/janus": true,
"bamarni/composer-bin-plugin": true
},
"sort-packages": true
Expand All @@ -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"
]
}
}
}
17 changes: 15 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 17 additions & 21 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0"/>
<env name="SYMFONY_PHPUNIT_VERSION" value="9.6"/>
</php>

<testsuites>
<testsuite name="Bundle tests">
<directory>tests</directory>
<exclude>tests/fixtures</exclude>
</testsuite>
</testsuites>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0" />
<env name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
</php>
<testsuites>
<testsuite name="Bundle tests">
<directory>tests</directory>
<exclude>tests/fixtures</exclude>
</testsuite>
</testsuites>
</phpunit>
12 changes: 4 additions & 8 deletions src/BuildInfo/BuildInfoStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,27 @@
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,
) {}

/**
*/
public function getBuildInfo () : BuildInfo
{
return $this->cache->get(
self::CACHE_KEY,
$this->loadBuildInfo(...),
);
return $this->cache ??= $this->loadBuildInfo();
}

/**
Expand Down Expand Up @@ -60,6 +55,7 @@ private function loadBuildInfo () : BuildInfo
// sort info before passing it to build info
uksort($data, "strnatcasecmp");

/** @var array<array-key, string|float|int|bool|null> $data */
return new BuildInfo($data);
}
catch (\JsonException $exception)
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/Deployment/Task/ResetBuildInfoTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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");
}
}
10 changes: 0 additions & 10 deletions src/Deployment/TaskCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,4 @@

final class TaskCli extends TorrStyle
{
/**
*
*/
public function done (string $message) : void
{
$this->write(\sprintf(
"<fg=green>✓</> %s",
$message,
));
}
}
3 changes: 1 addition & 2 deletions src/Listener/ValidateAppListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion tests/BuildInfo/BuildInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tests/Hosting/HostingEnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion vendor-bin/c-norm/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require-dev": {
"ergebnis/composer-normalize": "^2.42",
"ergebnis/composer-normalize": "^2.47",
"roave/security-advisories": "dev-latest"
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion vendor-bin/cs-fixer/composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
14 changes: 7 additions & 7 deletions vendor-bin/phpstan/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down