Skip to content

Commit

Permalink
Merge pull request #11 from kurozumi/support-eccube43
Browse files Browse the repository at this point in the history
EC-CUBE4.3対応
  • Loading branch information
kurozumi authored Apr 16, 2024
2 parents 1a4b6bc + dd4daa7 commit a38e215
Show file tree
Hide file tree
Showing 23 changed files with 203 additions and 154 deletions.
19 changes: 19 additions & 0 deletions .github/actions/composer/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
runs:
using: "Composite"
steps:
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
shell: bash

- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: composer install
run: composer install --dev --no-interaction -o --apcu-autoloader
shell: bash
61 changes: 29 additions & 32 deletions .github/workflows/phpstan.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
name: PHPStan
on: [workflow_dispatch, pull_request]
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
PLUGIN_CODE: CustomerGroupRank42
PLUGIN_BRANCH: '4.2'
CUSTOMER_GROUP_CODE: CustomerGroup42
CUSTOMER_GROUP_BRANCH: '4.2'

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
eccube-versions: ['4.2']
php-versions: [ '7.4', '8.0', '8.1' ]
eccube-versions: ['4.2', '4.3']
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
exclude:
- eccube-versions: 4.2
php-versions: 8.2
- eccube-versions: 4.2
php-versions: 8.3
- eccube-versions: 4.3
php-versions: 7.4
- eccube-versions: 4.3
php-versions: 8.0

steps:
- name: Checkout EC-CUBE
Expand All @@ -24,41 +31,31 @@ jobs:
repository: EC-CUBE/ec-cube
ref: ${{ matrix.eccube-versions }}

- name: Checkout CustomerGroup
uses: actions/checkout@v4
with:
repository: kurozumi/CustomerGroup
ref: ${{ env.CUSTOMER_GROUP_BRANCH }}
path: app/Plugin/${{ env.CUSTOMER_GROUP_CODE }}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Checkout
uses: actions/checkout@v4
with:
path: app/Plugin/${{ env.PLUGIN_CODE }}
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, mysql, intl
tools: composer:v2

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Setup CustomerGroup
run: |
git clone -b ${{ env.CUSTOMER_GROUP_BRANCH }} https://$PERSONAL_ACCESS_TOKEN:x-oauth-basic@github.com/kurozumi/CustomerGroup.git app/Plugin/${{ env.CUSTOMER_GROUP_CODE }}
- name: Checkout
uses: actions/checkout@v2
with:
path: app/Plugin/${{ env.PLUGIN_CODE }}
ref: ${{ env.PLUGIN_BRANCH }}
- name: Initialize Composer
uses: ./.github/actions/composer

- name: PHPStan
run: |
composer require phpstan/phpstan --dev
vendor/bin/phpstan analyze app/Plugin/${{ env.PLUGIN_CODE }} -c "app/Plugin/${{ env.PLUGIN_CODE }}/phpstan.neon" --error-format=github
./vendor/bin/phpstan analyze app/Plugin/${{ env.PLUGIN_CODE }} -c "app/Plugin/${{ env.PLUGIN_CODE }}/phpstan.neon" --error-format=github
83 changes: 39 additions & 44 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
name: CI/CD for EC-CUBE4 Plugin
on: [workflow_dispatch, pull_request]
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
PLUGIN_CODE: CustomerGroupRank42
PLUGIN_BRANCH: '4.2'
MAIN_PLUGIN_CODE: CustomerGroup42
MAIN_PLUGIN_BRANCH: '4.2'
CUSTOMER_GROUP_CODE: CustomerGroup42
CUSTOMER_GROUP_BRANCH: '4.2'
APP_ENV: 'test'
APP_DEBUG: 0
jobs:
phpunit:
name: PHPUnit
runs-on: ubuntu-latest
run-on-linux:
name: Run on Linux
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
eccube-versions: ['4.2']
php-versions: [ '7.4', '8.0', '8.1' ]
eccube-versions: [ '4.2', '4.3' ]
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
database: [ 'mysql', 'mysql8', 'pgsql' ]
include:
- database: mysql
Expand All @@ -31,6 +29,15 @@ jobs:
database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db
database_server_version: 14
database_charset: utf8
exclude:
- eccube-versions: 4.2
php-versions: 8.2
- eccube-versions: 4.2
php-versions: 8.3
- eccube-versions: 4.3
php-versions: 7.4
- eccube-versions: 4.3
php-versions: 8.0

services:
mysql:
Expand Down Expand Up @@ -64,29 +71,29 @@ jobs:
repository: EC-CUBE/ec-cube
ref: ${{ matrix.eccube-versions }}

- name: Checkout CustomerGroup
uses: actions/checkout@v4
with:
repository: kurozumi/CustomerGroup
ref: ${{ env.CUSTOMER_GROUP_BRANCH }}
path: app/Plugin/${{ env.CUSTOMER_GROUP_CODE }}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: app/Plugin/${{ env.PLUGIN_CODE }}

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, mysql, intl
extensions: mbstring, xml, ctype, iconv, mysql, intl, :xdebug
tools: composer:v2

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Initialize Composer
uses: ./.github/actions/composer

- name: Setup EC-CUBE
run: |
Expand All @@ -100,31 +107,21 @@ jobs:
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
DATABASE_CHARSET: ${{ matrix.database_charset }}

- name: Setup CustomerGroup
- name: Setup CustomerGroup Plugin
run: |
git clone -b ${{ env.MAIN_PLUGIN_BRANCH }} https://$PERSONAL_ACCESS_TOKEN:x-oauth-basic@github.com/kurozumi/CustomerGroup.git app/Plugin/${{ env.MAIN_PLUGIN_CODE }}
bin/console eccube:plugin:install --code ${{ env.MAIN_PLUGIN_CODE }}
bin/console cache:clear --no-warmup
bin/console eccube:plugin:enable --code ${{ env.MAIN_PLUGIN_CODE }}
bin/console eccube:plugin:install --code ${{ env.CUSTOMER_GROUP_CODE }}
bin/console eccube:plugin:enable --code ${{ env.CUSTOMER_GROUP_CODE }}
env:
APP_ENV: ${{ env.APP_ENV }}
APP_DEBUG: ${{ env.APP_DEBUG }}
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
DATABASE_CHARSET: ${{ matrix.database_charset }}

- name: Checkout
uses: actions/checkout@v2
with:
path: app/Plugin/${{ env.PLUGIN_CODE }}
ref: ${{ env.PLUGIN_BRANCH }}

- name: Setup Plugin
run: |
bin/console eccube:plugin:install --code ${{ env.PLUGIN_CODE }}
bin/console cache:clear --no-warmup
bin/console eccube:plugin:enable --code ${{ env.PLUGIN_CODE }}
bin/console cache:clear --no-warmup
env:
APP_ENV: ${{ env.APP_ENV }}
APP_DEBUG: ${{ env.APP_DEBUG }}
Expand All @@ -134,8 +131,8 @@ jobs:

- name: Run Tests
run: |
bin/console cache:clear --no-warmup
bin/phpunit -c app/Plugin/${{ env.PLUGIN_CODE }}/phpunit.xml.dist app/Plugin/${{ env.PLUGIN_CODE }}/Tests
rm -rf var/cache
./vendor/bin/phpunit -c app/Plugin/${{ env.PLUGIN_CODE }}/phpunit.xml.dist app/Plugin/${{ env.PLUGIN_CODE }}/Tests
env:
APP_ENV: ${{ env.APP_ENV }}
APP_DEBUG: ${{ env.APP_DEBUG }}
Expand All @@ -145,7 +142,6 @@ jobs:

- name: Update Plugin
run: |
bin/console cache:clear --no-warmup
bin/console eccube:plugin:update ${{ env.PLUGIN_CODE }}
env:
APP_ENV: ${{ env.APP_ENV }}
Expand All @@ -156,8 +152,7 @@ jobs:

- name: Uninstall Plugin
run: |
bin/console cache:clear --no-warmup
bin/console eccube:plugin:uninstall --code=${{ env.PLUGIN_CODE }}
bin/console eccube:plugin:uninstall --code ${{ env.PLUGIN_CODE }}
env:
APP_ENV: ${{ env.APP_ENV }}
APP_DEBUG: ${{ env.APP_DEBUG }}
Expand Down
32 changes: 32 additions & 0 deletions Bundle/CustomerGroupRankBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/*
* This file is part of CustomerGroupRank42
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* https://a-zumi.net
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Plugin\CustomerGroupRank42\Bundle;

use Plugin\CustomerGroupRank42\DependencyInjection\Compiler\RankPass;
use Plugin\CustomerGroupRank42\Service\Rank\RankInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class CustomerGroupRankBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);

$container->registerForAutoconfiguration(RankInterface::class)
->addTag(RankPass::TAG);

$container->addCompilerPass(new RankPass());
}
}
14 changes: 7 additions & 7 deletions DependencyInjection/Compiler/RankPass.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
/**
* This file is part of CustomerGroupRank42

/*
* This file is part of EC-CUBE
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* https://a-zumi.net
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Plugin\CustomerGroupRank42\DependencyInjection\Compiler;


use Plugin\CustomerGroupRank42\Service\Rank\Context;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
Expand All @@ -23,14 +23,14 @@ class RankPass implements CompilerPassInterface
{
use PriorityTaggedServiceTrait;

const TAG = 'plugin.customer.group.rank';
public const TAG = 'plugin.customer.group.rank';

public function process(ContainerBuilder $container)
{
$context = $container->findDefinition(Context::class);

foreach ($this->findAndSortTaggedServices(self::TAG, $container) as $id) {
$context->addMethodCall('addRank', [new Reference($id)]);
$context->addMethodCall('addRank', [$id]);
}
}
}
6 changes: 4 additions & 2 deletions Entity/GroupTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/**

/*
* This file is part of CustomerGroupRank42
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
Expand All @@ -17,7 +18,6 @@

/**
* Trait GroupTrait
* @package Plugin\CustomerGroupRank42\Entity
*
* @EntityExtension("Plugin\CustomerGroup42\Entity\Group")
*/
Expand Down Expand Up @@ -47,6 +47,7 @@ public function getBuyTimes(): ?float

/**
* @param float|null $buyTimes
*
* @return $this
*/
public function setBuyTimes(?float $buyTimes): self
Expand All @@ -66,6 +67,7 @@ public function getBuyTotal(): ?float

/**
* @param float|null $buyTotal
*
* @return $this
*/
public function setBuyTotal(?float $buyTotal): self
Expand Down
5 changes: 2 additions & 3 deletions Event.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/**

/*
* This file is part of CustomerGroupRank42
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
Expand All @@ -12,13 +13,11 @@

namespace Plugin\CustomerGroupRank42;


use Eccube\Event\TemplateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class Event implements EventSubscriberInterface
{

public static function getSubscribedEvents()
{
return [
Expand Down
Loading

0 comments on commit a38e215

Please sign in to comment.