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

Feature/op 358 update build #93

Merged
merged 4 commits into from
Aug 8, 2024
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
42 changes: 14 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ on:
release:
types: [created]
schedule:
-
cron: "0 1 * * 6" # Run at 1am every Saturday
- cron: "0 1 * * 6" # Run at 1am every Saturday
workflow_dispatch: ~

jobs:
Expand All @@ -23,14 +22,16 @@ jobs:
matrix:
php: [ "8.0", "8.1", "8.2", "8.3" ]
symfony: [ "^5.4", "^6.4" ]
sylius: [ "~1.12.0", "~1.13.0" ]
node: [ "^18.0", "^20.0" ]
sylius: [ "^1.12", "^1.13" ]
node: [ "18.x", "20.x" ]
mysql: [ "8.0" ]

exclude:
- sylius: "~1.13.0"
php: "8.0"
- symfony: "^6.4"
php: "8.0"
- sylius: ^1.13
php: 8.0
- sylius: ^1.12
php: 8.0
symfony: ^6.4

env:
APP_ENV: test
Expand Down Expand Up @@ -95,38 +96,37 @@ jobs:
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-

-
name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer config extra.symfony.require "${{ matrix.symfony }}"

-
name: Restrcting Sylius version
name: Restrict Sylius version
if: matrix.sylius != ''
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction

-
name: Install PHP dependencies
run: composer install --no-interaction
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}

-
name: Get Yarn cache directory
id: yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
run: echo "::set-output name=dir::$(yarn cache dir)"

-
name: Cache Yarn
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-yarn-

-
name: Install JS dependencies
run: (cd tests/Application && yarn install)
Expand All @@ -136,13 +136,11 @@ jobs:
run: |
(cd tests/Application && bin/console doctrine:database:create -vvv)
(cd tests/Application && bin/console doctrine:schema:create -vvv)

-
name: Prepare test application assets
run: |
(cd tests/Application && bin/console assets:install public -vvv)
(cd tests/Application && yarn encore dev)

-
name: Prepare test application cache
run: (cd tests/Application && bin/console cache:warmup -vvv)
Expand All @@ -159,18 +157,6 @@ jobs:
name: Validate database schema
run: (cd tests/Application && bin/console doctrine:schema:validate)

-
name: Run PHPStan
run: vendor/bin/phpstan analyse -c phpstan.neon -l 6 src/

-
name: Run ECS
run: vendor/bin/ecs check src

-
name: Run Psalm
run: vendor/bin/psalm

-
name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/coding_standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Coding standard

on:
push:
branches-ignore:
- 'dependabot/**'
pull_request: ~
release:
types: [ created ]
workflow_dispatch: ~

jobs:
tests:
runs-on: ubuntu-latest

name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"

strategy:
fail-fast: false
matrix:
php: [ "8.0", "8.1", "8.2", "8.3" ]
symfony: [ "^5.4", "^6.4" ]
sylius: [ "^1.12", "^1.13" ]
node: [ "18.x", "20.x" ]

exclude:
- sylius: ^1.13
php: 8.0
- sylius: ^1.12
php: 8.0
symfony: ^6.4

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
extensions: intl
tools: symfony
coverage: none

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-

- name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer config extra.symfony.require "${{ matrix.symfony }}"

- name: Restrict Sylius version
if: matrix.sylius != ''
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction

- name: Install PHP dependencies
run: composer install --no-interaction
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}

- name: Run PHPStan
run: vendor/bin/phpstan analyse -c phpstan.neon -l 8 src/

- name: Run ECS
run: vendor/bin/ecs check src

- name: Failed build Slack notification
uses: rtCamp/action-slack-notify@v2
if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
env:
SLACK_CHANNEL: ${{ secrets.FAILED_BUILD_SLACK_CHANNEL }}
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_MESSAGE: ':x:'
SLACK_TITLE: Failed build on ${{ github.event.repository.name }} repository
SLACK_USERNAME: ${{ secrets.FAILED_BUILD_SLACK_USERNAME }}
SLACK_WEBHOOK: ${{ secrets.FAILED_BUILD_SLACK_WEBHOOK }}
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"symplify/easy-coding-standard": "^10.0 || ^11.0",
"vimeo/psalm": "~4.12 || ^5.0.0",
"psalm/plugin-symfony": "~4.0 || ~5.0"
"symplify/easy-coding-standard": "^10.0 || ^11.0"
},
"config": {
"sort-packages": true,
Expand Down
24 changes: 0 additions & 24 deletions psalm.xml

This file was deleted.

4 changes: 0 additions & 4 deletions src/Bus/Handler/GetTokenHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ private function getUser(): ?UserInterface
return $user instanceof UserInterface ? $user : null;
}

/**
* @psalm-suppress MixedReturnStatement
* @psalm-suppress MixedInferredReturnType
*/
public function __invoke(GetToken $getTokenQuery): ?AdyenTokenInterface
{
if (null === $this->getUser()) {
Expand Down
8 changes: 0 additions & 8 deletions src/Bus/Handler/PaymentStatusReceivedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,9 @@ private function updateOrderState(OrderInterface $order): void

// This is necessary because in Sylius 1.11 namespace of SendOrderConfirmation has been changed
if (null !== $token) {
/**
* @psalm-suppress MixedArgument
* @psalm-suppress UndefinedClass
*/
if (class_exists('\Sylius\Bundle\ApiBundle\Command\SendOrderConfirmation')) {
$this->commandBus->dispatch(new \Sylius\Bundle\ApiBundle\Command\SendOrderConfirmation($token));
} elseif (class_exists('\Sylius\Bundle\ApiBundle\Command\Checkout\SendOrderConfirmation')) {
/**
* @psalm-suppress MixedArgument
* @psalm-suppress UndefinedClass
*/
$this->commandBus->dispatch(new \Sylius\Bundle\ApiBundle\Command\Checkout\SendOrderConfirmation($token));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Controller/Shop/AdyenDetailsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function __construct(

public function __invoke(Request $request, string $code): Response
{
/** @var string|null $referenceId */
$referenceId = $request->query->get(self::REFERENCE_ID_KEY);

if (null === $referenceId) {
Expand Down
3 changes: 0 additions & 3 deletions src/Controller/Shop/PaymentsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ private function prepareTargetUrl(OrderInterface $order): string

private function prepareOrder(Request $request, OrderInterface $order): void
{
/**
* @psalm-suppress InternalMethod
*/
if (null === $request->get('tokenValue')) {
$request->getSession()->set(self::ORDER_ID_KEY, $order->getId());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Shop/ProcessNotificationsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(
public function __invoke(string $code, Request $request): Response
{
foreach ($this->notificationResolver->resolve($code, $request) as $notificationItem) {
if (!$notificationItem->success) {
if (null === $notificationItem || false === $notificationItem->success) {
$this->logger->error(\sprintf(
'Payment with pspReference [%s] did not return success',
$notificationItem->pspReference ?? '',
Expand Down
1 change: 0 additions & 1 deletion src/Entity/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace BitBag\SyliusAdyenPlugin\Entity;

/** @psalm-suppress MissingConstructor */
class Log implements LogInterface
{
/** @var int */
Expand Down
1 change: 0 additions & 1 deletion src/Form/Type/CredentialType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function buildView(
return;
}

/** @psalm-suppress InvalidPropertyAssignmentValue */
$view->vars['value'] = self::CREDENTIAL_PLACEHOLDER;
}

Expand Down
1 change: 0 additions & 1 deletion src/Grid/Filter/LoggerLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function apply(
$data,
array $options,
): void {
/** @psalm-suppress MixedArrayAccess */
$dataSource->restrict($dataSource->getExpressionBuilder()->equals('level', $data['loggerLevel']));
}
}
4 changes: 2 additions & 2 deletions src/Processor/PaymentResponseProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ final class PaymentResponseProcessor implements PaymentResponseProcessorInterfac
{
private const DEFAULT_REDIRECT_ROUTE = 'sylius_shop_order_thank_you';

/** @var ProcessorInterface[] */
/** @var iterable<ProcessorInterface> */
private $processors;

/** @var UrlGeneratorInterface */
private $urlGenerator;

/**
* @param ProcessorInterface[] $processors
* @param iterable<ProcessorInterface> $processors
*/
public function __construct(
iterable $processors,
Expand Down
7 changes: 0 additions & 7 deletions src/Repository/AdyenReferenceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,12 @@ private function getQueryBuilderForCodeAndReference(string $code, string $pspRef
return $qb;
}

/**
* @psalm-suppress MixedReturnStatement
* @psalm-suppress MixedInferredReturnType
*/
public function getOneByCodeAndReference(string $code, string $pspReference): AdyenReferenceInterface
{
return $this->getQueryBuilderForCodeAndReference($code, $pspReference)->getQuery()->getSingleResult();
}

/**
* @psalm-suppress MixedReturnStatement
* @psalm-suppress MixedInferredReturnType
*
* @throws NoResultException
*/
public function getOneForRefundByCodeAndReference(string $code, string $pspReference): AdyenReferenceInterface
Expand Down
10 changes: 3 additions & 7 deletions src/Repository/AdyenTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,15 @@

final class AdyenTokenRepository extends EntityRepository implements AdyenTokenRepositoryInterface
{
/**
* @psalm-suppress MixedReturnStatement
* @psalm-suppress MixedInferredReturnType
* @psalm-suppress MoreSpecificReturnType
* @psalm-suppress LessSpecificReturnStatement
*/
public function findOneByPaymentMethodAndCustomer(
PaymentMethodInterface $paymentMethod,
CustomerInterface $customer,
): ?AdyenTokenInterface {
return $this->findOneBy([
$result = $this->findOneBy([
'paymentMethod' => $paymentMethod,
'customer' => $customer,
]);

return $result instanceof AdyenTokenInterface ? $result : null;
}
}
4 changes: 0 additions & 4 deletions src/Repository/AdyenTokenRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

interface AdyenTokenRepositoryInterface extends RepositoryInterface
{
/**
* @psalm-suppress MixedReturnStatement
* @psalm-suppress MixedInferredReturnType
*/
public function findOneByPaymentMethodAndCustomer(
PaymentMethodInterface $paymentMethod,
CustomerInterface $customer,
Expand Down
Loading
Loading