Skip to content

Commit

Permalink
Merge pull request #29 from kurozumi/support-eccube43
Browse files Browse the repository at this point in the history
EC-CUBE4.3対応
  • Loading branch information
kurozumi authored May 20, 2024
2 parents adeae7d + 7ccae70 commit cefcd36
Show file tree
Hide file tree
Showing 34 changed files with 670 additions and 387 deletions.
25 changes: 25 additions & 0 deletions .github/actions/composer/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
composer install --dev --no-interaction -o --apcu-autoloader
composer config --no-plugins allow-plugins.php-http/discovery false
composer require knpuniversity/oauth2-client-bundle
composer require riskio/oauth2-auth0
composer require auth0/auth0-php
shell: bash
37 changes: 17 additions & 20 deletions .github/workflows/phpstan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ jobs:
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
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: EC-CUBE/ec-cube
ref: ${{ matrix.eccube-versions }}
Expand All @@ -24,25 +33,13 @@ jobs:
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
- name: composer install
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
composer install --dev --no-interaction -o --apcu-autoloader
composer config --no-plugins allow-plugins.php-http/discovery false
composer require knpuniversity/oauth2-client-bundle
composer require riskio/oauth2-auth0
composer require auth0/auth0-php
Expand All @@ -56,4 +53,4 @@ jobs:
- 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
81 changes: 46 additions & 35 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: CI/CD for EC-CUBE4 Plugin
on: [ workflow_dispatch, pull_request ]
env:
PLUGIN_CODE: Auth0
PLUGIN_BRANCH: '4.2'
PACKAGE_NAME: 'ec-cube/auth0'
WORKING_DIRECTORY: 'ec-cube'
APP_ENV: 'test'
APP_DEBUG: 0
jobs:
Expand All @@ -12,8 +13,8 @@ jobs:
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 @@ -28,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 @@ -55,46 +65,40 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- name: Checkout EC-CUBE
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
repository: EC-CUBE/ec-cube
ref: ${{ matrix.eccube-versions }}
ref: ${{ github.event.pull_request.head.sha }}

- name: Archive Plugin
run: |
tar cvzf ${GITHUB_WORKSPACE}/${{ env.PLUGIN_CODE }}.tar.gz ./*
- name: Setup mock-package-api
run: |
mkdir -p /tmp/repos
cp ${GITHUB_WORKSPACE}/${{ env.PLUGIN_CODE }}.tar.gz /tmp/repos/${{ env.PLUGIN_CODE }}.tgz
docker run --name package-api -d -v /tmp/repos:/repos -e MOCK_REPO_DIR=/repos -p 8080:8080 eccube/mock-package-api:composer2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2 #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
- name: Checkout EC-CUBE
uses: actions/checkout@v4
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
composer require knpuniversity/oauth2-client-bundle
composer require riskio/oauth2-auth0
composer require auth0/auth0-php
repository: EC-CUBE/ec-cube
ref: ${{ matrix.eccube-versions }}
path: ${{ env.WORKING_DIRECTORY }}

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

- name: Setup EC-CUBE
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
bin/console doctrine:database:create
bin/console doctrine:schema:create
Expand All @@ -107,8 +111,10 @@ jobs:
DATABASE_CHARSET: ${{ matrix.database_charset }}

- name: Setup Plugin
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
bin/console eccube:plugin:install --code ${{ env.PLUGIN_CODE }}
bin/console doctrine:query:sql "update dtb_base_info set authentication_key='dummy'"
bin/console eccube:composer:require ${{ env.PACKAGE_NAME }}
bin/console cache:clear --no-warmup
bin/console eccube:plugin:enable --code ${{ env.PLUGIN_CODE }}
bin/console cache:clear --no-warmup
Expand All @@ -118,11 +124,14 @@ jobs:
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
DATABASE_CHARSET: ${{ matrix.database_charset }}
ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080'
USE_SELFSIGNED_SSL_CERTIFICATE: '1'

- name: Run Tests
- name: Run PHPUnit
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
bin/console cache:clear --no-warmup
bin/phpunit -c app/Plugin/${{ env.PLUGIN_CODE }}/phpunit.xml.dist app/Plugin/${{ env.PLUGIN_CODE }}/Tests
./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 @@ -131,6 +140,7 @@ jobs:
DATABASE_CHARSET: ${{ matrix.database_charset }}

- name: Update Plugin
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
bin/console cache:clear --no-warmup
bin/console eccube:plugin:update ${{ env.PLUGIN_CODE }}
Expand All @@ -142,6 +152,7 @@ jobs:
DATABASE_CHARSET: ${{ matrix.database_charset }}

- name: Uninstall Plugin
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
bin/console cache:clear --no-warmup
bin/console eccube:plugin:uninstall --code=${{ env.PLUGIN_CODE }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.tar.gz
!.gitkeep
.php-cs-fixer.cache
51 changes: 51 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/*
* This file is part of Auth0 for EC-CUBE
*
* 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.
*/

if (php_sapi_name() !== 'cli') {
throw new LogicException();
}

$header = <<<EOL
This file is part of Auth0 for EC-CUBE
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.
EOL;

$rules = [
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'phpdoc_align' => false,
'phpdoc_summary' => false,
'phpdoc_scalar' => false,
'phpdoc_annotation_without_dot' => false,
'no_superfluous_phpdoc_tags' => false,
'increment_style' => false,
'yoda_style' => false,
'header_comment' => ['header' => $header],
];

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->name('*.php')
;
$config = new PhpCsFixer\Config();

return $config
->setRules($rules)
->setFinder($finder)
;
12 changes: 8 additions & 4 deletions Bundle/Auth0Bundle.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

/**
* This file is part of Auth0
/*
* This file is part of Auth0 for EC-CUBE
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* https://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.
Expand All @@ -14,11 +14,15 @@
namespace Plugin\Auth0\Bundle;

use Plugin\Auth0\DependencyInjection\Auth0Extension;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class Auth0Bundle extends Bundle
{
public function getContainerExtension()
/**
* @return ExtensionInterface|null
*/
public function getContainerExtension(): ?ExtensionInterface
{
return new Auth0Extension();
}
Expand Down
11 changes: 5 additions & 6 deletions Controller/Admin/ConfigController.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

/**
* This file is part of Auth0
/*
* This file is part of Auth0 for EC-CUBE
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* https://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.
Expand All @@ -28,11 +28,9 @@ class ConfigController extends AbstractController
/**
* @var ConfigRepository
*/
protected $configRepository;
protected ConfigRepository $configRepository;

/**
* ConfigController constructor.
*
* @param ConfigRepository $configRepository
*/
public function __construct(ConfigRepository $configRepository)
Expand All @@ -42,6 +40,7 @@ public function __construct(ConfigRepository $configRepository)

/**
* @Route("/%eccube_admin_route%/social_login/config", name="social_login_admin_config")
*
* @Template("@Auth0/admin/config.twig")
*/
public function index(Request $request, CacheUtil $cacheUtil)
Expand Down
Loading

0 comments on commit cefcd36

Please sign in to comment.