Skip to content

Commit

Permalink
Merge pull request #53 from JanPalen/feature/OP-359-update-build
Browse files Browse the repository at this point in the history
Feature/op 359 update build
  • Loading branch information
senghe authored Aug 13, 2024
2 parents 5e78ef6 + e394afa commit 50becf4
Show file tree
Hide file tree
Showing 29 changed files with 277 additions and 157 deletions.
62 changes: 28 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@ 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:
tests:
runs-on: ubuntu-latest

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

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

exclude:
- sylius: "~1.13.0"
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 @@ -84,25 +86,23 @@ jobs:
-
name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

-
name: Cache Composer
uses: actions/cache@v2
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 != ''
Expand All @@ -111,21 +111,22 @@ jobs:
-
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 @@ -135,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 @@ -158,30 +157,25 @@ 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 8 src/

# TODO: Temporary disabled!
# -
# name: Run Psalm
# run: vendor/bin/psalm

-
name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction

# -
# name: Run PHPUnit
# run: vendor/bin/phpunit --colors=always
-
name: Run PHPUnit
run: vendor/bin/phpunit --colors=always

-
name: Create behat logs directory
run: (mkdir -p etc/build && chmod a+rw etc/build )

-
name: Run Behat
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun

-
name: Upload Behat logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: failure()
with:
name: Behat logs
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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

/behat.yml
/phpspec.yml
/phpunit.xml
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"behat/behat": "^3.7",
"behat/mink-selenium2-driver": "~1.6.0",
"symfony/webpack-encore-bundle": "^1.15",
"bitbag/coding-standard": "^1.0.1 || ^2.0.0",
"bitbag/coding-standard": "^3.0",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"friends-of-behat/mink": "^1.8",
Expand All @@ -36,7 +36,6 @@
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"vimeo/psalm": "4.7.1 || ^5.0.0",
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
},
"conflict": {
Expand Down
22 changes: 6 additions & 16 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,12 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/bitbag/coding-standard/ecs.php');
$services = $containerConfigurator->services();
$services->set(ArraySyntaxFixer::class)
->call('configure', [[
'syntax' => 'short',
]]);
return static function (ECSConfig $config): void {

$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
]);
putenv('ALLOW_BITBAG_OS_HEADER=1');

$config->import('vendor/bitbag/coding-standard/ecs.php');
$config->paths(['src', 'tests']);
};
27 changes: 27 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
9 changes: 5 additions & 4 deletions src/BitBagSyliusShippingExportPlugin.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/

declare(strict_types=1);

Expand Down
15 changes: 8 additions & 7 deletions src/Context/ShippingGatewayContext.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/

declare(strict_types=1);

Expand Down Expand Up @@ -36,7 +37,7 @@ public function __construct(
RequestStack $requestStack,
FormTypeRegistryInterface $shippingGatewayFormTypeRegistry,
ShippingGatewayRepositoryInterface $shippingGatewayRepository,
array $shippingGateways
array $shippingGateways,
) {
$this->requestStack = $requestStack;
$this->shippingGatewayFormTypeRegistry = $shippingGatewayFormTypeRegistry;
Expand Down Expand Up @@ -68,7 +69,7 @@ public function getCode(): ?string
if (false === $this->shippingGatewayFormTypeRegistry->has('shipping_gateway_config', $code)) {
throw new ShippingGatewayNotFoundException(sprintf(
'Gateway with %s code could not be found',
$code
$code,
));
}

Expand All @@ -93,7 +94,7 @@ private function getExistingShippingGateway(int $id): ShippingGatewayInterface
if (false === $shippingGateway instanceof ShippingGatewayInterface) {
throw new ShippingGatewayNotFoundException(sprintf(
'Gateway with %d id could not be found in the database.',
$id
$id,
));
}

Expand Down
9 changes: 5 additions & 4 deletions src/Context/ShippingGatewayContextInterface.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/

declare(strict_types=1);

Expand Down
Loading

0 comments on commit 50becf4

Please sign in to comment.