Skip to content

Commit 49bbd14

Browse files
author
Nikola
committed
Add CI workflow, phpcs config, editorconfig and composer keywords
- .github/workflows/ci.yml: test on PHP 8.2/8.3/8.4, cs and stan jobs - phpcs.xml: CakePHP coding standard config - .editorconfig: consistent coding style across editors - composer.json: add keywords for Packagist discoverability
1 parent 00ff715 commit 49bbd14

7 files changed

Lines changed: 110 additions & 3 deletions

File tree

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.php]
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.{json,yml,yaml}]
14+
indent_style = space
15+
indent_size = 4
16+
17+
[*.md]
18+
trim_trailing_whitespace = false
19+
20+
[Makefile]
21+
indent_style = tab

.github/workflows/ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, develop]
6+
pull_request:
7+
branches: [master, develop]
8+
9+
jobs:
10+
tests:
11+
name: PHP ${{ matrix.php-version }}
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
php-version: ["8.2", "8.3", "8.4"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php-version }}
25+
extensions: mbstring, sodium
26+
coverage: none
27+
28+
- name: Install dependencies
29+
run: composer install --no-interaction --prefer-dist
30+
31+
- name: Run tests
32+
run: composer test
33+
34+
cs:
35+
name: Code Style
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Setup PHP
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: "8.3"
45+
coverage: none
46+
47+
- name: Install dependencies
48+
run: composer install --no-interaction --prefer-dist
49+
50+
- name: Run phpcs
51+
run: composer cs
52+
53+
stan:
54+
name: Static Analysis
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Setup PHP
61+
uses: shivammathur/setup-php@v2
62+
with:
63+
php-version: "8.3"
64+
coverage: none
65+
66+
- name: Install dependencies
67+
run: composer install --no-interaction --prefer-dist
68+
69+
- name: Run phpstan
70+
run: composer stan 2>/dev/null || vendor/bin/phpstan analyse

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"description": "Verification and step-up authentication for CakePHP 5: email verification links, Email OTP, SMS OTP, and TOTP.",
44
"type": "cakephp-plugin",
55
"license": "MIT",
6+
"keywords": ["cakephp", "plugin", "verification", "authentication", "otp", "totp", "2fa", "mfa", "sms", "email"],
67
"require": {
78
"php": "^8.2",
89
"cakephp/cakephp": "^5.3",

phpcs.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="salines/cakephp-verification">
3+
<description>CakePHP coding standard</description>
4+
5+
<file>src</file>
6+
<file>tests</file>
7+
<file>config</file>
8+
9+
<arg name="extensions" value="php"/>
10+
<arg name="colors"/>
11+
<arg value="p"/>
12+
13+
<rule ref="CakePHP"/>
14+
</ruleset>

src/Command/InstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use Cake\Console\Arguments;
88
use Cake\Console\ConsoleIo;
99
use Cake\Console\ConsoleOptionParser;
10-
use Throwable;
1110
use Salines\Verification\Security\CryptoFactory;
11+
use Throwable;
1212

1313
final class InstallCommand extends Command
1414
{

tests/TestCase/Controller/Component/VerificationComponentChooseVerificationTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
namespace Salines\Verification\Test\TestCase\Controller\Component;
55

6-
use Cake\Controller\ComponentRegistry;
76
use Cake\Controller\Controller;
87
use Cake\Core\Configure;
98
use Cake\Http\Response;

tests/bootstrap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
use Cake\Cache\Cache;
55
use Cake\Core\Configure;
6+
use Cake\Core\Plugin;
67
use Cake\Routing\Router;
78
use Composer\Autoload\ClassLoader;
9+
use Salines\Verification\VerificationPlugin;
810

911
$pluginRoot = dirname(__DIR__);
1012
$rootVendorAutoload = dirname($pluginRoot, 2) . '/vendor/autoload.php';
@@ -41,7 +43,7 @@ function __(string $singular, mixed ...$args): string
4143
}
4244

4345
// Register plugin under its CakePHP name so Configure::load('Verification.verification') works
44-
\Cake\Core\Plugin::getCollection()->add(new \Salines\Verification\VerificationPlugin(['name' => 'Verification', 'path' => $pluginRoot . '/']));
46+
Plugin::getCollection()->add(new VerificationPlugin(['name' => 'Verification', 'path' => $pluginRoot . '/']));
4547

4648
// Minimal Cake bootstrap for plugin tests
4749
require $pluginRoot . '/config/bootstrap.php';

0 commit comments

Comments
 (0)