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
193 changes: 153 additions & 40 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI for TwoFactorAuthCustomerSms42
name: CI for TwoFactorAuthCustomerSms44
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: [ 'TwoFactorAuthCustomerSms42' ]
eccube_version: [ '4.4' ]
php: [ '8.2', '8.3', '8.4', '8.5' ]
db: [ 'mysql8', 'pgsql' ]
plugin_code: [ 'TwoFactorAuthCustomerSms44' ]
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 @@ -97,26 +76,29 @@ jobs:
- name: Checkout Base Plugin
uses: actions/checkout@v4
with:
repository: 'EC-CUBE/TwoFactorAuthCustomer42'
path: 'TwoFactorAuthCustomer42'
# 親プラグイン PR が公式 4.4 にマージされるまで、パッケージ名 twofactorauthcustomer44 が入っている
# KenTanaka/TwoFactorAuthCustomer の feat-4.4 を参照する。マージ後は EC-CUBE/TwoFactorAuthCustomer42@4.4 に戻す。
repository: 'KenTanaka/TwoFactorAuthCustomer'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

親プラグインを個人 fork KenTanaka/TwoFactorAuthCustomer@feat-4.4 から取得しています。公式リポジトリの CI が個人リポジトリに依存しないよう、EC-CUBE/TwoFactorAuthCustomer42#59 のマージ後に EC-CUBE/TwoFactorAuthCustomer42 の 4.4 へ戻してからマージしてください(L232 の static-analysis も同様)。

ref: 'feat-4.4'
path: 'TwoFactorAuthCustomer44'

- name: Archive Base Plugin
working-directory: 'TwoFactorAuthCustomer42'
working-directory: 'TwoFactorAuthCustomer44'
run: |
tar cvzf ${GITHUB_WORKSPACE}/TwoFactorAuthCustomer42.tar.gz ./*
tar cvzf ${GITHUB_WORKSPACE}/TwoFactorAuthCustomer44.tar.gz ./*

- name: Setup mock-package-api
env:
PLUGIN_CODE: ${{ matrix.plugin_code }}
run: |
mkdir -p /tmp/repos
for f in ${PLUGIN_CODE} TwoFactorAuthCustomer42; do
for f in ${PLUGIN_CODE} TwoFactorAuthCustomer44; do
cp ${GITHUB_WORKSPACE}/${f}.tar.gz /tmp/repos/${f}.tgz
done
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 @@ -125,16 +107,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 @@ -160,10 +144,33 @@ jobs:
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 eccube:plugin:enable --code=TwoFactorAuthCustomer42
bin/console eccube:composer:require ec-cube/twofactorauthcustomersms42
bin/console eccube:composer:require ec-cube/twofactorauthcustomer44
bin/console cache:clear --no-warmup
bin/console eccube:plugin:enable --code=TwoFactorAuthCustomer44
bin/console eccube:composer:require ec-cube/twofactorauthcustomersms44
bin/console cache:clear --no-warmup
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 }}
ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080'
working-directory: 'ec-cube'
run: |
# 有効化したプラグインのルーティングはコンテナのコンパイル時に確定する。
# phpunit プロセスでの遅延コンパイルに任せると DB/タイミングで有効プラグイン一覧を
# 取りこぼし RouteNotFound になることがあるため、クリーンなプロセスで warmup して確定させる。
bin/console cache:clear --no-warmup
bin/console cache:warmup
if [ -d "app/Plugin/${PLUGIN_CODE}/Tests" ]; then
./vendor/bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests
fi

- name: Disable Plugin
working-directory: 'ec-cube'
Expand All @@ -188,3 +195,109 @@ jobs:
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: TwoFactorAuthCustomerSms44
PARENT_PLUGIN_CODE: TwoFactorAuthCustomer44
APP_ENV: 'test'
APP_DEBUG: 0
DATABASE_URL: 'sqlite:///var/eccube.db'
DATABASE_SERVER_VERSION: 3
DATABASE_CHARSET: 'utf8'
ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080'
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 Base Plugin
uses: actions/checkout@v4
with:
# 親プラグイン PR が公式 4.4 にマージされるまで、パッケージ名 twofactorauthcustomer44 が入っている
# KenTanaka/TwoFactorAuthCustomer の feat-4.4 を参照する。マージ後は EC-CUBE/TwoFactorAuthCustomer42@4.4 に戻す。
repository: 'KenTanaka/TwoFactorAuthCustomer'
ref: 'feat-4.4'
path: 'TwoFactorAuthCustomer44'

- name: Archive Base Plugin
working-directory: 'TwoFactorAuthCustomer44'
run: |
tar cvzf ${GITHUB_WORKSPACE}/TwoFactorAuthCustomer44.tar.gz ./*

- name: Setup mock-package-api
run: |
mkdir -p /tmp/repos
for f in ${PLUGIN_CODE} ${PARENT_PLUGIN_CODE}; do
cp ${GITHUB_WORKSPACE}/${f}.tar.gz /tmp/repos/${f}.tgz
done
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@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: |
# DBAL 4 の SQLite は doctrine:database:create 非対応(getCreateDatabaseSQL が削除済み)。
# 本体 InstallerCommand と同様、SQLite ではファイル作成をスキップし schema:create で用意する。
if [[ "${DATABASE_URL}" != sqlite* ]]; then
bin/console doctrine:database:create
fi
bin/console doctrine:schema:create
bin/console eccube:fixtures:load
- name: Setup Plugin
working-directory: 'ec-cube'
run: |
bin/console eccube:composer:require ec-cube/twofactorauthcustomer44
bin/console cache:clear --no-warmup
bin/console eccube:plugin:enable --code=TwoFactorAuthCustomer44
bin/console eccube:composer:require ec-cube/twofactorauthcustomersms44
bin/console cache:clear --no-warmup
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
Loading
Loading