Skip to content
Open
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
104 changes: 52 additions & 52 deletions .github/workflows/ab-testing.yml

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions .github/workflows/e2e-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,39 +71,39 @@ jobs:
bin/console doctrine:database:create --env=dev
bin/console doctrine:schema:create --env=dev
bin/console eccube:fixtures:load --env=dev
- name: Download Plugin TwoFactorAuthCustomer42
- name: Download Plugin TwoFactorAuthCustomer44
uses: actions/checkout@master
with:
path: app/Plugin/TwoFactorAuthCustomer42
- name: Download Plugin TwoFactorAuthCustomerApp42
path: app/Plugin/TwoFactorAuthCustomer44
- name: Download Plugin TwoFactorAuthCustomerApp44
uses: actions/checkout@master
with:
repository: ${{ github.repository_owner }}/TwoFactorAuthCustomerApp42
path: app/Plugin/TwoFactorAuthCustomerApp42
- name: Download Plugin TwoFactorAuthCustomerSms42
repository: ${{ github.repository_owner }}/TwoFactorAuthCustomerApp44
path: app/Plugin/TwoFactorAuthCustomerApp44
- name: Download Plugin TwoFactorAuthCustomerSms44
uses: actions/checkout@master
with:
repository: ${{ github.repository_owner }}/TwoFactorAuthCustomerSms42
path: app/Plugin/TwoFactorAuthCustomerSms42
repository: ${{ github.repository_owner }}/TwoFactorAuthCustomerSms44
path: app/Plugin/TwoFactorAuthCustomerSms44
- name: Install Plugins
env:
APP_ENV: ${{ matrix.app_env }}
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
run: |
bin/console eccube:plugin:install --code=TwoFactorAuthCustomer42
bin/console eccube:plugin:install --code=TwoFactorAuthCustomer44
bin/console cache:clear
bin/console eccube:plugin:enable --code=TwoFactorAuthCustomer42
bin/console eccube:plugin:enable --code=TwoFactorAuthCustomer44
bin/console cache:clear

bin/console eccube:plugin:install --code=TwoFactorAuthCustomerApp42
bin/console eccube:plugin:install --code=TwoFactorAuthCustomerApp44
bin/console cache:clear
bin/console eccube:plugin:enable --code=TwoFactorAuthCustomerApp42
bin/console eccube:plugin:enable --code=TwoFactorAuthCustomerApp44
bin/console cache:clear

bin/console eccube:plugin:install --code=TwoFactorAuthCustomerSms42
bin/console eccube:plugin:install --code=TwoFactorAuthCustomerSms44
bin/console cache:clear
bin/console eccube:plugin:enable --code=TwoFactorAuthCustomerSms42
bin/console eccube:plugin:enable --code=TwoFactorAuthCustomerSms44

- name: setup-chromedriver
uses: nanasess/setup-chromedriver@master
Expand Down
153 changes: 106 additions & 47 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI for TwoFactorAuthCustomer42
name: CI for TwoFactorAuthCustomer44
on:
push:
branches:
Expand All @@ -17,19 +17,15 @@ on:
jobs:
run-on-linux:
name: Run on Linux
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
eccube_version: [ '4.2','4.3' ]
php: [ '7.4', '8.0', '8.1','8.2', '8.3' ]
db: [ 'mysql', 'mysql8', 'pgsql' ]
plugin_code: [ 'TwoFactorAuthCustomer42' ]
eccube_version: [ '4.4' ]
php: [ '8.2', '8.3', '8.4', '8.5' ]
db: [ 'mysql8', 'pgsql' ]
plugin_code: [ 'TwoFactorAuthCustomer44' ]
include:
- db: mysql
database_url: mysql://root:password@127.0.0.1:3306/eccube_db
database_server_version: 5.7
database_charset: utf8mb4
- db: mysql8
database_url: mysql://root:password@127.0.0.1:3308/eccube_db
database_server_version: 8
Expand All @@ -38,24 +34,7 @@ jobs:
database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db
database_server_version: 14
database_charset: utf8
exclude:
- eccube_version: 4.2
php: 8.2
- eccube_version: 4.2
php: 8.3
- eccube_version: 4.3
php: 7.4
- eccube_version: 4.3
php: 8.0
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: ${{ matrix.dbname }}
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
mysql8:
image: mysql:8
env:
Expand All @@ -81,7 +60,7 @@ jobs:
- 1025:1025
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: nanasess/setup-php@master
Expand All @@ -93,17 +72,8 @@ jobs:
PLUGIN_CODE: ${{ matrix.plugin_code }}
run: |
tar cvzf ${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz ./*

- name: Setup mock-package-api
env:
PLUGIN_CODE: ${{ matrix.plugin_code }}
run: |
mkdir -p /tmp/repos
cp ${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz /tmp/repos/${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: Checkout EC-CUBE
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 'EC-CUBE/ec-cube'
ref: ${{ matrix.eccube_version }}
Expand All @@ -112,16 +82,18 @@ jobs:
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install to composer
working-directory: 'ec-cube'
run: composer install --no-interaction -o --apcu-autoloader
# Symfony 7.4 の symfony/cache が ext-redis <6.1 と衝突するが、ランナーには
# 古い php-redis(5.3.7) が入っている。本プラグイン/本体テストは redis 未使用のため無視する。
run: composer install --no-interaction -o --apcu-autoloader --ignore-platform-req=ext-redis

- name: Setup EC-CUBE
env:
Expand All @@ -130,7 +102,6 @@ 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'
working-directory: 'ec-cube'
run: |
bin/console doctrine:database:create
Expand All @@ -144,12 +115,28 @@ jobs:
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
DATABASE_CHARSET: ${{ matrix.database_charset }}
PLUGIN_CODE: ${{ matrix.plugin_code }}
ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080'
working-directory: 'ec-cube'
run: |
bin/console eccube:composer:require ec-cube/twofactorauthcustomer42
bin/console cache:clear --no-warmup
bin/console eccube:plugin:install --code=${PLUGIN_CODE} --path=${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz
bin/console eccube:plugin:enable --code=${PLUGIN_CODE}
bin/console cache:clear --no-warmup
- name: Run PHPUnit
env:
APP_ENV: 'test'
APP_DEBUG: 0
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
DATABASE_CHARSET: ${{ matrix.database_charset }}
PLUGIN_CODE: ${{ matrix.plugin_code }}
working-directory: 'ec-cube'
run: |
# 有効化したプラグインのルーティングはコンテナのコンパイル時に確定する。
# phpunit プロセスでの遅延コンパイルに任せると DB/タイミングで有効プラグイン一覧を
# 取りこぼし RouteNotFound になることがあるため、クリーンなプロセスで warmup して確定させる。
bin/console cache:clear --no-warmup
bin/console cache:warmup
./vendor/bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests

- name: Disable Plugin
working-directory: 'ec-cube'
env:
Expand All @@ -159,7 +146,6 @@ jobs:
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
DATABASE_CHARSET: ${{ matrix.database_charset }}
PLUGIN_CODE: ${{ matrix.plugin_code }}
ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080'
run: bin/console eccube:plugin:disable --code=${PLUGIN_CODE}

- name: Uninstall Plugin
Expand All @@ -170,6 +156,79 @@ jobs:
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
DATABASE_CHARSET: ${{ matrix.database_charset }}
PLUGIN_CODE: ${{ matrix.plugin_code }}
ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080'
working-directory: 'ec-cube'
run: bin/console eccube:plugin:uninstall --code=${PLUGIN_CODE}

static-analysis:
name: Static Analysis
runs-on: ubuntu-24.04
# 静的解析は DB 種別に依存しないため、SQLite 1 構成で一度だけ実行する。
# (php-cs-fixer / rector は DB 不要だが、phpstan は objectManagerLoader が
# カーネルを起動し EccubeExtension が dtb_plugin を読むため本体+DBが必要)
env:
PLUGIN_CODE: TwoFactorAuthCustomer44
APP_ENV: 'test'
APP_DEBUG: 0
DATABASE_URL: 'sqlite:///var/eccube.db'
DATABASE_SERVER_VERSION: 3
DATABASE_CHARSET: 'utf8'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: nanasess/setup-php@master
with:
php-version: '8.5'

- name: Archive Plugin
run: |
tar cvzf ${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz ./*
- name: Checkout EC-CUBE
uses: actions/checkout@v4
with:
repository: 'EC-CUBE/ec-cube'
ref: '4.4'
path: 'ec-cube'

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install to composer
working-directory: 'ec-cube'
run: composer install --no-interaction -o --apcu-autoloader --ignore-platform-req=ext-redis

- name: Setup EC-CUBE
working-directory: 'ec-cube'
run: |
bin/console doctrine:database:create
bin/console doctrine:schema:create
# プラグイン有効化時に DeviceType 等のマスタデータを参照するため fixtures を投入する
bin/console eccube:fixtures:load
- name: Setup Plugin
working-directory: 'ec-cube'
run: |
bin/console eccube:plugin:install --code=${PLUGIN_CODE} --path=${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz
bin/console eccube:plugin:enable --code=${PLUGIN_CODE}
bin/console cache:clear --no-warmup

- name: Run php-cs-fixer
working-directory: 'ec-cube'
run: ./vendor/bin/php-cs-fixer fix --config=app/Plugin/${PLUGIN_CODE}/Resource/.php-cs-fixer.dist.php --dry-run --diff

- name: Run Rector
working-directory: 'ec-cube'
run: ./vendor/bin/rector process --config=app/Plugin/${PLUGIN_CODE}/Resource/rector.php --dry-run

- name: Run PHPStan
working-directory: 'ec-cube'
run: |
bin/console cache:clear --no-warmup
./vendor/bin/phpstan analyse -c app/Plugin/${PLUGIN_CODE}/phpstan.neon.dist --no-progress
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Packaging
working-directory: ../
run: |
rm -rf $GITHUB_WORKSPACE/.github
# 開発・テスト用ファイルは配布パッケージに含めない
rm -rf $GITHUB_WORKSPACE/docker-compose*.yml $GITHUB_WORKSPACE/dockerbuild
rm -rf $GITHUB_WORKSPACE/doc
rm -f $GITHUB_WORKSPACE/CLAUDE.md $GITHUB_WORKSPACE/phpstan.neon.dist
rm -f $GITHUB_WORKSPACE/Resource/rector.php "$GITHUB_WORKSPACE/Resource/.php-cs-fixer.dist.php"
find $GITHUB_WORKSPACE -name "dummy" -delete
find $GITHUB_WORKSPACE -name ".git*" -and ! -name ".gitkeep" -print0 | xargs -0 rm -rf
chmod -R o+w $GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE
tar cvzf ../${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.tar.gz ./*
- name: Upload binaries to release of TGZ
uses: svenstaro/upload-release-action@v2
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ runner.workspace }}/${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.tar.gz
Expand Down
32 changes: 13 additions & 19 deletions Controller/Admin/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,36 @@
* file that was distributed with this source code.
*/

namespace Plugin\TwoFactorAuthCustomer42\Controller\Admin;
namespace Plugin\TwoFactorAuthCustomer44\Controller\Admin;

use Eccube\Controller\AbstractController;
use Plugin\TwoFactorAuthCustomer42\Form\Type\TwoFactorAuthConfigType;
use Plugin\TwoFactorAuthCustomer42\Repository\TwoFactorAuthConfigRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Plugin\TwoFactorAuthCustomer44\Form\Type\TwoFactorAuthConfigType;
use Plugin\TwoFactorAuthCustomer44\Repository\TwoFactorAuthConfigRepository;
use Symfony\Bridge\Twig\Attribute\Template;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

/**
* Class SmsController
* Class ConfigController
*/
class ConfigController extends AbstractController
{
/**
* @var TwoFactorAuthConfigRepository
*/
private $smsConfigRepository;

/**
* ConfigController constructor.
*/
public function __construct(TwoFactorAuthConfigRepository $smsConfigRepository)
{
$this->smsConfigRepository = $smsConfigRepository;
public function __construct(
private readonly TwoFactorAuthConfigRepository $smsConfigRepository,
) {
}

/**
* @Route("/%eccube_admin_route%/two_factor_auth_customer42/config", name="two_factor_auth_customer42_admin_config", methods={"GET", "POST"})
* @Template("TwoFactorAuthCustomer42/Resource/template/admin/config.twig")
*
* @param Request $request
*
* @return RedirectResponse|array
*/
#[Route(path: '/%eccube_admin_route%/two_factor_auth_customer44/config', name: 'two_factor_auth_customer44_admin_config', methods: ['GET', 'POST'])]
#[Template('@TwoFactorAuthCustomer44/admin/config.twig')]
public function index(Request $request)
{
// 設定情報、フォーム情報を取得
Expand All @@ -72,14 +66,14 @@ public function index(Request $request)

// フォームの入力データを保存
$this->entityManager->persist($SmsConfig);
$this->entityManager->flush($SmsConfig);
$this->entityManager->flush();

// 完了メッセージを表示
log_info('config', ['status' => 'Success']);
$this->addSuccess('プラグインの設定を保存しました。', 'admin');

// 設定画面にリダイレクト
return $this->redirectToRoute('two_factor_auth_customer42_admin_config');
return $this->redirectToRoute('two_factor_auth_customer44_admin_config');
}

return [
Expand Down
Loading
Loading