Skip to content

Commit

Permalink
Merge 50f43f1 into ce8aef1
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Feb 13, 2021
2 parents ce8aef1 + 50f43f1 commit 99ebe32
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Expand Up @@ -8,3 +8,4 @@ tests export-ignore
phpstan.neon export-ignore
psalm.xml export-ignore
psalm-baseline.xml export-ignore
.github export-ignore
105 changes: 105 additions & 0 deletions .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
4 changes: 2 additions & 2 deletions 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)
Expand Down Expand Up @@ -148,7 +148,7 @@ I18n::config('default', function ($domain, $locale) {
$domain,
$locale
);

return $loader();
});
```
Expand Down
9 changes: 0 additions & 9 deletions composer.json
Expand Up @@ -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"
}
}
8 changes: 6 additions & 2 deletions tests/TestCase/Validation/ValidatorTest.php
Expand Up @@ -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');
Expand Down

0 comments on commit 99ebe32

Please sign in to comment.