Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.next: Cake5 compatiblity #75

Closed
wants to merge 17 commits into from
Closed
86 changes: 43 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@ on:
push:
pull_request:

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
testsuite:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: ['7.3', '7.4', '8.0']
db-type: [sqlite, mysql, pgsql]
prefer-lowest: ['']
php-version: ['8.1']
db-type: [sqlite, pgsql]
include:
- php-version: '8.1'
db-type: 'mariadb'
- php-version: '8.1'
db-type: 'mysql'

steps:
- name: Setup MySQL latest
Expand All @@ -24,7 +31,13 @@ jobs:
if: matrix.db-type == 'pgsql'
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres

- uses: actions/checkout@v2
- uses: getong/[email protected]
if: matrix.db-type == 'mariadb'
with:
mysql database: 'cakephp'
mysql root password: 'root'

- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -43,80 +56,67 @@ jobs:
run: echo "::set-output name=date::$(date +'%Y-%m')"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}

- name: Composer install
run: |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
else
composer update
fi
run: composer update


- name: Setup problem matchers for PHPUnit
if: matrix.php-version == '7.4' && matrix.db-type == 'mysql'
if: matrix.php-version == '8.1' && matrix.db-type == 'mysql'
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Wait for MySQL
if: matrix.db-type == 'mysql' || matrix.db-type == 'mariadb'
run: while ! `mysqladmin ping -h 127.0.0.1 --silent`; do printf 'Waiting for MySQL...\n'; sleep 2; done;

- 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:[email protected]/cakephp'; fi
if [[ ${{ matrix.db-type }} == 'mariadb' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi
if [[ ${{ matrix.php-version }} == '7.4' ]]; then
export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml

if [[ ${{ matrix.php-version }} == '8.1' ]]; then
export CODECOVERAGE=1
vendor/bin/phpunit --verbose --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi

- name: Submit code coverage
if: matrix.php-version == '7.4'
if: matrix.php-version == '8.1'
uses: codecov/codecov-action@v1

cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl, apcu, memcached, redis
tools: cs2pr
php-version: '8.1'
extensions: mbstring, intl
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Get date part for cache key
id: key-date
run: echo "::set-output name=date::$(date +'%Y-%m')"

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
tools: cs2pr, vimeo/psalm:5.4, phpstan:1.9

- name: composer install
run: composer stan-setup
run: ramsey/composer-install@v2

- name: Run PHP CodeSniffer
run: composer cs-check
run: vendor/bin/phpcs --report=checkstyle src/ tests/ | cs2pr
continue-on-error: true

- name: Run psalm
if: success() || failure()
run: composer psalm
continue-on-error: true
if: always()
run: psalm --output-format=github

- name: Run phpstan
if: success() || failure()
run: composer stan
continue-on-error: true
if: always()
run: phpstan analyse --error-format=github
23 changes: 13 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"issues": "https://github.com/CakeDC/auth/issues",
"source": "https://github.com/CakeDC/auth"
},
"-minimum-stability": "dev",
"minimum-stability": "dev",
"require": {
"php": ">=7.2.0",
"cakephp/cakephp": "^4.3"
"php": ">=8.1.0",
"cakephp/cakephp": "5.x-dev"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
Expand All @@ -40,11 +40,10 @@
"google/recaptcha": "@stable",
"robthree/twofactorauth": "^1.6",
"league/oauth1-client": "^1.7",
"cakephp/authorization": "^2.0",
"cakephp/cakephp-codesniffer": "^4.0",
"cakephp/authentication": "^2.0",
"yubico/u2flib-server": "^1.0",
"php-coveralls/php-coveralls": "^2.4"
"cakephp/authorization": "3.x-dev",
"cakephp/cakephp-codesniffer": "^5.0",
"cakephp/authentication": "3.x-dev",
"yubico/u2flib-server": "^1.0"
},
"suggest": {
},
Expand Down Expand Up @@ -73,7 +72,11 @@
"test": "phpunit --stderr",
"stan": "phpstan analyse src/",
"psalm": "php vendor/psalm/phar/psalm.phar --show-info=false src/ ",
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:0.12.94 psalm/phar:~4.9.2 && mv composer.backup composer.json",
"coverage-test": "phpunit --stderr --coverage-clover=clover.xml"
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^1.9.0 psalm/phar:^5.1.0 && mv composer.backup composer.json"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
2 changes: 1 addition & 1 deletion config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
'enabled' => false,
'appName' => null,//App must set a valid name here
'id' => null,//default value is the current domain
'checker' => \CakeDC\Auth\Authentication\DefaultWebauthn2fAuthenticationChecker::class,
'checker' => \CakeDC\Auth\Authentication\DefaultWebauthn2FAuthenticationChecker::class,
'startAction' => [
'plugin' => 'CakeDC/Users',
'controller' => 'Users',
Expand Down
14 changes: 1 addition & 13 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,5 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
use Cake\Core\Configure;
use Cake\Routing\Router;

Configure::load('CakeDC/Auth.auth');
$oauthPath = Configure::read('OAuth.path');
if (is_array($oauthPath)) {
$builder = Router::createRouteBuilder('/');
$builder->scope('/auth', function ($routes) use ($oauthPath) {
$routes->connect(
'/:provider',
$oauthPath,
['provider' => implode('|', array_keys(Configure::read('OAuth.providers')))]
);
});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been moved to the routes() method of the Plugin class

Configure::load('CakeDC/Auth.auth');
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ parameters:
level: 6
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
treatPhpDocTypesAsCertain: false
bootstrapFiles:
- tests/bootstrap.php
services:
60 changes: 37 additions & 23 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,45 @@
~ @copyright Copyright 2010 - 2018, Cake Development Corporation (https://www.cakedc.com)
~ @license MIT License (http://www.opensource.org/licenses/mit-license.php)
-->
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
<env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/>
</php>
<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="Auth Test Suite">
<directory>./tests/TestCase</directory>
</testsuite>
</testsuites>
<!-- Setup a listener for fixtures -->
<extensions>
<extension class="\Cake\TestSuite\Fixture\PHPUnitExtension" />
</extensions>
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
<env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/>

<!-- SQLite
<env name="DB_URL" value="sqlite:///:memory:"/>
-->
<!-- Postgres
<env name="DB_URL" value="postgres://localhost/cake_test?timezone=UTC"/>
-->
<!-- MySQL
<env name="DB_URL" value="mysql://localhost/cake_test?timezone=UTC"/>
-->
<!-- SQL Server
<env name="DB_URL" value="sqlserver://localhost/cake_test?timezone=UTC"/>
-->
</php>

<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="Auth Test Suite">
<directory>./tests/TestCase</directory>
</testsuite>
</testsuites>

<!-- Setup a listener for fixtures -->
<extensions>
<extension class="Cake\TestSuite\Fixture\PHPUnitExtension"/>
</extensions>
</phpunit>
Loading