Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/noticket-gitlab-ci-changes' into 'master'
Browse files Browse the repository at this point in the history
[NOTICKET] Add more checks to the gitlab ci

See merge request heidelpay/heidelpayment5!122
  • Loading branch information
Sironheart committed Dec 9, 2020
2 parents 8d41dfe + 40727cd commit 86b7f4b
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 90 deletions.
137 changes: 86 additions & 51 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,95 @@
stages:
- setup
- test
- setup
- test
- package

cache:
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
variables:
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
MYSQL_DATABASE: shopware
MYSQL_USER: shopware
MYSQL_PASSWORD: shopware
SHOPWARE_VERSION: "v5.6.0" # Tag
COMPOSER_COMMAND: "composer install --prefer-dist --no-ansi --no-interaction --no-progress --optimize-autoloader"

services:
- mysql:5.7
setup:
stage: setup
image: "edbizarro/gitlab-ci-pipeline-php:7.2"
script:
- mkdir -p /tmp/opt
- git clone -b ${SHOPWARE_VERSION} https://github.com/shopware/shopware "/tmp/opt/shopware"
- cd /tmp/opt/shopware && ${COMPOSER_COMMAND}
- cp -r ${CI_PROJECT_DIR} /tmp/opt/shopware/custom/plugins/${CI_PROJECT_NAME} && cd /tmp/opt/shopware/custom/plugins/${CI_PROJECT_NAME} && ${COMPOSER_COMMAND}
- cd /tmp/opt/shopware && composer dump-autoload -d custom/plugins/${CI_PROJECT_NAME}
- cp -r /tmp/opt/shopware ${CI_PROJECT_DIR}/sw_dir
artifacts:
paths:
- "sw_dir"
expire_in: 1 days
when: always

variables:
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
MYSQL_DATABASE: shopware
MYSQL_USER: shopware
MYSQL_PASSWORD: shopware
codestyle:
stage: test
image: "edbizarro/gitlab-ci-pipeline-php:7.2"
needs:
- job: setup
artifacts: true
script:
- cd ${CI_PROJECT_DIR}/sw_dir/custom/plugins/${CI_PROJECT_NAME} && vendor/bin/php-cs-fixer fix -v --dry-run
cache:
key: global
paths:
- .php_cs.cache

SHOPWARE_VERSION: "5.6.0"
k10r-phpstan:
stage: test
image: "edbizarro/gitlab-ci-pipeline-php:7.2"
needs:
- job: setup
artifacts: true
script:
- cd ${CI_PROJECT_DIR}/sw_dir/custom/plugins/${CI_PROJECT_NAME} && vendor/bin/phpstan analyse .

composer:
stage: setup
image: "edbizarro/gitlab-ci-pipeline-php:7.2"
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --optimize-autoloader
artifacts:
paths:
- vendor/
expire_in: 1 days
when: always
cache:
paths:
- vendor/
sw-phpstan:
stage: test
image: "edbizarro/gitlab-ci-pipeline-php:7.2"
needs:
- job: setup
artifacts: true
before_script:
- cd /tmp && git clone https://github.com/shopwareLabs/store-plugin-codereview.git && store-plugin-codereview && ${COMPOSER_COMMAND}
- cp -r /tmp/store-plugin-codereview/configs/phpstan/phpstan.neon.sw5 ${CI_PROJECT_DIR}/sw_dir/custom/plugins/${CI_PROJECT_NAME}/phpstan_sw.neon
script:
- cd ${CI_PROJECT_DIR}/sw_dir/custom/plugins/${CI_PROJECT_NAME} && vendor/bin/phpstan analyse -c phpstan_sw.neon -a vendor/autoload.php -a ../../../vendor/autoload.php .

codestyle:
stage: test
image: "edbizarro/gitlab-ci-pipeline-php:7.2"
dependencies:
- composer
script:
- vendor/bin/php-cs-fixer fix -v --dry-run
cache:
key: global
paths:
- .php_cs.cache
shopware-validate:
image:
name: friendsofshopware/plugin-uploader:0.3.5
entrypoint: [ "/bin/sh", "-c" ]
stage: test
only:
- tags
- master
- /^fix.*$/
needs:
- job: setup
artifacts: true
before_script:
- rm -rf sw_dir
script:
- php /app/bin/pluginupload ext:zip . $CI_COMMIT_SHA
- php /app/bin/pluginupload ext:validate *$CI_COMMIT_SHA.zip

php-unit:
image: "kellerkinder/shopware-testing:php71-1.0.0"
stage: test
dependencies:
- composer
script:
- /usr/local/bin/clone-shopware "${CI_PROJECT_DIR}" ${SHOPWARE_VERSION}
- mv ${CI_PROJECT_DIR}/opt /tmp/opt
- cp -r ${CI_PROJECT_DIR} /tmp/opt/shopware-${SHOPWARE_VERSION}/custom/plugins/HeidelPayment
- mv /tmp/opt ${CI_PROJECT_DIR}/opt
- cd ${CI_PROJECT_DIR}/opt/shopware-${SHOPWARE_VERSION}/build && ant -Ddb.name=${MYSQL_DATABASE} -Ddb.host=mysql -Ddb.user=${MYSQL_USER} -Ddb.password=${MYSQL_PASSWORD} configure && ant build-unit
- cd ${CI_PROJECT_DIR}/opt/shopware-${SHOPWARE_VERSION}/custom/plugins/HeidelPayment
- php ${CI_PROJECT_DIR}/opt/shopware-${SHOPWARE_VERSION}/composer.phar install -o
- php ${CI_PROJECT_DIR}/opt/shopware-${SHOPWARE_VERSION}/bin/console sw:plugin:refresh -v
- php ${CI_PROJECT_DIR}/opt/shopware-${SHOPWARE_VERSION}/bin/console sw:plugin:install --activate HeidelPayment -v
- cd ${CI_PROJECT_DIR}/opt/shopware-${SHOPWARE_VERSION}/custom/plugins/HeidelPayment && ${CI_PROJECT_DIR}/opt/shopware-${SHOPWARE_VERSION}/vendor/bin/phpunit
package:
image: kellerkinder/shopware-package-plugin:latest
stage: package
only:
- tags
- master
- /^fix.*$/
script:
- package-plugin
artifacts:
paths:
- ${CI_PROJECT_NAME}.zip
20 changes: 10 additions & 10 deletions Components/Hydrator/ResourceHydrator/BasketHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public function hydrateOrFetch(
return $heidelpayObj->fetchBasket($resourceId);
}

$isAmountInNet = isset($data['sAmountWithTax']);
$isTaxFree = $data['taxFree'];
$amountTotalGrossTransaction = $isAmountInNet && !$isTaxFree ? $data['sAmountWithTax'] : $data['sAmount'];
$isAmountInNet = isset($data['sAmountWithTax']);
$isTaxFree = $data['taxFree'];
$amountTotalGrossTransaction = $isAmountInNet && !$isTaxFree ? $data['sAmountWithTax'] : $data['sAmount'];

$basketAmountTotalGross = 0;
$basketAmountTotalVat = 0;
$basketAmountTotalGross = 0;
$basketAmountTotalVat = 0;
$basketAmountTotalDiscount = 0;

$result = new Basket();
Expand All @@ -56,7 +56,8 @@ public function hydrateOrFetch(
}

$basketItem = new BasketItem();
if($this->isBasketItemVoucher($lineItem)){

if ($this->isBasketItemVoucher($lineItem)) {
$basketItem->setType($this->getBasketItemType($lineItem));
$basketItem->setTitle($lineItem['articlename']);
$basketItem->setAmountDiscount(round($amountGross, 4));
Expand All @@ -77,7 +78,6 @@ public function hydrateOrFetch(
$basketAmountTotalVat += $basketItem->getAmountVat();
}


if ($lineItem['abo_attributes']['isAboArticle']) {
$result->setSpecialParams(array_merge($result->getSpecialParams(), ['isAbo' => true]));
$basketItem->setSpecialParams([
Expand Down Expand Up @@ -111,9 +111,9 @@ public function hydrateOrFetch(
$basketAmountTotalDiscount += $dispatchBasketItem->getAmountDiscount();

// setting of all totalAmounts
$result->setAmountTotalGross(round((float)$basketAmountTotalGross, 4));
$result->setAmountTotalVat(round((float)$basketAmountTotalVat, 4));
$result->setAmountTotalDiscount(round((float)$basketAmountTotalDiscount, 4));
$result->setAmountTotalGross(round((float) $basketAmountTotalGross, 4));
$result->setAmountTotalVat(round((float) $basketAmountTotalVat, 4));
$result->setAmountTotalDiscount(round((float) $basketAmountTotalDiscount, 4));

return $result;
}
Expand Down
2 changes: 1 addition & 1 deletion Components/PaymentHandler/Traits/CanRecur.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function createRecurringOrder(): string
/** @var SwOrder $newAboOrder */
$newAboOrder = $this->getModelManager()->getRepository(SwOrder::class)->findOneBy(['number' => $newOrderNumber]);

if (isset($newAboOrder)) {
if (isset($newAboOrder) && \class_exists(AboOrder::class)) {
/** @var AboOrder $aboModel */
$aboModel = $this->getModelManager()->getRepository(AboOrder::class)->find($recurringData['swAboId']);
$aboModel->run($newAboOrder->getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private function getPaymentTypeTransactionId(string $transactionId): ?HirePurcha
return $paymentType->getPayment()->getPaymentType();
}
} catch (HeidelpayApiException $apiException) {
$this->apiLoggerService->logException(sprintf('Error while fetching first charge of payment with payment-id [%s]', $paymentId), $apiException);
$this->apiLoggerService->logException(sprintf('Error while fetching first charge of payment with transaction-id [%s]', $transactionId), $apiException);
}

return null;
Expand Down
2 changes: 2 additions & 0 deletions Subscribers/Frontend/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ public function onPostDispatchShippingPayment(ActionEventArgs $args): void

private function getHeidelPaymentId(?Enlight_Components_Session_Namespace $session, ?Enlight_View_Default $view): string
{
$heidelPaymentId = null;

if (!$session || !$view) {
return '';
}
Expand Down
4 changes: 3 additions & 1 deletion Subscribers/Model/OrderSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ private function isShipmentAllowed(Order $order): bool

private function shipOrder(Order $order, string $documentId): ?Shipment
{
$shipResult = null;

try {
$shipResult = $this->heidelpayClient->ship($order->getTemporaryId(), $documentId);

Expand All @@ -138,7 +140,7 @@ private function shipOrder(Order $order, string $documentId): ?Shipment
$this->apiLogger->logException(sprintf('Unable to send shipping notification for order [%s] with payment-id [%s] and invoice-id [%s]', $order->getNumber(), $order->getTemporaryId(), $documentId), $apiException);
}

return $shipResult ?: null;
return $shipResult;
}

private function updateOrderPaymentStatus(Shipment $heidelShipment): void
Expand Down
5 changes: 0 additions & 5 deletions Tests/Functional/Bootstrap.php

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"installer-name": "HeidelPayment"
},
"scripts": {
"phpstan": "./vendor/bin/phpstan analyse . --memory-limit=512M --error-format=checkstyle | awk '{$1=$1;print}' > phpstan_result.xml | true",
"phpstan": "./vendor/bin/phpstan analyse .",
"phpcs:lint": "./vendor/bin/php-cs-fixer fix --dry-run -v",
"phpcs:fix": "./vendor/bin/php-cs-fixer fix"
}
Expand Down
7 changes: 1 addition & 6 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
parameters:
checkMissingIterableValueType: false
level: max
ignoreErrors:
- message: '#getAssign\(\) on Enlight_View_Default\|null#'
path: %currentWorkingDirectory%/
- message: '#assign\(\) on Enlight_View_Default\|null#'
path: %currentWorkingDirectory%/
level: 1
bootstrapFiles:
- vendor/autoload.php
- ../../../autoload.php
Expand Down
14 changes: 0 additions & 14 deletions phpunit.xml.dist

This file was deleted.

0 comments on commit 86b7f4b

Please sign in to comment.