Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use matrix generator #307

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
31 changes: 29 additions & 2 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,35 @@ jobs:
cs:
if: github.event_name != 'schedule'
uses: shopware/github-actions/.github/workflows/cs-fixer.yml@main
get-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get Shopware Version
id: shopware-constraint
run: echo "shopware_constraint=$(cat composer.json | jq -r '.require."shopware/core"')" >> $GITHUB_OUTPUT

- name: Get Shopware Matrix
uses: tinect/github-shopware-matrix-generator@main
id: matrix
with:
versionConstraint: ${{ steps.shopware-constraint.outputs.shopware_constraint }}
allowEol: false
justMinMaxShopware: true
allowShopwareNext: true
allowShopwareRC: true
includePhpVersion: false
phpstan:
name: PHPStan
needs: get-matrix
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.get-matrix.outputs.matrix) }}
uses: shopware/github-actions/.github/workflows/phpstan.yml@main
with:
extensionName: FroshTools
shopwareVersion: v6.6.0.0-rc1
extensionName: FroshTools
shopwareVersion: ${{ matrix.shopware }}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"require": {
"shopware/core": "~6.6.0"
},
"minimum-stability": "RC",
"config": {
"allow-plugins": {
"symfony/runtime": true
Expand Down
18 changes: 14 additions & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ parameters:
level: 8
paths:
- src
type_coverage:
return_type: 100
param_type: 98
property_type: 100

ignoreErrors:
-
message: "#^Out of .* possible param types, only .* %% actually have it\\. Add more param types to get over .* %%$#"
reportUnmatched: false

-
message: """
#^Fetching class constant class of deprecated class Shopware\\\\Core\\\\Framework\\\\Adapter\\\\Cache\\\\CacheDecorator\\:
tag\\:v6\\.7\\.0 \\- reason\\:decoration\\-will\\-be\\-removed \\- Will be removed$#
"""
reportUnmatched: false
count: 1
path: src/Components/CacheAdapter.php
1 change: 1 addition & 0 deletions src/Components/CacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function getType(): string

private function getCacheAdapter(AdapterInterface $adapter): AdapterInterface
{
// will be removed in Shopware 6.7
if ($adapter instanceof CacheDecorator) {
// Do not declare function as static
$func = \Closure::bind(fn() => $adapter->decorated, $adapter, $adapter::class);
Expand Down
5 changes: 3 additions & 2 deletions src/Components/Health/Checker/HealthChecker/MysqlChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ private function checkMysqlVersion(HealthCollection $collection, string $version
private function extract(string $versionString): array
{
if (mb_stripos($versionString, 'mariadb') === false) {
if (mb_strpos($versionString, '-')) {
$versionString = mb_substr($versionString, 0, mb_strpos($versionString, '-'));
$versionMetaPos = mb_strpos($versionString, '-');
if ($versionMetaPos) {
$versionString = mb_substr($versionString, 0, $versionMetaPos);
}

return ['mysql' => $versionString];
Expand Down
54 changes: 39 additions & 15 deletions src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Frosh\Tools\Components\Health\Checker\CheckerInterface;
use Frosh\Tools\Components\Health\HealthCollection;
use Frosh\Tools\Components\Health\SettingsResult;
use Shopware\Core\Maintenance\System\Struct\DatabaseConnectionInformation;
use Shopware\Core\DevOps\Environment\EnvironmentHelper;
use Symfony\Component\DependencyInjection\Attribute\Autowire;

class SystemInfoChecker implements HealthCheckerInterface, CheckerInterface
Expand Down Expand Up @@ -36,20 +36,44 @@ private function checkPath(HealthCollection $collection): void

private function getDatabaseInfo(HealthCollection $collection): void
{
$databaseConnectionInfo = (new DatabaseConnectionInformation())->fromEnv();
$result = new SettingsResult();
$result->assign([
'id' => 'database-info',
'snippet' => 'Database',
'current' => 'unknown',
]);

$collection->add(
SettingsResult::ok(
'database-info',
'Database',
\sprintf(
'%s@%s:%d/%s',
$databaseConnectionInfo->getUsername(),
$databaseConnectionInfo->getHostname(),
$databaseConnectionInfo->getPort(),
$databaseConnectionInfo->getDatabaseName(),
),
),
);
try {
$dsn = trim((string) EnvironmentHelper::getVariable('DATABASE_URL', getenv('DATABASE_URL')));
if ($dsn === '') {
return;
}

$params = parse_url($dsn);
if ($params === false) {
return;
}

foreach ($params as $param => $value) {
if (!\is_string($value)) {
continue;
}

$params[$param] = rawurldecode($value);
}

$path = (string) ($params['path'] ?? '/');
$dbName = trim(substr($path, 1));

$result->current = \sprintf(
'%s@%s:%d/%s',
$params['user'] ?? null,
$params['host'] ?? null,
(int) ($params['port'] ?? '3306'),
$dbName,
);
} finally {
$collection->add($result);
}
}
}
2 changes: 1 addition & 1 deletion src/Components/LineReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private static function readBackwards($fh, int $pos): \Generator
$pos -= $bufferSize;
}
fseek($fh, $pos);
if ($bufferSize < 0) {
if ($bufferSize < 1) {
throw new \RuntimeException('Buffer size cannot be negative');
}
$chunk = fread($fh, $bufferSize);
Expand Down
Loading