Skip to content

Commit

Permalink
Merge pull request #63 from spryker-sdk/bugfix/frw-7467/fatal-during-…
Browse files Browse the repository at this point in the history
…read-yaml-file

FRW-7467: Adjusted composer. Fixed yaml reader for wrong files
  • Loading branch information
vol4onok authored Mar 11, 2024
2 parents ac65775 + 7b6009a commit 7dea7c0
Show file tree
Hide file tree
Showing 12 changed files with 243 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/trigger-remote-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
TARGET_REPO: sdk
SOURCE_PACKAGE_NAME: 'spryker-sdk/evaluator'
PR_LABELS: 'composer dependencies'
PR_ASSIGNEES: pavelmaksimov25,DmytroKlymanSpryker
PR_ASSIGNEES: vol4onok,asmarovydlo

on:
release:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"ext-json": "*",
"composer/semver": "^3.3",
"guzzlehttp/guzzle": "^7.5",
"nikic/php-parser": "^4.0.0",
"nikic/php-parser": "^4.0",
"spryker-sdk/security-checker": "^0.2.0",
"spryker-sdk/utils": "^0.2.1",
"symfony/console": "^6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function check(CheckerInputDataDto $inputData): CheckerResponseDto

$devSprykerPackages = array_filter(
$sprykerPackages,
static fn (string $constraint): bool => strpos($constraint, static::DEV_PACKAGE_PREFIX) === 0
static fn (string $constraint): bool => strpos($constraint, static::DEV_PACKAGE_PREFIX) === 0,
);

return new CheckerResponseDto($this->createViolations($devSprykerPackages), $this->checkerDocUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function compareByMask(array $allowedPhpVersions, array $composerData)
{
return array_filter(
$allowedPhpVersions,
static fn (string $allowedVersion): bool => Semver::satisfies($allowedVersion . static::MAX_MINOR_VERSION_SUFFIX, $composerData['require']['php'])
static fn (string $allowedVersion): bool => Semver::satisfies($allowedVersion . static::MAX_MINOR_VERSION_SUFFIX, $composerData['require']['php']),
);
}

Expand All @@ -109,7 +109,7 @@ protected function compareByExactPhpVersion(array $allowedPhpVersions, array $co
{
return array_filter(
$allowedPhpVersions,
static fn (string $allowedVersion): bool => strpos($composerData['require']['php'], $allowedVersion) === 0
static fn (string $allowedVersion): bool => strpos($composerData['require']['php'], $allowedVersion) === 0,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function check(array $allowedPhpVersions, string $path): CheckerStrategyR
$phpVersion = $this->currentPhpVersion;
$validVersions = array_filter(
$allowedPhpVersions,
static fn (string $allowedVersion): bool => strpos($phpVersion, $allowedVersion) === 0 && version_compare($phpVersion, $allowedVersion, '>=')
static fn (string $allowedVersion): bool => strpos($phpVersion, $allowedVersion) === 0 && version_compare($phpVersion, $allowedVersion, '>='),
);

$violations = count($validVersions) === 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function checkDeployFile(string $fileName, array $deployStructure, arr
static fn (string $version): bool => (bool)preg_match(
sprintf('/[^\d.]%s/', str_replace('.', '\.', $version)),
$imageTag,
)
),
);

if (count($validVersions) === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use FilesystemIterator;
use GlobIterator;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;

class DeploymentYamlFileReader
Expand All @@ -26,7 +27,13 @@ public function read(string $globPattern): iterable

/** @var string $filePath */
foreach ($fileIterator as $filePath) {
yield $filePath => Yaml::parseFile($filePath);
try {
$content = Yaml::parseFile($filePath);
} catch (ParseException $e) {
continue;
}

yield $filePath => $content;
}
}
}
4 changes: 2 additions & 2 deletions src/Fetcher/CheckerFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function filterAllowedCheckers(EvaluatorInputDataDto $inputData, array

return array_filter(
$checkers,
static fn (CheckerInterface $checker): bool => in_array($checker->getName(), $inputData->getCheckerNames(), true)
static fn (CheckerInterface $checker): bool => in_array($checker->getName(), $inputData->getCheckerNames(), true),
);
}

Expand All @@ -68,7 +68,7 @@ protected function filterExcludedCheckers(EvaluatorInputDataDto $inputData, arra
{
return array_filter(
$checkers,
static fn (CheckerInterface $checker): bool => !in_array($checker->getName(), $inputData->getExcludedCheckerNames(), true)
static fn (CheckerInterface $checker): bool => !in_array($checker->getName(), $inputData->getExcludedCheckerNames(), true),
);
}
}
2 changes: 1 addition & 1 deletion src/Parser/PhpParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PhpParser implements PhpParserInterface
*/
public function __construct(ParserFactory $parserFactory)
{
$this->parser = $parserFactory->create(ParserFactory::PREFER_PHP7);
$this->parser = $parserFactory->createForNewestSupportedVersion();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getSecurityFixes(): self
return new self(
array_filter(
$this->elements,
fn (UpgradeInstructionsReleaseGroup $releaseGroup): bool => $releaseGroup->isSecurity()
fn (UpgradeInstructionsReleaseGroup $releaseGroup): bool => $releaseGroup->isSecurity(),
),
);
}
Expand All @@ -109,7 +109,7 @@ public function getNonSecurityFixes(): self
return new self(
array_filter(
$this->elements,
fn (UpgradeInstructionsReleaseGroup $releaseGroup): bool => !$releaseGroup->isSecurity()
fn (UpgradeInstructionsReleaseGroup $releaseGroup): bool => !$releaseGroup->isSecurity(),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function getSecurityFixes(): self
return new self(
array_filter(
$this->elements,
fn (ReleaseGroupDto $releaseGroup): bool => $releaseGroup->isSecurity()
fn (ReleaseGroupDto $releaseGroup): bool => $releaseGroup->isSecurity(),
),
);
}
Expand Down
222 changes: 222 additions & 0 deletions tests/Acceptance/_data/ValidProject/deploy.wrong.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
version: "0.1"

namespace: spryker_b2c
tag: '1.0'

environment: docker.production
image:
tag: spryker/php:6.2-alpine3.12
php:
ini:
"opcache.revalidate_freq": 0
"opcache.validate_timestamps": 0

composer:
mode: --no-dev
autoload: --classmap-authoritative
composer:
mode: --no-dev
autoload: --classmap-authoritative

assets:
mode: production
compression:
gzip:
static: true
level: 5

regions:
EU:
services:
database:
database: eu-docker
username: spryker
password: secret

stores:
DE:
services:
broker:
namespace: de-docker
key_value_store:
namespace: 1
search:
namespace: de_search
AT:
services:
broker:
namespace: at-docker
key_value_store:
namespace: 2
search:
namespace: at_search
US:
services:
database:
database: us-docker
username: spryker
password: secret
stores:
US:
services:
broker:
namespace: us-docker
key_value_store:
namespace: 3
search:
namespace: us_search
groups:
EU:
region: EU
applications:
yves_eu:
application: yves
endpoints:
yves.de.spryker.local:
store: DE
services:
session:
namespace: 1
yves.at.spryker.local:
store: AT
services:
session:
namespace: 2
glue_eu:
application: glue
endpoints:
glue.de.spryker.local:
store: DE
glue.at.spryker.local:
store: AT
backoffice_eu:
application: backoffice
endpoints:
backoffice.de.spryker.local:
store: DE
services:
session:
namespace: 3
backoffice.at.spryker.local:
store: AT
services:
session:
namespace: 4
backend_gateway_eu:
application: backend-gateway
endpoints:
backend-gateway.de.spryker.local:
store: DE
primal: true
backend-gateway.at.spryker.local:
store: AT
primal: true
backend_api_eu:
application: zed
endpoints:
backend-api.de.spryker.local:
store: DE
entry-point: BackendApi
backend-api.at.spryker.local:
store: AT
entry-point: BackendApi
US:
region: US
applications:
yves_us:
application: yves
endpoints:
yves.us.spryker.local:
store: US
services:
session:
namespace: 5
glue_us:
application: glue
endpoints:
glue.us.spryker.local:
store: US
backoffice_us:
application: backoffice
endpoints:
backoffice.us.spryker.local:
store: US
services:
session:
namespace: 6
backend_gateway_us:
application: backend-gateway
endpoints:
backend-gateway.us.spryker.local:
store: US
backend_api_us:
application: zed
endpoints:
backend-api.us.spryker.local:
store: US
entry-point: BackendApi
services:
database:
engine: mysql
version: mariadb-10.4
root:
username: "root"
password: "secret"
endpoints:
localhost:3306:
protocol: tcp
broker:
engine: rabbitmq
api:
username: "spryker"
password: "secret"
endpoints:
queue.spryker.local:
localhost:5672:
protocol: tcp
session:
engine: redis
key_value_store:
engine: redis
endpoints:
localhost:16379:
protocol: tcp
search:
engine: elastic
version: 7.6
endpoints:
localhost:9200:
protocol: tcp
scheduler:
engine: jenkins
endpoints:
scheduler.spryker.local:
mail_catcher:
engine: mailhog
endpoints:
mail.spryker.local:
swagger:
engine: swagger-ui
endpoints:
swagger.spryker.local:
dashboard:
engine: dashboard
endpoints:
spryker.local:

docker:

ssl:
enabled: false
redirect: true

debug:
enabled: false
xdebug:
enabled: false

testing:
store: DE

mount:
baked:

0 comments on commit 7dea7c0

Please sign in to comment.