From d79a94f6eee0c5f00dadafa4e07be181fc0ea1d0 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 13 Feb 2021 18:24:13 +0530 Subject: [PATCH 1/2] Fix tests failure on Cake 4.2. --- tests/TestCase/Validation/ValidatorTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/TestCase/Validation/ValidatorTest.php b/tests/TestCase/Validation/ValidatorTest.php index 8fb3336..1d61c45 100644 --- a/tests/TestCase/Validation/ValidatorTest.php +++ b/tests/TestCase/Validation/ValidatorTest.php @@ -25,17 +25,21 @@ public function setUp(): void Cache::clear('_cake_core_'); I18n::config('validation', function ($domain, $locale) { - return new \ADmad\I18n\I18n\DbMessagesLoader( + $loader = new \ADmad\I18n\I18n\DbMessagesLoader( $domain, $locale ); + + return $loader(); }); I18n::config('validation_non_default', function ($domain, $locale) { - return new \ADmad\I18n\I18n\DbMessagesLoader( + $loader = new \ADmad\I18n\I18n\DbMessagesLoader( $domain, $locale ); + + return $loader(); }); $I18nMessages = $this->getTableLocator()->get('I18nMessages'); From 50f43f1504323da2b3150ee5fe31578bca88a6a8 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 13 Feb 2021 18:36:20 +0530 Subject: [PATCH 2/2] Use GA workflow for CI --- .gitattributes | 1 + .github/workflows/ci.yml | 105 +++++++++++++++++++++++++++++++++++++++ README.md | 4 +- composer.json | 9 ---- 4 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.gitattributes b/.gitattributes index 2b61d82..e92883d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,3 +8,4 @@ tests export-ignore phpstan.neon export-ignore psalm.xml export-ignore psalm-baseline.xml export-ignore +.github export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fba4169 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,105 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + branches: + - '*' + +jobs: + testsuite: + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + php-version: ['7.2', '7.4', '8.0'] + db-type: [mysql, pgsql] + prefer-lowest: [''] + include: + - php-version: '7.2' + db-type: 'sqlite' + prefer-lowest: 'prefer-lowest' + + services: + postgres: + image: postgres + ports: + - 5432:5432 + env: + POSTGRES_PASSWORD: postgres + + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: Setup Service + if: matrix.db-type == 'mysql' + run: | + sudo service mysql start + mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;' + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, intl, pdo_${{ matrix.db-type }} + coverage: pcov + + - name: Composer install + run: | + composer --version + if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then + composer update --prefer-lowest --prefer-stable + else + composer install + fi + + - name: Run PHPUnit + run: | + if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi + if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi + if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:postgres@127.0.0.1/postgres'; fi + + if [[ ${{ matrix.php-version }} == '7.2' && ${{ matrix.db-type }} == 'mysql' ]]; then + vendor/bin/phpunit --coverage-clover=coverage.xml + else + vendor/bin/phpunit + fi + + - name: Code Coverage Report + if: success() && matrix.php-version == '7.2' && matrix.db-type == 'mysql' + uses: codecov/codecov-action@v1 + + cs-stan: + name: Coding Standard & Static Analysis + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: mbstring, intl + coverage: none + tools: psalm:^4.1, phpstan:^0.12 + + - name: Composer Install + run: composer require cakephp/cakephp-codesniffer:^4.2 + + - name: Run phpcs + run: vendor/bin/phpcs --standard=CakePHP src/ tests/ + + - name: Run psalm + if: success() || failure() + run: psalm --output-format=github + + - name: Run phpstan + if: success() || failure() + run: phpstan analyse diff --git a/README.md b/README.md index 13815d2..4d7d20f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # CakePHP plugin for I18n related tools. -[![Build Status](https://img.shields.io/travis/ADmad/cakephp-i18n/master.svg?style=flat-square)](https://travis-ci.org/ADmad/cakephp-i18n) +[![Build Status](https://img.shields.io/github/workflow/status/ADmad/cakephp-i18n/CI/master?style=flat-square)](https://github.com/ADmad/cakephp-i18n/actions?query=workflow%3ACI+branch%3Amaster) [![Coverage Status](https://img.shields.io/codecov/c/github/ADmad/cakephp-i18n.svg?style=flat-square)](https://codecov.io/github/ADmad/cakephp-i18n) [![Total Downloads](https://img.shields.io/packagist/dt/ADmad/cakephp-i18n.svg?style=flat-square)](https://packagist.org/packages/ADmad/cakephp-i18n) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE.txt) @@ -148,7 +148,7 @@ I18n::config('default', function ($domain, $locale) { $domain, $locale ); - + return $loader(); }); ``` diff --git a/composer.json b/composer.json index 4d60a72..4bf3502 100644 --- a/composer.json +++ b/composer.json @@ -40,14 +40,5 @@ "TestPlugin\\": "tests/test_app/plugins/TestPlugin/src", "Company\\TestPluginThree\\": "tests/test_app/plugins/Company/TestPluginThree/src" } - }, - "scripts": { - "phpstan": "phpstan.phar analyse", - "psalm": "psalm.phar", - "stan": [ - "@phpstan", - "@psalm" - ], - "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12 psalm/phar:^3.11.2 && mv composer.backup composer.json" } }