From cf44305fc56195309d13043b61337de80ad85a68 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 7 Dec 2020 17:38:53 +0900 Subject: [PATCH 1/8] Fix composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 0b264db..0782df0 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,10 @@ { - "name": "ec-cube/Recommend4", + "name": "ec-cube/recommend4", "version": "4.0.0", "description": "おすすめ商品管理プラグイン", "type": "eccube-plugin", "require": { - "ec-cube/plugin-installer": "~0.0.4" + "ec-cube/plugin-installer": "~0.0.6 || ^2.0@dev" }, "extra": { "code": "Recommend4" From 1da39449042ae3b9b8af80741d5b1abd04f759cd Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 7 Dec 2020 17:57:41 +0900 Subject: [PATCH 2/8] Fix compatiblity to Symfony4.4 --- Controller/RecommendSearchModelController.php | 5 +++-- PluginManager.php | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Controller/RecommendSearchModelController.php b/Controller/RecommendSearchModelController.php index ee896ac..b88fe90 100644 --- a/Controller/RecommendSearchModelController.php +++ b/Controller/RecommendSearchModelController.php @@ -17,11 +17,12 @@ use Eccube\Controller\AbstractController; use Eccube\Repository\CategoryRepository; use Eccube\Repository\ProductRepository; -use Knp\Component\Pager\Paginator; +use Knp\Component\Pager\PaginatorInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; + /** * Class RecommendSearchModelController. */ @@ -60,7 +61,7 @@ public function __construct(CategoryRepository $categoryRepository, ProductRepos * @Route("/%eccube_admin_route%/plugin/recommend/search/product/page/{page_no}", requirements={"page_no" = "\d+"}, name="plugin_recommend_search_product_page") * @Template("@Recommend4/admin/search_product.twig") */ - public function searchProduct(Request $request, $page_no = null, Paginator $paginator) + public function searchProduct(Request $request, $page_no = null, PaginatorInterface $paginator) { if (!$request->isXmlHttpRequest()) { return []; diff --git a/PluginManager.php b/PluginManager.php index 175fc1c..c455e52 100644 --- a/PluginManager.php +++ b/PluginManager.php @@ -77,8 +77,9 @@ public function uninstall(array $meta, ContainerInterface $container) */ public function enable(array $meta = null, ContainerInterface $container) { + $entityManager = $container->get('doctrine')->getManager(); $this->copyBlock($container); - $Block = $container->get(BlockRepository::class)->findOneBy(['file_name' => $this->blockFileName]); + $Block = $entityManager->getRepository(Block::class)->findOneBy(['file_name' => $this->blockFileName]); if (is_null($Block)) { // pagelayoutの作成 $this->createDataBlock($container); @@ -112,12 +113,12 @@ public function update(array $meta = null, ContainerInterface $container) */ private function createDataBlock(ContainerInterface $container) { - $em = $container->get('doctrine.orm.entity_manager'); - $DeviceType = $container->get(DeviceTypeRepository::class)->find(DeviceType::DEVICE_TYPE_PC); + $em = $container->get('doctrine')->getManager(); + $DeviceType = $em->getRepository(DeviceType::class)->find(DeviceType::DEVICE_TYPE_PC); try { /** @var Block $Block */ - $Block = $container->get(BlockRepository::class)->newBlock($DeviceType); + $Block = $em->getRepository(Block::class)->newBlock($DeviceType); // Blockの登録 $Block->setName($this->blockName) @@ -128,13 +129,13 @@ private function createDataBlock(ContainerInterface $container) $em->flush($Block); // check exists block position - $blockPos = $container->get(BlockPositionRepository::class)->findOneBy(['Block' => $Block]); + $blockPos = $em->getRepository(BlockPosition::class)->findOneBy(['Block' => $Block]); if ($blockPos) { return; } // BlockPositionの登録 - $blockPos = $container->get(BlockPositionRepository::class)->findOneBy( + $blockPos = $em->getRepository(BlockPosition::class)->findOneBy( ['section' => Layout::TARGET_ID_MAIN_BOTTOM, 'layout_id' => Layout::DEFAULT_LAYOUT_UNDERLAYER_PAGE], ['block_row' => 'DESC'] ); @@ -148,7 +149,7 @@ private function createDataBlock(ContainerInterface $container) $BlockPosition->setBlockRow($blockRow); } - $LayoutDefault = $container->get(LayoutRepository::class)->find(Layout::DEFAULT_LAYOUT_UNDERLAYER_PAGE); + $LayoutDefault = $em->getRepository(Layout::class)->find(Layout::DEFAULT_LAYOUT_UNDERLAYER_PAGE); $BlockPosition->setLayout($LayoutDefault) ->setLayoutId($LayoutDefault->getId()) @@ -172,15 +173,15 @@ private function createDataBlock(ContainerInterface $container) */ private function removeDataBlock(ContainerInterface $container) { + $em = $container->get('doctrine')->getManager(); // Blockの取得(file_nameはアプリケーションの仕組み上必ずユニーク) /** @var \Eccube\Entity\Block $Block */ - $Block = $container->get(BlockRepository::class)->findOneBy(['file_name' => $this->blockFileName]); + $Block = $em->getRepository(Block::class)->findOneBy(['file_name' => $this->blockFileName]); if (!$Block) { return; } - $em = $container->get('doctrine.orm.entity_manager'); try { // BlockPositionの削除 $blockPositions = $Block->getBlockPositions(); From dc633544aedba81faf8a4d04ac76a9c2338c0111 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 7 Dec 2020 18:03:43 +0900 Subject: [PATCH 3/8] Fix testcase --- .travis.yml | 21 ++++++++++++++++---- Tests/Repository/RecommendRepositoryTest.php | 6 ++++-- Tests/Web/RecommendAdminControllerTest.php | 8 +++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2ba3507..689f89e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,9 @@ env: - ECCUBE_VERSION=4.0.2 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - ECCUBE_VERSION=4.0.3 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - ECCUBE_VERSION=4.0.3 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 + - ECCUBE_VERSION=4.1 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 + - ECCUBE_VERSION=4.1 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 + matrix: exclude: - php: 7.3 @@ -74,12 +77,13 @@ before_install: &php_setup | echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini install_eccube: &install_eccube | + sh -c "if [ ! '${ECCUBE_VERSION}' = '4.1' ]; then composer selfupdate --1; fi" + sh -c "if [ '${ECCUBE_VERSION}' = '4.1' ]; then composer selfupdate; fi" tar cvzf ${HOME}/${PLUGIN_CODE}.tar.gz ./* git clone https://github.com/EC-CUBE/ec-cube.git cd ec-cube - sh -c "if [ '${ECCUBE_VERSION}' = '4.0' ]; then git checkout origin/${ECCUBE_VERSION}; fi" + sh -c "if [ '${ECCUBE_VERSION}' = '4.0' ] || [ '${ECCUBE_VERSION}' = '4.1' ]; then git checkout origin/${ECCUBE_VERSION}; fi" sh -c "if [ ! '${ECCUBE_VERSION}' = '4.0' ]; then git checkout refs/tags/${ECCUBE_VERSION}; fi" - composer selfupdate composer install --dev --no-interaction -o --apcu-autoloader eccube_setup: &eccube_setup | @@ -93,9 +97,18 @@ eccube_setup: &eccube_setup | install: - *install_eccube - *eccube_setup + - composer require --dev kiy0taka/eccube4-test-fixer -script: - - ./vendor/bin/phpunit app/Plugin/${PLUGIN_CODE}/Tests; +script: | + if [[ ! $ECCUBE_VERSION = '4.1' ]] + then + find app/Plugin/${PLUGIN_CODE}/Tests -name "*Test.php" | while read TESTCASE + do + ./vendor/bin/phpunit --include-path vendor/kiy0taka/eccube4-test-fixer/src --loader 'Eccube\PHPUnit\Loader\Eccube4CompatTestSuiteLoader' ${TESTCASE} + done + else + ./vendor/bin/phpunit app/Plugin/${PLUGIN_CODE}/Tests + fi after_script: # disable plugin diff --git a/Tests/Repository/RecommendRepositoryTest.php b/Tests/Repository/RecommendRepositoryTest.php index 1b25b9d..fc8cfa6 100644 --- a/Tests/Repository/RecommendRepositoryTest.php +++ b/Tests/Repository/RecommendRepositoryTest.php @@ -13,11 +13,13 @@ namespace Plugin\Recommend4\Tests\Repository; +use Eccube\Entity\Product; use Eccube\Repository\ProductRepository; use Eccube\Tests\Web\Admin\AbstractAdminWebTestCase; use Plugin\Recommend4\Entity\RecommendProduct; use Plugin\Recommend4\Repository\RecommendProductRepository; + /** * Class RecommendRepositoryTest. */ @@ -50,8 +52,8 @@ public function setUp() { parent::setUp(); $this->deleteAllRows(['plg_recommend_product']); - $this->recommendProductRepository = $this->container->get(RecommendProductRepository::class); - $this->productRepository = $this->container->get(ProductRepository::class); + $this->recommendProductRepository = $this->entityManager->getRepository(RecommendProduct::class); + $this->productRepository = $this->entityManager->getRepository(Product::class); // recommend for product 1 with rank 1 $this->Recommend = $this->initRecommendData(1, 1); diff --git a/Tests/Web/RecommendAdminControllerTest.php b/Tests/Web/RecommendAdminControllerTest.php index b060a43..8084c3f 100644 --- a/Tests/Web/RecommendAdminControllerTest.php +++ b/Tests/Web/RecommendAdminControllerTest.php @@ -19,8 +19,10 @@ use Eccube\Repository\Master\ProductStatusRepository; use Eccube\Repository\ProductRepository; use Eccube\Tests\Web\Admin\AbstractAdminWebTestCase; +use Plugin\Recommend4\Entity\RecommendProduct; use Plugin\Recommend4\Repository\RecommendProductRepository; + /** * Class RecommendAdminControllerTest. */ @@ -46,8 +48,8 @@ public function setUp() parent::setUp(); $this->deleteAllRows(['plg_recommend_product']); - $this->productRepo = $this->container->get(ProductRepository::class); - $this->recommendProductRepository = $this->container->get(RecommendProductRepository::class); + $this->productRepo = $this->entityManager->getRepository(Product::class); + $this->recommendProductRepository = $this->entityManager->getRepository(RecommendProduct::class); // recommend for product 1 with rank 1 $this->Recommend1 = $this->initRecommendData(1, 1); @@ -225,7 +227,7 @@ public function testAjaxSearchUnpublicProduct() { /** @var Product $Product */ $Product = $this->productRepo->findOneBy(['name' => '彩のジェラートCUBE']); - $Product->setStatus($this->container->get(ProductStatusRepository::class)->find(ProductStatus::DISPLAY_HIDE)); + $Product->setStatus($this->entityManager->getRepository(ProductStatus::class)->find(ProductStatus::DISPLAY_HIDE)); $this->entityManager->persist($Product); $this->entityManager->flush($Product); From 68761de658cf9770e36bf9905254f275cf0e40cc Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 2 Aug 2021 14:32:59 +0900 Subject: [PATCH 4/8] Add GitHub Actions --- .github/workflows/main.yml | 177 +++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ceca945 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,177 @@ +name: CI for Recommend4 +on: + push: + branches: + - '*' + tags: + - '*' + paths: + - '**' + - '!*.md' + pull_request: + branches: + - '*' + paths: + - '**' + - '!*.md' +jobs: + run-on-linux: + name: Run on Linux + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ ubuntu-18.04 ] + php: [ '7.1', '7.2', '7.3', '7.4' ] + db: [ mysql, pgsql ] + eccube_version: [ '4.0.6-p1', '4.1' ] + plugin_code: [ 'Recommend4' ] + include: + - eccube_version: '4.0.6-p1' + composer: 'v1' + - eccube_version: '4.1' + composer: 'v2' + - db: mysql + dbport: '3306' + dbuser: 'root' + dbpass: 'root' + dbname: 'myapp_test' + dbversion: 5.7 + - db: pgsql + dbport: '5432' + dbuser: 'postgres' + dbpass: 'password' + dbname: 'myapp_test' + dbversion: 9.5 + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: ${{ matrix.dbname }} + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + postgres: + image: postgres:9.5 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: ${{ matrix.dbname }} + ports: + - 5432:5432 + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + mailcatcher: + image: schickling/mailcatcher + ports: + - 1080:1080 + - 1025:1025 + steps: + - run: sudo apt-get purge -y hhvm + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: nanasess/setup-php@master + with: + php-version: ${{ matrix.php }} + + - name: Archive Plugin + env: + PLUGIN_CODE: ${{ matrix.plugin_code }} + run: | + tar cvzf ${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz ./* + - name: Checkout EC-CUBE + uses: actions/checkout@v2 + with: + repository: 'EC-CUBE/ec-cube' + ref: ${{ matrix.eccube_version }} + path: 'ec-cube' + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - if: matrix.composer == 'v1' + run: sudo composer selfupdate --1 + + - name: Install to composer + working-directory: 'ec-cube' + run: composer install --no-interaction -o --apcu-autoloader + + - if: matrix.composer == 'v1' + working-directory: 'ec-cube' + run: composer require kiy0taka/eccube4-test-fixer "dev-main@dev" + + - name: Setup EC-CUBE + env: + DB: ${{ matrix.db }} + USER: ${{ matrix.dbuser }} + DBUSER: ${{ matrix.dbuser }} + DBPASS: ${{ matrix.dbpass }} + DBNAME: ${{ matrix.dbname }} + DBPORT: ${{ matrix.dbport }} + DBSERVER: 127.0.0.1 + DBVERSION: ${{ matrix.dbversion }} + ROOT_URLPATH: /ec-cube/html + working-directory: 'ec-cube' + run: | + export PGPASSWORD=${DBPASS} + echo "APP_ENV=prod" > .env + echo "APP_DEBUG=0" >> .env + echo "DATABASE_URL=${DB}://${DBUSER}:${DBPASS}@${DBSERVER}/${DBNAME}" >> .env + echo "DATABASE_SERVER_VERSION=${DBVERSION}" >> .env + echo "MAILER_URL=null://localhost" >> .env + echo "HTTP_SITEURL=https://localhost" >> .env + echo "USE_SELFSIGNED_SSL_CERTIFICATE=1" >> .env + cat .env + bin/console doctrine:schema:create + bin/console eccube:fixtures:load + + - name: Setup Plugin + env: + PLUGIN_CODE: ${{ matrix.plugin_code }} + 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} + rm codeception/_support/*Tester.php + + - name: Run PHPUnit + if: matrix.composer == 'v2' + env: + PLUGIN_CODE: ${{ matrix.plugin_code }} + working-directory: 'ec-cube' + run: bin/phpunit app/Plugin/${PLUGIN_CODE}/Tests + + - name: Run PHPUnit + if: matrix.composer == 'v1' + env: + PLUGIN_CODE: ${{ matrix.plugin_code }} + working-directory: 'ec-cube' + run: | + find app/Plugin/${PLUGIN_CODE}/Tests -name "*Test.php" | while read TESTCASE + do + ./vendor/bin/phpunit --include-path vendor/kiy0taka/eccube4-test-fixer/src --loader 'Eccube\PHPUnit\Loader\Eccube4CompatTestSuiteLoader' ${TESTCASE} + done + + - name: Disable Plugin + working-directory: 'ec-cube' + env: + PLUGIN_CODE: ${{ matrix.plugin_code }} + run: bin/console eccube:plugin:disable --code=${PLUGIN_CODE} + + - name: Uninstall Plugin + env: + PLUGIN_CODE: ${{ matrix.plugin_code }} + working-directory: 'ec-cube' + run: bin/console eccube:plugin:uninstall --code=${PLUGIN_CODE} From 8c9862dba6ba77efdb6c956bd9c6d956a706826a Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 2 Aug 2021 16:34:51 +0900 Subject: [PATCH 5/8] Bump version --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 0782df0..9fa1b43 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,10 @@ { "name": "ec-cube/recommend4", - "version": "4.0.0", + "version": "4.1.0", "description": "おすすめ商品管理プラグイン", "type": "eccube-plugin", "require": { - "ec-cube/plugin-installer": "~0.0.6 || ^2.0@dev" + "ec-cube/plugin-installer": "~0.0.6 || ^2.0" }, "extra": { "code": "Recommend4" From dcfb2f7689cdc8ff115d2208ae8bb487c59e4ee4 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 2 Aug 2021 16:36:50 +0900 Subject: [PATCH 6/8] Remove --- .travis.yml | 149 --------------------------------------------------- appveyor.yml | 84 ----------------------------- 2 files changed, 233 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 689f89e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,149 +0,0 @@ -language: php - -dist: xenial - -services: - - mysql - - postgresql - -cache: - directories: - - vendor - - $HOME/.composer/cache - - bin/.phpunit - -php: - - 7.1 - - 7.2 - - 7.3 - - 7.4 - -env: - global: - PLUGIN_CODE=Recommend4 - matrix: - - ECCUBE_VERSION=4.0 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - ECCUBE_VERSION=4.0 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - ECCUBE_VERSION=4.0.0 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - ECCUBE_VERSION=4.0.0 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - ECCUBE_VERSION=4.0.1 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - ECCUBE_VERSION=4.0.1 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - ECCUBE_VERSION=4.0.2 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - ECCUBE_VERSION=4.0.2 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - ECCUBE_VERSION=4.0.3 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - ECCUBE_VERSION=4.0.3 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - ECCUBE_VERSION=4.1 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - ECCUBE_VERSION=4.1 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - -matrix: - exclude: - - php: 7.3 - env: ECCUBE_VERSION=4.0.0 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - php: 7.3 - env: ECCUBE_VERSION=4.0.0 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - php: 7.3 - env: ECCUBE_VERSION=4.0.1 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - php: 7.3 - env: ECCUBE_VERSION=4.0.1 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - php: 7.3 - env: ECCUBE_VERSION=4.0.2 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - php: 7.3 - env: ECCUBE_VERSION=4.0.2 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - php: 7.3 - env: ECCUBE_VERSION=4.0.3 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - php: 7.3 - env: ECCUBE_VERSION=4.0.3 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - php: 7.4 - env: ECCUBE_VERSION=4.0.0 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - php: 7.4 - env: ECCUBE_VERSION=4.0.0 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - php: 7.4 - env: ECCUBE_VERSION=4.0.1 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - php: 7.4 - env: ECCUBE_VERSION=4.0.1 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - php: 7.4 - env: ECCUBE_VERSION=4.0.2 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - php: 7.4 - env: ECCUBE_VERSION=4.0.2 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - - php: 7.4 - env: ECCUBE_VERSION=4.0.3 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5 - - php: 7.4 - env: ECCUBE_VERSION=4.0.3 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - -before_install: &php_setup | - phpenv config-rm xdebug.ini || true - echo "opcache.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - echo "apc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - -install_eccube: &install_eccube | - sh -c "if [ ! '${ECCUBE_VERSION}' = '4.1' ]; then composer selfupdate --1; fi" - sh -c "if [ '${ECCUBE_VERSION}' = '4.1' ]; then composer selfupdate; fi" - tar cvzf ${HOME}/${PLUGIN_CODE}.tar.gz ./* - git clone https://github.com/EC-CUBE/ec-cube.git - cd ec-cube - sh -c "if [ '${ECCUBE_VERSION}' = '4.0' ] || [ '${ECCUBE_VERSION}' = '4.1' ]; then git checkout origin/${ECCUBE_VERSION}; fi" - sh -c "if [ ! '${ECCUBE_VERSION}' = '4.0' ]; then git checkout refs/tags/${ECCUBE_VERSION}; fi" - composer install --dev --no-interaction -o --apcu-autoloader - -eccube_setup: &eccube_setup | - echo "APP_ENV=test" > .env - bin/console doctrine:database:create - bin/console doctrine:schema:create - bin/console eccube:fixtures:load - bin/console eccube:plugin:install --path=${HOME}/${PLUGIN_CODE}.tar.gz - bin/console eccube:plugin:enable --code=${PLUGIN_CODE} - -install: - - *install_eccube - - *eccube_setup - - composer require --dev kiy0taka/eccube4-test-fixer - -script: | - if [[ ! $ECCUBE_VERSION = '4.1' ]] - then - find app/Plugin/${PLUGIN_CODE}/Tests -name "*Test.php" | while read TESTCASE - do - ./vendor/bin/phpunit --include-path vendor/kiy0taka/eccube4-test-fixer/src --loader 'Eccube\PHPUnit\Loader\Eccube4CompatTestSuiteLoader' ${TESTCASE} - done - else - ./vendor/bin/phpunit app/Plugin/${PLUGIN_CODE}/Tests - fi - -after_script: - # disable plugin - - bin/console eccube:plugin:disable --code=${PLUGIN_CODE} - # uninstall plugin - - bin/console eccube:plugin:uninstall --code=${PLUGIN_CODE} - # re install plugin - - bin/console eccube:plugin:install --code=${PLUGIN_CODE} - # re enable plugin - - bin/console eccube:plugin:enable --code=${PLUGIN_CODE} - -jobs: - fast_finish: true - include: - - stage: Inspection - php: 7.2 - env: DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 - install: - - *install_eccube - - *eccube_setup - script: vendor/bin/php-cs-fixer fix --config=.php_cs.dist --dry-run --verbose app/Plugin/${PLUGIN_CODE} - - &coverage - stage: Code Coverage - php: 7.2 - env: DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9 COVERAGE=1 - before_install: - - *php_setup - - gem install mime-types -v 2.99.1 - - gem install mailcatcher - install: - - *install_eccube - - *eccube_setup - # mail catcher - - mailcatcher - script: - - phpdbg -qrr ./vendor/bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist --coverage-clover=coverage.clover - after_success: - - php vendor/bin/php-coveralls -v -x coverage.clover diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 0a71075..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,84 +0,0 @@ -# appveyor file -# http://www.appveyor.com/docs/appveyor-yml - -# Set build version format here instead of in the admin panel. -version: 4.0.x-{build} - -cache: - - '%LOCALAPPDATA%\Composer\files' - - vendor - - bin\.phpunit - - C:\ProgramData\chocolatey\bin -> appveyor.yml - - C:\ProgramData\chocolatey\lib -> appveyor.yml - -# Fix line endings in Windows. (runs before repo cloning) -init: - - git config --global core.autocrlf input - -environment: - global: - DATABASE_URL: "mysql://root:Password12!@localhost/myapp_test" - DATABASE_SERVER_VERSION: "5" - BASE_DIR: "C:/projects/ec-cube" - PLUGIN_BASE_DIR: "%APPVEYOR_BUILD_FOLDER%" - ECCUBE_VERSION: "4.0" - BRANCH: "4.0" - PLUGIN_CODE: "Recommend4" - matrix: - - db: mysql - provider: mysql - -services: - - mysql - -# Install scripts. (runs after repo cloning) -install: - - cd %PLUGIN_BASE_DIR% - - git archive -o %PLUGIN_CODE%.tar.gz HEAD - - - git clone https://github.com/EC-CUBE/ec-cube.git %BASE_DIR% - - cd %BASE_DIR% - - git checkout origin/%BRANCH% - # see https://github.com/phpmd/phpmd/blob/master/appveyor.yml#L10-L13 - - cinst -y OpenSSL.Light --version 1.1.1 --force - - SET PATH=C:\Program Files\OpenSSL;%PATH% - - sc config wuauserv start= auto - - net start wuauserv - # Set MySQL. - - cp tests/my.cnf c:\ - - SET PATH=C:\Program Files\MySql\MySQL Server 5.7\bin\;%PATH% - #- cinst mysql - #- SET PATH=C:\tools\mysql\current\bin\;%PATH% - # Set PHP. - - cinst php --version 7.2.15 --allow-empty-checksums --force - - SET PATH=C:\tools\php72\;%PATH% - - copy C:\tools\php72\php.ini-production C:\tools\php72\php.ini - - echo date.timezone="Asia/Tokyo" >> C:\tools\php72\php.ini - - echo extension_dir=ext >> C:\tools\php72\php.ini - - echo extension=php_gd2.dll >> C:\tools\php72\php.ini - - echo extension=php_mbstring.dll >> C:\tools\php72\php.ini - - echo extension=php_pgsql.dll >> C:\tools\php72\php.ini - - echo extension=php_pdo_mysql.dll >> C:\tools\php72\php.ini - - echo extension=php_pdo_pgsql.dll >> C:\tools\php72\php.ini - - echo extension=php_curl.dll >> C:\tools\php72\php.ini - - echo extension=php_fileinfo.dll >> C:\tools\php72\php.ini - - echo extension=php_intl.dll >> C:\tools\php72\php.ini - - echo extension=php_openssl.dll >> C:\tools\php72\php.ini - - echo memory_limit = 512M >> C:\tools\php72\php.ini - - echo APP_ENV=codeception >> .env - - php -r "readfile('http://getcomposer.org/installer');" | php - - php composer.phar install --dev --no-interaction -o - -# Don't actually build. -build: off - -before_test: - - php bin\console doctrine:database:create - - php bin\console doctrine:schema:create - - php bin\console eccube:fixtures:load - - php bin\console eccube:plugin:install --path=%PLUGIN_BASE_DIR%/%PLUGIN_CODE%.tar.gz - # enable plugin - - php bin\console eccube:plugin:enable --code=%PLUGIN_CODE% - -test_script: - - php bin\phpunit app/Plugin/%PLUGIN_CODE%/Tests From 985db1a51292c5d636277478d0d86626981a4e3a Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 2 Aug 2021 16:37:48 +0900 Subject: [PATCH 7/8] Fix badge --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 19d565d..d3544b9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ # おすすめ商品管理プラグイン -[![Build Status](https://travis-ci.org/EC-CUBE/Recommend-plugin.svg?branch=master)](https://travis-ci.org/EC-CUBE/Recommend-plugin) -[![Build status](https://ci.appveyor.com/api/projects/status/pql8xjdrsmp24teg?svg=true)](https://ci.appveyor.com/project/ECCUBE/recommend-plugin) +[![CI for Recommend4](https://github.com/EC-CUBE/Recommend-plugin/actions/workflows/main.yml/badge.svg)](https://github.com/EC-CUBE/Recommend-plugin/actions/workflows/main.yml) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/10c271df-67d7-415d-9dad-6ef44e09741c/mini.png)](https://insight.sensiolabs.com/projects/10c271df-67d7-415d-9dad-6ef44e09741c) -[![Coverage Status](https://coveralls.io/repos/github/EC-CUBE/Recommend-plugin/badge.svg)](https://coveralls.io/github/EC-CUBE/Recommend-plugin) ## 概要 サイトにおすすめ商品の一覧を追加することのできるプラグイン。 From b62113d8def3e0aad2133e55d233fd98d3bc60dd Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 2 Aug 2021 17:07:59 +0900 Subject: [PATCH 8/8] Add coverage --- .github/workflows/coverage.yml | 150 +++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..3b73b2c --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,150 @@ +name: Coverage +on: + push: + branches: + - '*' + tags: + - '*' + paths: + - '**' + - '!*.md' + pull_request: + branches: + - '*' + paths: + - '**' + - '!*.md' +jobs: + phpunit: + name: Run on Linux + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ ubuntu-18.04 ] + php: [ '7.4' ] + db: [ pgsql ] + eccube_version: [ '4.1' ] + plugin_code: [ 'Recommend4' ] + include: + - db: pgsql + dbport: '5432' + dbuser: 'postgres' + dbpass: 'password' + dbname: 'myapp_test' + dbversion: 9.5 + services: + postgres: + image: postgres:9.5 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: ${{ matrix.dbname }} + ports: + - 5432:5432 + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + mailcatcher: + image: schickling/mailcatcher + ports: + - 1080:1080 + - 1025:1025 + steps: + - run: sudo apt-get purge -y hhvm + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: nanasess/setup-php@master + with: + php-version: ${{ matrix.php }} + + - name: Archive Plugin + env: + PLUGIN_CODE: ${{ matrix.plugin_code }} + run: | + tar cvzf ${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz ./* + - name: Checkout EC-CUBE + uses: actions/checkout@v2 + with: + repository: 'EC-CUBE/ec-cube' + ref: ${{ matrix.eccube_version }} + path: 'ec-cube' + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - uses: actions/cache@v1 + 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 + + - name: Setup EC-CUBE + env: + DB: ${{ matrix.db }} + USER: ${{ matrix.dbuser }} + DBUSER: ${{ matrix.dbuser }} + DBPASS: ${{ matrix.dbpass }} + DBNAME: ${{ matrix.dbname }} + DBPORT: ${{ matrix.dbport }} + DBSERVER: 127.0.0.1 + DBVERSION: ${{ matrix.dbversion }} + ROOT_URLPATH: /ec-cube/html + working-directory: 'ec-cube' + run: | + export PGPASSWORD=${DBPASS} + echo "APP_ENV=prod" > .env + echo "APP_DEBUG=0" >> .env + echo "DATABASE_URL=${DB}://${DBUSER}:${DBPASS}@${DBSERVER}/${DBNAME}" >> .env + echo "DATABASE_SERVER_VERSION=${DBVERSION}" >> .env + echo "MAILER_URL=null://localhost" >> .env + echo "HTTP_SITEURL=https://localhost" >> .env + echo "USE_SELFSIGNED_SSL_CERTIFICATE=1" >> .env + cat .env + bin/console doctrine:schema:create + bin/console eccube:fixtures:load + + - name: Setup Plugin + env: + PLUGIN_CODE: ${{ matrix.plugin_code }} + 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} + rm codeception/_support/*Tester.php + + - name: Run PHPUnit + env: + PLUGIN_CODE: ${{ matrix.plugin_code }} + working-directory: 'ec-cube' + run: phpdbg -dmemory_limit=-1 -qrr bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests --coverage-clover=coverage1.xml + - name: Upload report + if: success() + uses: actions/upload-artifact@v2 + with: + name: phpunit-reports + path: ec-cube/coverage1.xml + upload: + name: Upload coverage reports + runs-on: ubuntu-latest + needs: [ phpunit ] + steps: + - name: Checkout + uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + path: reports + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + files: ./reports/phpunit-reports/coverage1.xml + flags: tests + fail_ci_if_error: true